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.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 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.
    static GeoBounds getMapBounds​(JXMapViewer mapViewer)
    Gets the map bounds.
    static java.awt.Dimension getMapSize​(int zoom, TileFactoryInfo info)  
    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
    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 Details

  • Method Details

    • getMapSize

      public static java.awt.Dimension getMapSize​(int zoom, TileFactoryInfo info)
      Parameters:
      zoom - the zoom level
      info - the 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 - the x value
      y - the y value
      zoomLevel - the zoom level
      info - 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 pair
      zoomLevel - the zoom level to extract the pixel coordinate for
      info - 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 latitude
      longitude - the longitude
      zoomLevel - the zoom level to extract the pixel coordinate for
      info - 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 pixels
      zoom - the zoom level
      info - the tile factory info
      Returns:
      a geo position
    • getMapBounds

      public static GeoBounds getMapBounds​(JXMapViewer mapViewer)
      Gets the map bounds.
      Parameters:
      mapViewer - The map viewer.
      Returns:
      Returns the bounds.