Package org.meteoinfo.global.util
Class GeoUtil
- java.lang.Object
-
- org.meteoinfo.global.util.GeoUtil
-
public final class GeoUtil extends java.lang.ObjectThese 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
All Methods Static Methods Concrete Methods 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 java.awt.DimensiongetMapSize(int zoom, TileFactoryInfo info)static GeoPositiongetPosition(java.awt.geom.Point2D pixelCoordinate, int zoom, TileFactoryInfo info)static GeoPositiongetPositionForAddress(java.lang.String[] fields)static GeoPositiongetPositionForAddress(java.lang.String street, java.lang.String city, java.lang.String state)Convert a street address into a position.static doublegetResolution(int zoomLevel, double lat)Get resolutionstatic doublegetScale(int zoomLevel, double lat)Get scalestatic booleanisValidTile(int x, int y, int zoomLevel, TileFactoryInfo info)
-
-
-
Method Detail
-
getMapSize
public static java.awt.Dimension getMapSize(int zoom, TileFactoryInfo info)- Parameters:
zoom- Zoominfo- Tile factory 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)- Parameters:
x- Xy- YzoomLevel- Zoom levelinfo- 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- Tile factory info- Returns:
- Bitmap coordinate point
-
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- Latitudelongitude- LongitudezoomLevel- the zoom level to extract the pixel coordinate forinfo- Tile factory info- Returns:
- Position point
-
getPosition
public static GeoPosition getPosition(java.awt.geom.Point2D pixelCoordinate, int zoom, TileFactoryInfo info)
-
getPositionForAddress
public static GeoPosition getPositionForAddress(java.lang.String[] fields) throws java.io.IOException
- Throws:
java.io.IOException
-
getPositionForAddress
public static GeoPosition getPositionForAddress(java.lang.String street, java.lang.String city, java.lang.String state) throws java.io.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:
java.io.IOException- if the request fails.
-
getResolution
public static double getResolution(int zoomLevel, double lat)Get resolution- Parameters:
zoomLevel- The zoom levellat- The latitude- Returns:
- Resolution
-
getScale
public static double getScale(int zoomLevel, double lat)Get scale- Parameters:
zoomLevel- The zoom levellat- The latitude- Returns:
- Scale
-
-