最近做Arcgis for android中发现 Arcgis 4 android API中并未提供路径查询的接口,查询其原因还是考虑到手机客户端的运算能力及手机性能有限,所有在客户端未能有接口可以直接使用。
要实现两点之间最短路径的查询,在Arcgis 4 android中有2中实现方式,GP/NA服务,我选择了NAServer服务实现最短路径的查询。
客户端通过HTTP get/post请求,调用发布的NA服务,通过要求返回的数据json或html,进行解析得到paths中的点串,再将得到的点串进行绘制,就能得到经过的最短路径了。
需要注意的是,地图坐标系必须一样,否则绘制的路径与地图就会不匹配。
HTTP调用样例:
NA服务:http://microinfowh.xicp.net:8399/arcgis/rest/services/CDRoute/NAServer
后面即传的参数等。
http://microinfowh.xicp.net:8399/arcgis/rest/services/CDRoute/NAServer/Route/solve?stops=104.06712589600005,30.737178542000038;104.06694000000005,30.736774000000025&barriers=&polylineBarriers=&polygonBarriers=&outSR=4326&ignoreInvalidLocations=true&accumulateAttributeNames=&impedanceAttributeName=Length&restrictionAttributeNames=&attributeParameterValues=&restrictUTurns=esriNFSBAllowBacktrack&useHierarchy=false&returnDirections=true&returnRoutes=true&returnStops=true&returnBarriers=false&returnPolylineBarriers=false&returnPolygonBarriers=false&directionsLanguage=&directionsStyleName=&outputLines=esriNAOutputLineTrueShape&findBestSequence=false&preserveFirstStop=true&preserveLastStop=true&useTimeWindows=false&startTime=-2209132800000&outputGeometryPrecision=&outputGeometryPrecisionUnits=esriDecimalDegrees&directionsTimeAttributeName=Minute&directionsLengthUnits=esriNAUMeters&f=pjson
Arcgis for android最短路径查询的实现
最新推荐文章于 2021-05-22 17:27:04 发布