iclient生成不了等值面

0 投票

问题1.参考http://iclient.supermap.io/examples/classic/editor.html#analysis_surfaceAnalyst生成等值线过程,结合http://ask.supermap.com/49263问题回答,将用http://iclient.supermap.io/examples/classic/editor.html#analysis_surfaceAnalyst这个范例里面替换DatasetSurfaceAnalystParameters接口修改为SuperMap.REST.GeometrySurfaceAnalystParameters接口,运用的是自己的数据,结果生成不了等值面。

问题2:DatasetSurfaceAnalystParameters接口用到是自己发布的数据分析服务,并设置里面的参数dataset和zValueFieldName,但是GeometrySurfaceAnalystParameters接口points参数和 zValues参数,points参数和 zValues参数是本地数据,就生成不了等值面图,请问这个是为什么呢???

示例数据:

 [
    {"x": "103.88333", "y": "36.05", "z": "11"},
    {"x": "105", "y": "35.38333", "z": "4"},
    {"x": "107.98333", "y": "39.1", "z": "8"},
    {"x": "111.15", "y": "39.38333", "z": "9"},
    {"x": "113.51667", "y": "38.95", "z": "-1"},
    {"x": "106.21667", "y": "38.48333", "z": "10"},
    {"x": "109.7", "y": "38.23333", "z": "9"},
    {"x": "112.71667", "y": "38.73333", "z": "10"},
    {"x": "114.41667", "y": "38.03333", "z": "14"},
    {"x": "105.66667", "y": "37.48333", "z": "10"},
    {"x": "107.4", "y": "37.78333", "z": "9"},
    {"x": "108.16667", "y": "36.91667", "z": "9"},
    {"x": "111.1", "y": "37.5", "z": "10"},
    {"x": "112.55", "y": "37.78333", "z": "12"},
    {"x": "112.98333", "y": "37.06667", "z": "10"},
    {"x": "114.5", "y": "37.06667", "z": "15"},
    {"x": "109.5", "y": "36.6", "z": "11"},
    {"x": "111.93333", "y": "37.05", "z": "11"},
    {"x": "111.5", "y": "36.06667", "z": "13"},
    {"x": "114.36667", "y": "36.11667", "z": "15"},
    {"x": "106.66667", "y": "35.55", "z": "9"},
    {"x": "107.63333", "y": "35.73333", "z": "9"},
    {"x": "109.06667", "y": "35.08333", "z": "11"},
    {"x": "111.01667", "y": "35.03333", "z": "15"},
    {"x": "112.4", "y": "35.48333", "z": "12"},
    {"x": "113.88333", "y": "35.31667", "z": "15"},
    {"x": "117.18333", "y": "39.1", "z": "13"},
    {"x": "115.51667", "y": "38.85", "z": "14"},
    {"x": "116.83333", "y": "38.33333", "z": "13"},
    {"x": "116.31667", "y": "37.43333", "z": "14"},
    {"x": "117.51667", "y": "37.5", "z": "13"},
    {"x": "120.26667", "y": "37.61667", "z": "13"},
    {"x": "115.58333", "y": "36.03333", "z": "14"},
    {"x": "117.05", "y": "36.6", "z": "15"},
    {"x": "117.1", "y": "36.25", "z": "6"},
    {"x": "118.15", "y": "36.18333", "z": "13"},
    {"x": "119.18333", "y": "36.75", "z": "13"},
    {"x": "115.43333", "y": "35.25", "z": "14"},
    {"x": "116.85", "y": "35.56667", "z": "14"},
    {"x": "118.35", "y": "35.05", "z": "14"},
    {"x": "119.53333", "y": "35.43333", "z": "14"},
    {"x": "104.01667", "y": "34.43333", "z": "6"},
    {"x": "104.91667", "y": "33.4", "z": "15"},
    {"x": "104.51667", "y": "32.41667", "z": "15"},
    {"x": "104.68333", "y": "31.46667", "z": "17"},
    {"x": "104.01667", "y": "30.66667", "z": "17"},
    {"x": "105.75", "y": "34.58333", "z": "12"},
    {"x": "107.13333", "y": "34.35", "z": "14"},
    {"x": "108.93333", "y": "34.3", "z": "15"},
    {"x": "110.08333", "y": "34.48333", "z": "7"},
    {"x": "111.03333", "y": "34.05", "z": "13"},
    {"x": "112.46667", "y": "34.63333", "z": "12"},
    {"x": "113.65", "y": "34.71667", "z": "15"},
    {"x": "107.03333", "y": "33.06667", "z": "15"},
    {"x": "112.58333", "y": "33.03333", "z": "15"},
    {"x": "114.51667", "y": "33.78333", "z": "15"},
    {"x": "108.03333", "y": "32.06667", "z": "15"},
    {"x": "109.03333", "y": "32.71667", "z": "16"},
    {"x": "110.76667", "y": "32.03333", "z": "15"},
    {"x": "111.66667", "y": "32.38333", "z": "16"},
    {"x": "112.75", "y": "32.15", "z": "16"},
    {"x": "114.01667", "y": "33", "z": "15"},
    {"x": "114.05", "y": "32.13333", "z": "16"},
    {"x": "105.96667", "y": "31.58333", "z": "17"},
    {"x": "106.76667", "y": "31.58333", "z": "17"},
    {"x": "107.5", "y": "31.2", "z": "17"},
    {"x": "109.5", "y": "31.05", "z": "17"},
    {"x": "112.56667", "y": "31.16667", "z": "17"},
    {"x": "115.01667", "y": "31.18333", "z": "17"},
    {"x": "106.1", "y": "30.78333", "z": "17"},
    {"x": "107.8", "y": "30.68333", "z": "17"},
    {"x": "109.46667", "y": "30.28333", "z": "16"},
    {"x": "111.3", "y": "30.7", "z": "17"},
    {"x": "112.18333", "y": "30.33333", "z": "17"},
    {"x": "114.13333", "y": "30.61667", "z": "17"},
    {"x": "117.15", "y": "34.28333", "z": "15"},
    {"x": "119.11667", "y": "34.83333", "z": "14"},
    {"x": "115.76667", "y": "33.86667", "z": "15"},
    {"x": "119.03333", "y": "33.6", "z": "15"},
    {"x": "115.81667", "y": "32.91667", "z": "16"},
    {"x": "115.66667", "y": "32.16667", "z": "16"},
    {"x": "117.38333", "y": "32.95", "z": "16"},
    {"x": "118.8", "y": "32", "z": "16"},
    {"x": "116.31667", "y": "31.4", "z": "16"},
    {"x": "117.23333", "y": "31.86667", "z": "17"},
    {"x": "118.58333", "y": "31.15", "z": "16"},
    {"x": "117.05", "y": "30.53333", "z": "17"},
    {"x": "118.15", "y": "30.13333", "z": "8"},
    {"x": "115.98333", "y": "29.58333", "z": "12"},

];

