Class 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 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
      • 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​(MapViewer<?,​Tile<?>> mapViewer)
        Gets the map bounds.
        Parameters:
        mapViewer - The map viewer.
        Returns:
        Returns the bounds.