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.Serializable
A map projection is a mathematical algorithm for representing a spheroidal surface on a plane. A single projection defines a (usually infinite) family ofCoordinateReferenceSystem
s, distinguished by different values for the projection parameters.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected double
a
The equator radiusprotected double
alpha
The projection alpha valueprivate AxisOrder
axes
The order of axes for the coordinate system.protected static double
DTR
protected double
e
The eccentricityprotected Ellipsoid
ellipsoid
The ellipsoid used by this projectionprotected static double
EPS10
protected double
es
The eccentricity squaredprotected double
falseEasting
The false Easting of this projectionprotected double
falseNorthing
The false Northing of this projectionprotected double
fromMetres
Conversion factor from metres to whatever units the projection uses.protected boolean
geocentric
True if this projection is geocentricprotected double
lonc
The projection lonc valueprotected double
maxLatitude
The maximum latitude of the bounds of this projectionprotected double
maxLongitude
The maximum longitude of the bounds of this projection.protected double
minLatitude
The minimum latitude of the bounds of this projectionprotected double
minLongitude
The minimum longitude of the bounds of this projection.protected java.lang.String
name
The name of this projectionprotected double
one_es
1-(eccentricity squared)private PrimeMeridian
primeMeridian
PrimeMeridian defining an offset from the Greenwich (the prime meridian used in WGS84)protected double
projectionLatitude
The latitude of the centre of projectionprotected double
projectionLatitude1
Standard parallel 1 (for projections which use it)protected double
projectionLatitude2
Standard parallel 2 (for projections which use it)protected double
projectionLongitude
The longitude of the centre of projection, in radiansprotected double
rone_es
1/(1-(eccentricity squared))protected static double
RTD
protected double
scaleFactor
The projection scale factorprotected boolean
spherical
True if this projection is using a sphere (es == 0)private double
totalFalseEasting
falseEasting, adjusted to the appropriate units using fromMetresprivate double
totalFalseNorthing
falseNorthing, adjusted to the appropriate units using fromMetresprotected double
totalScale
The total scale factor = Earth radius * unitsprotected double
trueScaleLatitude
The latitude of true scale.protected Unit
unit
units of this projection.
-
Constructor Summary
Constructors Modifier Constructor Description protected
Projection()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Object
clone()
boolean
equals(java.lang.Object that)
Represents quality between possible outputs ofproject(ProjCoordinate, ProjCoordinate)
.double
getAlpha()
Gets the alpha value, in radians.AxisOrder
getAxisOrder()
Ellipsoid
getEllipsoid()
int
getEPSGCode()
Returns the ESPG code for this projection, or 0 if unknown.double
getEquatorRadius()
double
getFalseEasting()
double
getFalseNorthing()
double
getFromMetres()
double
getHeightOfOrbit()
Get height of orbit - Geostationary satellite projectiondouble
getLonC()
Gets the lonc value, in radians.double
getMaxLatitude()
double
getMaxLatitudeDegrees()
double
getMaxLongitude()
double
getMaxLongitudeDegrees()
double
getMinLatitude()
double
getMinLatitudeDegrees()
double
getMinLongitude()
double
getMinLongitudeDegrees()
java.lang.String
getName()
PrimeMeridian
getPrimeMeridian()
java.lang.String
getPROJ4Description()
Get a string which describes this projection in PROJ.4 format.double
getProjectionLatitude()
double
getProjectionLatitude1()
double
getProjectionLatitude1Degrees()
double
getProjectionLatitude2()
double
getProjectionLatitude2Degrees()
double
getProjectionLatitudeDegrees()
double
getProjectionLongitude()
double
getProjectionLongitudeDegrees()
double
getScaleFactor()
Gets the projection scale factor.boolean
getSouthernHemisphere()
double
getTrueScaleLatitude()
double
getTrueScaleLatitudeDegrees()
Unit
getUnits()
int
hashCode()
Hash of those fields considered in Projection equalituy.boolean
hasInverse()
Tests whether this projection has an inverse.void
initialize()
Initialize the projection.boolean
inside(double x, double y)
Returns true if the given lat/long point is visible in this projectionProjCoordinate
inverseProject(ProjCoordinate src, ProjCoordinate dst)
Inverse-projects a point (in the units defined by the coordinate system), producing a geographic result (in degrees)ProjCoordinate
inverseProjectRadians(ProjCoordinate src, ProjCoordinate dst)
Inverse-transforms a point (in the units defined by the coordinate system), producing a geographic result (in radians)boolean
isConformal()
Tests whether this projection is conformal.boolean
isEqualArea()
Tests whether this projection is equal-area An equal-area projection preserves relative sizes of projected areas.java.lang.Boolean
isGeographic()
Is this "projection" longlat? Overridden in LongLatProjection.boolean
isRectilinear()
Tests whether under this projection lines of latitude and longitude form a rectangular gridstatic float
normalizeLongitude(float angle)
static double
normalizeLongitudeRadians(double angle)
boolean
parallelsAreParallel()
Returns true if latitude lines are parallel for this projectionprotected ProjCoordinate
project(double x, double y, ProjCoordinate dst)
Computes the projection of a given point (i.e.ProjCoordinate
project(ProjCoordinate src, ProjCoordinate dst)
Projects a geographic point (in degrees), producing a projected result (in the units of the target coordinate system).protected ProjCoordinate
projectInverse(double x, double y, ProjCoordinate dst)
Computes the inverse projection of a given point (i.e.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).ProjCoordinate
projectRadians(ProjCoordinate src, ProjCoordinate dst)
Projects a geographic point (in radians), producing a projected result (in the units of the target coordinate system).void
setAlpha(double alpha)
Sets the alpha value.void
setAlphaDegrees(double alpha)
Sets the alpha value.void
setAxisOrder(java.lang.String axes)
void
setEllipsoid(Ellipsoid ellipsoid)
void
setFalseEasting(double falseEasting)
Set the false Easting in projected units.void
setFalseNorthing(double falseNorthing)
Set the false Northing in projected units.void
setFromMetres(double fromMetres)
Set the conversion factor from metres to projected units.void
setGamma(double gamma)
void
setGammaDegrees(double gamma)
void
setHeightOfOrbit(double h)
Set height of orbit - Geostationary satellite projectionvoid
setLonC(double lonc)
Sets the lonc value.void
setLonCDegrees(double lonc)
Sets the lonc value.void
setMaxLatitude(double maxLatitude)
Set the maximum latitude.void
setMaxLongitude(double maxLongitude)
void
setMaxLongitudeDegrees(double maxLongitude)
void
setMinLatitude(double minLatitude)
Set the minimum latitude.void
setMinLongitude(double minLongitude)
void
setMinLongitudeDegrees(double minLongitude)
void
setName(java.lang.String name)
Set the name of this projection.void
setNoUoff(boolean no_uoff)
void
setPrimeMeridian(java.lang.String primeMeridian)
void
setProjectionLatitude(double projectionLatitude)
Set the projection latitude in radians.void
setProjectionLatitude1(double projectionLatitude1)
Set the projection latitude in radians.void
setProjectionLatitude1Degrees(double projectionLatitude1)
Set the projection latitude in degrees.void
setProjectionLatitude2(double projectionLatitude2)
Set the projection latitude in radians.void
setProjectionLatitude2Degrees(double projectionLatitude2)
Set the projection latitude in degrees.void
setProjectionLatitudeDegrees(double projectionLatitude)
Set the projection latitude in degrees.void
setProjectionLongitude(double projectionLongitude)
Set the projection longitude in radians.void
setProjectionLongitudeDegrees(double projectionLongitude)
Set the projection longitude in degrees.void
setRadius(double radius)
void
setScaleFactor(double scaleFactor)
Set the projection scale factor.void
setSouthernHemisphere(boolean isSouth)
void
setTrueScaleLatitude(double trueScaleLatitude)
Set the latitude of true scale in radians.void
setTrueScaleLatitudeDegrees(double trueScaleLatitude)
Set the latitude of true scale in degrees.void
setUnits(Unit unit)
java.lang.String
toString()
-
-
-
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:
clone
in 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 returns true then 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:
toString
in 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:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
Hash of those fields considered in Projection equalituy. Subclasses that override equality should override hashCode.- Overrides:
hashCode
in classjava.lang.Object
-
-