⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sdogeometry.pas

📁 ODAC 6 最新版的﹐網上找了好久才找到﹐不太好找啊﹐大家一起共享
💻 PAS
字号:
unit SdoGeometry;

interface

uses
  OraObjects;

type
  TSdoPoint = record
    IsNull: boolean;
    X, Y, Z: double;
  end;

  TSdoGeometry = class
  private
    FIsNull: boolean;
    FGType: integer;
    FSRID: integer;
    FPoint: TSdoPoint;
    FElemInfo: array of integer;
    FOrdinates: array of double;

    function GetElemInfoCount: integer;
    procedure SetElemInfoCount(Value: integer);
    function GetOrdinatesCount: integer;
    procedure SetOrdinatesCount(Value: integer);
    function GetElemInfo(Index: integer): integer;
    procedure SetElemInfo(Index: integer; Value: integer);
    function GetOrdinate(Index: integer): double;
    procedure SetOrdinate(Index: integer; Value: double);

  public
    constructor Create;

    procedure Load(GeometryObject: TOraObject);
    procedure Save(GeometryObject: TOraObject);

    property IsNull: boolean read FIsNull write FIsNull;
    property GType: integer read FGType write FGType;
    property SRID: integer read FSRID write FSRID;
    property Point: TSdoPoint read FPoint write FPoint;
    property ElemInfoCount: integer read GetElemInfoCount write SetElemInfoCount;
    property ElemInfo[Index: integer]: integer read GetElemInfo write SetElemInfo;
    property OrdinatesCount: integer read GetOrdinatesCount write SetOrdinatesCount;
    property Ordinates[Index: integer]: double read GetOrdinate write SetOrdinate;
  end;

implementation

{ TSdoGeometry }

constructor TSdoGeometry.Create;
begin
  inherited;
  
  FIsNull := True;
  FPoint.IsNull := True;
end;

function TSdoGeometry.GetElemInfoCount: integer;
begin
  Result := Length(FElemInfo);
end;

procedure TSdoGeometry.SetElemInfoCount(Value: integer);
begin
  SetLength(FElemInfo, Value);
end;

function TSdoGeometry.GetOrdinatesCount: integer;
begin
  Result := Length(FOrdinates);
end;

procedure TSdoGeometry.SetOrdinatesCount(Value: integer);
begin
  SetLength(FOrdinates, Value);
end;

function TSdoGeometry.GetElemInfo(Index: integer): integer;
begin
  Result := FElemInfo[Index];
end;

procedure TSdoGeometry.SetElemInfo(Index: integer; Value: integer);
begin
  FElemInfo[Index] := Value;
end;

function TSdoGeometry.GetOrdinate(Index: integer): double;
begin
  Result := FOrdinates[Index];
end;

procedure TSdoGeometry.SetOrdinate(Index: integer; Value: double);
begin
  FOrdinates[Index] := Value;
end;

procedure TSdoGeometry.Load(GeometryObject: TOraObject);
var
  PointObject: TOraObject;
  Arr: TOraArray;
  ArrSize, i: integer;
begin
  if GeometryObject.IsNull then begin
    FIsNull := True;
    exit;
  end
  else
    FIsNull := False;

  FGType := GeometryObject.AttrAsInteger['SDO_GTYPE'];
  FSRID := GeometryObject.AttrAsInteger['SDO_SRID'];

  PointObject := GeometryObject.AttrAsObject['SDO_POINT'];
  if PointObject.IsNull then begin
    FPoint.IsNull := True;
    FPoint.X := 0;
    FPoint.Y := 0;
    FPoint.Z := 0;
  end
  else begin
    FPoint.IsNull := False;
    FPoint.X := PointObject.AttrAsFloat['X'];
    FPoint.Y := PointObject.AttrAsFloat['Y'];
    FPoint.Z := PointObject.AttrAsFloat['Z'];
  end;

  Arr := GeometryObject.AttrAsArray['SDO_ELEM_INFO'];
  if Arr.IsNull then
    SetLength(FElemInfo, 0)
  else begin
    ArrSize := Arr.Size;
    SetLength(FElemInfo, ArrSize);
    for i := 0 to ArrSize - 1 do
      FElemInfo[i] := Arr.ItemAsInteger[i];
  end;

  Arr := GeometryObject.AttrAsArray['SDO_ORDINATES'];
  if Arr.IsNull then
    SetLength(FOrdinates, 0)
  else begin
    ArrSize := Arr.Size;
    SetLength(FOrdinates, ArrSize);
    for i := 0 to ArrSize - 1 do
      FOrdinates[i] := Arr.ItemAsFloat[i];
  end;
end;

procedure TSdoGeometry.Save(GeometryObject: TOraObject);
var
  PointObject: TOraObject;
  Arr: TOraArray;
  i: integer;
begin
  if FIsNull then begin
    GeometryObject.IsNull := True;
    exit;
  end;

  GeometryObject.AttrAsInteger['SDO_GTYPE'] := FGType;
  GeometryObject.AttrAsInteger['SDO_SRID'] := FSRID;

  PointObject := GeometryObject.AttrAsObject['SDO_POINT'];
  if FPoint.IsNull then
    PointObject.IsNull := True
  else begin
    PointObject.AttrAsFloat['X'] := FPoint.X;
    PointObject.AttrAsFloat['Y'] := FPoint.Y;
    PointObject.AttrAsFloat['Z'] := FPoint.Z;
  end;

  Arr := GeometryObject.AttrAsArray['SDO_ELEM_INFO'];
  Arr.Size := Length(FElemInfo);
  for i := 0 to Length(FElemInfo) - 1 do
    Arr.ItemAsInteger[i] := FElemInfo[i];

  Arr := GeometryObject.AttrAsArray['SDO_ORDINATES'];
  Arr.Size := Length(FOrdinates);
  for i := 0 to Length(FOrdinates) - 1 do
    Arr.ItemAsFloat[i] := FOrdinates[i];
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -