📄 ezshpimport.pas
字号:
Unit EzSHPImport;
{***********************************************************}
{ EzGIS/CAD Components }
{ (c) 2003 EzSoft Engineering }
{ All Rights Reserved }
{***********************************************************}
{$I EZ_FLAG.PAS}
{$DEFINE USENATIVEDLL}
Interface
Uses
Controls, SysUtils, Classes, Windows, Dialogs, Db,
EzLib, EzBase, EzBaseGIS, EzProjections, EzImportBase, EzCADCtrls;
Type
TEzShapeFileType = ( ftPoint, ftArc, ftPolygon, ftMultiPoint );
{ TEzSHPImport - Projector is used for the original .shp file }
TEzSHPImport = Class( TEzBaseImport )
Private
FTempCAD: TEzCAD;
{ for showing progress messages }
nEntities: Integer;
MyEntNo: Integer;
Procedure EraseShpIndexFiles;
Public
Constructor Create(AOwner: TComponent); Override;
Destructor Destroy; Override;
Procedure ImportInitialize; Override;
Procedure GetSourceFieldList( FieldList: TStrings ); Override;
Procedure ImportFirst; Override;
Procedure AddSourceFieldData(DestLayer: TEzBaseLayer; DestRecno: Integer); Override;
Function GetSourceExtension: TEzRect; Override;
Function ImportEof: Boolean; Override;
Function GetNextEntity(var progress,entno: Integer): TEzEntity; Override;
Procedure ImportNext; Override;
Procedure ImportEnd; Override;
End;
{ TEzSHPExport - Projector is used for exporting to that projection }
TEzSHPExport = Class( TEzBaseExport )
Private
FExportAs: TEzShapeFileType;
FTempCAD: TEzCAD;
Procedure CreateShapeFile;
Procedure EraseShpIndexFiles;
{$IFDEF BCB}
function GetExportAs: TEzShapeFileType;
procedure SetExportAs(const Value: TEzShapeFileType);
{$ENDIF}
Public
Constructor Create( AOwner: TComponent ); Override;
Destructor Destroy; Override;
Procedure ExportInitialize; Override;
Procedure ExportEntity( SourceLayer: TEzBaseLayer; Entity: TEzEntity ); Override;
Procedure ExportEnd; Override;
Published
Property ExportAs: TEzShapeFileType {$IFDEF BCB} Read GetExportAs Write SetExportAs {$ELSE} Read FExportAs Write FExportAs {$ENDIF} Default ftPolygon;
End;
{ this class is used for reading dBASE .DBF files }
TEzSHPDbfTable = Class( TEzBaseTable )
Private
{$IFDEF USENATIVEDLL}
FDBFHandle: Integer;
FDLLHandle: THandle;
FDLLLoaded: Boolean;
ezInitDBFTable: Function( fname, APassword: PChar; ReadWrite, Shared: boolean ): Integer; stdcall;
ezReleaseDBFTable: Procedure( Handle: Integer ); stdcall;
ezGetActive: Function( handle: integer ): boolean; stdcall;
ezSetActive: Procedure( handle: integer; Value: boolean ); stdcall;
ezGetRecNo: Function( handle: integer ): Integer; stdcall;
ezSetRecNo: Procedure( handle: integer; Value: Integer ); stdcall;
ezAppend: Procedure( handle: integer ); stdcall;
ezBOF: Function( handle: integer ): Boolean; stdcall;
ezEOF: Function( handle: integer ): Boolean; stdcall;
ezDateGet: Function( handle: integer; FieldName: pchar ): Integer; stdcall;
ezDateGetN: Function( handle: integer; FieldNo: integer ): Integer; stdcall;
ezDeleted: Function( handle: integer ): Boolean; stdcall;
ezField: Function( handle: integer; FieldNo: integer ): pchar; stdcall;
ezFieldCount: Function( handle: integer ): integer; stdcall;
ezFieldDec: Function( handle: integer; FieldNo: integer ): integer; stdcall;
ezFieldGet: Function( handle: integer; FieldName: pchar ): pchar; stdcall;
ezFieldGetN: Function( handle: integer; FieldNo: integer ): pchar; stdcall;
ezFieldLen: Function( handle: integer; FieldNo: integer ): integer; stdcall;
ezFieldNo: Function( handle: integer; FieldName: pchar ): integer; stdcall;
ezFieldType: Function( handle: integer; FieldNo: integer ): char; stdcall;
ezFind: Function( handle: integer; ss: pchar; IsExact, IsNear: boolean ): boolean; stdcall;
ezFloatGet: Function( handle: integer; FieldName: pchar ): Double; stdcall;
ezFloatGetN: Function( handle: integer; FieldNo: Integer ): Double; stdcall;
ezIndexCount: Function( handle: integer ): integer; stdcall;
ezIndexAscending: Function( handle: integer; Value: integer ): boolean; stdcall;
ezIndex: Function( handle: integer; INames, Tag: pchar ): integer; stdcall;
ezIndexCurrent: Function( handle: integer ): pchar; stdcall;
ezIndexUnique: Function( handle: integer; Value: integer ): boolean; stdcall;
ezIndexExpression: Function( handle: integer; Value: integer ): pchar; stdcall;
ezIndexTagName: Function( handle: integer; Value: integer ): pchar; stdcall;
ezIndexFilter: Function( handle: integer; Value: integer ): pchar; stdcall;
ezIntegerGet: Function( handle: integer; FieldName: pchar ): Integer; stdcall;
ezIntegerGetN: Function( handle: integer; FieldNo: integer ): Integer; stdcall;
ezLogicGet: Function( handle: integer; FieldName: pchar ): Boolean; stdcall;
ezLogicGetN: Function( handle: integer; FieldNo: integer ): Boolean; stdcall;
ezMemoSave: Function( handle: integer; FieldName: pchar; Buf: PChar;
Var cb: Integer ): Integer; stdcall;
ezMemoSaveN: Function( handle: integer; FieldNo: integer; Buf: PChar;
Var cb: Integer ): Integer; stdcall;
ezMemoSize: Function( handle: integer; FieldName: pchar ): Integer; stdcall;
ezMemoSizeN: Function( handle: integer; FieldNo: integer ): Integer; stdcall;
ezRecordCount: Function( handle: integer ): Integer; stdcall;
ezStringGet: Function( handle: integer; FieldName: pchar ): pchar; stdcall;
ezStringGetN: Function( handle: integer; FieldNo: integer ): pchar; stdcall;
ezCopyStructure: Procedure( handle: integer; FileName, APassword: pchar ); stdcall;
ezCopyTo: Procedure( handle: integer; FileName, APassword: pchar ); stdcall;
ezDatePut: Procedure( handle: integer; FieldName: pchar; jdte: longint ); stdcall;
ezDatePutN: Procedure( handle: integer; FieldNo: integer; jdte: longint ); stdcall;
ezDelete: Procedure( handle: integer ); stdcall;
ezEdit: Procedure( handle: integer ); stdcall;
ezFieldPut: Procedure( handle: integer; FieldName, Value: pchar ); stdcall;
ezFieldPutN: Procedure( handle: integer; FieldNo: integer; Value: pchar ); stdcall;
ezFirst: Procedure( handle: integer ); stdcall;
ezFloatPut: Procedure( handle: integer; FieldName: pchar; Const Value: Double ); stdcall;
ezFloatPutN: Procedure( handle: integer; FieldNo: integer; Const Value: Double ); stdcall;
ezFlushDBF: Procedure( handle: integer ); stdcall;
ezGo: Procedure( handle: integer; n: Integer ); stdcall;
ezIndexOn: Procedure( handle: integer; IName, tag, keyexp, forexp: pchar;
uniq: integer; ascnd: integer ); stdcall;
ezIntegerPut: Procedure( handle: integer; FieldName: pchar; Value: Integer ); stdcall;
ezIntegerPutN: Procedure( handle: integer; FieldNo: integer; Value: Integer ); stdcall;
ezLast: Procedure( handle: integer ); stdcall;
ezLogicPut: Procedure( handle: integer; FieldName: pchar; value: boolean ); stdcall;
ezLogicPutN: Procedure( handle: integer; fieldno: integer; value: boolean ); stdcall;
ezMemoLoad: Procedure( handle: integer; FieldName: pchar; Buf: PChar; Var cb: integer ); stdcall;
ezMemoLoadN: Procedure( handle: integer; fieldno: integer; buf: PChar; Var cb: integer ); stdcall;
ezNext: Procedure( handle: integer ); stdcall;
ezPack: Procedure( handle: integer ); stdcall;
ezPost: Procedure( handle: integer ); stdcall;
ezPrior: Procedure( handle: integer ); stdcall;
ezRecall: Procedure( handle: integer ); stdcall;
ezRefresh: Procedure( handle: integer ); stdcall;
ezReindex: Procedure( handle: integer ); stdcall;
ezSetTagTo: Procedure( handle: integer; TName: pchar ); stdcall;
ezSetUseDeleted: Procedure( handle: integer; tf: boolean ); stdcall;
ezStringPut: Procedure( handle: integer; FieldName, value: pchar ); stdcall;
ezStringPutN: Procedure( handle: integer; fieldno: integer; value: pchar ); stdcall;
ezZap: Procedure( handle: integer ); stdcall;
Procedure LoadDLL;
{$ELSE}
FDbf: TDbf;
{$ENDIF}
Protected
Function GetActive: boolean; Override;
Procedure SetActive( Value: boolean ); Override;
Function GetRecNo: Integer; Override;
Procedure SetRecNo( Value: Integer ); Override;
Public
Constructor Create( Gis: TEzBaseGis; Const fname: String;
ReadWrite, Shared: boolean ); Override;
Destructor Destroy; Override;
Procedure Append( NewRecno: Integer ); Override;
Function BOF: Boolean; Override;
Function EOF: Boolean; Override;
Function DateGet( Const FieldName: String ): TDateTime; Override;
Function DateGetN( FieldNo: integer ): TDateTime; Override;
Function Deleted: Boolean; Override;
Function Field( FieldNo: integer ): String; Override;
Function FieldCount: integer; Override;
Function FieldDec( FieldNo: integer ): integer; Override;
Function FieldGet( Const FieldName: String ): String; Override;
Function FieldGetN( FieldNo: integer ): String; Override;
Function FieldLen( FieldNo: integer ): integer; Override;
Function FieldNo( Const FieldName: String ): integer; Override;
Function FieldType( FieldNo: integer ): char; Override;
Function Find( Const ss: String; IsExact, IsNear: boolean ): boolean; Override;
Function FloatGet( Const FieldName: String ): Double; Override;
Function FloatGetN( FieldNo: Integer ): Double; Override;
Function IndexCount: integer; Override;
Function IndexAscending( Value: integer ): boolean; Override;
Function Index( Const INames, Tag: String ): integer; Override;
Function IndexCurrent: String; Override;
Function IndexUnique( Value: integer ): boolean; Override;
Function IndexExpression( Value: integer ): String; Override;
Function IndexTagName( Value: integer ): String; Override;
Function IndexFilter( Value: integer ): String; Override;
Function IntegerGet( Const FieldName: String ): Integer; Override;
Function IntegerGetN( FieldNo: integer ): Integer; Override;
Function LogicGet( Const FieldName: String ): Boolean; Override;
Function LogicGetN( FieldNo: integer ): Boolean; Override;
procedure MemoSave( Const FieldName: String; Stream: TStream ); Override;
procedure MemoSaveN( FieldNo: integer; stream: TStream ); Override;
Function MemoSize( Const FieldName: String ): Integer; Override;
Function MemoSizeN( FieldNo: integer ): Integer; Override;
Function RecordCount: Integer; Override;
Function StringGet( Const FieldName: String ): String; Override;
Function StringGetN( FieldNo: integer ): String; Override;
//Procedure CopyStructure( Const FileName, APassword: String ); Override;
//Procedure CopyTo( Const FileName, APassword: String ); Override;
Procedure DatePut( Const FieldName: String; value: TDateTime ); Override;
Procedure DatePutN( FieldNo: integer; value: TDateTime ); Override;
Procedure Delete; Override;
Procedure Edit; Override;
Procedure FieldPut( Const FieldName, Value: String ); Override;
Procedure FieldPutN( FieldNo: integer; Const Value: String ); Override;
Procedure First; Override;
Procedure FloatPut( Const FieldName: String; Const Value: Double ); Override;
Procedure FloatPutN( FieldNo: integer; Const Value: Double ); Override;
Procedure FlushDB; Override;
Procedure Go( n: Integer ); Override;
Procedure IndexOn( Const IName, tag, keyexp, forexp: String;
uniq: TEzIndexUnique; ascnd: TEzSortStatus ); Override;
Procedure IntegerPut( Const FieldName: String; Value: Integer ); Override;
Procedure IntegerPutN( FieldNo: integer; Value: Integer ); Override;
Procedure Last; Override;
Procedure LogicPut( Const FieldName: String; value: boolean ); Override;
Procedure LogicPutN( fieldno: integer; value: boolean ); Override;
Procedure MemoLoad( Const FieldName: String; stream: tstream ); Override;
Procedure MemoLoadN( fieldno: integer; stream: tstream ); Override;
Procedure Next; Override;
Procedure Pack; Override;
Procedure Post; Override;
Procedure Prior; Override;
Procedure Recall; Override;
Procedure Refresh; Override;
Procedure Reindex; Override;
Procedure SetTagTo( Const TName: String ); Override;
Procedure SetUseDeleted( tf: boolean ); Override;
Procedure StringPut( Const FieldName, value: String ); Override;
Procedure StringPutN( fieldno: integer; Const value: String ); Override;
Procedure Zap; Override;
End;
Implementation
Uses
ezimpl, ezConsts, EzSystem, EzBasicCtrls, EzRtree, fProj
{$IFNDEF USENATIVEDLL}
, dbf
{$ENDIF}
;
{$IFDEF USENATIVEDLL}
type
TEzDBFTypes = ( dtClipper, dtDBaseIII, dtDBaseIV, dtFoxPro2 );
Procedure TEzSHPDbfTable.LoadDLL;
Var
ErrorMode: Integer;
Begin
If FDLLLoaded Then Exit;
ErrorMode := SetErrorMode( SEM_NOOPENFILEERRORBOX );
FDLLHandle := LoadLibrary( 'ezde10.dll' );
If FDLLHandle >= 32 Then
Begin
FDLLLoaded := True;
@ezInitDBFTable := GetProcAddress( FDLLHandle, 'InitDBFTable' );
Assert( @ezInitDBFTable <> Nil );
@ezReleaseDBFTable := GetProcAddress( FDLLHandle, 'ReleaseDBFTable' );
Assert( @ezReleaseDBFTable <> Nil );
@ezGetActive := GetProcAddress( FDLLHandle, 'GetActive' );
Assert( @ezGetActive <> Nil );
@ezSetActive := GetProcAddress( FDLLHandle, 'SetActive' );
Assert( @ezSetActive <> Nil );
@ezGetRecNo := GetProcAddress( FDLLHandle, 'GetRecNo' );
Assert( @ezGetRecNo <> Nil );
@ezSetRecNo := GetProcAddress( FDLLHandle, 'SetRecNo' );
Assert( @ezSetRecNo <> Nil );
@ezAppend := GetProcAddress( FDLLHandle, 'Append' );
Assert( @ezAppend <> Nil );
@ezBOF := GetProcAddress( FDLLHandle, 'BOF' );
Assert( @ezBOF <> Nil );
@ezEOF := GetProcAddress( FDLLHandle, 'EOF' );
Assert( @ezEOF <> Nil );
@ezDateGet := GetProcAddress( FDLLHandle, 'DateGet' );
Assert( @ezDateGet <> Nil );
@ezDateGetN := GetProcAddress( FDLLHandle, 'DateGetN' );
Assert( @ezDateGetN <> Nil );
@ezDeleted := GetProcAddress( FDLLHandle, 'Deleted' );
Assert( @ezDeleted <> Nil );
@ezField := GetProcAddress( FDLLHandle, 'Field' );
Assert( @ezField <> Nil );
@ezFieldCount := GetProcAddress( FDLLHandle, 'FieldCount' );
Assert( @ezFieldCount <> Nil );
@ezFieldDec := GetProcAddress( FDLLHandle, 'FieldDec' );
Assert( @ezFieldDec <> Nil );
@ezFieldGet := GetProcAddress( FDLLHandle, 'FieldGet' );
Assert( @ezFieldGet <> Nil );
@ezFieldGetN := GetProcAddress( FDLLHandle, 'FieldGetN' );
Assert( @ezFieldGetN <> Nil );
@ezFieldLen := GetProcAddress( FDLLHandle, 'FieldLen' );
Assert( @ezFieldLen <> Nil );
@ezFieldNo := GetProcAddress( FDLLHandle, 'FieldNo' );
Assert( @ezFieldNo <> Nil );
@ezFieldType := GetProcAddress( FDLLHandle, 'FieldType' );
Assert( @ezFieldType <> Nil );
@ezFind := GetProcAddress( FDLLHandle, 'Find' );
Assert( @ezFind <> Nil );
@ezFloatGet := GetProcAddress( FDLLHandle, 'FloatGet' );
Assert( @ezFloatGet <> Nil );
@ezFloatGetN := GetProcAddress( FDLLHandle, 'FloatGetN' );
Assert( @ezFloatGetN <> Nil );
@ezIndexCount := GetProcAddress( FDLLHandle, 'IndexCount' );
Assert( @ezIndexCount <> Nil );
@ezIndexAscending := GetProcAddress( FDLLHandle, 'IndexAscending' );
Assert( @ezIndexAscending <> Nil );
@ezIndex := GetProcAddress( FDLLHandle, 'Index' );
Assert( @ezIndex <> Nil );
@ezIndexCurrent := GetProcAddress( FDLLHandle, 'IndexCurrent' );
Assert( @ezIndexCurrent <> Nil );
@ezIndexUnique := GetProcAddress( FDLLHandle, 'IndexUnique' );
Assert( @ezIndexUnique <> Nil );
@ezIndexExpression := GetProcAddress( FDLLHandle, 'IndexExpression' );
Assert( @ezIndexExpression <> Nil );
@ezIndexTagName := GetProcAddress( FDLLHandle, 'IndexTagName' );
Assert( @ezIndexTagName <> Nil );
@ezIndexFilter := GetProcAddress( FDLLHandle, 'IndexFilter' );
Assert( @ezIndexFilter <> Nil );
@ezIntegerGet := GetProcAddress( FDLLHandle, 'IntegerGet' );
Assert( @ezIntegerGet <> Nil );
@ezIntegerGetN := GetProcAddress( FDLLHandle, 'IntegerGetN' );
Assert( @ezIntegerGetN <> Nil );
@ezLogicGet := GetProcAddress( FDLLHandle, 'LogicGet' );
Assert( @ezLogicGet <> Nil );
@ezLogicGetN := GetProcAddress( FDLLHandle, 'LogicGetN' );
Assert( @ezLogicGetN <> Nil );
@ezMemoSave := GetProcAddress( FDLLHandle, 'MemoSave' );
Assert( @ezMemoSave <> Nil );
@ezMemoSaveN := GetProcAddress( FDLLHandle, 'MemoSaveN' );
Assert( @ezMemoSaveN <> Nil );
@ezMemoSize := GetProcAddress( FDLLHandle, 'MemoSize' );
Assert( @ezMemoSize <> Nil );
@ezMemoSizeN := GetProcAddress( FDLLHandle, 'MemoSizeN' );
Assert( @ezMemoSizeN <> Nil );
@ezRecordCount := GetProcAddress( FDLLHandle, 'RecordCount' );
Assert( @ezRecordCount <> Nil );
@ezStringGet := GetProcAddress( FDLLHandle, 'StringGet' );
Assert( @ezStringGet <> Nil );
@ezStringGetN := GetProcAddress( FDLLHandle, 'StringGetN' );
Assert( @ezStringGetN <> Nil );
@ezCopyStructure := GetProcAddress( FDLLHandle, 'CopyStructure' );
Assert( @ezCopyStructure <> Nil );
@ezCopyTo := GetProcAddress( FDLLHandle, 'CopyTo' );
Assert( @ezCopyTo <> Nil );
@ezDatePut := GetProcAddress( FDLLHandle, 'DatePut' );
Assert( @ezDatePut <> Nil );
@ezDatePutN := GetProcAddress( FDLLHandle, 'DatePutN' );
Assert( @ezDatePutN <> Nil );
@ezDelete := GetProcAddress( FDLLHandle, 'Delete' );
Assert( @ezDelete <> Nil );
@ezEdit := GetProcAddress( FDLLHandle, 'Edit' );
Assert( @ezEdit <> Nil );
@ezFieldPut := GetProcAddress( FDLLHandle, 'FieldPut' );
Assert( @ezFieldPut <> Nil );
@ezFieldPutN := GetProcAddress( FDLLHandle, 'FieldPutN' );
Assert( @ezFieldPutN <> Nil );
@ezFirst := GetProcAddress( FDLLHandle, 'First' );
Assert( @ezFirst <> Nil );
@ezFloatPut := GetProcAddress( FDLLHandle, 'FloatPut' );
Assert( @ezFloatPut <> Nil );
@ezFloatPutN := GetProcAddress( FDLLHandle, 'FloatPutN' );
Assert( @ezFloatPutN <> Nil );
@ezFlushDBF := GetProcAddress( FDLLHandle, 'FlushDBF' );
Assert( @ezFlushDBF <> Nil );
@ezGo := GetProcAddress( FDLLHandle, 'Go' );
Assert( @ezGo <> Nil );
@ezIndexOn := GetProcAddress( FDLLHandle, 'IndexOn' );
Assert( @ezIndexOn <> Nil );
@ezIntegerPut := GetProcAddress( FDLLHandle, 'IntegerPut' );
Assert( @ezIntegerPut <> Nil );
@ezIntegerPutN := GetProcAddress( FDLLHandle, 'IntegerPutN' );
Assert( @ezIntegerPutN <> Nil );
@ezLast := GetProcAddress( FDLLHandle, 'Last' );
Assert( @ezLast <> Nil );
@ezLogicPut := GetProcAddress( FDLLHandle, 'LogicPut' );
Assert( @ezLogicPut <> Nil );
@ezLogicPutN := GetProcAddress( FDLLHandle, 'LogicPutN' );
Assert( @ezLogicPutN <> Nil );
@ezMemoLoad := GetProcAddress( FDLLHandle, 'MemoLoad' );
Assert( @ezMemoLoad <> Nil );
@ezMemoLoadN := GetProcAddress( FDLLHandle, 'MemoLoadN' );
Assert( @ezMemoLoadN <> Nil );
@ezNext := GetProcAddress( FDLLHandle, 'Next' );
Assert( @ezNext <> Nil );
@ezPack := GetProcAddress( FDLLHandle, 'Pack' );
Assert( @ezPack <> Nil );
@ezPost := GetProcAddress( FDLLHandle, 'Post' );
Assert( @ezPost <> Nil );
@ezPrior := GetProcAddress( FDLLHandle, 'Prior' );
Assert( @ezPrior <> Nil );
@ezRecall := GetProcAddress( FDLLHandle, 'Recall' );
Assert( @ezRecall <> Nil );
@ezRefresh := GetProcAddress( FDLLHandle, 'Refresh' );
Assert( @ezRefresh <> Nil );
@ezReindex := GetProcAddress( FDLLHandle, 'Reindex' );
Assert( @ezReindex <> Nil );
@ezSetTagTo := GetProcAddress( FDLLHandle, 'SetTagTo' );
Assert( @ezSetTagTo <> Nil );
@ezSetUseDeleted := GetProcAddress( FDLLHandle, 'SetUseDeleted' );
Assert( @ezSetUseDeleted <> Nil );
@ezStringPut := GetProcAddress( FDLLHandle, 'StringPut' );
Assert( @ezStringPut <> Nil );
@ezStringPutN := GetProcAddress( FDLLHandle, 'StringPutN' );
Assert( @ezStringPutN <> Nil );
@ezZap := GetProcAddress( FDLLHandle, 'Zap' );
Assert( @ezZap <> Nil );
End
Else
FDLLLoaded := False;
SetErrorMode( ErrorMode );
If Not FDLLLoaded Then
Begin
MessageToUser( 'EzGIS: Unable to load required ezde10.dll', smsgerror, MB_ICONERROR );
End;
End;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -