- 积分
- 229
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2013-10-17
- 最后登录
- 1970-1-1
|
登录后查看更多精彩内容~
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
此次教程实现站点数据来生成各种图层,主要包括Station Point(站点)、Station Model(站点填图)、Weather Symbol(天气现象符号)、 Station Vector(站点风场矢量)、Station Shaded(站点数据插值成格点数据再生成等值线填色图层)。
用DrawMeteoData类的一些静态方法来创建各种图层:
Station_Point: DrawMeteoData.createSTPointLayer(StationData stationData, LegendScheme aLS, String lName, String fieldName)
Station_Model: DrawMeteoData.createStationModelLayer(StationModelData stationModelData, LegendScheme aLS, String layerName, boolean isSurface)
Weather_Symbol: DrawMeteoData.createWeatherSymbolLayer(StationData weatherData, String WeatherType, String layerName)
Station_Vector: DrawMeteoData.createSTVectorLayer(StationData uData, StationData vData, StationData stData, LegendScheme aLS, String layerName, boolean isUV)
创建好菜单后,具体的代码如下:
- private void jMenuItem_StationPointActionPerformed(java.awt.event.ActionEvent evt) {
- // TODO add your handling code here:
- //Create a MeteoDataInfo object
- MeteoDataInfo aDataInfo = new MeteoDataInfo();
- //Open MICAPS data file
- String dataDir = "E:\\MeteoInfo\\sample\\MICAPS\\";
- String fileName = dataDir + "10101414.000";
- aDataInfo.openMICAPSData(fileName);
- //Get StationData
- StationData visData = aDataInfo.getStationData("Visibility");
- //Create a legend scheme
- LegendScheme aLS = LegendManage.createLegendSchemeFromStationData(visData, LegendType.GraduatedColor, ShapeTypes.Point);
- for (int i = 0; i < aLS.getBreakNum(); i++) {
- PointBreak pointBreak = (PointBreak) aLS.getLegendBreaks().get(i);
- pointBreak.setSize(8);
- }
- //Create a contour layer
- VectorLayer aLayer = DrawMeteoData.createSTPointLayer(visData, aLS, "StationPoint_Vis", "Vis");
- //Add layer
- layersLegend1.getActiveMapFrame().addLayer(aLayer);
- layersLegend1.repaint();
- //Change title of the layout
- LayoutGraphic aTitle = mapLayout1.getTexts().get(0);
- aTitle.setLabelText("MeteoInfo Class Library Demo - Station Point Layer");
- //Add or change the legend in layout
- LayoutLegend aLegend;
- if (mapLayout1.getLegends().size() > 0) {
- aLegend = mapLayout1.getLegends().get(0);
- } else {
- aLegend = mapLayout1.addLegend(650, 100);
- }
- aLegend.setLegendStyle(LegendStyles.Bar_Vertical);
- aLegend.setLegendLayer(aLayer);
- mapLayout1.paintGraphics();
- }
- private void jMenuItem_StationModelActionPerformed(java.awt.event.ActionEvent evt) {
- // TODO add your handling code here:
- //Create a MeteoDataInfo object
- MeteoDataInfo aDataInfo = new MeteoDataInfo();
- //Open SYNOP data file
- String dataDir = "E:\\MeteoInfo\\sample\\MICAPS\\";
- String fileName = dataDir + "10101414.000";
- aDataInfo.openMICAPSData(fileName);
- //Create a legend scheme
- LegendScheme aLS = LegendManage.createSingleSymbolLegendScheme(ShapeTypes.Point, Color.blue, 12);
- //Get station model data
- StationModelData stationModelData = aDataInfo.getStationModelData();
- //Create a layer
- VectorLayer aLayer = DrawMeteoData.createStationModelLayer(stationModelData,aLS, "StationModel", true);
- aLayer.setShapeType(ShapeTypes.Point);
- //Add layer
- layersLegend1.getActiveMapFrame().addLayer(aLayer);
- layersLegend1.repaint();
- //Change title of the layout
- LayoutGraphic aTitle = mapLayout1.getTexts().get(0);
- aTitle.setLabelText("MeteoInfo Class Library Demo - Station Model Layer");
- }
- private void jMenuItem_WeatherSymbolActionPerformed(java.awt.event.ActionEvent evt) {
- // TODO add your handling code here:
- //Create a MeteoDataInfo object
- MeteoDataInfo aDataInfo = new MeteoDataInfo();
- //Open SYNOP data file
- String dataDir = "E:\\MeteoInfo\\sample\\MICAPS\\";
- String fileName = dataDir + "10101414.000";
- aDataInfo.openMICAPSData(fileName);
- //Get StationData
- StationData wData = aDataInfo.getStationData("WeatherNow");
- //Create a legend scheme
- LegendScheme aLS = LegendManage.createSingleSymbolLegendScheme(ShapeTypes.Point, Color.blue, 15);
- //Create a contour layer
- VectorLayer aLayer = DrawMeteoData.createWeatherSymbolLayer(wData, "All Weather", "Weather");
- //Add layer
- layersLegend1.getActiveMapFrame().addLayer(aLayer);
- layersLegend1.repaint();
- //Change title of the layout
- LayoutGraphic aTitle = mapLayout1.getTexts().get(0);
- aTitle.setLabelText("MeteoInfo Class Library Demo - Weather Symbol Layer");
- //Add or change the legend in layout
- LayoutLegend aLegend;
- if (mapLayout1.getLegends().size() > 0) {
- aLegend = mapLayout1.getLegends().get(0);
- } else {
- aLegend = mapLayout1.addLegend(650, 100);
- }
- aLegend.setLegendStyle(LegendStyles.Bar_Vertical);
- aLegend.setLegendLayer(aLayer);
- if (this.jTabbedPane1.getSelectedIndex() == 1) {
- mapLayout1.paintGraphics();
- }
- }
- private void jMenuItem_StationVectorActionPerformed(java.awt.event.ActionEvent evt) {
- // TODO add your handling code here:
- //Create a MeteoDataInfo object
- MeteoDataInfo aDataInfo = new MeteoDataInfo();
- //Open MICAPS data file
- String dataDir = "E:\\MeteoInfo\\sample\\MICAPS\\";
- String fileName = dataDir + "10101414.000";
- aDataInfo.openMICAPSData(fileName);
- //Get StationData
- StationData wdData = aDataInfo.getStationData("WindDirection");
- StationData wsData = aDataInfo.getStationData("WindSpeed");
- //Create a legend scheme
- LegendScheme aLS = LegendManage.createSingleSymbolLegendScheme(ShapeTypes.Point, Color.blue, 15);
- //Create a contour layer
- VectorLayer aLayer = DrawMeteoData.createSTVectorLayer(wdData, wsData, wdData, aLS, "StationVector", false);
- //Add layer
- layersLegend1.getActiveMapFrame().addLayer(aLayer);
- layersLegend1.repaint();
- //Change title of the layout
- LayoutGraphic aTitle = mapLayout1.getTexts().get(0);
- aTitle.setLabelText("MeteoInfo Class Library Demo - Station Wind Vector Layer");
- }
- private void jMenuItem_StationShadedActionPerformed(java.awt.event.ActionEvent evt) {
- //TODO add your handling code here:
- //Read data info
- MeteoDataInfo aDataInfo = new MeteoDataInfo();
- String dataDir = "E:\\MeteoInfo\\sample\\MICAPS\\";
- String fileName = dataDir + "10101414.000";
- aDataInfo.openMICAPSData(fileName);
- //Get station data
- StationData stationData = aDataInfo.getStationData("Precipitation6h");
- //Interpolate
- GridDataSetting aGDP = new GridDataSetting();
- aGDP.dataExtent.minX = 60;
- aGDP.dataExtent.maxX = 140;
- aGDP.dataExtent.minY = -20;
- aGDP.dataExtent.maxY = 60;
- aGDP.xNum = 80;
- aGDP.yNum = 80;
- InterpolationSetting gridInterp = new InterpolationSetting();
- gridInterp.setGridDataSetting(aGDP);
- gridInterp.setInterpolationMethod(InterpolationMethods.IDW_Radius);
- gridInterp.setRadius(2);
- gridInterp.setMinPointNum(1);
- GridData gridData = stationData.interpolateData(gridInterp);
- //Create legend scheme
- LegendScheme aLS = LegendManage.createLegendSchemeFromGridData(gridData, LegendType.GraduatedColor,ShapeTypes.Polygon);
- ((PolygonBreak) aLS.getLegendBreaks().get(0)).setDrawFill(false);
- //Create layer
- VectorLayer aLayer = new VectorLayer(ShapeTypes.Polygon);
- aLayer = DrawMeteoData.createShadedLayer(gridData, aLS, "Rain", "Rain", true);
- aLayer.setMaskout(true);
- //Add layer
- layersLegend1.getActiveMapFrame().addLayer(aLayer);
- layersLegend1.getActiveMapFrame().moveLayer(aLayer, 0);
- layersLegend1.repaint();
- //Change title of the layout
- LayoutGraphic aTitle = mapLayout1.getTexts().get(0);
- aTitle.setLabelText("MeteoInfo Class Library Demo - Station Shaded Layer");
- //Add or change the legend in layout
- LayoutLegend aLegend;
- if (mapLayout1.getLegends().size() > 0) {
- aLegend = mapLayout1.getLegends().get(0);
- } else {
- aLegend = mapLayout1.addLegend(650, 100);
- }
- aLegend.setLegendStyle(LegendStyles.Bar_Vertical);
- aLegend.setLegendLayer(aLayer);
- if (this.jTabbedPane1.getSelectedIndex() == 1) {
- mapLayout1.paintGraphics();
- }
- }
调试结果如下:
|
|