1. 程式人生 > >arcgis總結——網路分析服務的釋出以及路徑規劃

arcgis總結——網路分析服務的釋出以及路徑規劃

       說明:不方便截圖,釋出步驟全文字描述

       這裡只說明通過圖層檔案shapefile如何生成network dataset從而釋出網路分析服務,對於通過資料庫的方式這裡不做說明

       1、開啟arcCatalog

       2、點選選單customize->extensions,勾選network analyst

       3、在需要建立network dataset的圖層上右鍵,點選new network dataset。如果不進行第二部操作,這裡的new network dataset則為灰色的

       4、如果沒有什麼特殊要求,全部直接下一步即可

       5、開啟arcMap

       6、點選選單customize->extensions,勾選network analyst

       7、點選選單customize->toolbar,勾選network analyst

       8、這個時候可以看到network analyst的工具欄,但是選項出了options之外都是灰色的

       9、滑鼠右鍵圖層,選擇add data,選中之前建立的network dataset

       10、這個時候network analyst工具欄可以使用了,點選new route,這個時候則會生成路徑圖層

       11、點選選單file->share as->server

       12、同釋出地圖服務一樣,一直到service editor視窗

       13、在service editor視窗中點選Capabilities,勾選Network Analysis

       14、接下來的步驟和釋出地圖服務一樣

       路徑規劃也是通過呼叫rest服務實現

       前端關鍵程式碼如下:

function solveRoute(startPos,endPos){  <pre name="code" class="javascript">   dojo.xhrGet({
     url:'http://testtest:8080/arcgisDemo/solveRoute?startPos='+startPos+'&endPos='+endPos,
     load:function(data){
       var json=dojox.json.ref.fromJson(data);
       showResults(json.candidates[0].location.x+";"+json.candidates[0].location.y);
     }
   });
}

      後端servlet關鍵程式碼如下:

@Override
proptected void doGet(
  HttpServletRequest request,
  HttpServletResponse response
){
  response.setContentType("text/html;charset=UTF-8");
  response.setContentType("application/json;charset=UTF-8");
  String startPos=request.getParameter("startPos");
  String endPos=request.getParameter("endPos");
  PrintWriter out=null;
  try{
      String rs=ClientUtil.executeHttp("http://server_url:6080/arcgis/rest/services/serverName/NAServer/Route/solve?stops="+startPos.split(",")[0]+"%2C"+startPos.split(",")[1]+"%3B"+endPos.split(",")[0]+"%2C"+endPos.split(",")[1]+"&barriers=&polylineBarriers=&polygonBarriers=&outSR=&ignoreInvalidLocations=true&accumulateAttributeNames=&impedanceAttributeName=Length&restrictionAttributeNames=&attributeParameterValues=&restrictUTurns=esriNFSBAllowBacktrack&useHierarchy=false&returnDirections=false&returnRoutes=true&returnStops=false&returnBarriers=false&returnPolylineBarriers=false&returnPolygonBarriers=false&directionsLanguage=en-US&directionsStyleName=&outputLines=esriNAOutputLineTrueShapeWithMeasure&findBestSequence=false&preserveFirstStop=false&preserveLastStop=false&useTimeWindows=false&startTime=0&outputGeometryPrecision=&outputGeometryPrecisionUnits=esriDecimalDegrees&directionsOutputType=esriDOTComplete&directionsTimeAttributeName=&directionsLengthUnits=esriNAUMiles&returnZ=false&f=pjson");
      out=response.getWriter();
      out.write(rs);
  }catch(Exception e){
      e.printStactTrace();
  }finally{
      if(out!=null){
      out.close();
  }
}