Class AbstractProjection

java.lang.Object
org.openstreetmap.josm.data.projection.AbstractProjection
All Implemented Interfaces:
Projecting, Projection
Direct Known Subclasses:
CustomProjection

public abstract class AbstractProjection extends Object implements Projection
Implementation of the Projection interface that represents a coordinate reference system and delegates the real projection and datum conversion to other classes. It handles false easting and northing, central meridian and general scale factor before calling the delegate projection. Forwards lat/lon values to the real projection in units of radians. The fields are named after Proj.4 parameters. Subclasses of AbstractProjection must set ellps and proj to a non-null value. In addition, either datum or nadgrid has to be initialized to some value.
  • Field Details

  • Constructor Details

  • Method Details

    • getEllipsoid

      public final Ellipsoid getEllipsoid()
      Get the base ellipsoid that this projection uses.
      Returns:
      The Ellipsoid
    • getDatum

      public final Datum getDatum()
      Gets the datum this projection is based on.
      Returns:
      The datum
    • getProj

      public final Proj getProj()
      Replies the projection (in the narrow sense)
      Returns:
      The projection object
    • getFalseEasting

      public final double getFalseEasting()
      Gets an east offset that gets applied when converting the coordinate
      Returns:
      The offset to apply in meter
    • getFalseNorthing

      public final double getFalseNorthing()
      Gets an north offset that gets applied when converting the coordinate
      Returns:
      The offset to apply in meter
    • getCentralMeridian

      public final double getCentralMeridian()
      Gets the meridian that this projection is centered on.
      Returns:
      The longitude of the meridian.
    • getScaleFactor

      public final double getScaleFactor()
    • getToMeter

      public final double getToMeter()
      Get the factor that converts meters to intended units of east/north coordinates. For projected coordinate systems, the semi-major axis of the ellipsoid is always given in meters, which means the preliminary projection result will be in meters as well. This factor is used to convert to the intended units of east/north coordinates (e.g. feet in the US). For geographic coordinate systems, the preliminary "projection" result will be in degrees, so there is no reason to convert anything and this factor will by 1 by default.
      Returns:
      factor that converts meters to intended units of east/north coordinates
    • latlon2eastNorth

      public EastNorth latlon2eastNorth(ILatLon toConvert)
      Description copied from interface: Projecting
      Convert from lat/lon to easting/northing. This method uses the newer ILatLon interface.
      Specified by:
      latlon2eastNorth in interface Projecting
      Parameters:
      toConvert - the geographical point to convert (in WGS84 lat/lon)
      Returns:
      the corresponding east/north coordinates
      See Also:
    • eastNorth2latlon

      Description copied from interface: Projection
      Convert from easting/norting to lat/lon.
      Specified by:
      eastNorth2latlon in interface Projection
      Parameters:
      en - the geographical point to convert (in projected coordinates)
      Returns:
      the corresponding lat/lon (WGS84)
    • eastNorth2latlonClamped

      Description copied from interface: Projecting
      Convert a east/north coordinate to the LatLon coordinate. This method clamps the lat/lon coordinate to the nearest point in the world bounds.
      Specified by:
      eastNorth2latlonClamped in interface Projecting
      Parameters:
      en - east/north
      Returns:
      The lat/lon coordinate.
    • eastNorth2latlon

    • getProjectingsForArea

      Description copied from interface: Projecting
      Returns an map or (subarea, projecting) paris that contains projecting instances to convert the coordinates inside the given area. This can be used by projections to support continuous projections. It is possible that the area covered by the map is bigger than the one given as area. There may be holes.
      Specified by:
      getProjectingsForArea in interface Projecting
      Parameters:
      area - The base area
      Returns:
      a map of non-overlapping ProjectionBounds instances mapped to the Projecting object to use for that area.
    • getDefaultZoomInPPD

      public double getDefaultZoomInPPD()
      Description copied from interface: Projection
      The default scale factor in east/north units per pixel (NavigatableComponent.getState())). FIXME: misnomer
      Specified by:
      getDefaultZoomInPPD in interface Projection
      Returns:
      the scale factor
    • getEpsgCode

      public abstract Integer getEpsgCode()
      Returns The EPSG Code of this CRS.
      Returns:
      The EPSG Code of this CRS, null if it doesn't have one.
    • toCode

      public String toCode()
      Default implementation of toCode(). Should be overridden, if there is no EPSG code for this CRS.
      Specified by:
      toCode in interface Projection
      Returns:
      the projection identifier
    • convertMinuteSecond

      protected static final double convertMinuteSecond(double minute, double second)
    • convertDegreeMinuteSecond

      protected static final double convertDegreeMinuteSecond(double degree, double minute, double second)
    • getWorldBoundsBoxEastNorth

      Description copied from interface: Projection
      Get an approximate EastNorth box around the lat/lon world bounds. Note: The projection is only valid within the bounds returned by Projection.getWorldBoundsLatLon(). The lat/lon bounds need not be a rectangular shape in east/north space. This method returns a box that contains this shape.
      Specified by:
      getWorldBoundsBoxEastNorth in interface Projection
      Returns:
      EastNorth box around the lat/lon world bounds
    • getBaseProjection

      Description copied from interface: Projecting
      Gets the base projection instance used. This may be the same as this one or a different one if this one is translated in east/north space.
      Specified by:
      getBaseProjection in interface Projecting
      Returns:
      The projection.
    • visitOutline

      public void visitOutline(Bounds b, Consumer<EastNorth> visitor)
      Description copied from interface: Projection
      Visit points along the edge of this bounds instance.

      Depending on the shape in east/north space, it may simply visit the 4 corners or (more generally) several points along the curved edges.

      Specified by:
      visitOutline in interface Projection
      Parameters:
      b - the lat/lon rectangle to trace
      visitor - a function to call for the points on the edge.
    • visitOutline

      private void visitOutline(Bounds b, int nPoints, Consumer<EastNorth> visitor)