IntersectFeatures 如何用?(30分)

靴子

Unregistered / Unconfirmed
GUEST, unregistred user!
我有一个线图层,在线图层中定一点,然后查找距这一点一定范围内的线的和一个圆的交点,但是就是通不过IntersectFeatures。我的代码如下:
procedure TForm1.Button3Click(Sender: TObject);
var
vl_ftrs : cmapxfeatures;//图层中所有的图元
vl_pnt : cmapxPoint;
ftrac : cmapxfeaturefactory;
ftr : cmapxfeature;
vl_ftrInterSect : cmapxfeature;//得到和半径相交的图元
vl_lyr1 : cmapxlayer;
begin

vl_lyr1 := map1.Layers.Item[1];//线图元所在的图层
vl_pnt := coPoint.Create;
vl_pnt.Set_(strtofloat(edit1.Text),strtofloat(edit2.Text));
ftrac := map1.FeatureFactory;

ftr :=ftrac.CreateCircularRegion(1,vl_pnt,strtofloat(edit3.text),7,24,map1.DefaultStyle);

vl_ftrs := vl_lyr1.SearchWithinDistance(vl_pnt,strtofloat(edit3.text),7,1);
showmessage(inttostr(vl_ftrs.Count));


vl_ftrInterSect := ftrac.IntersectFeatures(ftr,vl_ftrs)

showmessage(inttostr(vl_ftrInterSect.Parts.Count));


end;
 

大唐电信

Unregistered / Unconfirmed
GUEST, unregistred user!
vl_ftrs是图元的集合,你要一个一个的和圆求交点。
求交叉点可以用IntersectionPoints。
var
pt,temppt:points;
vl_ftrs : cmapxfeatures;//图层中所有的图元
vl_pnt : cmapxPoint;
ftrac : cmapxfeaturefactory;
ftr : cmapxfeature;
vl_ftrInterSect : cmapxfeature;//得到和半径相交的图元
vl_lyr1 : cmapxlayer;
begin

vl_lyr1 := map1.Layers.Item[1];//线图元所在的图层
vl_pnt := coPoint.Create;
vl_pnt.Set_(strtofloat(edit1.Text),strtofloat(edit2.Text));
ftrac := map1.FeatureFactory;

ftr :=ftrac.CreateCircularRegion(1,vl_pnt,strtofloat(edit3.text),7,24,map1.DefaultStyle);

vl_ftrs := vl_lyr1.SearchWithinDistance(vl_pnt,strtofloat(edit3.text),7,1);


pt:=copoints.create;
for i:=1 to vl_ftrs.Countdo

begin

temppt:=map1.FeatureFactory.IntersectionPoints( ftr,vl_ftrs.item,miIntersectAll);
for j:=1 to temppt.countdo

pt.add(temppt.item[j]);
end;



showmessage(inttostr(pt.Count));
 

靴子

Unregistered / Unconfirmed
GUEST, unregistred user!
接受答案了.
 
顶部