Class Coordinate

  • All Implemented Interfaces:
    Serializable

    public class Coordinate
    extends Object
    implements Serializable
    Represents map coordinates in a specific projection. Which projection the coordinates are in is not known by the coordinate itself, and developers must ensure themselves to use the same projection between coordinates, the map viewport, and map sources.
    See Also:
    Serialized Form
    • Constructor Detail

      • Coordinate

        public Coordinate()
      • Coordinate

        public Coordinate​(double x,
                          double y)
        Constructs a new coordinate instance from x and y coordinates. Unless the map's view uses a custom projection, it is assumed that the coordinates are in EPSG:3857 / Web Mercator Sphere projection. To create coordinates from latitude and longitude, see fromLonLat(double, double).
        Parameters:
        x -
        y -
    • Method Detail

      • getX

        public double getX()
      • getY

        public double getY()
      • fromLonLat

        public static Coordinate fromLonLat​(double longitude,
                                            double latitude)
        Creates a coordinate from a longitude and latitude, and converts it into Projection.EPSG_3857 projection.
        Parameters:
        longitude - longitude value
        latitude - latitude value
        Returns:
        coordinate in Projection.EPSG_3857 projection
      • fromLonLat

        public static Coordinate fromLonLat​(double longitude,
                                            double latitude,
                                            Projection targetProjection)
        Creates a coordinate from a longitude and latitude, and converts it into the specified projection.

        Currently, only converting into Projection.EPSG_3857 projection is supported.

        Parameters:
        longitude - longitude value
        latitude - latitude value
        targetProjection - the projection of the resulting coordinate
        Returns:
        coordinate in the specified projection