各位老师,请帮我看这段程序哪里错了?(我已经没有分可以给了) (5分)

  • 主题发起人 主题发起人 狐狸精
  • 开始时间 开始时间

狐狸精

Unregistered / Unconfirmed
GUEST, unregistred user!
其中红色部分就是取不到图元属性的代码。1009工具能正常取得所选图元的Site属性的值。
1008和1010工具不行。请各位老师指教指教。谢谢了,我也没有分了。
procedure TShowMap.Map1ToolUsed(Sender: TObject;
ToolNum: Smallint;
X1, Y1,
X2, Y2, Distance:do
uble;
Shift, Ctrl: WordBool;
var EnableDefault: WordBool);
var
pnt,rc: Variant;
ftrs : Variant;
// Used for storing collection of features
EditLayer : Variant;
// Layer variable to hold current edit layer
searchLayer:Variant;
infoFeature : Variant;// Global value to hold selected feature for Info Tool
i:integer;
dist :do
uble;
begin

searchResultsList.Clear;
// EditLayer := Map1.ControlInterface.Layers.Item('cell');
EditLayer := Map1.Layers.Item('cell');
pnt := CreateOleObject('MapX.Point.4');
case toolnum of
GetDataToolID://取单个基站的数据
begin

pnt.set(X1,Y1);
Ftrs := EditLayer.SearchAtPoint(pnt);
if Ftrs.Count = 1 then

begin

infoFeature := Ftrs.Item(1);
EditLayer.KeyField:='site';
searchResultsList.Items.Add(infoFeature.KeyValue);
end;

VarClear(pnt);
end;

[red]1008: //取圆形选择区域的基站数据
begin

dist := Map1.Distance(X1, Y1, X2, Y2);
pnt.Set(X1,Y1);
ftrs := EditLayer.SearchWithinDistance(pnt, dist, miUnitMile, miSearchTypeEntirelyWithin);
MessageDlg(inttostr(Ftrs.Count), mtInformation, [mbOK], 0);
for i:=1 to ftrs.countdo

begin

infoFeature := Ftrs.Item(i);
EditLayer.KeyField:='site';
searchResultsList.Items.Add(infoFeature.KeyValue);
end;

VarClear(pnt);
end;
[/red]
1009: //取方形选择区域的基站数据
begin

rc := CreateOleObject('MapX.Rectangle.4');
rc.Set(X1, Y1, X2, Y2);
ftrs := EditLayer.SearchWithinRectangle(rc, miSearchTypeEntirelyWithin);
for i := 1 to ftrs.Countdo

begin

infoFeature := Ftrs.Item(i);
EditLayer.KeyField:='site';
searchResultsList.Items.Add(infoFeature.KeyValue);
end;

VarClear(rc);

end;

[red]1010: //取不规则选择区域的基站数据
begin

SearchLayer:=map1.Layers.Item('Cell');
pnt.Set(X1,Y1);
ftrs := SearchLayer.SearchAtPoint(pnt);
MessageDlg(inttostr(Ftrs.Count), mtInformation, [mbOK], 0);
if ftrs.Count > 0 then

infoFeature := ftrs.Item(1)
else

exit;
ftrs := EditLayer.SearchWithinFeature(infoFeature, miSearchTypeEntirelyWithin);
MessageDlg(inttostr(Ftrs.Count), mtInformation, [mbOK], 0);
for i:=1 to ftrs.countdo

begin

infoFeature := Ftrs.Item(i);
EditLayer.KeyField:='site';
searchResultsList.Items.Add(infoFeature.KeyValue);
end;

VarClear(pnt);
end;
[/red]
end;

end;
 
后退
顶部