org.jdesktop.swingx.mapviewer.util
Class GeoUtil

java.lang.Object
  extended by org.jdesktop.swingx.mapviewer.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.


Constructor Summary
GeoUtil()
           
 
Method Summary
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.
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.
static GeoBounds getMapBounds(JXMapViewer mapViewer)
          Gets the map bounds.
static Dimension getMapSize(int zoom, TileFactoryInfo info)
           
static GeoPosition getPosition(Point2D pixelCoordinate, int zoom, TileFactoryInfo info)
           
static GeoPosition getPositionForAddress(String[] fields)
           
static GeoPosition getPositionForAddress(String street, String city, String state)
          Convert a street address into a position.
static boolean isValidTile(int x, int y, int zoomLevel, TileFactoryInfo info)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GeoUtil

public GeoUtil()
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 pair
zoomLevel - 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 - latitude
double - longitude
zoomLevel - 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 - Street
city - City
state - State (must be a US state)
Returns:
the position of this street address
Throws:
IOException - if the request fails.

getMapBounds

public static GeoBounds getMapBounds(JXMapViewer mapViewer)
Gets the map bounds.

Parameters:
mapViewer - The map viewer.
Returns:
Returns the bounds.