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 java.lang.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.
-
-
Constructor Summary
Constructors Constructor Description AbstractProjection()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected static double
convertDegreeMinuteSecond(double degree, double minute, double second)
protected static double
convertMinuteSecond(double minute, double second)
LatLon
eastNorth2latlon(EastNorth en)
Convert from easting/norting to lat/lon.private LatLon
eastNorth2latlon(EastNorth en, java.util.function.DoubleUnaryOperator normalizeLon)
LatLon
eastNorth2latlonClamped(EastNorth en)
Convert a east/north coordinate to theLatLon
coordinate.Projection
getBaseProjection()
Gets the base projection instance used.double
getCentralMeridian()
Gets the meridian that this projection is centered on.Datum
getDatum()
Gets the datum this projection is based on.double
getDefaultZoomInPPD()
The default scale factor in east/north units per pixel (NavigatableComponent.getState()
)).Ellipsoid
getEllipsoid()
Get the base ellipsoid that this projection uses.abstract java.lang.Integer
getEpsgCode()
Returns The EPSG Code of this CRS.double
getFalseEasting()
Gets an east offset that gets applied when converting the coordinatedouble
getFalseNorthing()
Gets an north offset that gets applied when converting the coordinateProj
getProj()
Replies the projection (in the narrow sense)java.util.Map<ProjectionBounds,Projecting>
getProjectingsForArea(ProjectionBounds area)
Returns an map or (subarea, projecting) paris that contains projecting instances to convert the coordinates inside the given area.double
getScaleFactor()
double
getToMeter()
Get the factor that converts meters to intended units of east/north coordinates.ProjectionBounds
getWorldBoundsBoxEastNorth()
Get an approximate EastNorth box around the lat/lon world bounds.EastNorth
latlon2eastNorth(ILatLon toConvert)
Convert from lat/lon to easting/northing.java.lang.String
toCode()
Default implementation of toCode().private void
visitOutline(Bounds b, int nPoints, java.util.function.Consumer<EastNorth> visitor)
void
visitOutline(Bounds b, java.util.function.Consumer<EastNorth> visitor)
Visit points along the edge of this bounds instance.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.openstreetmap.josm.data.projection.Projecting
getCacheKey, latlon2eastNorth
-
Methods inherited from interface org.openstreetmap.josm.data.projection.Projection
getEastNorthBoundsBox, getLatLonBoundsBox, getMetersPerUnit, getWorldBoundsLatLon, switchXY, toString
-
-
-
-
Field Detail
-
x0
protected double x0
-
y0
protected double y0
-
lon0
protected double lon0
-
pm
protected double pm
-
k0
protected double k0
-
toMeter
protected double toMeter
-
projectionBoundsBox
private volatile ProjectionBounds projectionBoundsBox
-
-
Constructor Detail
-
AbstractProjection
public AbstractProjection()
-
-
Method Detail
-
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 newerILatLon
interface.- Specified by:
latlon2eastNorth
in interfaceProjecting
- Parameters:
toConvert
- the geographical point to convert (in WGS84 lat/lon)- Returns:
- the corresponding east/north coordinates
- See Also:
as shorthand.
-
eastNorth2latlon
public LatLon eastNorth2latlon(EastNorth en)
Description copied from interface:Projection
Convert from easting/norting to lat/lon.- Specified by:
eastNorth2latlon
in interfaceProjection
- Parameters:
en
- the geographical point to convert (in projected coordinates)- Returns:
- the corresponding lat/lon (WGS84)
-
eastNorth2latlonClamped
public LatLon eastNorth2latlonClamped(EastNorth en)
Description copied from interface:Projecting
Convert a east/north coordinate to theLatLon
coordinate. This method clamps the lat/lon coordinate to the nearest point in the world bounds.- Specified by:
eastNorth2latlonClamped
in interfaceProjecting
- Parameters:
en
- east/north- Returns:
- The lat/lon coordinate.
-
eastNorth2latlon
private LatLon eastNorth2latlon(EastNorth en, java.util.function.DoubleUnaryOperator normalizeLon)
-
getProjectingsForArea
public java.util.Map<ProjectionBounds,Projecting> getProjectingsForArea(ProjectionBounds area)
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 interfaceProjecting
- Parameters:
area
- The base area- Returns:
- a map of non-overlapping
ProjectionBounds
instances mapped to theProjecting
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 interfaceProjection
- Returns:
- the scale factor
-
getEpsgCode
public abstract java.lang.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 java.lang.String toCode()
Default implementation of toCode(). Should be overridden, if there is no EPSG code for this CRS.- Specified by:
toCode
in interfaceProjection
- 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
public final ProjectionBounds 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 byProjection.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 interfaceProjection
- Returns:
- EastNorth box around the lat/lon world bounds
-
getBaseProjection
public Projection 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 interfaceProjecting
- Returns:
- The projection.
-
visitOutline
public void visitOutline(Bounds b, java.util.function.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 interfaceProjection
- Parameters:
b
- the lat/lon rectangle to tracevisitor
- a function to call for the points on the edge.
-
visitOutline
private void visitOutline(Bounds b, int nPoints, java.util.function.Consumer<EastNorth> visitor)
-
-