通过核密度分析工具建模,基于arcgis js api 4.27 加载gp服务

编程入门 行业动态 更新时间:2024-10-19 02:16:57

通过核密度分析工具<a href=https://www.elefans.com/category/jswz/34/1769748.html style=建模,基于arcgis js api 4.27 加载gp服务"/>

通过核密度分析工具建模,基于arcgis js api 4.27 加载gp服务

一、通过arcmap10.2建模,其中包含三个参数

注意input属性,选择数据类型为要素类:

二、建模之后,加载数据,执行模型,无错误的话,找到执行结果,进行发布gp服务

注意,发布gp服务服务的时候,参数可以设置同步,也可以设置异步,我选择的异步执行

三、发布完gp服务,通过api进行调用


<!DOCTYPE html>
<html>
<head><meta charset="utf-8" /><meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no" /><style>html,body,#viewDiv {padding: 0;margin: 0;height: 100%;width: 100%;}#paneDiv {position: absolute;top: 18px;right: 18px;padding: 12px;background-color: rgba(0, 0, 0, 0.5);color: white;width: 200px;}</style><link rel="stylesheet" href=".27/esri/themes/light/main.css"><script src=".27/"></script><script>require(["esri/rest/geoprocessor","esri/views/MapView","esri/layers/WebTileLayer","esri/Map","esri/layers/GraphicsLayer","esri/rest/support/FeatureSet","esri/Graphic","esri/symbols/SimpleMarkerSymbol","esri/rest/support/JobInfo"], function (geoprocessor,MapView,WebTileLayer,Map,GraphicsLayer,FeatureSet,Graphic,SimpleMarkerSymbol,JobInfo) {//gp服务地址let gpUrl = "http://localhost:6080/arcgis/rest/services/kenerDenNew3/GPServer/kenerDen"//gp服务输出参数名称let map = new Map();let tdtVecLayer = new WebTileLayer({urlTemplate:'http://{subDomain}.tianditu.gov/DataServer?T=vec_w&x={col}&y={row}&l={level}&tk=bb8b7ddbbafd349de08d74835c91d83a',subDomains: ['t0', 't1', 't2', 't3', 't4', 't5', 't6', 't7'],})let tdtPoiLayer = new WebTileLayer({urlTemplate:'http://{subDomain}.tianditu.gov/DataServer?T=cva_w&x={col}&y={row}&l={level}&tk=bb8b7ddbbafd349de08d74835c91d83a',subDomains: ['t0', 't1', 't2', 't3', 't4', 't5', 't6', 't7'],})map.add(tdtVecLayer);map.add(tdtPoiLayer);const view = new MapView({map: map,container: "viewDiv",zoom: 15,center: [118.583979, 31.89568],});//创建矢量图层并加入到地图上var graphicsLayer = new GraphicsLayer();map.add(graphicsLayer);var inputGraphicContainer = [];//创建要素集实例,它的features位graphic数组var featureSet = new FeatureSet();//点击添加点 大于15个点时执行gp服务生成核密度图view.on("click", (evt) => {let symbol = {type: "simple-marker",style: "circle",color: "blue",size: "18px",outline: {color: [255, 255, 0],width: 1}};var point = evt.mapPoint;//构建矢量数据源,包含几何和样式let inputGraphic = new Graphic({geometry: point,symbol: symbol,});graphicsLayer.add(inputGraphic);inputGraphicContainer.push(inputGraphic);if (inputGraphicContainer.length > 5) {featureSet.features = inputGraphicContainer;var params = {input: featureSet,outcellsize:0.5};geoprocessor.submitJob(gpUrl, params).then(jobInfo => {console.log(jobInfo)const jobid = jobInfo.jobId;console.log("job ID: ", jobid);const options = {interval: 1500,statusCallback: (j) => {console.log("Job Status: ", j.jobStatus);}};jobInfo.waitForJobCompletion(options).then(() => {const layer = jobInfo.fetchResultMapImageLayer();map.add(layer);});})}})});</script>
</head><body><div id="viewDiv"></div>
</body>
</html>

结果如下:

四、分析执行过程:

1.执行提交job 获取到jobid

   http://localhost:6080/arcgis/rest/services/kenerDenNew3/GPServer/kenerDen/submitJob

2.取到jobid轮训,直到jobStatus为"esriJobSucceeded"http://localhost:6080/arcgis/rest/services/kenerDenNew3/GPServer/kenerDen/jobs/jc6c8f53ed9ca48419c0705a2bd199014?f=json:6080/arcgis/rest/services/kenerDenNew3/GPServer/kenerDen/jobs/jc6c8f53ed9ca48419c0705a2bd199014?f=json3.最后一步,通过范围去加载图片http://localhost:6080/arcgis/rest/services/kenerDenNew3/MapServer/jobs/jc6c8f53ed9ca48419c0705a2bd199014/export?bbox=13198742.293698987%2C3747343.614782717%2C13202674.023341509%2C3751905.9499086086&bboxSR=102100&imageSR=102100&size=823%2C955&dpi=96&format=png32&transparent=true&layers=show%3A0&f=imagehttp://localhost:6080/arcgis/rest/services/kenerDenNew3/MapServer/jobs/jc6c8f53ed9ca48419c0705a2bd199014/export?bbox=13198742.293698987%2C3747343.614782717%2C13202674.023341509%2C3751905.9499086086&bboxSR=102100&imageSR=102100&size=823%2C955&dpi=96&format=png32&transparent=true&layers=show%3A0&f=image

更多推荐

通过核密度分析工具建模,基于arcgis js api 4.27 加载gp服务

本文发布于:2023-12-08 12:00:33,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1672722.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:建模   密度   加载   工具   js

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!