mirror of
https://github.com/meteoinfo/MeteoInfo.git
synced 2025-12-08 20:36:05 +00:00
update web map plot functions
This commit is contained in:
parent
60288729d5
commit
dbd85287f6
@ -493,7 +493,8 @@ public class MapPlot extends AbstractPlot2D implements IWebMapPanel {
|
||||
void drawGraph(Graphics2D g, Rectangle2D area) {
|
||||
this.mapView.setLockViewUpdate(false);
|
||||
this.mapView.setAntiAlias(this.antialias);
|
||||
this.mapView.setViewExtent((Extent) this.getDrawExtent().clone());
|
||||
//this.mapView.setViewExtent((Extent) this.getDrawExtent().clone());
|
||||
this.mapView.zoomToExtent((Extent) this.getDrawExtent().clone());
|
||||
if (this.boundary != null) {
|
||||
PolygonBreak pb = (PolygonBreak)this.boundary.getLegend().clone();
|
||||
if (pb.isDrawFill()) {
|
||||
|
||||
@ -14,6 +14,7 @@ import java.awt.Graphics2D;
|
||||
import java.awt.Image;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.geom.Point2D;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
@ -100,8 +101,8 @@ public class WebMapLayer extends MapLayer {
|
||||
private boolean horizontalWrapped = true;
|
||||
private WebMapProvider defaultProvider = WebMapProvider.OpenStreetMap;
|
||||
private Graphics2D graphics;
|
||||
private int width;
|
||||
private int height;
|
||||
private double width;
|
||||
private double height;
|
||||
private List<Double> scales = new ArrayList<>();
|
||||
// </editor-fold>
|
||||
// <editor-fold desc="Event">
|
||||
@ -532,7 +533,7 @@ public class WebMapLayer extends MapLayer {
|
||||
* Repaint
|
||||
*/
|
||||
public void repaint() {
|
||||
Rectangle rect = this.calculateViewportBounds(graphics, width, height);
|
||||
Rectangle2D rect = this.calculateViewportBounds(graphics, width, height);
|
||||
this.drawMapTiles(graphics, zoom, rect);
|
||||
}
|
||||
|
||||
@ -544,12 +545,12 @@ public class WebMapLayer extends MapLayer {
|
||||
* @param width The width
|
||||
* @param height The height
|
||||
*/
|
||||
public void drawMapTiles(final Graphics2D g, final int zoom, int width, int height) {
|
||||
public void drawMapTiles(final Graphics2D g, final int zoom, double width, double height) {
|
||||
this.graphics = g;
|
||||
this.zoom = zoom;
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
Rectangle rect = this.calculateViewportBounds(g, width, height);
|
||||
Rectangle2D rect = this.calculateViewportBounds(g, width, height);
|
||||
this.drawMapTiles(g, zoom, rect);
|
||||
}
|
||||
|
||||
@ -560,13 +561,13 @@ public class WebMapLayer extends MapLayer {
|
||||
* @param zoom zoom level to draw at
|
||||
* @param viewportBounds View bounds
|
||||
*/
|
||||
public void drawMapTiles(final Graphics2D g, final int zoom, final Rectangle viewportBounds) {
|
||||
public void drawMapTiles(final Graphics2D g, final int zoom, final Rectangle2D viewportBounds) {
|
||||
int size = getTileFactory().getTileSize(zoom);
|
||||
Dimension mapSize = getTileFactory().getMapSize(zoom);
|
||||
|
||||
//calculate the "visible" viewport area in tiles
|
||||
int numWide = viewportBounds.width / size + 2;
|
||||
int numHigh = viewportBounds.height / size + 2;
|
||||
int numWide = (int) (viewportBounds.getWidth() / size) + 2;
|
||||
int numHigh = (int) (viewportBounds.getHeight() / size) + 2;
|
||||
|
||||
//TilePoint topLeftTile = getTileFactory().getTileCoordinate(
|
||||
// new Point2D.Double(viewportBounds.x, viewportBounds.y));
|
||||
@ -588,8 +589,8 @@ public class WebMapLayer extends MapLayer {
|
||||
//itpy * size - viewportBounds.y, size, size))) {
|
||||
Tile tile = getTileFactory().getTile(itpx, itpy, zoom);
|
||||
//tile.addUniquePropertyChangeListener("loaded", tileLoadListener); //this is a filthy hack
|
||||
int ox = ((itpx * getTileFactory().getTileSize(zoom)) - viewportBounds.x);
|
||||
int oy = ((itpy * getTileFactory().getTileSize(zoom)) - viewportBounds.y);
|
||||
int ox = ((itpx * getTileFactory().getTileSize(zoom)) - (int) viewportBounds.getX());
|
||||
int oy = ((itpy * getTileFactory().getTileSize(zoom)) - (int) viewportBounds.getY());
|
||||
|
||||
//if the tile is off the map to the north/south, then just don't paint anything
|
||||
if (isTileOnMap(itpx, itpy, mapSize)) {
|
||||
@ -634,16 +635,16 @@ public class WebMapLayer extends MapLayer {
|
||||
* @param height Canvas height
|
||||
* @param tll TileLoadListener
|
||||
*/
|
||||
public void drawWebMapLayer(Graphics2D g, int width, int height, TileLoadListener tll) {
|
||||
public void drawWebMapLayer(Graphics2D g, double width, double height, TileLoadListener tll) {
|
||||
//layer.setZoom(zoom);
|
||||
//layer.drawMapTiles(g, zoom, width, height);
|
||||
Rectangle viewportBounds = this.calculateViewportBounds(g, width, height);
|
||||
Rectangle2D viewportBounds = this.calculateViewportBounds(g, width, height);
|
||||
int size = this.getTileFactory().getTileSize(zoom);
|
||||
Dimension mapSize = this.getTileFactory().getMapSize(zoom);
|
||||
|
||||
//calculate the "visible" viewport area in tiles
|
||||
int numWide = viewportBounds.width / size + 2;
|
||||
int numHigh = viewportBounds.height / size + 2;
|
||||
int numWide = (int) (viewportBounds.getWidth() / size) + 2;
|
||||
int numHigh = (int) (viewportBounds.getHeight() / size) + 2;
|
||||
|
||||
//TilePoint topLeftTile = getTileFactory().getTileCoordinate(
|
||||
// new Point2D.Double(viewportBounds.x, viewportBounds.y));
|
||||
@ -666,8 +667,8 @@ public class WebMapLayer extends MapLayer {
|
||||
//itpy * size - viewportBounds.y, size, size))) {
|
||||
Tile tile = this.getTileFactory().getTile(itpx, itpy, zoom);
|
||||
tile.addUniquePropertyChangeListener("loaded", tll); //this is a filthy hack
|
||||
int ox = ((itpx * this.getTileFactory().getTileSize(zoom)) - viewportBounds.x);
|
||||
int oy = ((itpy * this.getTileFactory().getTileSize(zoom)) - viewportBounds.y);
|
||||
int ox = ((itpx * this.getTileFactory().getTileSize(zoom)) - (int) viewportBounds.getX());
|
||||
int oy = ((itpy * this.getTileFactory().getTileSize(zoom)) - (int) viewportBounds.getY());
|
||||
|
||||
//if the tile is off the map to the north/south, then just don't paint anything
|
||||
if (this.isTileOnMap(itpx, itpy, mapSize)) {
|
||||
@ -739,13 +740,13 @@ public class WebMapLayer extends MapLayer {
|
||||
* @param height The height
|
||||
* @return View port bounds rectangle
|
||||
*/
|
||||
public Rectangle calculateViewportBounds(Graphics2D g, int width, int height) {
|
||||
public Rectangle2D calculateViewportBounds(Graphics2D g, double width, double height) {
|
||||
//calculate the "visible" viewport area in pixels
|
||||
//double sx = g.getTransform().getTranslateX();
|
||||
//double sy = g.getTransform().getTranslateY();
|
||||
double viewportX = (center.getX() - width / 2);
|
||||
double viewportY = (center.getY() - height / 2);
|
||||
return new Rectangle((int) viewportX, (int) viewportY, width, height);
|
||||
return new Rectangle2D.Double(viewportX, viewportY, width, height);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -4403,7 +4403,7 @@ public class MapView extends JPanel implements IWebMapPanel {
|
||||
drawLayers(g, this.getWidth(), this.getHeight());
|
||||
}
|
||||
|
||||
private void drawLayers(Graphics2D g, int width, int height) {
|
||||
private void drawLayers(Graphics2D g, double width, double height) {
|
||||
java.awt.Shape oldRegion = g.getClip();
|
||||
double geoScale = this.getGeoScale();
|
||||
for (MapLayer aLayer : layers) {
|
||||
@ -4521,7 +4521,7 @@ public class MapView extends JPanel implements IWebMapPanel {
|
||||
this.fixMapScale = false;
|
||||
}
|
||||
|
||||
private void drawImage(Graphics2D g, ImageLayer aILayer, double LonShift, int width, int height) {
|
||||
private void drawImage(Graphics2D g, ImageLayer aILayer, double LonShift, double width, double height) {
|
||||
Extent lExtent = MIMath.shiftExtentLon(aILayer.getExtent(), LonShift);
|
||||
if (MIMath.isExtentCross(lExtent, _drawExtent)) {
|
||||
g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, aILayer.getInterpolation());
|
||||
@ -4543,7 +4543,7 @@ public class MapView extends JPanel implements IWebMapPanel {
|
||||
}
|
||||
|
||||
//Draw image
|
||||
BufferedImage dImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
|
||||
BufferedImage dImage = new BufferedImage((int) width, (int) height, BufferedImage.TYPE_INT_ARGB);
|
||||
Graphics2D dg = (Graphics2D) dImage.getGraphics();
|
||||
//dg.drawImage(aILayer.getImage(), 0, 0, null);
|
||||
// Image dImage = new Bitmap(width, height);
|
||||
@ -5719,11 +5719,11 @@ public class MapView extends JPanel implements IWebMapPanel {
|
||||
return rPoints;
|
||||
}
|
||||
|
||||
private void drawWebMapLayer(WebMapLayer layer, Graphics2D g, int width, int height) {
|
||||
private void drawWebMapLayer(WebMapLayer layer, Graphics2D g, double width, double height) {
|
||||
this.drawWebMapLayer(layer, g, width, height, tileLoadListener);
|
||||
}
|
||||
|
||||
private void drawWebMapLayer(WebMapLayer layer, Graphics2D g, int width, int height, TileLoadListener tll) {
|
||||
private void drawWebMapLayer(WebMapLayer layer, Graphics2D g, double width, double height, TileLoadListener tll) {
|
||||
PointD geoCenter = this.getGeoCenter();
|
||||
layer.setAddressLocation(new GeoPosition(geoCenter.Y, geoCenter.X));
|
||||
if (this.fixMapScale) {
|
||||
@ -5887,12 +5887,12 @@ public class MapView extends JPanel implements IWebMapPanel {
|
||||
// }
|
||||
// }
|
||||
|
||||
private double getWebMapScale(WebMapLayer layer, int zoom, int width, int height) {
|
||||
private double getWebMapScale(WebMapLayer layer, int zoom, double width, double height) {
|
||||
Point2D center = layer.getCenter();
|
||||
double minx = center.getX() - width / 2;
|
||||
double miny = center.getY() - height / 2;
|
||||
double maxx = center.getX() + width / 2;
|
||||
double maxy = center.getY() + height / 2;
|
||||
double minx = center.getX() - width / 2.;
|
||||
double miny = center.getY() - height / 2.;
|
||||
double maxx = center.getX() + width / 2.;
|
||||
double maxy = center.getY() + height / 2.;
|
||||
GeoPosition pos1 = GeoUtil.getPosition(new Point2D.Double(minx, miny), zoom, layer.getTileFactory().getInfo());
|
||||
GeoPosition pos2 = GeoUtil.getPosition(new Point2D.Double(maxx, maxy), zoom, layer.getTileFactory().getInfo());
|
||||
PointD p1 = Reproject.reprojectPoint(new PointD(pos1.getLongitude(), pos1.getLatitude()),
|
||||
@ -7822,7 +7822,7 @@ public class MapView extends JPanel implements IWebMapPanel {
|
||||
setCoordinateGeoMap(aExtent, this.getWidth(), this.getHeight());
|
||||
}
|
||||
|
||||
private void setCoordinateGeoMap(Extent aExtent, int width, int height) {
|
||||
private void setCoordinateGeoMap(Extent aExtent, double width, double height) {
|
||||
double scaleFactor, lonRan, latRan, temp;
|
||||
|
||||
_scaleX = width / (aExtent.maxX - aExtent.minX);
|
||||
@ -7854,7 +7854,7 @@ public class MapView extends JPanel implements IWebMapPanel {
|
||||
setCoordinateGeoMapEx(aExtent, this.getWidth(), this.getHeight());
|
||||
}
|
||||
|
||||
private void setCoordinateGeoMapEx(Extent aExtent, int width, int height) {
|
||||
private void setCoordinateGeoMapEx(Extent aExtent, double width, double height) {
|
||||
double scaleFactor;
|
||||
|
||||
_scaleX = width / (aExtent.maxX - aExtent.minX);
|
||||
@ -7878,12 +7878,12 @@ public class MapView extends JPanel implements IWebMapPanel {
|
||||
setCoordinateMap(aExtent, this.getWidth(), this.getHeight());
|
||||
}
|
||||
|
||||
private void setCoordinateMap(Extent aExtent, int width, int height) {
|
||||
private void setCoordinateMap(Extent aExtent, double width, double height) {
|
||||
_scaleX = width / (aExtent.maxX - aExtent.minX);
|
||||
_scaleY = height / (aExtent.maxY - aExtent.minY);
|
||||
}
|
||||
|
||||
private void setScale(double scale, int width, int height) {
|
||||
private void setScale(double scale, double width, double height) {
|
||||
this._scaleX = scale;
|
||||
this._scaleY = scale;
|
||||
//PointD center = (PointD)this._drawExtent.getCenterPoint().clone();
|
||||
@ -7911,7 +7911,7 @@ public class MapView extends JPanel implements IWebMapPanel {
|
||||
* @param width The width
|
||||
* @param height The height
|
||||
*/
|
||||
public void refreshXYScale(int width, int height) {
|
||||
public void refreshXYScale(double width, double height) {
|
||||
Extent aExtent = (Extent) _viewExtent.clone();
|
||||
|
||||
if (_isGeoMap) {
|
||||
@ -7923,6 +7923,23 @@ public class MapView extends JPanel implements IWebMapPanel {
|
||||
_drawExtent = aExtent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Refresh X/Y scale
|
||||
*
|
||||
* @param extent The extent
|
||||
* @param width The width
|
||||
* @param height The height
|
||||
*/
|
||||
public void refreshXYScale(Extent extent, double width, double height) {
|
||||
if (_isGeoMap) {
|
||||
setCoordinateGeoMap(extent, width, height);
|
||||
} else {
|
||||
setCoordinateMap(extent, width, height);
|
||||
}
|
||||
|
||||
_drawExtent = extent;
|
||||
}
|
||||
|
||||
private double getGeoWidth(double width) {
|
||||
double geoWidth = width / _scaleX;
|
||||
if (_projection.isLonLatMap()) {
|
||||
@ -7964,7 +7981,7 @@ public class MapView extends JPanel implements IWebMapPanel {
|
||||
/**
|
||||
* Get geographic center with longitude/latitude
|
||||
*
|
||||
* @return Geogrphic center
|
||||
* @return Geographic center
|
||||
*/
|
||||
public PointD getGeoCenter() {
|
||||
PointD viewCenter = this.getViewCenter();
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<MeteoInfo File="milconfig.xml" Type="configurefile">
|
||||
<Path OpenPath="D:\Working\MIScript\Jython\mis\map\webmap">
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\polar"/>
|
||||
<Path OpenPath="D:\Working\MIScript\Jython\mis\map\projection">
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\wind"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\isosurface"/>
|
||||
@ -14,8 +13,9 @@
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\io"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\io\geotiff"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\map"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\map\webmap"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\map"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\map\projection"/>
|
||||
</Path>
|
||||
<File>
|
||||
<OpenedFiles>
|
||||
@ -36,5 +36,5 @@
|
||||
</Font>
|
||||
<LookFeel DockWindowDecorated="true" LafDecorated="true" Name="FlatDarkLaf"/>
|
||||
<Figure DoubleBuffering="true"/>
|
||||
<Startup MainFormLocation="-7,-7" MainFormSize="1293,685"/>
|
||||
<Startup MainFormLocation="7,3" MainFormSize="1417,797"/>
|
||||
</MeteoInfo>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user