Cesium 接入Arcgis Server服务wms与返回geojson

Arcgis Server 10.2 wms返回值geojson格式问题

Cesium接入arcgis server发布地图服务

如何使用Arcgis Server发布地图服务在此不表,具体详情:发布地图服务

Arcgis Server 选择地图服务类型,将OGC的wms服务与WFS服务勾选:

image.png

使用多域名的方式进行接入:

   var provider = new Cesium.WebMapServiceImageryProvider({
        url: 'http://10.16.{s}:6080/arcgis/services/QJDC/BDCDY/MapServer/WmsServer', // 服务地址
        layers: '0,1', //接入图层
        tilingScheme: new Cesium.WebMercatorTilingScheme(), // web墨卡托
        getFeatureInfoFormats :  [new Cesium.GetFeatureInfoFormat('json', 'application/geojson')],  //获取格式,可以多种
        subdomains: ['30.237', '30.238', '30.239'], //多域名
        parameters: {
            service: 'WMS',
            format: 'image/png',
            transparent: true
        }
    });
    viewer.imageryLayers.addImageryProvider(provider);

var phjc_provider = new Cesium.WebMapServiceImageryProvider({
        url: 'http://10.16.{s}:6080/arcgis/services/PHJC/PHJC/MapServer/WmsServer',
        layers: '0,1',
        tilingScheme: new Cesium.WebMercatorTilingScheme(),
        getFeatureInfoFormats : [new Cesium.GetFeatureInfoFormat('json', 'application/geojson')],
        subdomains: ['30.237', '30.238', '30.239'],
        parameters: {
            service: 'WMS',
            format: 'image/png',
            transparent: true
        }
    });
    viewer.imageryLayers.addImageryProvider(phjc_provider);

WMS服务返回值格式自定义

查看发布的WMS服务到底含有哪些内容:

http://10.16.30.236:6080/arcgis/services/QJDC/BDCDY/MapServer/WMSServer?request=GetCapabilities&service=WMS
image.png

GetFeatureInfo中的几个样式分别对应ArcGIS server 安装目录下的几个样式文件。

image.png

按照正常的调用方法,将getFeatureInfoFormats : [new Cesium.GetFeatureInfoFormat('json', 'application/geojson')],设置为application/geojson之后,WMS自动将向 ArcGIS Server发送请求,Arcgis Server将寻找到featureinfo_application_geojson.xsl的样式文件,并且根据该样式文件返回geojson格式的返回值:

http://10.16.30.239:6080/arcgis/services/QJDC/BDCDY/MapServer/WmsServer?service=WMS&version=1.1.1&request=GetFeatureInfo&layers=1&bbox=13042297.262243055%2C3372707.4360551164%2C13042603.010356195%2C3373013.184168257&width=256&height=256&srs=EPSG%3A3857&query_layers=1&x=39&y=106&info_format=application%2Fgeojson
image.png

但是,在切换到10.2后,问题来了,

  • 在ArcGIS Server 10.3中可以正常使用提供的application/geojson样式进行请求:
image.png
  • 但是,在Arcgis Server 10.2中虽然安装目录有相关的配置文件,但是不能调用到:
image.png
image.png

最终解决办法

Arcgis Server 10.2既然可以用text/html的方式进行样式的调用,修改featureinfo_text_html.xsl样式文件,将geojson中的值拷贝到里面:

image.png

getFeatureInfoFormats : [new Cesium.GetFeatureInfoFormat('json', 'application/geojson')],修改为getFeatureInfoFormats : [new Cesium.GetFeatureInfoFormat('json', 'text/html')],

发送请求:

http://10.16.30.236:6080/arcgis/services/QJDC/BDCDY/MapServer/WmsServer?service=WMS&version=1.1.1&request=GetFeatureInfo&layers=1&bbox=13042297.262243055%2C3372707.4360551164%2C13042603.010356195%2C3373013.184168257&width=256&height=256&srs=EPSG%3A3857&query_layers=1&x=39&y=106&info_format=text%2Fhtml

PS: ArcGIS Server 扩展开发(SOE)

如果以上的几种数据发布方式都不能满足项目需要,Arcgis Server 还提供了使用AO进行二次开发的方式进行扩展。

image.png

具体博客见:
GeoJSON

image.png

你可能感兴趣的:(Cesium 接入Arcgis Server服务wms与返回geojson)