如何在MAPINFO里检索物体然后定位呢? ( 积分: 200 )

  • 主题发起人 主题发起人 appleman
  • 开始时间 开始时间
A

appleman

Unregistered / Unconfirmed
GUEST, unregistred user!
下边是用遍历的方法写的 太慢了
procedure TfrmsearchRs.searchResultsListListBoxDblClick(Sender: TObject);
var
i,j,layerCount,FeatureCount:integer;
FoundObj, lyr, ds, curFeatures : variant;
nothing: variant;
s:string;
begin

if trim(bsSkinEdit1.Text)='' then
exit;
try
//Set nothing to be a varDispatch variant
TVarData(nothing).VType := varDispatch;
layerCount:=frmmain.map.Layers.Count;
for i:=1 to layerCountdo

begin

curFeatures :=frmmain.map.Layers.AllFeatures
FeatureCount := curFeatures.Count;
for j := 1 to FeatureCountdo

begin

FoundObj := curFeatures.Item[j];
s:=FoundObj.Name;
if s='' then
continue;
if pos(searchStr,s)>0 then

begin

frmmain.map.ZoomTo(25, FoundObj.CenterX, FoundObj.CenterY);
break;
end
else

end;


end;

showmessage(searchStr);
except
on e:exceptiondo

begin

showmessage(e.Message);
end;

end;

end;

地图目录里有些*.id 的文件 应该可以采用索引机制 可是 调用Feature的Search 方法 老是报错,晕死了.到底是哪里出了问题了????[?]
 
下边是用遍历的方法写的 太慢了
procedure TfrmsearchRs.searchResultsListListBoxDblClick(Sender: TObject);
var
i,j,layerCount,FeatureCount:integer;
FoundObj, lyr, ds, curFeatures : variant;
nothing: variant;
s:string;
begin

if trim(bsSkinEdit1.Text)='' then
exit;
try
//Set nothing to be a varDispatch variant
TVarData(nothing).VType := varDispatch;
layerCount:=frmmain.map.Layers.Count;
for i:=1 to layerCountdo

begin

curFeatures :=frmmain.map.Layers.AllFeatures
FeatureCount := curFeatures.Count;
for j := 1 to FeatureCountdo

begin

FoundObj := curFeatures.Item[j];
s:=FoundObj.Name;
if s='' then
continue;
if pos(searchStr,s)>0 then

begin

frmmain.map.ZoomTo(25, FoundObj.CenterX, FoundObj.CenterY);
break;
end
else

end;


end;

showmessage(searchStr);
except
on e:exceptiondo

begin

showmessage(e.Message);
end;

end;

end;

地图目录里有些*.id 的文件 应该可以采用索引机制 可是 调用Feature的Search 方法 老是报错,晕死了.到底是哪里出了问题了????[?]
 
后退
顶部