From 5364bc713a3e00f5d5748b8de9a7aab629a500d2 Mon Sep 17 00:00:00 2001 From: wyq Date: Thu, 2 Sep 2021 14:13:16 +0800 Subject: [PATCH] update web map functions --- .../Maven__com_formdev_flatlaf_1_5.xml | 13 +++++ .../Maven__com_formdev_flatlaf_extras_1_5.xml | 13 +++++ .../data/mapdata/geotiff/GeoTiff.java | 12 ++-- .../data/mapdata/webmap/TileFactoryInfo.java | 2 +- .../org/meteoinfo/geo/layer/WebMapLayer.java | 8 +-- .../org/meteoinfo/geo/mapview/MapView.java | 57 +++++++------------ meteoinfo-lab/milconfig.xml | 18 +++--- meteoinfo-map/default.mip | 9 +-- 8 files changed, 70 insertions(+), 62 deletions(-) create mode 100644 .idea/libraries/Maven__com_formdev_flatlaf_1_5.xml create mode 100644 .idea/libraries/Maven__com_formdev_flatlaf_extras_1_5.xml diff --git a/.idea/libraries/Maven__com_formdev_flatlaf_1_5.xml b/.idea/libraries/Maven__com_formdev_flatlaf_1_5.xml new file mode 100644 index 00000000..88b7c72e --- /dev/null +++ b/.idea/libraries/Maven__com_formdev_flatlaf_1_5.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Maven__com_formdev_flatlaf_extras_1_5.xml b/.idea/libraries/Maven__com_formdev_flatlaf_extras_1_5.xml new file mode 100644 index 00000000..9906e1f6 --- /dev/null +++ b/.idea/libraries/Maven__com_formdev_flatlaf_extras_1_5.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/meteoinfo-data/src/main/java/org/meteoinfo/data/mapdata/geotiff/GeoTiff.java b/meteoinfo-data/src/main/java/org/meteoinfo/data/mapdata/geotiff/GeoTiff.java index 8db6d68a..d683fb1d 100644 --- a/meteoinfo-data/src/main/java/org/meteoinfo/data/mapdata/geotiff/GeoTiff.java +++ b/meteoinfo-data/src/main/java/org/meteoinfo/data/mapdata/geotiff/GeoTiff.java @@ -1614,7 +1614,7 @@ public class GeoTiff { ByteBuffer buffer = ByteBuffer.allocate(8); int n = channel.read(buffer); assert n == 8; - buffer.flip(); + ((Buffer)buffer).flip(); if (this.showHeaderBytes) { printBytes(System.out, "header", buffer, 4); buffer.rewind(); @@ -1639,7 +1639,7 @@ public class GeoTiff { buffer = ByteBuffer.allocate(size); buffer.order(this.byteOrder); channel.read(buffer); - buffer.flip(); + ((Buffer)buffer).flip(); firstIFD = buffer.getLong(); } else { firstIFD = buffer.getInt(); @@ -1666,7 +1666,7 @@ public class GeoTiff { buffer.order(this.byteOrder); int n = channel.read(buffer); - buffer.flip(); + ((Buffer)buffer).flip(); if (this.showBytes) { printBytes(System.out, "IFD", buffer, 2); buffer.rewind(); @@ -1698,7 +1698,7 @@ public class GeoTiff { buffer = this.bigTiff ? ByteBuffer.allocate(8) : ByteBuffer.allocate(4); buffer.order(this.byteOrder); n = channel.read(buffer); - buffer.flip(); + ((Buffer)buffer).flip(); long nextIFD = this.bigTiff ? buffer.getLong() : buffer.getInt(); if (this.debugRead) { System.out.println(" nextIFD == " + nextIFD); @@ -1723,7 +1723,7 @@ public class GeoTiff { ByteBuffer buffer = this.bigTiff ? ByteBuffer.allocate(20) : ByteBuffer.allocate(12); buffer.order(this.byteOrder); channel.read(buffer); - buffer.flip(); + ((Buffer)buffer).flip(); if (this.showBytes) { printBytes(System.out, "IFDEntry bytes", buffer, buffer.limit()); } @@ -1755,7 +1755,7 @@ public class GeoTiff { ByteBuffer vBuffer = ByteBuffer.allocate((int)ifd.count * ifd.type.size); vBuffer.order(this.byteOrder); channel.read(vBuffer); - vBuffer.flip(); + ((Buffer)vBuffer).flip(); readValues(vBuffer, ifd); } diff --git a/meteoinfo-data/src/main/java/org/meteoinfo/data/mapdata/webmap/TileFactoryInfo.java b/meteoinfo-data/src/main/java/org/meteoinfo/data/mapdata/webmap/TileFactoryInfo.java index 73fc3000..b8e0a02f 100644 --- a/meteoinfo-data/src/main/java/org/meteoinfo/data/mapdata/webmap/TileFactoryInfo.java +++ b/meteoinfo-data/src/main/java/org/meteoinfo/data/mapdata/webmap/TileFactoryInfo.java @@ -55,7 +55,7 @@ public class TileFactoryInfo { private String zparam; private boolean xr2l = true; private boolean yt2b = true; - private int defaultZoomLevel; + private int defaultZoomLevel = 1; /** * A name for this info. */ diff --git a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/layer/WebMapLayer.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/layer/WebMapLayer.java index c0a66f0e..bb7b7418 100644 --- a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/layer/WebMapLayer.java +++ b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/layer/WebMapLayer.java @@ -196,9 +196,9 @@ public class WebMapLayer extends MapLayer { } //if(zoom >= 0 && zoom <= 15 && zoom != this.zoom) { - int oldzoom = this.zoom; + int oldZoom = this.zoom; Point2D oldCenter = getCenter(); - Dimension oldMapSize = getTileFactory().getMapSize(oldzoom); + Dimension oldMapSize = getTileFactory().getMapSize(oldZoom); this.zoom = zoom; //this.firePropertyChange("zoom", oldzoom, zoom); @@ -327,8 +327,8 @@ public class WebMapLayer extends MapLayer { */ public void setTileFactory(TileFactory factory) { this.factory = factory; - this.setZoom(factory.getInfo().getDefaultZoomLevel()); - this.setCenterPosition(new GeoPosition(0, 0)); + //this.setZoom(factory.getInfo().getDefaultZoomLevel()); + //this.setCenterPosition(new GeoPosition(0, 0)); } /** diff --git a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/mapview/MapView.java b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/mapview/MapView.java index 97582e96..8656b2ba 100644 --- a/meteoinfo-geo/src/main/java/org/meteoinfo/geo/mapview/MapView.java +++ b/meteoinfo-geo/src/main/java/org/meteoinfo/geo/mapview/MapView.java @@ -4357,13 +4357,13 @@ public class MapView extends JPanel implements IWebMapPanel { drawProjectedMap(g, this.getWidth(), this.getHeight()); } - private void drawProjectedMap(Graphics2D g, int width, int heigth) { - this.drawProjectedMap(g, width, heigth, tileLoadListener); + private void drawProjectedMap(Graphics2D g, int width, int height) { + this.drawProjectedMap(g, width, height, tileLoadListener); } - private void drawProjectedMap(Graphics2D g, int width, int heigth, TileLoadListener tll) { + private void drawProjectedMap(Graphics2D g, int width, int height, TileLoadListener tll) { //Draw layers - drawProjectedLayers(g, width, heigth, tll); + drawProjectedLayers(g, width, height, tll); //Draw lon/lat if (_drawGridLine) { @@ -5715,46 +5715,31 @@ public class MapView extends JPanel implements IWebMapPanel { if (this.fixMapScale) { layer.setWebMapScale(this._scaleX); layer.setZoom(this.zoomLevel); - } else { - zoomLevel = layer.getZoom(); + } else { double webMapScale = layer.getWebMapScale(); if (!MIMath.doubleEquals(_scaleX, webMapScale)) { int minZoom = layer.getTileFactory().getInfo().getMinimumZoomLevel(); int maxZoom = layer.getTileFactory().getInfo().getMaximumZoomLevel(); - //int totalZoom = layer.getTileFactory().getInfo().getTotalMapZoom(); - int nzoom = minZoom; - double scale; + int newZoom = minZoom; + double scale = webMapScale; for (int i = maxZoom; i >= minZoom; i--) { - //int z = totalZoom - i; - //double res = GeoUtil.getResolution(z, geoCenter.Y); - //double scale = 1.0 / res; - //layer.setAddressLocation(new GeoPosition(geoCenter.Y, geoCenter.X), i); layer.setZoom(i); scale = getWebMapScale(layer, i, width, height); - if (_scaleX < scale || MIMath.doubleEquals(_scaleX, scale)) { - this.setScale(scale, width, height); - nzoom = i; - webMapScale = scale; - layer.setWebMapScale(webMapScale); + if (_scaleX < scale) { + newZoom = i; + if (_scaleX < webMapScale) { + if (i < maxZoom) { + newZoom = i + 1; + scale = getWebMapScale(layer, newZoom, width, height); + } + } break; } } - - boolean addOne = false; - if (zoomLevel == minZoom) { - addOne = true; - } else if (nzoom < maxZoom) { - addOne = true; - } - if (addOne) { - zoomLevel = nzoom + 1; - webMapScale = getWebMapScale(layer, zoomLevel, width, height); - this.setScale(webMapScale, width, height); - layer.setWebMapScale(webMapScale); - layer.setZoom(zoomLevel); - } else { - zoomLevel = nzoom; - } + this.setScale(scale, width, height); + layer.setWebMapScale(scale); + layer.setZoom(newZoom); + zoomLevel = newZoom; } this.fixMapScale = true; } @@ -5901,9 +5886,7 @@ public class MapView extends JPanel implements IWebMapPanel { PointD p2 = Reproject.reprojectPoint(new PointD(pos2.getLongitude(), pos2.getLatitude()), KnownCoordinateSystems.geographic.world.WGS1984, this.getProjection().getProjInfo()); if (pos2.getLongitude() - pos1.getLongitude() < 360.0) { - double xlen = p2.X - p1.X; -// if (pos2.getLongitude() - pos1.getLongitude() > 360) -// xlen += 2.0037497210840166E7 * 2; + double xlen = Math.abs(p2.X - p1.X); return (double) width / xlen; } else { double ylen = Math.abs(p2.Y - p1.Y); diff --git a/meteoinfo-lab/milconfig.xml b/meteoinfo-lab/milconfig.xml index c01a9ec3..3bda6c78 100644 --- a/meteoinfo-lab/milconfig.xml +++ b/meteoinfo-lab/milconfig.xml @@ -1,10 +1,6 @@ - - - - - + @@ -14,19 +10,21 @@ - + + + + + - - + - - + diff --git a/meteoinfo-map/default.mip b/meteoinfo-map/default.mip index b6d34d35..747dfa6d 100644 --- a/meteoinfo-map/default.mip +++ b/meteoinfo-map/default.mip @@ -2,13 +2,14 @@ - + - + - + + @@ -24,7 +25,7 @@ - +