Package org.locationtech.proj4j
Class CRSFactory
- java.lang.Object
-
- org.locationtech.proj4j.CRSFactory
-
public class CRSFactory extends java.lang.ObjectA factory which can createCoordinateReferenceSystems 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 defineCoordinateTransforms to perform transformations onProjCoordinates.
-
-
Field Summary
Fields Modifier and Type Field Description private static Proj4FileReadercsReaderprivate static Registryregistry
-
Constructor Summary
Constructors Constructor Description CRSFactory()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description CoordinateReferenceSystemcreateFromName(java.lang.String name)Creates aCoordinateReferenceSystem(CRS) from a well-known name.CoordinateReferenceSystemcreateFromParameters(java.lang.String name, java.lang.String paramStr)Creates aCoordinateReferenceSystemfrom a PROJ.4 projection parameter string.CoordinateReferenceSystemcreateFromParameters(java.lang.String name, java.lang.String[] params)Creates aCoordinateReferenceSystemdefined by an array of PROJ.4 projection parameters.RegistrygetRegistry()Gets theRegistryused by this factory.java.lang.StringreadEpsgFromParameters(java.lang.String paramStr)Finds a EPSG Code from a PROJ.4 projection parameter string.java.lang.StringreadEpsgFromParameters(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 theRegistryused 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:authorityis a code for a namespace supported by PROJ.4. Currently supported values areEPSG,ESRI,WORLD,NA83,NAD27. If no authority is provided, theEPSGnamespace is assumed.codeis the id of a coordinate system in the authority namespace. For example, in theEPSGnamespace a code is an integer value which identifies a CRS definition in the EPSG database. (Codes are read and handled as strings).
EPSG:3005.- Parameters:
name- the name of a coordinate system, with optional authority prefix- Returns:
- the
CoordinateReferenceSystemcorresponding 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 aCoordinateReferenceSystemfrom 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 benullfor 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 aCoordinateReferenceSystemdefined 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.IOExceptionFinds 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.IOExceptionFinds 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)
-
-