做差值专题图,一直报这个错,不知道是什么原因?

0 投票
323 浏览

240行

每次都执行失败方法。240报的错误不知道是什么原因导致

最新提问 7月 4, 2017 分类:  323次浏览 | 用户: matt0614 初出茅庐 (27 分)
重新显示 7月 6, 2017 用户:matt0614

1个回答

0 投票
 
已采纳

您好!不太清楚你说的240行报的什么错,你现在是得不到插值结果还是不能生成专题图呢

你可以参照官网的这个例子做:

http://support.supermap.com.cn:8090/iserver/iClient/forJavaScript/examples/examples.html#interpolationAnalystByKriging

如果找不出原因,可以把插值的代码帖出来我帮你看看!

最新回答 7月 5, 2017 用户: 李晓 学富五车 (602 分)
采纳于 7月 6, 2017 用户:matt0614
/**
 *
 * Created by matt0614@qq.com on 2017/6/15 0015.
 */

var Charzhifengxi = function (map) {
    this.host = "http://localhost:20005";
    this.url = this.host  +"/iserver/services/map-IOT_Weather/rest/maps/TownInfo";
    this.url2 = this.host +"/iserver/services/spatialAnalysis-IOT_Weather/restjsr/spatialanalyst";
    this.themeLayer ="";
    this.index = null;
    this.map = map;
    this.dataSource = "127.0.0.1_IOT1";
    this.dataSet = "县界";

};
Charzhifengxi.prototype = {
    constructor: Charzhifengxi,
    //IDW插值分析
    interpolationIDW: function (field) {
        var _this = this;
        _this.index = layer.load(1, {
            shade: [0.3,'#000000'] //0.1透明度的白色背景
        });
        _this.removeInterpolation();
        var clipparmmy=new SuperMap.REST.ClipParameter({
            clipDatasetName:_this.dataSet,
            clipDatasourceName:_this.dataSource,
            isClipInRegion:true
        });
        var interpolationParams = new SuperMap.REST.InterpolationIDWAnalystParameters({
            //用于做插值分析的数据源中数据集的名称
            dataset: "TownInfo@127.0.0.1_IOT1",//"TownInfo@127.0.0.1_IOT_Weather",
            //插值分析结果数据集的名称
            outputDatasetName: "IDW_result",

            //插值分析结果数据源的名称
            outputDatasourceName: "127.0.0.1_IOT1",//"127.0.0.1_IOT_Weather",
            //结果栅格数据集存储的像素格式
            pixelFormat: SuperMap.REST.PixelFormat.double,
            // 属性过滤条件
            // filterQueryParameter: {
            // attributeFilter: ""
            // },
            //存储用于进行插值分析的字段名称
            zValueFieldName: "tempture",
            resolution: 0.02,
            clipParam:clipparmmy,//将得到的栅格按照指定的Region进行裁剪
            //采取固定点数查找参与运算点的方式
            searchMode: "KDTREE_FIXED_COUNT",
            //固定点数查找方式下,参与差值运算的点数默认为12。
            expectedCount: 2,
            bounds: new SuperMap.Bounds(103.5 , 35.24 ,  108.96 , 39.39)
        });
        console.log(_this.url2);
        var interpolationService = new SuperMap.REST.InterpolationAnalystService(_this.url2, {
            eventListeners: {
                // "processCompleted": _this.processCompleted,
                "processCompleted": function (InterpolationAnalystEventArgs) {
                    _this.processCompleted(InterpolationAnalystEventArgs, _this);
                },
                "processFailed": _this.processFailed
            }
        });
        interpolationService.processAsync(interpolationParams);
    },

把这行注释了,就执行themeCompleted方法 不注释,就执行 themeFailed方法

//插值分析成功后,使用栅格分段专题图展示
    processCompleted:function (InterpolationAnalystEventArgs,_this) {
        console.log(111,InterpolationAnalystEventArgs);
        var color1 = new SuperMap.REST.ServerColor(170,240,233),
            color2 = new SuperMap.REST.ServerColor(176,244,188),
            color3 = new SuperMap.REST.ServerColor(218,251,178),
            color4 = new SuperMap.REST.ServerColor(220,236,145),
            color5 = new SuperMap.REST.ServerColor(96,198,66),
            color6 = new SuperMap.REST.ServerColor(20,142,53),
            color7 = new SuperMap.REST.ServerColor(85,144,55),
            color8 = new SuperMap.REST.ServerColor(171,168,38),
            color9 = new SuperMap.REST.ServerColor(235,165,9),
            color10 = new SuperMap.REST.ServerColor(203,89,2),
            color11= new SuperMap.REST.ServerColor(157,25,1),
            color12= new SuperMap.REST.ServerColor(118,15,3),
            color13= new SuperMap.REST.ServerColor(112,32,7),
            color14= new SuperMap.REST.ServerColor(106,45,12),
            color15= new SuperMap.REST.ServerColor(129,80,50),
            color16= new SuperMap.REST.ServerColor(160,154,146),
            color17= new SuperMap.REST.ServerColor(107,47,14),
            color18= new SuperMap.REST.ServerColor(125,75,44),
            color19= new SuperMap.REST.ServerColor(146,110,88),
            color20= new SuperMap.REST.ServerColor(166,153,146),

            themeGridRangeIteme1 = new SuperMap.REST.ThemeGridRangeItem({
                start: -8,
                end: 8,
                color: color1
            }),
            themeGridRangeIteme2 = new SuperMap.REST.ThemeGridRangeItem({
                start: 8,
                end: 9,
                color: color2
            }),
            themeGridRangeIteme3 = new SuperMap.REST.ThemeGridRangeItem({
                start: 9,
                end: 10,
                color: color3
            }),
            themeGridRangeIteme4 = new SuperMap.REST.ThemeGridRangeItem({
                start: 10,
                end: 11,
                color: color4
            }),
            themeGridRangeIteme5 = new SuperMap.REST.ThemeGridRangeItem({
                start: 11,
                end: 12,
                color: color5
            }),
            themeGridRangeIteme6 = new SuperMap.REST.ThemeGridRangeItem({
                start: 12,
                end: 13,
                color: color6
            }),
            themeGridRangeIteme7 = new SuperMap.REST.ThemeGridRangeItem({
                start: 13,
                end: 14,
                color: color7
            }),
            themeGridRangeIteme8 = new SuperMap.REST.ThemeGridRangeItem({
                start: 14,
                end: 15,
                color: color8
            }),

            themeGridRangeIteme9 = new SuperMap.REST.ThemeGridRangeItem({
                start: 15,
                end: 16,
                color: color9
            }),
            themeGridRangeIteme10 = new SuperMap.REST.ThemeGridRangeItem({
                start: 16,
                end: 17,
                color: color10
            }),
            themeGridRangeIteme11 = new SuperMap.REST.ThemeGridRangeItem({
                start: 17,
                end: 18,
                color: color11
            }),
            themeGridRangeIteme12 = new SuperMap.REST.ThemeGridRangeItem({
                start: 18,
                end: 19,
                color: color12
            }),
            themeGridRangeIteme13 = new SuperMap.REST.ThemeGridRangeItem({
                start: 19,
                end: 20,
                color: color13
            }),
            themeGridRangeIteme14 = new SuperMap.REST.ThemeGridRangeItem({
                start: 20,
                end: 39,
                color: color14
            }),

            themeGridRange = new SuperMap.REST.ThemeGridRange({
                reverseColor:false,
                rangeMode: SuperMap.REST.RangeMode.EQUALINTERVAL,
                //栅格分段专题图子项数组
                items: [themeGridRangeIteme1,
                    themeGridRangeIteme2,
                    themeGridRangeIteme3,
                    themeGridRangeIteme4,
                    themeGridRangeIteme5,
                    themeGridRangeIteme6,
                    themeGridRangeIteme7,
                    themeGridRangeIteme8,
                    themeGridRangeIteme9,
                    themeGridRangeIteme10,
                    themeGridRangeIteme11,
                    themeGridRangeIteme12,
                    themeGridRangeIteme13,
                    themeGridRangeIteme14
                ]
            }),
            themeParameters = new SuperMap.REST.ThemeParameters({
                //制作专题图的数据集数组
                datasetNames: [InterpolationAnalystEventArgs.result.dataset.split('@')[0]],
                // 制作专题图的数据集所在的数据源数组
                dataSourceNames: ["127.0.0.1_IOT1"],
                joinItems: null,
                //专题图对象列表
                themes: [themeGridRange]
            });
        console.log(themeGridRange);
        console.log(InterpolationAnalystEventArgs);
        console.log(themeParameters.datasetNames);

        console.log(_this.url);
        var themeService = new SuperMap.REST.ThemeService(_this.url, {
            eventListeners: {
                // "processCompleted": _this.themeCompleted,
                "processCompleted": function (themeEventArgs) {
                    console.log(444, themeEventArgs);
                    _this.themeCompleted(themeEventArgs,_this);
                },
                "processFailed": _this.themeFailed
            }
        });
        themeService.processAsync(themeParameters);
    },
    //服务端成功返回专题图结果时调用
    themeCompleted:function (themeEventArgs,_this) {
        console.log(2222222);
        if (themeEventArgs.result.resourceInfo.id) {
            _this.themeLayer = new SuperMap.Layer.TiledDynamicRESTLayer("插值分析结果图", _this.url, {
                cacheEnabled: true,
                transparent: true,
                layersID: themeEventArgs.result.resourceInfo.id
            }, {"maxResolution": "auto"});
            layer.close(_this.index);
            _this.themeLayer.events.on({"layerInitialized": function () {
                console.log("layerInitialized");
                _this.addThemelayer(_this);
            }});
        }
    },
    //添加专题图至map
    addThemelayer:function () {
        var _this = this;
        console.log(_this.themeLayer);
        _this.map.addLayer(_this.themeLayer);
    },
    //插值分析失败后调用
    processFailed:function (ServiceFailedEventArgs) {
        alert(ServiceFailedEventArgs.error.errorMsg);
    },
    //服务端返回专题图结果失败时调用
    themeFailed:function (serviceFailedEventArgs) {
        console.log(33,serviceFailedEventArgs);
        console.log(serviceFailedEventArgs.error.errorMsg);
        alert(serviceFailedEventArgs.error.errorMsg);
    },
    //清除专题图图层
    removeInterpolation:function () {
        var _this = this;
        var tlayer = _this.map.getLayersByName('插值分析结果图');
        if (tlayer.length > 0) {
            _this.map.removeLayer(tlayer[0], true);
        }
    }
}

每次只能回复8000字。。。。

您好!看代码貌似没什么问题,你可以把你的参数拿到你服务资源管理界面(下图的位置)进行插值分析看看能不能出结果

...