Package org.locationtech.proj4j.proj
Class Projection
- java.lang.Object
-
- org.locationtech.proj4j.proj.Projection
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Cloneable
- Direct Known Subclasses:
AiryProjection,AlbersProjection,AugustProjection,AzimuthalProjection,BipolarProjection,BonneProjection,CassiniProjection,CollignonProjection,ConicProjection,CrasterProjection,CylindricalEqualAreaProjection,CylindricalProjection,DenoyerProjection,Eckert1Projection,Eckert2Projection,Eckert4Projection,Eckert5Projection,FaheyProjection,FoucautSinusoidalProjection,GallProjection,GaussProjection,GeocentProjection,GeostationarySatelliteProjection,Ginsburg8Projection,GoodeProjection,HatanoProjection,KrovakProjection,LagrangeProjection,LambertAzimuthalEqualAreaProjection,LandsatProjection,LarriveeProjection,LaskowskiProjection,LinearProjection,LongLatProjection,McBrydeThomasFlatPolarParabolicProjection,McBrydeThomasFlatPolarSine2Projection,NellHProjection,NellProjection,NewZealandMapGridProjection,NicolosiProjection,NullProjection,PerspectiveProjection,PolyconicProjection,PutninsP2Projection,PutninsP4Projection,PutninsP5Projection,RectangularPolyconicProjection,SwissObliqueMercatorProjection,TransverseCylindricalEqualArea,UrmaevFlatPolarSinusoidalProjection,VanDerGrintenProjection,Wagner2Projection,Wagner7Projection
public abstract class Projection extends java.lang.Object implements java.lang.Cloneable, java.io.SerializableA map projection is a mathematical algorithm for representing a spheroidal surface on a plane. A single projection defines a (usually infinite) family ofCoordinateReferenceSystems, distinguished by different values for the projection parameters.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected doubleaThe equator radiusprotected doublealphaThe projection alpha valueprivate AxisOrderaxesThe order of axes for the coordinate system.protected static doubleDTRprotected doubleeThe eccentricityprotected EllipsoidellipsoidThe ellipsoid used by this projectionprotected static doubleEPS10protected doubleesThe eccentricity squaredprotected doublefalseEastingThe false Easting of this projectionprotected doublefalseNorthingThe false Northing of this projectionprotected doublefromMetresConversion factor from metres to whatever units the projection uses.protected booleangeocentricTrue if this projection is geocentricprotected doubleloncThe projection lonc valueprotected doublemaxLatitudeThe maximum latitude of the bounds of this projectionprotected doublemaxLongitudeThe maximum longitude of the bounds of this projection.protected doubleminLatitudeThe minimum latitude of the bounds of this projectionprotected doubleminLongitudeThe minimum longitude of the bounds of this projection.protected java.lang.StringnameThe name of this projectionprotected doubleone_es1-(eccentricity squared)private PrimeMeridianprimeMeridianPrimeMeridian defining an offset from the Greenwich (the prime meridian used in WGS84)protected doubleprojectionLatitudeThe latitude of the centre of projectionprotected doubleprojectionLatitude1Standard parallel 1 (for projections which use it)protected doubleprojectionLatitude2Standard parallel 2 (for projections which use it)protected doubleprojectionLongitudeThe longitude of the centre of projection, in radiansprotected doublerone_es1/(1-(eccentricity squared))protected static doubleRTDprotected doublescaleFactorThe projection scale factorprotected booleansphericalTrue if this projection is using a sphere (es == 0)private doubletotalFalseEastingfalseEasting, adjusted to the appropriate units using fromMetresprivate doubletotalFalseNorthingfalseNorthing, adjusted to the appropriate units using fromMetresprotected doubletotalScaleThe total scale factor = Earth radius * unitsprotected doubletrueScaleLatitudeThe latitude of true scale.protected Unitunitunits of this projection.
-
Constructor Summary
Constructors Modifier Constructor Description protectedProjection()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Objectclone()booleanequals(java.lang.Object that)Represents quality between possible outputs ofproject(ProjCoordinate, ProjCoordinate).doublegetAlpha()Gets the alpha value, in radians.AxisOrdergetAxisOrder()EllipsoidgetEllipsoid()intgetEPSGCode()Returns the ESPG code for this projection, or 0 if unknown.doublegetEquatorRadius()doublegetFalseEasting()doublegetFalseNorthing()doublegetFromMetres()doublegetHeightOfOrbit()Get height of orbit - Geostationary satellite projectiondoublegetLonC()Gets the lonc value, in radians.doublegetMaxLatitude()doublegetMaxLatitudeDegrees()doublegetMaxLongitude()doublegetMaxLongitudeDegrees()doublegetMinLatitude()doublegetMinLatitudeDegrees()doublegetMinLongitude()doublegetMinLongitudeDegrees()java.lang.StringgetName()PrimeMeridiangetPrimeMeridian()java.lang.StringgetPROJ4Description()Get a string which describes this projection in PROJ.4 format.doublegetProjectionLatitude()doublegetProjectionLatitude1()doublegetProjectionLatitude1Degrees()doublegetProjectionLatitude2()doublegetProjectionLatitude2Degrees()doublegetProjectionLatitudeDegrees()doublegetProjectionLongitude()doublegetProjectionLongitudeDegrees()doublegetScaleFactor()Gets the projection scale factor.booleangetSouthernHemisphere()doublegetTrueScaleLatitude()doublegetTrueScaleLatitudeDegrees()UnitgetUnits()inthashCode()Hash of those fields considered in Projection equalituy.booleanhasInverse()Tests whether this projection has an inverse.voidinitialize()Initialize the projection.booleaninside(double x, double y)Returns true if the given lat/long point is visible in this projectionProjCoordinateinverseProject(ProjCoordinate src, ProjCoordinate dst)Inverse-projects a point (in the units defined by the coordinate system), producing a geographic result (in degrees)ProjCoordinateinverseProjectRadians(ProjCoordinate src, ProjCoordinate dst)Inverse-transforms a point (in the units defined by the coordinate system), producing a geographic result (in radians)booleanisConformal()Tests whether this projection is conformal.booleanisEqualArea()Tests whether this projection is equal-area An equal-area projection preserves relative sizes of projected areas.java.lang.BooleanisGeographic()Is this "projection" longlat? Overridden in LongLatProjection.booleanisRectilinear()Tests whether under this projection lines of latitude and longitude form a rectangular gridstatic floatnormalizeLongitude(float angle)static doublenormalizeLongitudeRadians(double angle)booleanparallelsAreParallel()Returns true if latitude lines are parallel for this projectionprotected ProjCoordinateproject(double x, double y, ProjCoordinate dst)Computes the projection of a given point (i.e.ProjCoordinateproject(ProjCoordinate src, ProjCoordinate dst)Projects a geographic point (in degrees), producing a projected result (in the units of the target coordinate system).protected ProjCoordinateprojectInverse(double x, double y, ProjCoordinate dst)Computes the inverse projection of a given point (i.e.private ProjCoordinateprojectRadians(double x, double y, ProjCoordinate dst)Transform a geographic point (in radians), producing a projected result (in the units of the target coordinate system).ProjCoordinateprojectRadians(ProjCoordinate src, ProjCoordinate dst)Projects a geographic point (in radians), producing a projected result (in the units of the target coordinate system).voidsetAlpha(double alpha)Sets the alpha value.voidsetAlphaDegrees(double alpha)Sets the alpha value.voidsetAxisOrder(java.lang.String axes)voidsetEllipsoid(Ellipsoid ellipsoid)voidsetFalseEasting(double falseEasting)Set the false Easting in projected units.voidsetFalseNorthing(double falseNorthing)Set the false Northing in projected units.voidsetFromMetres(double fromMetres)Set the conversion factor from metres to projected units.voidsetGamma(double gamma)voidsetGammaDegrees(double gamma)voidsetHeightOfOrbit(double h)Set height of orbit - Geostationary satellite projectionvoidsetLonC(double lonc)Sets the lonc value.voidsetLonCDegrees(double lonc)Sets the lonc value.voidsetMaxLatitude(double maxLatitude)Set the maximum latitude.voidsetMaxLongitude(double maxLongitude)voidsetMaxLongitudeDegrees(double maxLongitude)voidsetMinLatitude(double minLatitude)Set the minimum latitude.voidsetMinLongitude(double minLongitude)voidsetMinLongitudeDegrees(double minLongitude)voidsetName(java.lang.String name)Set the name of this projection.voidsetNoUoff(boolean no_uoff)voidsetPrimeMeridian(java.lang.String primeMeridian)voidsetProjectionLatitude(double projectionLatitude)Set the projection latitude in radians.voidsetProjectionLatitude1(double projectionLatitude1)Set the projection latitude in radians.voidsetProjectionLatitude1Degrees(double projectionLatitude1)Set the projection latitude in degrees.voidsetProjectionLatitude2(double projectionLatitude2)Set the projection latitude in radians.voidsetProjectionLatitude2Degrees(double projectionLatitude2)Set the projection latitude in degrees.voidsetProjectionLatitudeDegrees(double projectionLatitude)Set the projection latitude in degrees.voidsetProjectionLongitude(double projectionLongitude)Set the projection longitude in radians.voidsetProjectionLongitudeDegrees(double projectionLongitude)Set the projection longitude in degrees.voidsetRadius(double radius)voidsetScaleFactor(double scaleFactor)Set the projection scale factor.voidsetSouthernHemisphere(boolean isSouth)voidsetTrueScaleLatitude(double trueScaleLatitude)Set the latitude of true scale in radians.voidsetTrueScaleLatitudeDegrees(double trueScaleLatitude)Set the latitude of true scale in degrees.voidsetUnits(Unit unit)java.lang.StringtoString()
-
-
-
Field Detail
-
minLatitude
protected double minLatitude
The minimum latitude of the bounds of this projection
-
minLongitude
protected double minLongitude
The minimum longitude of the bounds of this projection. This is relative to the projection centre.
-
maxLatitude
protected double maxLatitude
The maximum latitude of the bounds of this projection
-
maxLongitude
protected double maxLongitude
The maximum longitude of the bounds of this projection. This is relative to the projection centre.
-
projectionLatitude
protected double projectionLatitude
The latitude of the centre of projection
-
projectionLongitude
protected double projectionLongitude
The longitude of the centre of projection, in radians
-
projectionLatitude1
protected double projectionLatitude1
Standard parallel 1 (for projections which use it)
-
projectionLatitude2
protected double projectionLatitude2
Standard parallel 2 (for projections which use it)
-
alpha
protected double alpha
The projection alpha value
-
lonc
protected double lonc
The projection lonc value
-
scaleFactor
protected double scaleFactor
The projection scale factor
-
falseEasting
protected double falseEasting
The false Easting of this projection
-
falseNorthing
protected double falseNorthing
The false Northing of this projection
-
trueScaleLatitude
protected double trueScaleLatitude
The latitude of true scale. Only used by specific projections.
-
a
protected double a
The equator radius
-
e
protected double e
The eccentricity
-
es
protected double es
The eccentricity squared
-
one_es
protected double one_es
1-(eccentricity squared)
-
rone_es
protected double rone_es
1/(1-(eccentricity squared))
-
ellipsoid
protected Ellipsoid ellipsoid
The ellipsoid used by this projection
-
spherical
protected boolean spherical
True if this projection is using a sphere (es == 0)
-
geocentric
protected boolean geocentric
True if this projection is geocentric
-
name
protected java.lang.String name
The name of this projection
-
fromMetres
protected double fromMetres
Conversion factor from metres to whatever units the projection uses.
-
totalScale
protected double totalScale
The total scale factor = Earth radius * units
-
totalFalseEasting
private double totalFalseEasting
falseEasting, adjusted to the appropriate units using fromMetres
-
totalFalseNorthing
private double totalFalseNorthing
falseNorthing, adjusted to the appropriate units using fromMetres
-
unit
protected Unit unit
units of this projection. Default is metres, but may be degrees
-
primeMeridian
private PrimeMeridian primeMeridian
PrimeMeridian defining an offset from the Greenwich (the prime meridian used in WGS84)
-
axes
private AxisOrder axes
The order of axes for the coordinate system. Default is easting, northing, vertical (up)
-
EPS10
protected static final double EPS10
- See Also:
- Constant Field Values
-
RTD
protected static final double RTD
- See Also:
- Constant Field Values
-
DTR
protected static final double DTR
- See Also:
- Constant Field Values
-
-
Method Detail
-
clone
public java.lang.Object clone()
- Overrides:
clonein classjava.lang.Object
-
project
public ProjCoordinate project(ProjCoordinate src, ProjCoordinate dst)
Projects a geographic point (in degrees), producing a projected result (in the units of the target coordinate system).- Parameters:
src- the input geographic coordinate (in degrees)dst- the projected coordinate (in coordinate system units)- Returns:
- the target coordinate
-
projectRadians
public ProjCoordinate projectRadians(ProjCoordinate src, ProjCoordinate dst)
Projects a geographic point (in radians), producing a projected result (in the units of the target coordinate system).- Parameters:
src- the input geographic coordinate (in radians)dst- the projected coordinate (in coordinate system units)- Returns:
- the target coordinate
-
projectRadians
private ProjCoordinate projectRadians(double x, double y, ProjCoordinate dst)
Transform a geographic point (in radians), producing a projected result (in the units of the target coordinate system).- Parameters:
x- the geographic x ordinate (in radians)y- the geographic y ordinate (in radians)dst- the projected coordinate (in coordinate system units)- Returns:
- the target coordinate
-
project
protected ProjCoordinate project(double x, double y, ProjCoordinate dst)
Computes the projection of a given point (i.e. from geographics to projection space). This should be overridden for all projections.- Parameters:
x- the geographic x ordinate (in radians)y- the geographic y ordinatee (in radians)dst- the projected coordinate (in coordinate system units)- Returns:
- the target coordinate
-
inverseProject
public ProjCoordinate inverseProject(ProjCoordinate src, ProjCoordinate dst)
Inverse-projects a point (in the units defined by the coordinate system), producing a geographic result (in degrees)- Parameters:
src- the input projected coordinate (in coordinate system units)dst- the inverse-projected geographic coordinate (in degrees)- Returns:
- the target coordinate
-
inverseProjectRadians
public ProjCoordinate inverseProjectRadians(ProjCoordinate src, ProjCoordinate dst)
Inverse-transforms a point (in the units defined by the coordinate system), producing a geographic result (in radians)- Parameters:
src- the input projected coordinate (in coordinate system units)dst- the inverse-projected geographic coordinate (in radians)- Returns:
- the target coordinate
-
projectInverse
protected ProjCoordinate projectInverse(double x, double y, ProjCoordinate dst)
Computes the inverse projection of a given point (i.e. from projection space to geographics). This should be overridden for all projections.- Parameters:
x- the projected x ordinate (in coordinate system units)y- the projected y ordinate (in coordinate system units)dst- the inverse-projected geographic coordinate (in radians)- Returns:
- the target coordinate
-
isConformal
public boolean isConformal()
Tests whether this projection is conformal. A conformal projection preserves local angles.- Returns:
- true if this projection is conformal
-
isEqualArea
public boolean isEqualArea()
Tests whether this projection is equal-area An equal-area projection preserves relative sizes of projected areas.- Returns:
- true if this projection is equal-area
-
hasInverse
public boolean hasInverse()
Tests whether this projection has an inverse. If this method returnstruethen theinverseProject(ProjCoordinate, ProjCoordinate)andinverseProjectRadians(ProjCoordinate, ProjCoordinate)methods will return meaningful results.- Returns:
- true if this projection has an inverse
-
isRectilinear
public boolean isRectilinear()
Tests whether under this projection lines of latitude and longitude form a rectangular grid
-
parallelsAreParallel
public boolean parallelsAreParallel()
Returns true if latitude lines are parallel for this projection
-
inside
public boolean inside(double x, double y)Returns true if the given lat/long point is visible in this projection
-
setName
public void setName(java.lang.String name)
Set the name of this projection.
-
getName
public java.lang.String getName()
-
getPROJ4Description
public java.lang.String getPROJ4Description()
Get a string which describes this projection in PROJ.4 format.WARNING: currently this does not output all required parameters in some cases. E.g. for Albers the standard latitudes are missing.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
setAxisOrder
public void setAxisOrder(java.lang.String axes)
-
getAxisOrder
public AxisOrder getAxisOrder()
-
setPrimeMeridian
public void setPrimeMeridian(java.lang.String primeMeridian)
-
getPrimeMeridian
public PrimeMeridian getPrimeMeridian()
-
setMinLatitude
public void setMinLatitude(double minLatitude)
Set the minimum latitude. This is only used for Shape clipping and doesn't affect projection.
-
getMinLatitude
public double getMinLatitude()
-
setMaxLatitude
public void setMaxLatitude(double maxLatitude)
Set the maximum latitude. This is only used for Shape clipping and doesn't affect projection.
-
getMaxLatitude
public double getMaxLatitude()
-
getMaxLatitudeDegrees
public double getMaxLatitudeDegrees()
-
getMinLatitudeDegrees
public double getMinLatitudeDegrees()
-
setMinLongitude
public void setMinLongitude(double minLongitude)
-
getMinLongitude
public double getMinLongitude()
-
setMinLongitudeDegrees
public void setMinLongitudeDegrees(double minLongitude)
-
getMinLongitudeDegrees
public double getMinLongitudeDegrees()
-
setMaxLongitude
public void setMaxLongitude(double maxLongitude)
-
getMaxLongitude
public double getMaxLongitude()
-
setMaxLongitudeDegrees
public void setMaxLongitudeDegrees(double maxLongitude)
-
getMaxLongitudeDegrees
public double getMaxLongitudeDegrees()
-
setProjectionLatitude
public void setProjectionLatitude(double projectionLatitude)
Set the projection latitude in radians.
-
getProjectionLatitude
public double getProjectionLatitude()
-
setProjectionLatitudeDegrees
public void setProjectionLatitudeDegrees(double projectionLatitude)
Set the projection latitude in degrees.
-
getProjectionLatitudeDegrees
public double getProjectionLatitudeDegrees()
-
setProjectionLongitude
public void setProjectionLongitude(double projectionLongitude)
Set the projection longitude in radians.
-
getProjectionLongitude
public double getProjectionLongitude()
-
setProjectionLongitudeDegrees
public void setProjectionLongitudeDegrees(double projectionLongitude)
Set the projection longitude in degrees.
-
getProjectionLongitudeDegrees
public double getProjectionLongitudeDegrees()
-
setTrueScaleLatitude
public void setTrueScaleLatitude(double trueScaleLatitude)
Set the latitude of true scale in radians. This is only used by certain projections.
-
getTrueScaleLatitude
public double getTrueScaleLatitude()
-
setTrueScaleLatitudeDegrees
public void setTrueScaleLatitudeDegrees(double trueScaleLatitude)
Set the latitude of true scale in degrees. This is only used by certain projections.
-
getTrueScaleLatitudeDegrees
public double getTrueScaleLatitudeDegrees()
-
setProjectionLatitude1
public void setProjectionLatitude1(double projectionLatitude1)
Set the projection latitude in radians.
-
getProjectionLatitude1
public double getProjectionLatitude1()
-
setProjectionLatitude1Degrees
public void setProjectionLatitude1Degrees(double projectionLatitude1)
Set the projection latitude in degrees.
-
getProjectionLatitude1Degrees
public double getProjectionLatitude1Degrees()
-
setProjectionLatitude2
public void setProjectionLatitude2(double projectionLatitude2)
Set the projection latitude in radians.
-
getProjectionLatitude2
public double getProjectionLatitude2()
-
setProjectionLatitude2Degrees
public void setProjectionLatitude2Degrees(double projectionLatitude2)
Set the projection latitude in degrees.
-
getProjectionLatitude2Degrees
public double getProjectionLatitude2Degrees()
-
setAlpha
public void setAlpha(double alpha)
Sets the alpha value.
-
setAlphaDegrees
public void setAlphaDegrees(double alpha)
Sets the alpha value.
-
getAlpha
public double getAlpha()
Gets the alpha value, in radians.- Returns:
- the alpha value
-
setLonC
public void setLonC(double lonc)
Sets the lonc value.
-
setLonCDegrees
public void setLonCDegrees(double lonc)
Sets the lonc value.
-
getLonC
public double getLonC()
Gets the lonc value, in radians.- Returns:
- the lonc value
-
setFalseNorthing
public void setFalseNorthing(double falseNorthing)
Set the false Northing in projected units.
-
getFalseNorthing
public double getFalseNorthing()
-
setFalseEasting
public void setFalseEasting(double falseEasting)
Set the false Easting in projected units.
-
getFalseEasting
public double getFalseEasting()
-
setSouthernHemisphere
public void setSouthernHemisphere(boolean isSouth)
-
getSouthernHemisphere
public boolean getSouthernHemisphere()
-
setScaleFactor
public void setScaleFactor(double scaleFactor)
Set the projection scale factor. This is set to 1 by default. This value is called "k0" in PROJ.4.
-
getScaleFactor
public double getScaleFactor()
Gets the projection scale factor. This value is called "k0" in PROJ.4.- Returns:
-
getEquatorRadius
public double getEquatorRadius()
-
setFromMetres
public void setFromMetres(double fromMetres)
Set the conversion factor from metres to projected units. This is set to 1 by default.
-
getFromMetres
public double getFromMetres()
-
setEllipsoid
public void setEllipsoid(Ellipsoid ellipsoid)
-
getEllipsoid
public Ellipsoid getEllipsoid()
-
setRadius
public void setRadius(double radius)
-
getEPSGCode
public int getEPSGCode()
Returns the ESPG code for this projection, or 0 if unknown.
-
setUnits
public void setUnits(Unit unit)
-
getUnits
public Unit getUnits()
-
getHeightOfOrbit
public double getHeightOfOrbit()
Get height of orbit - Geostationary satellite projection- Returns:
- Height of orbit
-
setHeightOfOrbit
public void setHeightOfOrbit(double h)
Set height of orbit - Geostationary satellite projection- Parameters:
h- Height of orbit
-
initialize
public void initialize()
Initialize the projection. This should be called after setting parameters and before using the projection. This is for performance reasons as initialization may be expensive.
-
normalizeLongitude
public static float normalizeLongitude(float angle)
-
normalizeLongitudeRadians
public static double normalizeLongitudeRadians(double angle)
-
setGamma
public void setGamma(double gamma)
-
setGammaDegrees
public void setGammaDegrees(double gamma)
-
setNoUoff
public void setNoUoff(boolean no_uoff)
-
isGeographic
public java.lang.Boolean isGeographic()
Is this "projection" longlat? Overridden in LongLatProjection.
-
equals
public boolean equals(java.lang.Object that)
Represents quality between possible outputs ofproject(ProjCoordinate, ProjCoordinate). Subclasses of Projection should capture additional state that is used in the project method and delgate to base. Note: The name of the projection is not part of equality.- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
Hash of those fields considered in Projection equalituy. Subclasses that override equality should override hashCode.- Overrides:
hashCodein classjava.lang.Object
-
-