Class TiledMapCoordinatesConverter
java.lang.Object
com.amalgamasimulation.graphicaleditor.utils.TiledMapCoordinatesConverter
-
Constructor Summary
ConstructorsConstructorDescriptionTiledMapCoordinatesConverter(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.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. -
Method Summary
Modifier and TypeMethodDescriptionReturns base map position, i.e.intReturns base map zoom.static doublegetDegreeFromDMS(String dms) static PointgetLonLatPoint(String lonDMS, String latDMS) intgetMapZoom(double scale) Returns tiled maps zoom by the given scale value.logicalPointToLonLat(Point logicalPoint) Converts a point in logical coordinates system to geographical point of (lon, lat)logicalPointToMapPosition(Point logicalPoint, double scale) Converts point in logical coordinates system to tiled map positionlonLatToLogicalPoint(Point lonLat) Converts a geographical point of (lon, lat) to a point in logical coordinates systemmapPositionToLogicalPoint(Point mapPosition, double scale) Converts tiled map position to point in logical coordinates system
-
Constructor Details
-
TiledMapCoordinatesConverter
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
Converts tiled map position to point in logical coordinates system- Parameters:
mapPosition- Tiled map position (x, y) at the zoom determined by the specified scalescale- Specified scale. Tiled map zoom can be obtained by callinggetMapZoom(double)for the specified scale- Returns:
- Point in logical coordinates system (x, y)
-
logicalPointToMapPosition
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
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
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
-
getLonLatPoint
-
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
-