前端克里金插值生成不了

0 投票


  methods: {
    addMap() {
		let host = window.isLocal ? window.server : 'http://10.100.244.22:8090'
		// 注册4490坐标系
		proj4.defs('EPSG:4490', '+proj=longlat +ellps=GRS80 +no_defs')
		// leaflet CRS投影设置
		let p1 = L.point(-180, -90),
		p2 = L.point(180, 90),
		// 识图范围
		bounds = L.bounds(p1, p2)
		let crs = L.Proj.CRS('EPSG:4490', {
			origin: [119.82, 29.56],
			bounds: bounds
		})
		
		let baseLayer = L.supermap.tiledMapLayer(this.baseUrl, {transparent: true});
        this.map = L.map('map', {
          crs: crs,
          center: [30, 100],
          maxZoom: 18,
          minZoom: 1,
          zoom: 4,
          layers: [baseLayer],
          attributionControl: false,
          zoomControl: false
        })
        L.control
          .scale({
            position: 'bottomright',
            maxWidth: 200,
            metric: true,
            imperial: false
          })
          .addTo(this.map)
        //初始化数据
        this.loadData("2020","11","zl")
        
      
    },
	// 读取数据进行插值计算
    loadData(year, month, type) {
      let _self = this
      var url = '/shjmap/getDmWrwnd'
      url += '?year=' + year + '&month=' + month + '&type='+type
      this.$axios(url, {})
        .then((response) => {
			let inputPoints = [];
			_self.max = response.data.max;
            response.data.data.forEach(function(item, idx) {
							if(idx < 100){
								var geometry= new SuperMap.Geometry.Point(item.jingdu, item.weidu, 'Point', item.data);
      					geometry.SRID=4490;
								inputPoints.push(
									geometry
									//L.latLng({'lat':parseFloat(item.weidu),'lng':parseFloat(item.jingdu),'alt':item.data})
								);
							}
                
						})	
	    
			console.log(inputPoints)
			//创建点密度插值分析参数实例
			_self.interpolationAnalystParameters = new SuperMap.InterpolationKrigingAnalystParameters({
				//普通克吕金插值的类型
				type: "KRIGING",
				searchMode: "KDTREE_FIXED_COUNT",
				bounds: L.bounds([73.5 ,3.84], [ 135.09,53.56]),
				//用于做插值分析的数据源中数据集的名称
				//插值分析结果数据集的名称
				outputDatasetName: "Kriging_Result",
				//插值分析结果数据源的名称
				outputDatasourceName: "chazhi",
				//结果栅格数据集存储的像素格式
				pixelFormat: SuperMap.PixelFormat.DOUBLE,
				//zValueFieldName: "总磷",
				searchRadius: "0",
				//dataset: "chazhi@chazhi",
				// 裁剪参数
				/* clipParam: new SuperMap.ClipParameter({
					clipDatasetName:"guojie@guojie",
					clipDatasourceName:"guojie"
				}), */
				// 插值分析类型
				InterpolationAnalystType: "geometry",
				//存储用于进行插值分析的字段名称
				inputPoints: inputPoints,					
			});
			//创建点密度插值分析服务实例
			_self.interpolationAnalystService = L.supermap.spatialAnalystService(_self.serviceUrl);
			_self.interpolationAnalystService.interpolationAnalysis(_self.interpolationAnalystParameters, function (serviceResult) {
			_self.interpolationAnalystResult = serviceResult.result;
				if (_self.interpolationAnalystResult && _self.interpolationAnalystResult.dataset) {
					//用栅格专题图展示分析结果
					//console.log("_self.interpolationAnalystResult",_self.interpolationAnalystResult)
					_self.showAnalysisResult_ThemeGridRange();
				} else {
					//alert(serviceResult.error.errorMsg);
					console.error('serviceResult',serviceResult)
				}
			});
			
       
        })
        .catch((err) => {
          console.log('err', err)
				})
				
    },
	////用栅格专题图展示分析结果
	showAnalysisResult_ThemeGridRange() {
		let _self = this
		//创建专题图服务实例
		_self.themeService = L.supermap.themeService(_self.baseUrl);
		//var zlArr = [0.02,0.1,0.2,0.3,0.4];
		//var zdArr = [0.2,0.5,1.0,1.5,2.0];
		var max = _self.max
		var disNum = max / 32;
		var startArr = [];
		var endArr = [];
		for(var num=0; num<32; num++){
			startArr.push(num*disNum);
			endArr.push(num*disNum+disNum);
		}
		console.log("startArr",startArr)
		console.log("endArr",endArr)
		var colorArr = [
			      new SuperMap.ServerColor(0, 0, 255),
						new SuperMap.ServerColor(0, 33, 255),
						new SuperMap.ServerColor(0, 66, 255),
						new SuperMap.ServerColor(0, 99, 255),
						new SuperMap.ServerColor(0, 132, 255),
						new SuperMap.ServerColor(0, 165, 255),
						new SuperMap.ServerColor(0, 197, 255),
						new SuperMap.ServerColor(0, 230, 255),     
						new SuperMap.ServerColor(0, 255, 247),
						new SuperMap.ServerColor(0, 255, 214),
						new SuperMap.ServerColor(0, 255, 181),
						new SuperMap.ServerColor(0, 255, 148),
						new SuperMap.ServerColor(0, 255, 115),
						new SuperMap.ServerColor(0, 255, 82),
						new SuperMap.ServerColor(0, 255, 46),
						new SuperMap.ServerColor(0, 255, 16),
						new SuperMap.ServerColor(16, 255, 1),
						new SuperMap.ServerColor(49, 255, 2),
						new SuperMap.ServerColor(82, 255, 3),
						new SuperMap.ServerColor(115, 255, 5),
						new SuperMap.ServerColor(148, 255, 6),
						new SuperMap.ServerColor(181, 255, 7),
						new SuperMap.ServerColor(214, 255, 8),
						new SuperMap.ServerColor(247, 255, 10),
						new SuperMap.ServerColor(255, 230, 9),
						new SuperMap.ServerColor(255, 197, 8),
						new SuperMap.ServerColor(255, 165, 6),
						new SuperMap.ServerColor(255, 132, 5),
						new SuperMap.ServerColor(255, 99, 4),
						new SuperMap.ServerColor(255, 66, 3),
						new SuperMap.ServerColor(255, 33, 1),
						new SuperMap.ServerColor(255, 0, 0)];
		var themeGridRangeItemArr = [];
		for(var i=0; i<colorArr.length; i++){
			themeGridRangeItemArr.push(new SuperMap.ThemeGridRangeItem({
				start: startArr[i],
				end: endArr[i],
				color: colorArr[i]
			}))
		}		;
		        
            });
		_self.themeGridRange = new SuperMap.ThemeGridRange({
			reverseColor: false,
			rangeMode: SuperMap.RangeMode.EQUALINTERVAL,
			//栅格分段专题图子项数组
			items: themeGridRangeItemArr
            
		});
		console.log("_self.themeGridRange",_self.themeGridRange)
		_self.themeParameters = new SuperMap.ThemeParameters({
			//制作专题图的数据集
			datasetNames: [_self.interpolationAnalystResult.dataset.split('@')[0]],
			dataSourceNames: ["chazhi"],
			joinItems: null,
			themes: [_self.themeGridRange]
		});
		_self.themeService.getThemeInfo(_self.themeParameters, function (getThemeInfoServiceResult) {
			console.log("getThemeInfoServiceResult",getThemeInfoServiceResult)
			var result = getThemeInfoServiceResult.result;
			if (result && result.newResourceID) {
				_self.themeLayer = L.supermap.tiledMapLayer(_self.baseUrl, {
					noWrap: true,
					cacheEnabled: false,
					transparent: true,
					layersID: result.newResourceID,
					//opacity: 0.8
				}).addTo(_self.map);
				console.log("_self.themeLayer",_self.themeLayer)
			}
		});
	},
  },
  mounted() {
		this.addMap()
	 
  }
}
</script>

