当前位置: 首页 > news >正文

通过核密度分析工具建模,基于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="https://js.arcgis.com/4.27/esri/themes/light/main.css"><script src="https://js.arcgis.com/4.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.cn/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.cn/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=jsonicon-default.png?t=N7T8http://10.1.8.37: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=imageicon-default.png?t=N7T8http://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

http://www.lryc.cn/news/196517.html

相关文章:

  • 【vue2高德地图api】02-npm引入插件,在页面中展示效果
  • ai智能语音电销机器人怎么选?
  • NumPy基础及取值操作
  • vue webpack/vite的区别
  • 多线程下的单例设计模式(新手必看!!!)
  • JDK 21的新特性总结和分析
  • 【VR】【Unity】白马VR课堂系列-VR开发核心基础03-项目准备-VR项目设置
  • Windows服务器安装php+mysql环境的经验分享
  • 【LeetCode热题100】--287.寻找重复数
  • JUC并发编程——Stream流式计算(基于狂神说的学习笔记)
  • 【Eclipse】取消按空格自动补全,以及出现没有src的解决办法
  • ps制作透明公章 公章变透明 ps自动化批量抠图制作透明公章
  • Fetch与Axios数据请求
  • 论文阅读-FCD-Net: 学习检测多类型同源深度伪造人脸图像
  • 云服务器快速搭建网站
  • 小程序首页搭建
  • 5、使用 pgAdmin4 图形化创建和管理 PostgreSQL 数据库
  • EtherCAT转Modbus-TCP协议网关与DCS连接的配置方法
  • 合伙企业的执行事务合伙人委派代表是什么样的存在
  • visual studio设置主题和背景颜色
  • [JVM]问下,对象在堆上的内存分配是怎样的
  • TCP/IP网络分层模型
  • 数据结构-----红黑树的插入
  • Excel大量表格选择,快速定位表格
  • 力扣环形链表(1)进阶环形链表(2)及环形链表的约瑟夫问题
  • linux文件权限与目录配置
  • 2023年10月wxid转微信号方法
  • 【Spring Boot 源码学习】@Conditional 条件注解
  • jupyter_快速开始
  • 英特尔 SGX 技术概述