mirror of
https://github.com/meteoinfo/MeteoInfo.git
synced 2025-12-08 20:36:05 +00:00
update WebImage plot function
This commit is contained in:
parent
6a124a2344
commit
e207d3821a
@ -345,6 +345,10 @@ public class MapGridLine extends GridLine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void updateLonLatGridLabels() {
|
protected void updateLonLatGridLabels() {
|
||||||
|
if (extent == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
//Longitude
|
//Longitude
|
||||||
List<GridLabel> tLabels = new ArrayList<>();
|
List<GridLabel> tLabels = new ArrayList<>();
|
||||||
for (int i = 0; i < this.longitudeLines.size(); i++) {
|
for (int i = 0; i < this.longitudeLines.size(); i++) {
|
||||||
|
|||||||
@ -493,6 +493,8 @@ public class MapPlot extends Plot2D implements IWebMapPanel {
|
|||||||
Graphic graphic = this.graphics.get(m);
|
Graphic graphic = this.graphics.get(m);
|
||||||
if (graphic.isVisible()) {
|
if (graphic.isVisible()) {
|
||||||
if (graphic instanceof WebMapImage) {
|
if (graphic instanceof WebMapImage) {
|
||||||
|
this.updateXYScale(area.getWidth(), area.getHeight());
|
||||||
|
this.updateWebMapScale(area.getWidth(), area.getHeight());
|
||||||
this.drawWebMapImage(g, (WebMapImage) graphic, area);
|
this.drawWebMapImage(g, (WebMapImage) graphic, area);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -611,6 +613,65 @@ public class MapPlot extends Plot2D implements IWebMapPanel {
|
|||||||
this.drawExtent.maxY = center.Y + ylen;
|
this.drawExtent.maxY = center.Y + ylen;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void updateXYScale(double width, double height) {
|
||||||
|
updateXYScale(this.drawExtent, width, height);
|
||||||
|
updateDrawExtent();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateXYScale(Extent aExtent, double width, double height) {
|
||||||
|
double scaleFactor, lonRan, latRan, temp;
|
||||||
|
|
||||||
|
this.xScale = width / (aExtent.maxX - aExtent.minX);
|
||||||
|
this.yScale = height / (aExtent.maxY - aExtent.minY);
|
||||||
|
|
||||||
|
if (xScale > yScale) {
|
||||||
|
xScale = yScale;
|
||||||
|
temp = aExtent.minX;
|
||||||
|
aExtent.minX = aExtent.maxX - width / xScale;
|
||||||
|
lonRan = (aExtent.minX - temp) / 2;
|
||||||
|
aExtent.minX = aExtent.minX - lonRan;
|
||||||
|
aExtent.maxX = aExtent.maxX - lonRan;
|
||||||
|
} else if (xScale < yScale) {
|
||||||
|
yScale = xScale;
|
||||||
|
temp = aExtent.minY;
|
||||||
|
aExtent.minY = aExtent.maxY - height / yScale;
|
||||||
|
latRan = (aExtent.minY - temp) / 2;
|
||||||
|
aExtent.minY = aExtent.minY - latRan;
|
||||||
|
aExtent.maxY = aExtent.maxY - latRan;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateWebMapScale(double width, double height) {
|
||||||
|
updateWebMapScale(this.getWebMapImage(), width, height);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateWebMapScale(WebMapImage layer, double width, double height) {
|
||||||
|
double webMapScale = layer.getWebMapScale();
|
||||||
|
if (!MIMath.doubleEquals(xScale, webMapScale)) {
|
||||||
|
int minZoom = layer.getTileFactory().getInfo().getMinimumZoomLevel();
|
||||||
|
int maxZoom = layer.getTileFactory().getInfo().getMaximumZoomLevel();
|
||||||
|
int newZoom = minZoom;
|
||||||
|
double scale = webMapScale;
|
||||||
|
for (int i = maxZoom; i >= minZoom; i--) {
|
||||||
|
layer.setZoom(i);
|
||||||
|
scale = getWebMapScale(layer, i, width, height);
|
||||||
|
if (xScale < scale) {
|
||||||
|
newZoom = i;
|
||||||
|
if (xScale < webMapScale) {
|
||||||
|
if (i < maxZoom) {
|
||||||
|
newZoom = i + 1;
|
||||||
|
scale = getWebMapScale(layer, newZoom, width, height);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.setScale(scale, width, height);
|
||||||
|
layer.setWebMapScale(scale);
|
||||||
|
layer.setZoom(newZoom);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void drawWebMapImage(Graphics2D g, WebMapImage graphic, Rectangle2D area) {
|
void drawWebMapImage(Graphics2D g, WebMapImage graphic, Rectangle2D area) {
|
||||||
PointD geoCenter = this.getGeoCenter();
|
PointD geoCenter = this.getGeoCenter();
|
||||||
graphic.setAddressLocation(new GeoPosition(geoCenter.Y, geoCenter.X));
|
graphic.setAddressLocation(new GeoPosition(geoCenter.Y, geoCenter.X));
|
||||||
@ -748,7 +809,11 @@ public class MapPlot extends Plot2D implements IWebMapPanel {
|
|||||||
*/
|
*/
|
||||||
public void zoomToExtentLonLatEx(Extent aExtent) {
|
public void zoomToExtentLonLatEx(Extent aExtent) {
|
||||||
if (!this.projInfo.isLonLat()) {
|
if (!this.projInfo.isLonLat()) {
|
||||||
aExtent = ProjectionUtil.getProjectionExtent(ProjectionInfo.LONG_LAT, this.projInfo, aExtent, 10);
|
if (this.projInfo.getProjectionName() == ProjectionNames.Mercator) {
|
||||||
|
aExtent = ProjectionUtil.getProjectionExtent(ProjectionInfo.LONG_LAT, this.projInfo, aExtent);
|
||||||
|
} else {
|
||||||
|
aExtent = ProjectionUtil.getProjectionExtent(ProjectionInfo.LONG_LAT, this.projInfo, aExtent, 10);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.setDrawExtent(aExtent);
|
this.setDrawExtent(aExtent);
|
||||||
@ -795,6 +860,14 @@ public class MapPlot extends Plot2D implements IWebMapPanel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateDrawExtent() {
|
||||||
|
super.updateDrawExtent();
|
||||||
|
if (!this.isLonLatMap()) {
|
||||||
|
((MapGridLine) this.gridLine).setExtent(extent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add point graphic
|
* Add point graphic
|
||||||
*
|
*
|
||||||
|
|||||||
@ -1,11 +1,8 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
<MeteoInfo File="milconfig.xml" Type="configurefile">
|
<MeteoInfo File="milconfig.xml" Type="configurefile">
|
||||||
<Path OpenPath="D:\Working\MIScript\Jython\mis\io\grib">
|
<Path OpenPath="D:\Working\MIScript\Jython\mis\map\webmap">
|
||||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\common_math\interpolate"/>
|
|
||||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl"/>
|
|
||||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\surf"/>
|
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\surf"/>
|
||||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\io\radar\cinrad"/>
|
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\io\radar\cinrad"/>
|
||||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis"/>
|
|
||||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\chart"/>
|
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\chart"/>
|
||||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\contour"/>
|
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\contour"/>
|
||||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\chart\legend"/>
|
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\chart\legend"/>
|
||||||
@ -16,15 +13,20 @@
|
|||||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\io\dataconvert"/>
|
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\io\dataconvert"/>
|
||||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\io"/>
|
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\io"/>
|
||||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\io\grib"/>
|
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\io\grib"/>
|
||||||
|
<RecentFolder Folder="D:\Working\MIScript\Jython\mis"/>
|
||||||
|
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\map"/>
|
||||||
|
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\map\webmap"/>
|
||||||
</Path>
|
</Path>
|
||||||
<File>
|
<File>
|
||||||
<OpenedFiles>
|
<OpenedFiles>
|
||||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\slice\slice_2d.py"/>
|
<OpenedFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\slice\slice_2d.py"/>
|
||||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\slice\plot_cuace_3d_slice.py"/>
|
<OpenedFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\slice\plot_cuace_3d_slice.py"/>
|
||||||
|
<OpenedFile File="D:\Working\MIScript\Jython\mis\map\webmap\webmap_4.py"/>
|
||||||
</OpenedFiles>
|
</OpenedFiles>
|
||||||
<RecentFiles>
|
<RecentFiles>
|
||||||
<RecentFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\slice\slice_2d.py"/>
|
<RecentFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\slice\slice_2d.py"/>
|
||||||
<RecentFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\slice\plot_cuace_3d_slice.py"/>
|
<RecentFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\slice\plot_cuace_3d_slice.py"/>
|
||||||
|
<RecentFile File="D:\Working\MIScript\Jython\mis\map\webmap\webmap_4.py"/>
|
||||||
</RecentFiles>
|
</RecentFiles>
|
||||||
</File>
|
</File>
|
||||||
<Font>
|
<Font>
|
||||||
@ -32,5 +34,5 @@
|
|||||||
</Font>
|
</Font>
|
||||||
<LookFeel DockWindowDecorated="true" LafDecorated="true" Name="FlatDarkLaf"/>
|
<LookFeel DockWindowDecorated="true" LafDecorated="true" Name="FlatDarkLaf"/>
|
||||||
<Figure DoubleBuffering="true"/>
|
<Figure DoubleBuffering="true"/>
|
||||||
<Startup MainFormLocation="-7,0" MainFormSize="1383,860"/>
|
<Startup MainFormLocation="-7,0" MainFormSize="1361,832"/>
|
||||||
</MeteoInfo>
|
</MeteoInfo>
|
||||||
|
|||||||
@ -105,6 +105,21 @@ public class ProjectionUtil {
|
|||||||
return aExtent;
|
return aExtent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get projected extent
|
||||||
|
*
|
||||||
|
* @param fromProj From projection
|
||||||
|
* @param toProj To projection
|
||||||
|
* @param fromExtent From extent
|
||||||
|
* @return To extent
|
||||||
|
*/
|
||||||
|
public static Extent getProjectionExtent(ProjectionInfo fromProj, ProjectionInfo toProj, Extent fromExtent) {
|
||||||
|
PointD pll = Reproject.reprojectPoint(fromExtent.minX, fromExtent.minY, fromProj, toProj);
|
||||||
|
PointD pur = Reproject.reprojectPoint(fromExtent.maxX, fromExtent.maxY, fromProj, toProj);
|
||||||
|
|
||||||
|
return new Extent(pll.X, pur.X, pll.Y, pur.Y);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get projected extent
|
* Get projected extent
|
||||||
*
|
*
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user