1月 7 分类:  116次浏览 | 用户: 旧梦失辞 (2 分)

1个回答

0 投票
你好,能否将您传参用到的inputPoints发一下吗?我这边重现一下您的问题
1月 8 用户: 张亮 名扬四海 (2,169 分)
let inputPoints = [];
  _self.max = response.data.max;
  response.data.data.forEach(function(item, idx) {
  if(idx < 100){
    var geometry= new SuperMap.Geometry.Point(item.jingdu, item.weidu, 'Point', item.data);
    geometry.SRID=4490;
    inputPoints.push(geometry);
  }
})	
	    

你好,这段是inputPoints的代码,部分数据在下面

[
    {
        "weidu":"39.776",
        "wq_pi_name":"西屯桥",
        "data":0.083,
        "jingdu":"117.4",
        "wq_pi_code":"120225_0005"
    },
    {
        "weidu":"31.063",
        "wq_pi_name":"十四号灯标",
        "data":0.05,
        "jingdu":"120.151",
        "wq_pi_code":"320200_0027"
    },
    {
        "weidu":"31.225",
        "wq_pi_name":"平台山",
        "data":0.051,
        "jingdu":"120.104",
        "wq_pi_code":"320200_0026"
    },
    {
        "weidu":"30.4",
        "wq_pi_name":"黄陵大桥",
        "data":0.161,
        "jingdu":"114.098",
        "wq_pi_code":"420100_2017"
    },
    {
        "weidu":"34.641",
        "wq_pi_name":"华山闸",
        "data":0.063,
        "jingdu":"116.713",
        "wq_pi_code":"320300_2006"
    },
    {
        "weidu":"40.559",
        "wq_pi_name":"双塔水库",
        "data":0.03,
        "jingdu":"96.312",
        "wq_pi_code":"620900_2007"
    },
    {
        "weidu":"33.532",
        "wq_pi_name":"芦岭桥",
        "data":0.08,
        "jingdu":"117.175",
        "wq_pi_code":"341300_2006"
    },
    {
        "weidu":"23.487",
        "wq_pi_name":"九龙潭",
        "data":0.019,
        "jingdu":"113.916",
        "wq_pi_code":"440100_2020"
    },
    {
        "weidu":"43.421",
        "wq_pi_name":"四双大桥",
        "data":0.08,
        "jingdu":"123.717",
        "wq_pi_code":"220300_0001"
    },
    {
        "weidu":"32.309",
        "wq_pi_name":"水口",
        "data":0.096,
        "jingdu":"118.456",
        "wq_pi_code":"341100_2003"
    },
    {
        "weidu":"26.571",
        "wq_pi_name":"蒙姑",
        "data":0.02,
        "jingdu":"103.042",
        "wq_pi_code":"530100_0001"
    },
    {
        "weidu":"30.982",
        "wq_pi_name":"池家浜水文站",
        "data":0.082,
        "jingdu":"120.989",
        "wq_pi_code":"330400_2004"
    },
    {
        "weidu":"43.231",
        "wq_pi_name":"林家",
        "data":0.243,
        "jingdu":"124.066",
        "wq_pi_code":"220300_0005"
    },
    {
        "weidu":"38.469",
        "wq_pi_name":"南庄",
        "data":0.008,
        "jingdu":"113.231",
        "wq_pi_code":"140900_2005"
    },
    {
        "weidu":"46.295",
        "wq_pi_name":"白沙滩",
        "data":0.069,
        "jingdu":"123.852",
        "wq_pi_code":"220800_0001"
    },
    {
        "weidu":"31.157",
        "wq_pi_name":"金溪电站",
        "data":0.053,
        "jingdu":"106.262",
        "wq_pi_code":"511300_2003"
    },
    {
        "weidu":"30.577",
        "wq_pi_name":"宗关",
        "data":0.107,
        "jingdu":"114.216",
        "wq_pi_code":"420100_0013"
    },
    {
        "weidu":"24.899",
        "wq_pi_name":"龙南自来水厂",
        "data":0.026,
        "jingdu":"114.779",
        "wq_pi_code":"360700_2010"
    },
    {
        "weidu":"25.464",
        "wq_pi_name":"长汀美溪桥",
        "data":0.067,
        "jingdu":"116.293",
        "wq_pi_code":"350800_2008"
    },
    {
        "weidu":"36.266",
        "wq_pi_name":"赵村桥",
        "data":0.09,
        "jingdu":"120.411",
        "wq_pi_code":"370200_2007"
    },
    {
        "weidu":"42.072",
        "wq_pi_name":"博湖8",
        "data":0.005,
        "jingdu":"86.9",
        "wq_pi_code":"652800_0015"
    },
    {
        "weidu":"45.345",
        "wq_pi_name":"新开流",
        "data":0.07,
        "jingdu":"132.367",
        "wq_pi_code":"230300_0002"
    },
    {
        "weidu":"33.462",
        "wq_pi_name":"郾城漯邓桥",
        "data":0.245,
        "jingdu":"114.218",
        "wq_pi_code":"411100_2004"
    },
    {
        "weidu":"31.941",
        "wq_pi_name":"聚南大桥",
        "data":0.075,
        "jingdu":"121.537",
        "wq_pi_code":"320600_2007"
    },
    {
        "weidu":"29.623",
        "wq_pi_name":"洪下水文站",
        "data":0.041,
        "jingdu":"114.004",
        "wq_pi_code":"421200_2005"
    },
    {
        "weidu":"31.469",
        "wq_pi_name":"丁埠大桥",
        "data":0.026,
        "jingdu":"115.644",
        "wq_pi_code":"341500_2009"
    },
    {
        "weidu":"27.037",
        "wq_pi_name":"大桥边",
        "data":0.045,
        "jingdu":"105.216",
        "wq_pi_code":"520500_2005"
    },
    {
        "weidu":"37.0714634",
        "wq_pi_name":"甘冲口",
        "data":0.006,
        "jingdu":"102.3737239",
        "wq_pi_code":"632100_0002"
    },
    {
        "weidu":"31.206",
        "wq_pi_name":"马尔邦碉王山庄",
        "data":0.005,
        "jingdu":"102.009",
        "wq_pi_code":"513200_2004"
    },
    {
        "weidu":"43.051",
        "wq_pi_name":"河清",
        "data":0.082,
        "jingdu":"124.863",
        "wq_pi_code":"220400_0003"
    },
    {
        "weidu":"32.232",
        "wq_pi_name":"马甸闸西",
        "data":0.074,
        "jingdu":"119.945",
        "wq_pi_code":"321200_2006"
    },
    {
        "weidu":"25.774",
        "wq_pi_name":"打邦",
        "data":0.016,
        "jingdu":"105.743",
        "wq_pi_code":"520400_2004"
    },
    {
        "weidu":"25.493",
        "wq_pi_name":"江口桥",
        "data":0.14,
        "jingdu":"119.2",
        "wq_pi_code":"350300_2004"
    },
    {
        "weidu":"39.576",
        "wq_pi_name":"张坊",
        "data":0.005,
        "jingdu":"115.687",
        "wq_pi_code":"110000_0002"
    }
]

生成完的inputPoints是这个样子的

...