-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUMap.pas
More file actions
238 lines (203 loc) · 6.42 KB
/
UMap.pas
File metadata and controls
238 lines (203 loc) · 6.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
unit UMap;
interface
uses
UInterfaceWrapper, GrymCore_TLB, ULayers, UMapTools, UMapPoint, UPopupMenu
, UDevPoint, UMapCoordinateTransformationGeo, UMapRect, UGrymGraphic
, UMapCoordinateTransformationUTM, UMapInfoControllers, UCallout, USelection
, UFeature;
type
TMap = class(TInterfaceWrapper<IMap>)
FLayers: TLayers;
FTools: TMapTools;
FPopupMenu: TPopupMenu;
FCoordinateTransformationGEO: TMapCoordinateTransformationGeo;
FCoordinateTransformationUTM: TMapCoordinateTransformationUTM;
FMapInfoControllers: TMapInfoControllers;
public
destructor Destroy; override;
// IMap
function GetLayers: TLayers;
function GetTools: TMapTools;
function ContextMenu: TPopupMenu;
function Handle: THandle;
function CoordinateTransformationGEO: TMapCoordinateTransformationGeo;
function CoordinateTransformationUTM: TMapCoordinateTransformationUTM;
function FullExtend: TMapRect;
function GetSelection(bsTag: string; bForceCreate: Boolean = False): TSelection;
function MapInfoControllers: TMapInfoControllers;
// IDeviceMap
function DeviceToMap(Pnt: TDevPoint): TMapPoint;
function MapToDevice(Pnt: TMapPoint): TDevPoint;
procedure Invalidate(Full: Boolean = False);
// IMapGraphics
procedure AddGraphic(Graphic: IGraphicBase);
procedure RemoveGraphic(Graphic: IGraphicBase);
function CreateCallout(Point: TMapPoint; AutoClose: Boolean = True
; Vector: TDevPoint = nil; pSize: IDevSize = nil): TCallout;
function GraphicByTag(Tag: string): IGraphicBase;
// IMap2
function CreateInfoCard(Feature: TFeature): TCallout;
end;
implementation
uses
SysUtils, ComObj;
{ TMap }
procedure TMap.AddGraphic(Graphic: IGraphicBase);
begin
OleCheck((Self.GetInterface as IMapGraphics).AddGraphic(Graphic));
end;
function TMap.ContextMenu: TPopupMenu;
var
pPopupMenu: IPopupMenu;
begin
if not Assigned(Self.FPopupMenu) then
begin
OleCheck(Self.GetInterface.Get_ContextMenu(pPopupMenu));
Self.FPopupMenu := TPopupMenu.Create(pPopupMenu);
end;
Result := Self.FPopupMenu;
end;
function TMap.CoordinateTransformationGEO: TMapCoordinateTransformationGeo;
var
Transformation: IUnknown;
TransformationGEO: IMapCoordinateTransformationGeo;
begin
if not Assigned(Self.FCoordinateTransformationGEO) then
begin
OleCheck(Self.GetInterface.Get_CoordinateTransformation(Transformation));
Transformation.QueryInterface(IID_IMapCoordinateTransformationGeo
, TransformationGEO);
Self.FCoordinateTransformationGEO
:= TMapCoordinateTransformationGeo.Create(TransformationGEO);
end;
Result := Self.FCoordinateTransformationGEO;
end;
function TMap.CoordinateTransformationUTM: TMapCoordinateTransformationUTM;
var
Transformation: IUnknown;
TransformationUTM: IMapCoordinateTransformationUTM;
begin
if not Assigned(Self.FCoordinateTransformationUTM) then
begin
OleCheck(Self.GetInterface.Get_CoordinateTransformation(Transformation));
Transformation.QueryInterface(IID_IMapCoordinateTransformationUTM
, TransformationUTM);
Self.FCoordinateTransformationUTM
:= TMapCoordinateTransformationUTM.Create(TransformationUTM);
end;
Result := Self.FCoordinateTransformationUTM;
end;
function TMap.CreateCallout(Point: TMapPoint; AutoClose: Boolean;
Vector: TDevPoint; pSize: IDevSize): TCallout;
var
Callout: ICallout;
begin
OleCheck((Self.GetInterface as IMapGraphics).CreateCallout(Point, AutoClose
, Vector, pSize, Callout));
Result := TCallout.Create(Callout);
end;
function TMap.CreateInfoCard(Feature: TFeature): TCallout;
var
Callout: ICallout;
begin
OleCheck((Self.GetInterface as IMap2).CreateInfoCard(Feature.GetInterface
, Callout));
Result := TCallout.Create(Callout);
end;
destructor TMap.Destroy;
begin
FreeAndNil(Self.FTools);
FreeAndNil(Self.FLayers);
FreeAndNil(Self.FPopupMenu);
FreeAndNil(Self.FCoordinateTransformationGEO);
FreeAndNil(Self.FCoordinateTransformationUTM);
inherited;
end;
function TMap.DeviceToMap(Pnt: TDevPoint): TMapPoint;
var
MapPoint: IMapPoint;
begin
OleCheck((Self.GetInterface as IMapDevice).DeviceToMap(Pnt, MapPoint));
Result := TMapPoint.Create(MapPoint);
end;
function TMap.FullExtend: TMapRect;
var
MapRect: IMapRect;
begin
OleCheck(Self.GetInterface.Get_FullExtent(MapRect));
Result := TMapRect.Create(MapRect);
end;
function TMap.GetLayers: TLayers;
var
pLayers: ILayerCollection;
begin
if not Assigned(Self.FLayers) then
begin
OleCheck(Self.GetInterface.Get_Layers(pLayers));
Self.FLayers := TLayers.Create(pLayers);
end;
Result := Self.FLayers;
end;
function TMap.GetSelection(bsTag: string; bForceCreate: Boolean): TSelection;
var
Selection: ISelection;
begin
OleCheck(Self.GetInterface.GetSelection(bsTag, bForceCreate, Selection));
Result := TSelection.Create(Selection);
end;
function TMap.GetTools: TMapTools;
var
pTools: IMapTools;
begin
if not Assigned(Self.FTools) then
begin
OleCheck(Self.GetInterface.Get_Tools(pTools));
Self.FTools := TMapTools.Create(pTools);
end;
Result := Self.FTools;
end;
function TMap.GraphicByTag(Tag: string): IGraphicBase;
var
Res: HRESULT;
begin
Res := (Self.GetInterface as IMapGraphics).Get_GraphicByTag(Tag, Result);
if Res = S_FALSE then
begin
Result := nil
end
else if Res <> S_OK then
begin
OleCheck(Res);
end;
end;
function TMap.Handle: THandle;
begin
OleCheck(Self.GetInterface.Get_HWindow(Result));
end;
procedure TMap.Invalidate(Full: Boolean);
begin
OleCheck(Self.GetInterface.Invalidate(Full));
end;
function TMap.MapInfoControllers: TMapInfoControllers;
var
pMapInfoControllers: IMapInfoControllers;
begin
if not Assigned(Self.FMapInfoControllers) then
begin
OleCheck(Self.GetInterface.Get_MapInfoControllers(pMapInfoControllers));
Self.FMapInfoControllers := TMapInfoControllers.Create(pMapInfoControllers);
end;
Result := Self.FMapInfoControllers;
end;
function TMap.MapToDevice(Pnt: TMapPoint): TDevPoint;
var
DevPoint: IDevPoint;
begin
OleCheck((Self.GetInterface as IMapDevice).MapToDevice(Pnt, DevPoint));
Result := TDevPoint.Create(DevPoint);
end;
procedure TMap.RemoveGraphic(Graphic: IGraphicBase);
begin
OleCheck((Self.GetInterface as IMapGraphics).RemoveGraphic(Graphic));
end;
end.