[jmapviewer] 01/05: Imported Upstream version 2.1+dfsg
Bas Couwenberg
sebastic at debian.org
Mon May 1 17:15:38 UTC 2017
This is an automated email from the git hooks/post-receive script.
sebastic pushed a commit to branch master
in repository jmapviewer.
commit 01ffecef089e7cf53d0c1b1d68de29720b0239b3
Author: Bas Couwenberg <sebastic at xs4all.nl>
Date: Mon May 1 18:53:49 2017 +0200
Imported Upstream version 2.1+dfsg
---
build.xml | 2 +-
.../openstreetmap/gui/jmapviewer/Coordinate.java | 5 +-
.../gui/jmapviewer/MapPolygonImpl.java | 6 +-
.../gui/jmapviewer/OsmTileLoader.java | 5 --
.../jmapviewer/{Coordinate.java => Projected.java} | 45 ++++-------
src/org/openstreetmap/gui/jmapviewer/Tile.java | 23 ++++--
.../openstreetmap/gui/jmapviewer/TileRange.java | 57 ++++++++++++++
src/org/openstreetmap/gui/jmapviewer/TileXY.java | 5 ++
.../gui/jmapviewer/interfaces/IProjected.java | 22 ++++++
.../gui/jmapviewer/interfaces/TileJob.java | 9 ---
.../gui/jmapviewer/interfaces/TileSource.java | 90 ++++++++++++++++++----
.../tilesources/BingAerialTileSource.java | 6 +-
.../jmapviewer/tilesources/ScanexTileSource.java | 8 +-
.../gui/jmapviewer/tilesources/TMSTileSource.java | 45 +++++++++++
14 files changed, 248 insertions(+), 80 deletions(-)
diff --git a/build.xml b/build.xml
index 2625650..114b95d 100644
--- a/build.xml
+++ b/build.xml
@@ -77,7 +77,7 @@
<target name="checkstyle">
<taskdef resource="com/puppycrawl/tools/checkstyle/ant/checkstyle-ant-task.properties"
- classpath="tools/checkstyle/checkstyle-7.1-all.jar"/>
+ classpath="tools/checkstyle/checkstyle-7.7-all.jar"/>
<checkstyle config="tools/checkstyle/jmapviewer_checks.xml">
<fileset dir="${basedir}/src" includes="**/*.java" />
<formatter type="xml" toFile="checkstyle-jmapviewer.xml"/>
diff --git a/src/org/openstreetmap/gui/jmapviewer/Coordinate.java b/src/org/openstreetmap/gui/jmapviewer/Coordinate.java
index 0acbf76..89f2812 100644
--- a/src/org/openstreetmap/gui/jmapviewer/Coordinate.java
+++ b/src/org/openstreetmap/gui/jmapviewer/Coordinate.java
@@ -75,9 +75,6 @@ public class Coordinate implements ICoordinate {
return false;
}
final Coordinate other = (Coordinate) obj;
- if (!Objects.equals(this.data, other.data)) {
- return false;
- }
- return true;
+ return Objects.equals(this.data, other.data);
}
}
diff --git a/src/org/openstreetmap/gui/jmapviewer/MapPolygonImpl.java b/src/org/openstreetmap/gui/jmapviewer/MapPolygonImpl.java
index 971625a..b4ffb21 100644
--- a/src/org/openstreetmap/gui/jmapviewer/MapPolygonImpl.java
+++ b/src/org/openstreetmap/gui/jmapviewer/MapPolygonImpl.java
@@ -21,7 +21,7 @@ public class MapPolygonImpl extends MapObjectImpl implements MapPolygon {
private List<? extends ICoordinate> points;
- public MapPolygonImpl(ICoordinate ... points) {
+ public MapPolygonImpl(ICoordinate... points) {
this(null, null, points);
}
@@ -33,7 +33,7 @@ public class MapPolygonImpl extends MapObjectImpl implements MapPolygon {
this(null, name, points);
}
- public MapPolygonImpl(String name, ICoordinate ... points) {
+ public MapPolygonImpl(String name, ICoordinate... points) {
this(null, name, points);
}
@@ -45,7 +45,7 @@ public class MapPolygonImpl extends MapObjectImpl implements MapPolygon {
this(layer, name, points, getDefaultStyle());
}
- public MapPolygonImpl(Layer layer, String name, ICoordinate ... points) {
+ public MapPolygonImpl(Layer layer, String name, ICoordinate... points) {
this(layer, name, Arrays.asList(points), getDefaultStyle());
}
diff --git a/src/org/openstreetmap/gui/jmapviewer/OsmTileLoader.java b/src/org/openstreetmap/gui/jmapviewer/OsmTileLoader.java
index c7ab9a2..2877c00 100644
--- a/src/org/openstreetmap/gui/jmapviewer/OsmTileLoader.java
+++ b/src/org/openstreetmap/gui/jmapviewer/OsmTileLoader.java
@@ -79,11 +79,6 @@ public class OsmTileLoader implements TileLoader {
}
@Override
- public Tile getTile() {
- return tile;
- }
-
- @Override
public void submit() {
submit(false);
}
diff --git a/src/org/openstreetmap/gui/jmapviewer/Coordinate.java b/src/org/openstreetmap/gui/jmapviewer/Projected.java
similarity index 57%
copy from src/org/openstreetmap/gui/jmapviewer/Coordinate.java
copy to src/org/openstreetmap/gui/jmapviewer/Projected.java
index 0acbf76..14cbc24 100644
--- a/src/org/openstreetmap/gui/jmapviewer/Coordinate.java
+++ b/src/org/openstreetmap/gui/jmapviewer/Projected.java
@@ -7,40 +7,31 @@ import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.Objects;
-import org.openstreetmap.gui.jmapviewer.interfaces.ICoordinate;
+import org.openstreetmap.gui.jmapviewer.interfaces.IProjected;
/**
- * This class encapsulates a Point2D.Double and provide access
- * via <tt>lat</tt> and <tt>lon</tt>.
- *
- * @author Jan Peter Stotz
- *
+ * Projected coordinates represented by an encapsulates a Point2D.Double value.
*/
-public class Coordinate implements ICoordinate {
+public class Projected implements IProjected {
private transient Point2D.Double data;
- public Coordinate(double lat, double lon) {
- data = new Point2D.Double(lon, lat);
+ /**
+ * Constructs a new {@code Projected}.
+ * @param east easting
+ * @param north northing
+ */
+ public Projected(double east, double north) {
+ data = new Point2D.Double(east, north);
}
@Override
- public double getLat() {
- return data.y;
- }
-
- @Override
- public void setLat(double lat) {
- data.y = lat;
- }
-
- @Override
- public double getLon() {
+ public double getEast() {
return data.x;
}
@Override
- public void setLon(double lon) {
- data.x = lon;
+ public double getNorth() {
+ return data.y;
}
private void writeObject(ObjectOutputStream out) throws IOException {
@@ -56,7 +47,7 @@ public class Coordinate implements ICoordinate {
@Override
public String toString() {
- return "Coordinate[" + data.y + ", " + data.x + ']';
+ return "Projected[" + data.y + ", " + data.x + ']';
}
@Override
@@ -74,10 +65,8 @@ public class Coordinate implements ICoordinate {
if (getClass() != obj.getClass()) {
return false;
}
- final Coordinate other = (Coordinate) obj;
- if (!Objects.equals(this.data, other.data)) {
- return false;
- }
- return true;
+ final Projected other = (Projected) obj;
+ return Objects.equals(this.data, other.data);
}
}
+
diff --git a/src/org/openstreetmap/gui/jmapviewer/Tile.java b/src/org/openstreetmap/gui/jmapviewer/Tile.java
index f0c73fc..cbde18d 100644
--- a/src/org/openstreetmap/gui/jmapviewer/Tile.java
+++ b/src/org/openstreetmap/gui/jmapviewer/Tile.java
@@ -126,7 +126,7 @@ public class Tile {
final CachedCallable<BufferedImage> tmpImage = new CachedCallable<>(new Callable<BufferedImage>() {
@Override
public BufferedImage call() throws Exception {
- return new BufferedImage(source.getTileSize(), source.getTileSize(), BufferedImage.TYPE_INT_RGB);
+ return new BufferedImage(source.getTileSize(), source.getTileSize(), BufferedImage.TYPE_INT_ARGB);
}
});
@@ -228,7 +228,7 @@ public class Tile {
}
/**
- * @return tile indexes as TileXY object
+ * @return tile indexes of the top left corner as TileXY object
*/
public TileXY getTileXY() {
return new TileXY(xtile, ytile);
@@ -243,7 +243,7 @@ public class Tile {
}
public void loadImage(InputStream input) throws IOException {
- image = ImageIO.read(input);
+ setImage(ImageIO.read(input));
}
/**
@@ -301,7 +301,17 @@ public class Tile {
@Override
public String toString() {
- return "Tile " + key;
+ StringBuilder sb = new StringBuilder(35).append("Tile ").append(key);
+ if (loading) {
+ sb.append(" [LOADING...]");
+ }
+ if (loaded) {
+ sb.append(" [loaded]");
+ }
+ if (error) {
+ sb.append(" [ERROR]");
+ }
+ return sb.toString();
}
/**
@@ -340,10 +350,7 @@ public class Tile {
return false;
if (zoom != other.zoom)
return false;
- if (!getTileSource().equals(other.getTileSource())) {
- return false;
- }
- return true;
+ return getTileSource().equals(other.getTileSource());
}
public static String getTileKey(TileSource source, int xtile, int ytile, int zoom) {
diff --git a/src/org/openstreetmap/gui/jmapviewer/TileRange.java b/src/org/openstreetmap/gui/jmapviewer/TileRange.java
new file mode 100644
index 0000000..a35760f
--- /dev/null
+++ b/src/org/openstreetmap/gui/jmapviewer/TileRange.java
@@ -0,0 +1,57 @@
+// License: GPL. For details, see Readme.txt file.
+package org.openstreetmap.gui.jmapviewer;
+
+/**
+ * This is a rectangular range of tiles.
+ */
+public class TileRange {
+ protected int minX;
+ protected int maxX;
+ protected int minY;
+ protected int maxY;
+ protected int zoom;
+
+ protected TileRange() {
+ }
+
+ /**
+ * Constructs a new {@code TileRange}.
+ * @param t1 first tile
+ * @param t2 second tile
+ * @param zoom zoom level
+ */
+ public TileRange(TileXY t1, TileXY t2, int zoom) {
+ minX = (int) Math.floor(Math.min(t1.getX(), t2.getX()));
+ minY = (int) Math.floor(Math.min(t1.getY(), t2.getY()));
+ maxX = (int) Math.ceil(Math.max(t1.getX(), t2.getX()));
+ maxY = (int) Math.ceil(Math.max(t1.getY(), t2.getY()));
+ this.zoom = zoom;
+ }
+
+ /**
+ * Constructs a new {@code TileRange}.
+ * @param r existing tile range to copy
+ */
+ public TileRange(TileRange r) {
+ minX = r.minX;
+ minY = r.minY;
+ maxX = r.maxX;
+ maxY = r.maxY;
+ zoom = r.zoom;
+ }
+
+ protected double tilesSpanned() {
+ return Math.sqrt(1.0 * this.size());
+ }
+
+ /**
+ * Returns size
+ * @return size
+ */
+ public int size() {
+ int xSpan = maxX - minX + 1;
+ int ySpan = maxY - minY + 1;
+ return xSpan * ySpan;
+ }
+}
+
diff --git a/src/org/openstreetmap/gui/jmapviewer/TileXY.java b/src/org/openstreetmap/gui/jmapviewer/TileXY.java
index f341999..ca671cc 100644
--- a/src/org/openstreetmap/gui/jmapviewer/TileXY.java
+++ b/src/org/openstreetmap/gui/jmapviewer/TileXY.java
@@ -54,4 +54,9 @@ public class TileXY {
public double getY() {
return y;
}
+
+ @Override
+ public String toString() {
+ return "TileXY{" + x + ", " + y + "}";
+ }
}
diff --git a/src/org/openstreetmap/gui/jmapviewer/interfaces/IProjected.java b/src/org/openstreetmap/gui/jmapviewer/interfaces/IProjected.java
new file mode 100644
index 0000000..4e554d9
--- /dev/null
+++ b/src/org/openstreetmap/gui/jmapviewer/interfaces/IProjected.java
@@ -0,0 +1,22 @@
+// License: GPL. For details, see Readme.txt file.
+package org.openstreetmap.gui.jmapviewer.interfaces;
+
+/**
+ * Projected coordinates (east / north space).
+ *
+ * For most projections, one unit in projected space is roughly one meter, but
+ * can also be degrees or feet.
+ */
+public interface IProjected {
+ /**
+ * Returns easting.
+ * @return easting
+ */
+ double getEast();
+
+ /**
+ * Returns northing.
+ * @return northing
+ */
+ double getNorth();
+}
diff --git a/src/org/openstreetmap/gui/jmapviewer/interfaces/TileJob.java b/src/org/openstreetmap/gui/jmapviewer/interfaces/TileJob.java
index 7a5ad54..143b34f 100644
--- a/src/org/openstreetmap/gui/jmapviewer/interfaces/TileJob.java
+++ b/src/org/openstreetmap/gui/jmapviewer/interfaces/TileJob.java
@@ -1,8 +1,6 @@
// License: GPL. For details, see Readme.txt file.
package org.openstreetmap.gui.jmapviewer.interfaces;
-import org.openstreetmap.gui.jmapviewer.Tile;
-
/**
* Interface for implementing a tile loading job. Tiles are usually loaded via HTTP
* or from a file.
@@ -12,13 +10,6 @@ import org.openstreetmap.gui.jmapviewer.Tile;
public interface TileJob extends Runnable {
/**
- * Function to return the tile associated with the job
- *
- * @return {@link Tile} to be handled
- */
- Tile getTile();
-
- /**
* submits download job to backend.
*/
void submit();
diff --git a/src/org/openstreetmap/gui/jmapviewer/interfaces/TileSource.java b/src/org/openstreetmap/gui/jmapviewer/interfaces/TileSource.java
index 742b5a2..9db81b5 100644
--- a/src/org/openstreetmap/gui/jmapviewer/interfaces/TileSource.java
+++ b/src/org/openstreetmap/gui/jmapviewer/interfaces/TileSource.java
@@ -8,6 +8,7 @@ import java.util.Map;
import org.openstreetmap.gui.jmapviewer.JMapViewer;
import org.openstreetmap.gui.jmapviewer.Tile;
+import org.openstreetmap.gui.jmapviewer.TileRange;
import org.openstreetmap.gui.jmapviewer.TileXY;
/**
@@ -96,21 +97,24 @@ public interface TileSource extends Attributed {
double getDistance(double la1, double lo1, double la2, double lo2);
/**
+ * Transforms longitude and latitude to pixel space (as if all tiles at specified zoom level where joined).
* @param lon longitude
* @param lat latitude
* @param zoom zoom level
- * @return transforms longitude and latitude to pixel space (as if all tiles at specified zoom level where joined)
+ * @return the pixel coordinates
*/
Point latLonToXY(double lat, double lon, int zoom);
/**
+ * Transforms longitude and latitude to pixel space (as if all tiles at specified zoom level where joined).
* @param point point
* @param zoom zoom level
- * @return transforms longitude and latitude to pixel space (as if all tiles at specified zoom level where joined)
+ * @return the pixel coordinates
*/
Point latLonToXY(ICoordinate point, int zoom);
/**
+ * Transforms a point in pixel space to longitude/latitude (WGS84).
* @param point point
* @param zoom zoom level
* @return WGS84 Coordinates of given point
@@ -118,7 +122,7 @@ public interface TileSource extends Attributed {
ICoordinate xyToLatLon(Point point, int zoom);
/**
- *
+ * Transforms a point in pixel space to longitude/latitude (WGS84).
* @param x X coordinate
* @param y Y coordinate
* @param zoom zoom level
@@ -127,6 +131,7 @@ public interface TileSource extends Attributed {
ICoordinate xyToLatLon(int x, int y, int zoom);
/**
+ * Transforms longitude and latitude to tile indices.
* @param lon longitude
* @param lat latitude
* @param zoom zoom level
@@ -135,7 +140,7 @@ public interface TileSource extends Attributed {
TileXY latLonToTileXY(double lat, double lon, int zoom);
/**
- *
+ * Transforms longitude and latitude to tile indices.
* @param point point
* @param zoom zoom level
* @return x and y tile indices
@@ -143,51 +148,55 @@ public interface TileSource extends Attributed {
TileXY latLonToTileXY(ICoordinate point, int zoom);
/**
- * @param xy X/Y coordinates
+ * Transforms tile indices to longitude and latitude.
+ * @param xy X/Y tile indices
* @param zoom zoom level
* @return WGS84 coordinates of given tile
*/
ICoordinate tileXYToLatLon(TileXY xy, int zoom);
/**
- *
+ * Determines to longitude and latitude of a tile.
+ * (Refers to the tile origin - upper left tile corner)
* @param tile Tile
* @return WGS84 coordinates of given tile
*/
ICoordinate tileXYToLatLon(Tile tile);
/**
- *
- * @param x X coordinate
- * @param y Y coordinate
+ * Transforms tile indices to longitude and latitude.
+ * @param x x tile index
+ * @param y y tile index
* @param zoom zoom level
* @return WGS84 coordinates of given tile
*/
ICoordinate tileXYToLatLon(int x, int y, int zoom);
/**
+ * Get maximum x index of tile for specified zoom level.
* @param zoom zoom level
- * @return maximum X index of tile for specified zoom level
+ * @return maximum x index of tile for specified zoom level
*/
int getTileXMax(int zoom);
/**
- *
+ * Get minimum x index of tile for specified zoom level.
* @param zoom zoom level
- * @return minimum X index of tile for specified zoom level
+ * @return minimum x index of tile for specified zoom level
*/
int getTileXMin(int zoom);
/**
- *
+ * Get maximum y index of tile for specified zoom level.
* @param zoom zoom level
- * @return maximum Y index of tile for specified zoom level
+ * @return maximum y index of tile for specified zoom level
*/
int getTileYMax(int zoom);
/**
+ * Get minimum y index of tile for specified zoom level
* @param zoom zoom level
- * @return minimum Y index of tile for specified zoom level
+ * @return minimum y index of tile for specified zoom level
*/
int getTileYMin(int zoom);
@@ -209,4 +218,55 @@ public interface TileSource extends Attributed {
* @return tile metadata
*/
Map<String, String> getMetadata(Map<String, List<String>> headers);
+
+ /**
+ * Convert tile indices (x/y/zoom) into projected coordinates of the tile origin.
+ * @param x x tile index
+ * @param y z tile index
+ * @param zoom zoom level
+ * @return projected coordinates of the tile origin
+ */
+ IProjected tileXYtoProjected(int x, int y, int zoom);
+
+ /**
+ * Convert projected coordinates to tile indices.
+ * @param p projected coordinates
+ * @param zoom zoom level
+ * @return corresponding tile index x/y (floating point, truncate to integer
+ * for tile index)
+ */
+ TileXY projectedToTileXY(IProjected p, int zoom);
+
+ /**
+ * Check if one tile is inside another tile.
+ * @param inner the tile that is suspected to be inside the other tile
+ * @param outer the tile that might contain the first tile
+ * @return true if first tile is inside second tile (or both are identical),
+ * false otherwise
+ */
+ boolean isInside(Tile inner, Tile outer);
+
+ /**
+ * Returns a range of tiles, that cover a given tile, which is
+ * usually at a different zoom level.
+ *
+ * In standard tile layout, 4 tiles cover a tile one zoom lower, 16 tiles
+ * cover a tile 2 zoom levels below etc.
+ * If the zoom level of the covering tiles is greater or equal, a single
+ * tile suffices.
+ *
+ * @param tile the tile to cover
+ * @param newZoom zoom level of the covering tiles
+ * @return TileRange of all covering tiles at zoom <code>newZoom</code>
+ */
+ TileRange getCoveringTileRange(Tile tile, int newZoom);
+
+ /**
+ * Get coordinate reference system for this tile source.
+ *
+ * E.g. "EPSG:3857" for Google-Mercator.
+ * @return code for the coordinate reference system in use
+ */
+ String getServerCRS();
+
}
diff --git a/src/org/openstreetmap/gui/jmapviewer/tilesources/BingAerialTileSource.java b/src/org/openstreetmap/gui/jmapviewer/tilesources/BingAerialTileSource.java
index 534d93e..be2ee08 100644
--- a/src/org/openstreetmap/gui/jmapviewer/tilesources/BingAerialTileSource.java
+++ b/src/org/openstreetmap/gui/jmapviewer/tilesources/BingAerialTileSource.java
@@ -243,7 +243,7 @@ public class BingAerialTileSource extends TMSTileSource {
return r;
} catch (IOException ex) {
System.err.println("Could not connect to Bing API. Will retry in " + waitTimeSec + " seconds.");
- Thread.sleep(waitTimeSec * 1000L);
+ Thread.sleep(TimeUnit.SECONDS.toMillis(waitTimeSec));
waitTimeSec *= 2;
}
}
@@ -303,10 +303,10 @@ public class BingAerialTileSource extends TMSTileSource {
char digit = 48;
int mask = 1 << (i - 1);
if ((tilex & mask) != 0) {
- digit += 1;
+ digit += (char) 1;
}
if ((tiley & mask) != 0) {
- digit += 2;
+ digit += (char) 2;
}
k.append(digit);
}
diff --git a/src/org/openstreetmap/gui/jmapviewer/tilesources/ScanexTileSource.java b/src/org/openstreetmap/gui/jmapviewer/tilesources/ScanexTileSource.java
index a3d38ed..25b5f1d 100644
--- a/src/org/openstreetmap/gui/jmapviewer/tilesources/ScanexTileSource.java
+++ b/src/org/openstreetmap/gui/jmapviewer/tilesources/ScanexTileSource.java
@@ -29,8 +29,8 @@ public class ScanexTileSource extends TMSTileSource {
IRS("irs", "/TileSender.ashx?ModeKey=tile&MapName=F7B8CF651682420FA1749D894C8AD0F6&LayerName=BAC78D764F0443BD9AF93E7A998C9F5B"),
SPOT("spot", "/TileSender.ashx?ModeKey=tile&MapName=F7B8CF651682420FA1749D894C8AD0F6&LayerName=F51CE95441284AF6B2FC319B609C7DEC");
- private String name;
- private String uri;
+ private final String name;
+ private final String uri;
ScanexLayer(String name, String uri) {
this.name = name;
@@ -124,7 +124,7 @@ public class ScanexTileSource extends TMSTileSource {
@Override
public ICoordinate xyToLatLon(int x, int y, int zoom) {
return new Coordinate(
- tileYToLat((double) y, zoom),
+ tileYToLat(y, zoom),
osmMercator.xToLon(x, zoom)
);
}
@@ -140,7 +140,7 @@ public class ScanexTileSource extends TMSTileSource {
@Override
public ICoordinate tileXYToLatLon(int x, int y, int zoom) {
return new Coordinate(
- tileYToLat((double) y, zoom),
+ tileYToLat(y, zoom),
osmMercator.xToLon(x * getTileSize(), zoom)
);
}
diff --git a/src/org/openstreetmap/gui/jmapviewer/tilesources/TMSTileSource.java b/src/org/openstreetmap/gui/jmapviewer/tilesources/TMSTileSource.java
index cc112b8..975ef33 100644
--- a/src/org/openstreetmap/gui/jmapviewer/tilesources/TMSTileSource.java
+++ b/src/org/openstreetmap/gui/jmapviewer/tilesources/TMSTileSource.java
@@ -5,8 +5,12 @@ import java.awt.Point;
import org.openstreetmap.gui.jmapviewer.Coordinate;
import org.openstreetmap.gui.jmapviewer.OsmMercator;
+import org.openstreetmap.gui.jmapviewer.Projected;
+import org.openstreetmap.gui.jmapviewer.Tile;
+import org.openstreetmap.gui.jmapviewer.TileRange;
import org.openstreetmap.gui.jmapviewer.TileXY;
import org.openstreetmap.gui.jmapviewer.interfaces.ICoordinate;
+import org.openstreetmap.gui.jmapviewer.interfaces.IProjected;
/**
* TMS tile source.
@@ -74,4 +78,45 @@ public class TMSTileSource extends AbstractTMSTileSource {
osmMercator.xToLon(x * getTileSize(), zoom)
);
}
+
+ @Override
+ public IProjected tileXYtoProjected(int x, int y, int zoom) {
+ double mercatorWidth = 2 * Math.PI * OsmMercator.EARTH_RADIUS;
+ double f = mercatorWidth * getTileSize() / osmMercator.getMaxPixels(zoom);
+ return new Projected(f * x - mercatorWidth / 2, -(f * y - mercatorWidth / 2));
+ }
+
+ @Override
+ public TileXY projectedToTileXY(IProjected p, int zoom) {
+ double mercatorWidth = 2 * Math.PI * OsmMercator.EARTH_RADIUS;
+ double f = mercatorWidth * getTileSize() / osmMercator.getMaxPixels(zoom);
+ return new TileXY((p.getEast() + mercatorWidth / 2) / f, (-p.getNorth() + mercatorWidth / 2) / f);
+ }
+
+ @Override
+ public boolean isInside(Tile inner, Tile outer) {
+ int dz = inner.getZoom() - outer.getZoom();
+ if (dz < 0) return false;
+ return outer.getXtile() == inner.getXtile() >> dz &&
+ outer.getYtile() == inner.getYtile() >> dz;
+ }
+
+ @Override
+ public TileRange getCoveringTileRange(Tile tile, int newZoom) {
+ if (newZoom <= tile.getZoom()) {
+ int dz = tile.getZoom() - newZoom;
+ TileXY xy = new TileXY(tile.getXtile() >> dz, tile.getYtile() >> dz);
+ return new TileRange(xy, xy, newZoom);
+ } else {
+ int dz = newZoom - tile.getZoom();
+ TileXY t1 = new TileXY(tile.getXtile() << dz, tile.getYtile() << dz);
+ TileXY t2 = new TileXY(t1.getX() + (1 << dz) - 1, t1.getY() + (1 << dz) - 1);
+ return new TileRange(t1, t2, newZoom);
+ }
+ }
+
+ @Override
+ public String getServerCRS() {
+ return "EPSG:3857";
+ }
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-grass/jmapviewer.git
More information about the Pkg-grass-devel
mailing list