Package org.jxmapviewer.viewer.util
Class GeoUtil
java.lang.Object
org.jxmapviewer.viewer.util.GeoUtil
public final class GeoUtil
extends java.lang.Object
These are math utilities for converting between pixels, tiles, and geographic coordinates. Implements a Google Maps
style mercator projection.
-
Constructor Summary
Constructors Constructor Description GeoUtil() -
Method Summary
Modifier and Type Method Description static java.awt.geom.Point2DgetBitmapCoordinate(double latitude, double longitude, int zoomLevel, TileFactoryInfo info)Given a position (latitude/longitude pair) and a zoom level, return the appropriate point in pixels.static java.awt.geom.Point2DgetBitmapCoordinate(GeoPosition c, int zoomLevel, TileFactoryInfo info)Given a position (latitude/longitude pair) and a zoom level, return the appropriate point in pixels.static GeoBoundsgetMapBounds(JXMapViewer mapViewer)Gets the map bounds.static java.awt.DimensiongetMapSize(int zoom, TileFactoryInfo info)static GeoPositiongetPosition(java.awt.geom.Point2D pixelCoordinate, int zoom, TileFactoryInfo info)Convert an on screen pixel coordinate and a zoom level to a geo positionstatic booleanisValidTile(int x, int y, int zoomLevel, TileFactoryInfo info)
-
Constructor Details
-
GeoUtil
public GeoUtil()
-
-
Method Details
-
getMapSize
- Parameters:
zoom- the zoom levelinfo- the tile factory info- Returns:
- the size of the map at the given zoom, in tiles (num tiles tall by num tiles wide)
-
isValidTile
- Parameters:
x- the x valuey- the y valuezoomLevel- the zoom levelinfo- the tile factory info- Returns:
- true if this point in tiles is valid at this zoom level. For example, if the zoom level is 0 (zoomed all the way out, where there is only one tile), then x,y must be 0,0
-
getBitmapCoordinate
public static java.awt.geom.Point2D getBitmapCoordinate(GeoPosition c, int zoomLevel, TileFactoryInfo info)Given a position (latitude/longitude pair) and a zoom level, return the appropriate point in pixels. The zoom level is necessary because pixel coordinates are in terms of the zoom level- Parameters:
c- A lat/lon pairzoomLevel- the zoom level to extract the pixel coordinate forinfo- the tile factory info- Returns:
- the coordinate
-
getBitmapCoordinate
public static java.awt.geom.Point2D getBitmapCoordinate(double latitude, double longitude, int zoomLevel, TileFactoryInfo info)Given a position (latitude/longitude pair) and a zoom level, return the appropriate point in pixels. The zoom level is necessary because pixel coordinates are in terms of the zoom level- Parameters:
latitude- the latitudelongitude- the longitudezoomLevel- the zoom level to extract the pixel coordinate forinfo- the tile factory info- Returns:
- the coordinate
-
getPosition
public static GeoPosition getPosition(java.awt.geom.Point2D pixelCoordinate, int zoom, TileFactoryInfo info)Convert an on screen pixel coordinate and a zoom level to a geo position- Parameters:
pixelCoordinate- the coordinate in pixelszoom- the zoom levelinfo- the tile factory info- Returns:
- a geo position
-
getMapBounds
Gets the map bounds.- Parameters:
mapViewer- The map viewer.- Returns:
- Returns the bounds.
-