程序代码:

function surfaceAnalystProcess() {
        widgets.alert.clearAlert();
        resultLayer.removeAllFeatures();
        var
            surfaceAnalystService = new SuperMap.REST.SurfaceAnalystService(url2),
            surfaceAnalystParameters = new SuperMap.REST.SurfaceAnalystParametersSetting({
                datumValue: 0,
                // interval: 2,
                interval: 1,
                resampleTolerance: 0,
                smoothMethod: SuperMap.REST.SmoothMethod.BSPLINE,
                smoothness: 3,
                clipRegion: region
                // clipRegion: null
            }),
            // params = new SuperMap.REST.DatasetSurfaceAnalystParameters({
            //     extractParameter: surfaceAnalystParameters,
            //     dataset: "SamplesP@Interpolation",
            //     resolution: 3000,
            //     zValueFieldName: "AVG_TMP"
            // });

        params = SuperMap.REST.GeometrySurfaceAnalystParameters({
            points: pointsArray,
            zValues: zvalues,
            resolution: 3000,
            extractParameter: surfaceAnalystParameters,
            surfaceAnalystMethod: SuperMap.REST.SurfaceAnalystMethod.ISOREGION
        });

        surfaceAnalystService.events.on({
            "processCompleted": surfaceAnalystCompleted,
            "processFailed": surfaceAnalystFailed
        });
        surfaceAnalystService.processAsync(params);
    }


