type
TExtendedPoint = record
X, Y: Extended;
end;
procedure Blob2ExtArr(
ABlobField: TField;
const AAggregator: IDoublePointsAggregator
);
const
CMaxDegres: Extended = 360;
CMinDegres: Extended = -360;
var
VSize: Integer;
VPointsCount: Integer;
VField: TBlobfield;
VStream: TStream;
i: Integer;
VPoint: TExtendedPoint;
VDoublePoint: TDoublePoint;
begin
VField := TBlobfield(ABlobField);
VStream := VField.DataSet.CreateBlobStream(VField, bmRead);
try
VSize := VStream.Size;
VPointsCount := VSize div SizeOf(TExtendedPoint);
for i := 0 to VPointsCount - 1 do begin
VStream.ReadBuffer(VPoint, SizeOf(TExtendedPoint));
try
if IsNan(VPoint.X) or IsNan(VPoint.Y) then begin
VDoublePoint := CEmptyDoublePoint;
end else if (VPoint.X >= CMaxDegres) or (VPoint.X <= CMinDegres) or (VPoint.Y >= CMaxDegres) or (VPoint.Y <= CMinDegres) then begin
VDoublePoint := CEmptyDoublePoint;
end else begin
VDoublePoint := DoublePoint(VPoint.X, VPoint.Y);
end;
except
VDoublePoint := CEmptyDoublePoint;
end;
AAggregator.Add(VDoublePoint);
end;
finally
VStream.Free;
end;
end;
procedure BlobFromPoint(
const APoint: TDoublePoint;
ABlobField: TField
);
var
VField: TBlobfield;
VStream: TStream;
VPoint: TExtendedPoint;
begin
VField := TBlobfield(ABlobField);
VStream := VField.DataSet.CreateBlobStream(VField, bmWrite);
try
VPoint.X := APoint.X;
VPoint.Y := APoint.Y;
VStream.Write(VPoint, SizeOf(VPoint));
finally
VStream.Free;
end;
end;
procedure BlobFromPath(
const APath: ILonLatPath;
ABlobField: TField
);
var
VField: TBlobfield;
VStream: TStream;
i: Integer;
VPoint: TExtendedPoint;
VEnum: IEnumDoublePoint;
VFirstPoint: TDoublePoint;
VCurrPoint: TDoublePoint;
VPrevPoint: TDoublePoint;
begin
VField := TBlobfield(ABlobField);
VStream := VField.DataSet.CreateBlobStream(VField, bmWrite);
try
VEnum := APath.GetEnum;
i := 0;
if VEnum.Next(VFirstPoint) then begin
VCurrPoint := VFirstPoint;
VPrevPoint := VCurrPoint;
VPoint.X := VCurrPoint.X;
VPoint.Y := VCurrPoint.Y;
VStream.Write(VPoint, SizeOf(VPoint));
Inc(i);
while VEnum.Next(VCurrPoint) do begin
VPoint.X := VCurrPoint.X;
VPoint.Y := VCurrPoint.Y;
VStream.Write(VPoint, SizeOf(VPoint));
VPrevPoint := VCurrPoint;
Inc(i);
end;
end;
if (i = 1) or ((i > 1) and DoublePointsEqual(VFirstPoint, VPrevPoint)) then begin
VPoint.X := CEmptyDoublePoint.X;
VPoint.Y := CEmptyDoublePoint.Y;
VStream.Write(VPoint, SizeOf(VPoint));
end;
finally
VStream.Free;
end;
end;
procedure BlobFromPolygon(
const APolygon: ILonLatPolygon;
ABlobField: TField
);
var
VField: TBlobfield;
VStream: TStream;
VPoint: TExtendedPoint;
VEnum: IEnumDoublePoint;
VCurrPoint: TDoublePoint;
VLine: ILonLatPolygonLine;
begin
VField := TBlobfield(ABlobField);
VStream := VField.DataSet.CreateBlobStream(VField, bmWrite);
try
if APolygon.Count > 0 then begin
VLine := APolygon.Item[0];
if VLine.Count = 1 then begin
VPoint.X := VLine.Points[0].X;
VPoint.Y := VLine.Points[0].Y;
VStream.Write(VPoint, SizeOf(VPoint));
VStream.Write(VPoint, SizeOf(VPoint));
end else begin
VEnum := VLine.GetEnum;
while VEnum.Next(VCurrPoint) do begin
VPoint.X := VCurrPoint.X;
VPoint.Y := VCurrPoint.Y;
VStream.Write(VPoint, SizeOf(VPoint));
end;
end;
end;
finally
VStream.Free;
end;
end;
Сейчас этот форум просматривают: нет зарегистрированных пользователей и гости: 26