如何判断一个指定的经纬度点是否落在一个多边形区域内?

来源:学生作业帮助网 编辑:作业帮 时间:2024/05/05 15:14:41

如何判断一个指定的经纬度点是否落在一个多边形区域内?

判断指定的经纬度坐标点是否落在指定的多边形区域内\x0d@paramALon指定点的经度\x0d@paramALat指定点的纬度\x0d@paramAPoints指定多边形区域各个节点坐标\x0d@returnTrue落在范围内False不在范围内\x0d------------------------------------------------------------------------------*}functionIsPtInPoly(ALon,ALat:double;APoints:arrayofTMyPoint):Boolean;variSum,iCount,iIndex:Integer;\x0ddLon1,dLon2,dLat1,dLat2,dLon:double;beginResult:=False;if(Length(APoints)<3)thenbeginResult:=False;Exit;end;iSum:=0;iCount:=Length(APoints);foriIndex:=0toiCount-1dobeginif(iIndex=iCount-1)thenbegindLon1:=APoints[iIndex].X;dLat1:=APoints[iIndex].Y;dLon2:=APoints[0\x0d].X;dLat2:=APoints[0\x0d].Y;endelsebegindLon1:=APoints[iIndex].X;dLat1:=APoints[iIndex].Y;dLon2:=APoints[iIndex+1