var
ft,ftr1,ft1:cmapxfeature;
fs:cmapxfeatures;
j,cnt:integer;
pt1,pt2:Cmapxpoint;
obj:variant; // 相交的图元
arrVals: Variant; // 节点
r:double;
x,y:array of array of double; // x,y:中心线的节点,第一维表示节点的序号,第二维表示选择的图元序号;
x1,y1:array of double
x2,y2:double; // 所有相交图元中最短距离的点
nodecnt:integer; // 记录所有相交图元的节点
dd,tt:double; // 中间变量
dist,d:double;
beginft:=map1.FeatureFactory.CreateCircularRegion(1,pt,radiu,miUnitMeter,24,map1.DefaultStyle); //以接收到的点做圆
fs:=map1.Layers.Item['街道中心线'].SearchWithinDistance(pt,radiu+30,miUnitMeter,1); //接收点200米范围内的街道中心线的所有图元 //////////////画最短路径
tt:=1000000;
if fs.Count>0 then
begin
setlength(x1,fs.Count);
setlength(y1,fs.Count);
for j:=1 to fs.Count do
begin
ftr1:=fs.Item[j];
if map1.FeatureFactory.IntersectionTest(ftr1,ft,miintersectfeature) then
begin
if ftr1.Type_=1 then
begin
setlength(x,ftr1.Parts.Item[1].Count,fs.Count);
setlength(y,ftr1.Parts.Item[1].Count,fs.Count); dd:=1000000;
for i:=1 to ftr1.Parts.Item[1].Count do
begin
x[i-1,j-1]:=ftr1.Parts.Item[1].Item[i].X;
y[i-1,j-1]:=ftr1.Parts.Item[1].Item[i].Y; dist:=map1.Distance(x[i-1,j-1],y[i-1,j-1],pt.X,pt.Y);//接收点与中心线节点的距离
//求最短路径的点
if dist<dd then
begin
x1[j-1]:=x[i-1,j-1];
y1[j-1]:=y[i-1,j-1];
dd:=dist;
end;
end;
end
else
continue;
d:=map1.Distance(x1[j-1],y1[j-1],pt.X,pt.Y);
if d<tt then
begin
x2:=x1[j-1];
y2:=y1[j-1];
tt:=d;
end;
end;//endfor j end; //end if fs>0 //x2,y2是要求的匹配的点
if int(x2)<>0 then
begin
v_temp.longitude:=x2;
v_temp.latitude:=y2;
pt.Set_(x2,y2);
end;
varclear(obj);
varclear(arrvals);
end;
ft,ftr1,ft1:cmapxfeature;
fs:cmapxfeatures;
j,cnt:integer;
pt1,pt2:Cmapxpoint;
obj:variant; // 相交的图元
arrVals: Variant; // 节点
r:double;
x,y:array of array of double; // x,y:中心线的节点,第一维表示节点的序号,第二维表示选择的图元序号;
x1,y1:array of double
x2,y2:double; // 所有相交图元中最短距离的点
nodecnt:integer; // 记录所有相交图元的节点
dd,tt:double; // 中间变量
dist,d:double;
beginft:=map1.FeatureFactory.CreateCircularRegion(1,pt,radiu,miUnitMeter,24,map1.DefaultStyle); //以接收到的点做圆
fs:=map1.Layers.Item['街道中心线'].SearchWithinDistance(pt,radiu+30,miUnitMeter,1); //接收点200米范围内的街道中心线的所有图元 //////////////画最短路径
tt:=1000000;
if fs.Count>0 then
begin
setlength(x1,fs.Count);
setlength(y1,fs.Count);
for j:=1 to fs.Count do
begin
ftr1:=fs.Item[j];
if map1.FeatureFactory.IntersectionTest(ftr1,ft,miintersectfeature) then
begin
if ftr1.Type_=1 then
begin
setlength(x,ftr1.Parts.Item[1].Count,fs.Count);
setlength(y,ftr1.Parts.Item[1].Count,fs.Count); dd:=1000000;
for i:=1 to ftr1.Parts.Item[1].Count do
begin
x[i-1,j-1]:=ftr1.Parts.Item[1].Item[i].X;
y[i-1,j-1]:=ftr1.Parts.Item[1].Item[i].Y; dist:=map1.Distance(x[i-1,j-1],y[i-1,j-1],pt.X,pt.Y);//接收点与中心线节点的距离
//求最短路径的点
if dist<dd then
begin
x1[j-1]:=x[i-1,j-1];
y1[j-1]:=y[i-1,j-1];
dd:=dist;
end;
end;
end
else
continue;
d:=map1.Distance(x1[j-1],y1[j-1],pt.X,pt.Y);
if d<tt then
begin
x2:=x1[j-1];
y2:=y1[j-1];
tt:=d;
end;
end;//endfor j end; //end if fs>0 //x2,y2是要求的匹配的点
if int(x2)<>0 then
begin
v_temp.longitude:=x2;
v_temp.latitude:=y2;
pt.Set_(x2,y2);
end;
varclear(obj);
varclear(arrvals);
end;
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货