Class LatLonProjection

  • All Implemented Interfaces:
    Serializable, Projection

    public class LatLonProjection
    extends ProjectionImpl
    This is the "fake" identity projection where world coord = latlon coord. Topologically its the same as a cylinder tangent to the earth at the equator. The cylinder is cut at the "seam" = centerLon +- 180. Longitude values are always kept in the range [centerLon +-180]
    See Also:
    ProjectionImpl, Serialized Form
    • Constructor Detail

      • LatLonProjection

        public LatLonProjection()
        Default constructor
      • LatLonProjection

        public LatLonProjection​(Earth earth)
      • LatLonProjection

        public LatLonProjection​(String name)
        Create a new LatLonProjection
        Parameters:
        name - name of projection
      • LatLonProjection

        public LatLonProjection​(String name,
                                ProjectionRect defaultMapArea)
        Create a new LatLonProjection
        Parameters:
        name - name of projection
        defaultMapArea - bounding box
    • Method Detail

      • equals

        public boolean equals​(Object o)
        See if this projection equals the object in question
        Specified by:
        equals in interface Projection
        Specified by:
        equals in class ProjectionImpl
        Parameters:
        o - object in question
        Returns:
        true if it is a LatLonProjection and covers the same area
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • projToLatLon

        public LatLonPoint projToLatLon​(ProjectionPoint world,
                                        LatLonPointImpl result)
        Description copied from class: ProjectionImpl
        Convert projection coordinates to a LatLonPoint Note: a new object is not created on each call for the return value.
        Specified by:
        projToLatLon in interface Projection
        Specified by:
        projToLatLon in class ProjectionImpl
        Parameters:
        world - convert from these projection coordinates
        result - the object to write to
        Returns:
        LatLonPoint convert to these lat/lon coordinates
      • projToLatLon

        public float[][] projToLatLon​(float[][] from,
                                      float[][] to)
        Convert projection coordinates to lat/lon coordinate.
        Overrides:
        projToLatLon in class ProjectionImpl
        Parameters:
        from - array of projection coordinates: from[2][n], where (from[0][i], from[1][i]) is the (x, y) coordinate of the ith point
        to - resulting array of lat/lon coordinates: to[2][n] where (to[0][i], to[1][i]) is the (lat, lon) coordinate of the ith point
        Returns:
        the "to" array
      • latLonToProj

        public float[][] latLonToProj​(float[][] from,
                                      float[][] to,
                                      int latIndex,
                                      int lonIndex)
        Convert lat/lon coordinates to projection coordinates.
        Overrides:
        latLonToProj in class ProjectionImpl
        Parameters:
        from - array of lat/lon coordinates: from[2][n], where (from[latIndex][i], from[lonIndex][i]) is the (lat,lon) coordinate of the ith point
        to - resulting array of projection coordinates: to[2][n] where (to[0][i], to[1][i]) is the (x,y) coordinate of the ith point
        latIndex - index of lat coordinate; must be 0 or 1
        lonIndex - index of lon coordinate; must be 0 or 1
        Returns:
        the "to" array
      • projToLatLon

        public double[][] projToLatLon​(double[][] from,
                                       double[][] to)
        Convert projection coordinates to lat/lon coordinate.
        Overrides:
        projToLatLon in class ProjectionImpl
        Parameters:
        from - array of projection coordinates: from[2][n], where (from[0][i], from[1][i]) is the (x, y) coordinate of the ith point
        to - resulting array of lat/lon coordinates: to[2][n] where (to[0][i], to[1][i]) is the (lat, lon) coordinate of the ith point
        Returns:
        the "to" array
      • latLonToProj

        public double[][] latLonToProj​(double[][] from,
                                       double[][] to,
                                       int latIndex,
                                       int lonIndex)
        Convert lat/lon coordinates to projection coordinates.
        Overrides:
        latLonToProj in class ProjectionImpl
        Parameters:
        from - array of lat/lon coordinates: from[2][n], where (from[latIndex][i], from[lonIndex][i]) is the (lat,lon) coordinate of the ith point
        to - resulting array of projection coordinates: to[2][n] where (to[0][i], to[1][i]) is the (x,y) coordinate of the ith point
        latIndex - index of lat coordinate; must be 0 or 1
        lonIndex - index of lon coordinate; must be 0 or 1
        Returns:
        the "to" array
      • setCenterLon

        public double setCenterLon​(double centerLon)
        Set the center of the Longitude range. It is normalized to +/- 180. The cylinder is cut at the "seam" = centerLon +- 180. Use this to keep the Longitude values kept in the range [centerLon +-180], which makes seam handling easier.
        Parameters:
        centerLon - the center of the Longitude range.
        Returns:
        centerLon normalized to +/- 180.
      • getCenterLon

        public double getCenterLon()
        Get the center of the Longitude range. It is normalized to +/- 180.
        Returns:
        the center longitude
      • crossSeam

        public boolean crossSeam​(ProjectionPoint pt1,
                                 ProjectionPoint pt2)
        Does the line between these two points cross the projection "seam".
        Specified by:
        crossSeam in interface Projection
        Specified by:
        crossSeam in class ProjectionImpl
        Parameters:
        pt1 - the line goes between these two points
        pt2 - the line goes between these two points
        Returns:
        false if there is no seam
      • latLonToProjRect

        public ProjectionRect[] latLonToProjRect​(LatLonRect latlonR)
        Split a latlon rectangle to the equivalent ProjectionRect using this LatLonProjection to split it at the seam if needed.
        Parameters:
        latlonR - the latlon rectangle to transform
        Returns:
        1 or 2 ProjectionRect. If it doesnt cross the seam, the second rectangle is null.
      • latLonToProjRect

        public ProjectionRect[] latLonToProjRect​(double lat0,
                                                 double lon0,
                                                 double lat1,
                                                 double lon1)
        Create a latlon rectangle and split it into the equivalent ProjectionRect using this LatLonProjection. The latlon rect is constructed from 2 lat/lon points. The lon values are considered coords in the latlonProjection, and so do not have to be +/- 180.
        Parameters:
        lat0 - lat of point 1
        lon0 - lon of point 1
        lat1 - lat of point 1
        lon1 - lon of point 1
        Returns:
        1 or 2 ProjectionRect. If it doesnt cross the seam, the second rectangle is null.