Package org.locationtech.proj4j
Class CRSFactory
- java.lang.Object
-
- org.locationtech.proj4j.CRSFactory
-
public class CRSFactory extends java.lang.Object
A factory which can createCoordinateReferenceSystem
s from a variety of ways of specifying them. This is the primary way of creating coordinate systems for carrying out projections transformations.CoordinateReferenceSystems can be used to define
CoordinateTransform
s to perform transformations onProjCoordinate
s.
-
-
Field Summary
Fields Modifier and Type Field Description private static Proj4FileReader
csReader
private static Registry
registry
-
Constructor Summary
Constructors Constructor Description CRSFactory()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description CoordinateReferenceSystem
createFromName(java.lang.String name)
Creates aCoordinateReferenceSystem
(CRS) from a well-known name.CoordinateReferenceSystem
createFromParameters(java.lang.String name, java.lang.String paramStr)
Creates aCoordinateReferenceSystem
from a PROJ.4 projection parameter string.CoordinateReferenceSystem
createFromParameters(java.lang.String name, java.lang.String[] params)
Creates aCoordinateReferenceSystem
defined by an array of PROJ.4 projection parameters.Registry
getRegistry()
Gets theRegistry
used by this factory.java.lang.String
readEpsgFromParameters(java.lang.String paramStr)
Finds a EPSG Code from a PROJ.4 projection parameter string.java.lang.String
readEpsgFromParameters(java.lang.String[] params)
Finds a EPSG Code defined by an array of PROJ.4 projection parameters.private static java.lang.String[]
splitParameters(java.lang.String paramStr)
-
-
-
Field Detail
-
csReader
private static Proj4FileReader csReader
-
registry
private static Registry registry
-
-
Method Detail
-
getRegistry
public Registry getRegistry()
Gets theRegistry
used by this factory.- Returns:
- the Registry
-
createFromName
public CoordinateReferenceSystem createFromName(java.lang.String name) throws UnsupportedParameterException, InvalidValueException, UnknownAuthorityCodeException
Creates aCoordinateReferenceSystem
(CRS) from a well-known name. CRS names are of the form: "authority:code", with the components being:- authority is a code for a namespace supported by PROJ.4. Currently supported values are EPSG, ESRI, WORLD, NA83, NAD27. If no authority is provided, the EPSG namespace is assumed.
- code is the id of a coordinate system in the authority namespace. For example, in the EPSG namespace a code is an integer value which identifies a CRS definition in the EPSG database. (Codes are read and handled as strings).
- Parameters:
name
- the name of a coordinate system, with optional authority prefix- Returns:
- the
CoordinateReferenceSystem
corresponding to the given name - Throws:
UnsupportedParameterException
- if a PROJ.4 parameter is not supportedInvalidValueException
- if a parameter value is invalidUnknownAuthorityCodeException
- if the authority code cannot be found
-
createFromParameters
public CoordinateReferenceSystem createFromParameters(java.lang.String name, java.lang.String paramStr) throws UnsupportedParameterException, InvalidValueException
Creates aCoordinateReferenceSystem
from a PROJ.4 projection parameter string.An example of a valid PROJ.4 projection parameter string is:
+proj=aea +lat_1=50 +lat_2=58.5 +lat_0=45 +lon_0=-126 +x_0=1000000 +y_0=0 +ellps=GRS80 +units=m
- Parameters:
name
- a name for this coordinate system (may be null for an anonymous coordinate system)paramStr
- a PROJ.4 projection parameter string- Returns:
- the specified
CoordinateReferenceSystem
- Throws:
UnsupportedParameterException
- if a given PROJ.4 parameter is not supportedInvalidValueException
- if a supplied parameter value is invalid
-
createFromParameters
public CoordinateReferenceSystem createFromParameters(java.lang.String name, java.lang.String[] params) throws UnsupportedParameterException, InvalidValueException
Creates aCoordinateReferenceSystem
defined by an array of PROJ.4 projection parameters. PROJ.4 parameters are generally of the form "+name=value".- Parameters:
name
- a name for this coordinate system (may be null)params
- an array of PROJ.4 projection parameters- Returns:
- a
CoordinateReferenceSystem
- Throws:
UnsupportedParameterException
- if a PROJ.4 parameter is not supportedInvalidValueException
- if a parameter value is invalid
-
readEpsgFromParameters
public java.lang.String readEpsgFromParameters(java.lang.String paramStr) throws java.io.IOException
Finds a EPSG Code from a PROJ.4 projection parameter string.An example of a valid PROJ.4 projection parameter string is:
+proj=aea +lat_1=50 +lat_2=58.5 +lat_0=45 +lon_0=-126 +x_0=1000000 +y_0=0 +ellps=GRS80 +units=m
- Parameters:
paramStr
- a PROJ.4 projection parameter string- Returns:
- the specified
CoordinateReferenceSystem
- Throws:
java.io.IOException
- if there was an issue in reading EPSG file
-
readEpsgFromParameters
public java.lang.String readEpsgFromParameters(java.lang.String[] params) throws java.io.IOException
Finds a EPSG Code defined by an array of PROJ.4 projection parameters. PROJ.4 parameters are generally of the form "+name=value".- Parameters:
params
- an array of PROJ.4 projection parameters- Returns:
- s String EPSG code
- Throws:
java.io.IOException
- if there was an issue in reading EPSG file
-
splitParameters
private static java.lang.String[] splitParameters(java.lang.String paramStr)
-
-