概述:javascript
本文講述如何利用Arcgis 的Gp服務實現Spline插值,並將插值的結果按照指定的區域進行裁剪,最後將裁剪的結果根據特定的樣式渲染,並在頁面實現多期輪播的這樣一個效果。java
實現效果:git
實現步驟:github
一、模型構建web
a、肯定須要工具ajax
該功能須要兩個工具:一、Spline,實現插值計算;二、Extract by Mask,實現指定區域的裁剪。json
b、肯定模型參數dom
輸入參數:一、計算點;ssh
二、計算字段;async
輸出參數:一、裁剪後柵格;
常 量:裁剪區域
c、設置輸出樣式
1)執行模型,驗證模型正確性;
2)設置結果樣式,並導出爲lyr圖層;
設置樣式
存爲lyr
3)設置輸出柵格樣式;
二、服務發佈
a、再執行一遍模型
b、設置參數,發佈服務
將服務發佈爲一個MapService
填寫參數
三、前臺調用
/** * 插值計算 */ var gpUrl = "http://localhost:6080/arcgis/rest/services/lzugis/MaskSpline/GPServer/Spline"; var jobIds = []; var calcFlag = 0;//循環請求 $("#calgp").on("click", function () { $("#modal").show(); calcFlag = setInterval(calSplineGp,3000); } ); function calSplineGp(){ var gpFeatures = []; var features = gpData.features; for(var i in features){ var feature = features[i]; var gpFeature = { "attributes": { "id": i, "name": feature.attributes.name, "heat": Math.random()*100 + 1 }, "geometry": { "x": feature.geometry.x, "y": feature.geometry.y } }; gpFeatures.push(gpFeature); } var inputFeature = { "features":gpFeatures }; $.ajax( { type : "POST", cache : false, url : gpUrl + "/submitJob?InputFeatures="+JSON.stringify(inputFeature)+"&Field=heat&f=json", async : false, success : function (result) { result = eval("(" + result + ")"); var jobId = result.jobId; if (jobId) { submitJob(jobId); } else { console.log("計算失敗"); } } } ); } function submitJob(jobId) { $.ajax({ type: "POST", cache: false, url: gpUrl+"/jobs/"+jobId+"?f=json", async: false, success: function (result1) { result1 = eval("("+result1+")"); if(result1.jobStatus==="esriJobSucceeded"){ jobIds.push(jobId); if(jobIds.length===5){ clearInterval(calcFlag); loadResultLayer(); } } else if(result1.jobStatus==="esriJobFailed"){ console.log("計算失敗"); } else{ submitJob(jobId); } } }); } var showFlag = 0, showIndex=0; var gpLayer; var gp = new Geoprocessor(gpUrl); function loadResultLayer(){ $("#modal").hide(); showFlag = setInterval(function(){ var jobId = jobIds[showIndex]; gp.getResultImageLayer(jobId, null, null, function(_gpLayer){ if(gpLayer)map.removeLayer(gLayer); gpLayer = _gpLayer; gpLayer.setOpacity(0.9); map.addLayer(gpLayer); gpLayer.on("load",function(){ showIndex++; if(showIndex===jobIds.length-1){ showIndex = 0; } }); }); },2000); }
---------------------------------------------------------------------------------------------------------------
技術博客
http://blog.csdn.NET/gisshixisheng
在線教程
http://edu.csdn.Net/course/detail/799
Github
https://github.com/lzugis/
聯繫方式
q q:1004740957
e-mail:niujp08@qq.com
公衆號:lzugis15
Q Q 羣:452117357(webgis)
337469080(Android)