6月 19 分类:  45次浏览 | 用户: johnforrest 牛刀小试 (190 分)

1个回答

0 投票

有相关的报错信息吗?你看下js请求是不是正常的,地图加载完成后把请求都清空然后再触发生成等值线的功能,看看新生成的js请求,另外看了一下你的坐标,是经纬度的值,底图的坐标系是投影的,你可以把你的坐标值换一下,可能是因为坐标值太小了,都聚在一起看起来像是没有出现等值线。

我用官网的范例http://iclient.supermap.io/examples/classic/editor.html#analysis_surfaceAnalyst写了一下代码,你可以参考一下


<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title data-i18n="resources.title_surfaceAnalyst"></title>
<style type="text/css">
        body {
            margin: 0;
            overflow: hidden;
            background: #fff;
            width: 100%;
            height: 100%
        }

        #map {
            position: absolute;
            width: 100%;
            height: 100%;
            border: 1px solid #3473b7;
        }

        #toolbar {
            position: absolute;
            top: 50px;
            right: 10px;
            text-align: center;
            z-index: 100;
            border-radius: 4px;
        }
    </style>
</head>
<body>
<div id="toolbar" class="panel panel-primary">
<div class='panel-heading'>
<h5 class='panel-title text-center' data-i18n="resources.text_surfaceAnalyst"></h5></div>
<div class='panel-body content'>
<input type="button" class="btn btn-default" data-i18n="[value]resources.text_contourLine" onclick="surfaceAnalystProcess()"/>&nbsp; &nbsp;
<input type="button" class="btn btn-default" data-i18n="[value]resources.text_remove" onclick="removeData()"/>
</div>
</div>
<div id="map"></div>
<script type="text/javascript" include="bootstrap,widgets.alert" src="../js/include-web.js"></script>
<script type="text/javascript" exclude="iclient-classic" src="../../dist/classic/include-classic.js"></script>
<script>
    var map, local, baseLayer, resultLayer, Spatialanalyst_sample,
        points = new SuperMap.Geometry.LinearRing([
            new SuperMap.Geometry.Point(0, 4010338),
            new SuperMap.Geometry.Point(1063524, 4010338),
            new SuperMap.Geometry.Point(1063524, 3150322),
            new SuperMap.Geometry.Point(0, 3150322)
        ]),
        region = new SuperMap.Geometry.Polygon([points]),
        host = window.isLocal ? window.server : "http://support.supermap.com.cn:8090",
        url = host + "/iserver/services/map-temperature/rest/maps/全国温度变化图",
        url2 = host + "/iserver/services/spatialanalyst-sample/restjsr/spatialanalyst";

    init();
    var point1 = new SuperMap.Geometry.Point(100000,3150322);
    var point2 = new SuperMap.Geometry.Point(1210000,315322);
    var point3 = new SuperMap.Geometry.Point(111000,315062);
    var point4 = new SuperMap.Geometry.Point(1120000,3110322);
    var point5 = new SuperMap.Geometry.Point(1520000,3106322);
    var point6 = new SuperMap.Geometry.Point(1320000,3020322);
    var point7 = new SuperMap.Geometry.Point(112000,31320322);
    var point8 = new SuperMap.Geometry.Point(133000,3151322);
    var pointarr=new Array(point1,point2,point3,point4,point5,point6,point7,point8);
    var zv = new Array(581.4,732.6,576.6,306.5,195,266.8,997.2,202.7);
    console.log(zv);
    function init() {
        map = new SuperMap.Map("map", {
            controls: [
                new SuperMap.Control.ScaleLine(),
                new SuperMap.Control.Zoom(),
                new SuperMap.Control.Navigation({
                    dragPanOptions: {
                        enableKinetic: true
                    }
                })], units: "m"
        });
        map.addControl(new SuperMap.Control.LayerSwitcher(), new SuperMap.Pixel(42, 80));
        map.allOverlays = true;
        baseLayer = new SuperMap.Layer.TiledDynamicRESTLayer("全国温度变化图", url, {
            transparent: true,
            cacheEnabled: true
        }, {maxResolution: "auto"});
        baseLayer.events.on({"layerInitialized": addLayer});
        resultLayer = new SuperMap.Layer.Vector("等值线");
    }

    function addLayer() {
        map.addLayers([baseLayer, resultLayer]);
        map.setCenter(new SuperMap.LonLat(531762, 3580330), 2);
    }

    function surfaceAnalystProcess() {
        widgets.alert.clearAlert();
        resultLayer.removeAllFeatures();
        var surfaceAnalystService = new SuperMap.REST.SurfaceAnalystService(url2),
            surfaceAnalystParameters = new SuperMap.REST.SurfaceAnalystParametersSetting({
                datumValue: 0,
                interval: 10,
                resampleTolerance: 0,
                smoothMethod: SuperMap.REST.SmoothMethod.BSPLINE,
                smoothness: 3,
                clipRegion: null
            }),
            params = new SuperMap.REST.GeometrySurfaceAnalystParameters({
                extractParameter: surfaceAnalystParameters,
                //dataset: "SamplesP@Interpolation",
                // [{"y":3150322,"x":100000},{"y":315322,"x":1210000},{"y":315062,"x":111000},{"y":3110322,"x":1120000},{"y":3106322,"x":1520000},{"y":3020322,"x":1320000},{"y":31320322,"x":112000},{"y":3151322,"x":133000}]
                resolution: 3500,
                points: pointarr,
                zValues:zv
                //zValueFieldName: "AVG_TMP"
            });
        surfaceAnalystService.events.on({
            "processCompleted": surfaceAnalystCompleted,
            "processFailed": surfaceAnalystFailed
        });
        surfaceAnalystService.processAsync(params);
    }

    function surfaceAnalystCompleted(args) {
        var features = args.result.recordset.features;
        for (var len = features.length, i = 0; i < len; i++) {
            style = {
                strokeColor: "#304DBE",
                fillOpacity: 0
            }
            features[i].style = style;
        }
        resultLayer.addFeatures(args.result.recordset.features);
    }

    function surfaceAnalystFailed(args) {
        widgets.alert.showAlert(args.error.errorMsg, false);
    }

    function removeData() {
        widgets.alert.clearAlert();
        resultLayer.removeAllFeatures();
    }
</script>
</body>
</html>

6月 20 用户: 于浩 名扬四海 (4,003 分)

回复:没有相关的报错信息,js请求正常。但是SuperMap.REST.GeometrySurfaceAnalystParameters服务的points数组换成了经纬度就不能画出等值面了,应该是投影坐标的问题。

问题1:超图的地图没有设置坐标系,默认就是投影坐标吗?

问题2:如果默认的底图是投影坐标,那么SuperMap.REST.DatasetSurfaceAnalystParameters用到的数据分析服务(spatialAnalyst.sxwu)的数据集(dataset: "SamplesP@Interpolation",)是地理坐标啊,DatasetSurfaceAnalystParameters用地理坐标可以生成等值线图,那么SuperMap.REST.GeometrySurfaceAnalystParameters为什么要用投影坐标呢??

问题3:SuperMap.REST.GeometrySurfaceAnalystParameters的参数设置并没有用到数据分析服务中的任何数据集,那么利用SuperMap.REST.GeometrySurfaceAnalystParameters绘制等值面的话是不是就可以不用发布数据分析服务了?如果不发布数据分析服务,就不能设置你上面代码的surfaceAnalystCompleted函数,也就不能把等值面加载到地图上显示,如果这样的话,那么代码应该怎么写?

...