Package nl.bebr.mapviewer.data.util
Class GeoUtil
- java.lang.Object
-
- nl.bebr.mapviewer.data.util.GeoUtil
-
public final class GeoUtil extends Object
These are math utilities for converting between pixels, tiles, and geographic coordinates. Implements a Google Maps style mercator projection.- Author:
- joshy
-
-
Constructor Summary
Constructors Constructor Description GeoUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static 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 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(MapViewer<?,Tile<?>> mapViewer)Gets the map bounds.static DimensiongetMapSize(int zoom, TileFactoryInfo info)static GeoPositiongetPosition(Point2D pixelCoordinate, int zoom, TileFactoryInfo info)static GeoPositiongetPositionForAddress(String[] fields)static GeoPositiongetPositionForAddress(String street, String city, String state)Convert a street address into a position.static booleanisValidTile(int x, int y, int zoomLevel, TileFactoryInfo info)
-
-
-
Method Detail
-
getMapSize
public static Dimension getMapSize(int zoom, TileFactoryInfo info)
- Returns:
- the size of the map at the given zoom, in tiles (num tiles tall by num tiles wide)
-
isValidTile
public static boolean isValidTile(int x, int y, int zoomLevel, TileFactoryInfo info)
-
getBitmapCoordinate
public static 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 for
-
getBitmapCoordinate
public static 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:
double- latitudedouble- longitudezoomLevel- the zoom level to extract the pixel coordinate for
-
getPosition
public static GeoPosition getPosition(Point2D pixelCoordinate, int zoom, TileFactoryInfo info)
-
getPositionForAddress
public static GeoPosition getPositionForAddress(String[] fields) throws IOException
- Throws:
IOException
-
getPositionForAddress
public static GeoPosition getPositionForAddress(String street, String city, String state) throws IOException
Convert a street address into a position. Uses the Yahoo GeoCoder. You must supply your own yahoo id.- Parameters:
street- Streetcity- Citystate- State (must be a US state)- Returns:
- the position of this street address
- Throws:
IOException- if the request fails.
-
-