Class TiledMapCoordinatesConverter

java.lang.Object
com.amalgamasimulation.graphicaleditor.utils.TiledMapCoordinatesConverter

public class TiledMapCoordinatesConverter extends Object
  • Constructor Details

    • TiledMapCoordinatesConverter

      public TiledMapCoordinatesConverter(Point baseMapPoint, int baseMapZoom)
      Creates a new instance of converter by base point in tiled map coordinates and base zoom of the tiled map.
      Parameters:
      baseMapPoint - base point in tiled map coordinates. E.g. for zoom 15 can be (4878159, 4827483). This base point is assumed zero point of logical coordinates.
      baseMapZoom - tiled map zoom ( 0 to 18 ) at which the base point is set
    • TiledMapCoordinatesConverter

      public TiledMapCoordinatesConverter(Point baseLonLat, double metersInPixel, double baseMapSizeMeters)
      Creates a new instance of converter by base geographical coordinate point (lon, lat), scale of logical coordinates and initially displayed map size.
      Parameters:
      baseLonLat - Base geographical coordinate point (lon, lat). This base point is assumed zero point of logical coordinates.
      metersInPixel - Scale of logical coordinates relative to real-world distance, meters per pixel. Typical values are 1 to 10.
      baseMapSizeMeters - Size of initially displayed map in meters. Typical values are 1000 to 10000 (i.e. show area of 1 sq.km. to 100 sq.km. on the initial map)
  • Method Details

    • getMapZoom

      public int getMapZoom(double scale)
      Returns tiled maps zoom by the given scale value.
      Parameters:
      scale - Given canvas scale value (or user zoom factor)
      Returns:
      integer value of tiled maps zoom that must be used for the given scale factor
    • mapPositionToLogicalPoint

      public Point mapPositionToLogicalPoint(Point mapPosition, double scale)
      Converts tiled map position to point in logical coordinates system
      Parameters:
      mapPosition - Tiled map position (x, y) at the zoom determined by the specified scale
      scale - Specified scale. Tiled map zoom can be obtained by calling getMapZoom(double) for the specified scale
      Returns:
      Point in logical coordinates system (x, y)
    • logicalPointToMapPosition

      public Point logicalPointToMapPosition(Point logicalPoint, double scale)
      Converts point in logical coordinates system to tiled map position
      Parameters:
      logicalPoint - Point in logical coordinates system (x, y)
      scale - Scale of the tiled map. Tiled by position depends of map zoom which is in its turn dependent on canvas scale (or zoom factor)
      Returns:
      Tiled map position (x, y)
    • logicalPointToLonLat

      public Point logicalPointToLonLat(Point logicalPoint)
      Converts a point in logical coordinates system to geographical point of (lon, lat)
      Parameters:
      logicalPoint - Point in logical coordinates system (x, y)
      Returns:
      Geographical point (lon, lat) that corresponds to the given logical point
    • lonLatToLogicalPoint

      public Point lonLatToLogicalPoint(Point lonLat)
      Converts a geographical point of (lon, lat) to a point in logical coordinates system
      Parameters:
      lonLat - Geographical point (lon, lat)
      Returns:
      Point in logical coordinates system that corresponds to the given geographical point
    • getDegreeFromDMS

      public static double getDegreeFromDMS(String dms)
    • getLonLatPoint

      public static Point getLonLatPoint(String lonDMS, String latDMS)
    • getBaseMapPosition

      public Point getBaseMapPosition()
      Returns base map position, i.e. tiled map position that corresponds to the zero logical point at base map zoom - see #getBaseMapZoom
      Returns:
      Base map position (x, y)
    • getBaseMapZoom

      public int getBaseMapZoom()
      Returns base map zoom. Base map zoom is an integer number determining level of tiles intially displayed on the tiled map
      Returns:
      Base map zoom