- 积分
- 116
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2018-9-1
- 最后登录
- 1970-1-1
|
登录后查看更多精彩内容~
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
数据:
出图效果:
从图片看明显是错误的。折腾了很久了没有发现什么原因,Debug确认插值结果是对的,就是出图不行,感觉和legendScheme有关,但很多函数看不懂啊,文档也比较缺乏。请大佬帮忙看下吧。
我的代码
- VectorLayer clipLayer = MapDataManage.readMapFile_ShapeFile(shpFile);
- //初始化图层和画布
- var mapLayout = new MapLayout();
- var mapView = MeteoInfoHelper.createMapView(mapLayout,this.mapconfig,clipLayer);
- //读入站点数据
- var stationData = MeteoInfoHelper.getStationData(req.getDS());
- stationData.projInfo = clipLayer.getProjInfo();
- //设定插值参数
- GridDataSetting gridDataSetting = new GridDataSetting();
- gridDataSetting.dataExtent = clipLayer.getExtent();
- gridDataSetting.xNum = 20;// 格点点数
- gridDataSetting.yNum =30;// 格点点数
- //插值
- InterpolationSetting interSet = new InterpolationSetting();
- interSet.setGridDataSetting(gridDataSetting);
- interSet.setInterpolationMethod(InterpolationMethods.KRIGING);
- interSet.setMinPointNum(1);
- GridData gridData = GeoMathUtil.interpolateData(stationData,interSet);
- double[] minMax=MeteoInfoHelper.getMaxAndMin(req.getDS());
- var legendScheme = new LegendScheme(ShapeTypes.POLYGON);
- legendScheme.importFromXMLFile(lgsFile);
- legendScheme.setHasNoData(false);
- legendScheme.setMinValue(0);
- //插值生成图层
- VectorLayer contourLayer = DrawMeteoData.createShadedLayer(gridData, legendScheme, "Tem", "Value",
- mapconfig.getSmooth()>0);
- //裁切图片
- VectorLayer dataLayer = contourLayer.clip(clipLayer);
- mapView.addLayer(dataLayer);
- var staLayout=MeteoInfoHelper.LoadStation(req.getDS(),0);
- mapView.addLayer(staLayout);
- if(req.getTitle()!=null){
- mapLayout.addText(req.getTitle(), 200, 35, "宋体", 35);
- }
- var aLegend = mapLayout.addLegend(800, 307);
- aLegend.setLegendStyle(LegendStyles.NORMAL);
- aLegend.setFont(new Font("宋体",Font.PLAIN,20));
- //= ;
- aLegend.setHeight(370);
- aLegend.setWidth(100);
- //生成剪切图层
- PolygonBreak aPGB2 = (PolygonBreak)clipLayer.getLegendScheme().getLegendBreak(0);//LegendBreaks[0];
- aPGB2.setDrawFill(false);// = false;
- aPGB2.setDrawOutline(true);// = true;
- aPGB2.setOutlineColor(Color.darkGray);// = Color.Gray;
- aPGB2.setOutlineSize(2);
- dataLayer.setMaskout(true);//= true;
- //mapFrame.addLayer(dataLayer);
- //mapFrame.moveLayer(dataLayer,0);
- mapLayout.getActiveMapFrame().addLayer(clipLayer);
- aLegend.setTitle("能见度(km)") ;
- toImageStream(response, mapLayout);
复制代码 Lgs文件内容
- <?xml version="1.0" encoding="utf-8"?>
- <LegendScheme FieldName="Value" LegendType="UniqueValue"
- ShapeType="Polygon" BreakNum="5"
- HasNoData="False" MinValue="0" MaxValue="999" UNDEF="-9999">
- <Breaks>
- <Break Caption="0~0.2" StartValue="0" EndValue="0.2" Color="#63220A" DrawShape="True" OutlineColor="Gray" DrawOutline="False" DrawFill="True" OutlineSize="1" />
- <Break Caption="0.2~0.5" StartValue="0.2" EndValue="0.5" Color="#7B1EEA" DrawShape="True" OutlineColor="Gray" DrawOutline="False" DrawFill="True" OutlineSize="1" />
- <Break Caption="0.5~1" StartValue="0.5" EndValue="1" Color="#D01F05" DrawShape="True" OutlineColor="Gray" DrawOutline="False" DrawFill="True" OutlineSize="1" />
- <Break Caption="1~2" StartValue="1" EndValue="2" Color="#D35C07" DrawShape="True" OutlineColor="Gray" DrawOutline="False" DrawFill="True" OutlineSize="1" />
- <Break Caption="2~3" StartValue="2" EndValue="3" Color="#E9B155" DrawShape="True" OutlineColor="Gray" DrawOutline="False" DrawFill="True" OutlineSize="1" />
- <Break Caption="3~5" StartValue="3" EndValue="5" Color="#FCFB24" DrawShape="True" OutlineColor="Gray" DrawOutline="False" DrawFill="True" OutlineSize="1" />
- <Break Caption="5~10" StartValue="5" EndValue="10" Color="#AEF546" DrawShape="True" OutlineColor="Gray" DrawOutline="False" DrawFill="True" OutlineSize="1" />
- <Break Caption="10~20" StartValue="10" EndValue="20" Color="#AFDBFE" DrawShape="True" OutlineColor="Gray" DrawOutline="False" DrawFill="True" OutlineSize="1" />
- <Break Caption="20~30" StartValue="20" EndValue="30" Color="#D1EDFF" DrawShape="True" OutlineColor="Gray" DrawOutline="False" DrawFill="True" OutlineSize="1" />
- <Break Caption="30以上" StartValue="30" EndValue="999" Color="#FFFFFF" DrawShape="True" OutlineColor="Gray" DrawOutline="False" DrawFill="True" OutlineSize="1" />
- </Breaks>
- </LegendScheme>
复制代码
|
|