Package org.locationtech.proj4j.geoapi
Class Importer
- java.lang.Object
-
- org.locationtech.proj4j.geoapi.Importer
-
public class Importer extends java.lang.Object
Builder of PROJ4J objects from GeoAPI objects. If the GeoAPI object has been created by a call to aWrappers.geoapi(…)
method, then the wrapped object is returned directly. Otherwise, this class tries to creates new PROJ4J instances using the information provided in the GeoAPI object. It may fail, in which case anUnconvertibleInstanceException
is thrown.
-
-
Field Summary
Fields Modifier and Type Field Description (package private) static Importer
DEFAULT
Default instance used byWrappers.proj4j(…)
methods.private static java.lang.String[]
OGC_NAMESPACES
Possible name spaces for OGC parameters, case-insensitive.private static java.lang.String[]
PROJ_NAMESPACES
Possible name spaces for PROJ4J operation methods, case-insensitive.protected Registry
registry
A registry for creatingProjection
instances if needed.private static java.util.Set<org.opengis.referencing.cs.AxisDirection>
SUPPORTED_AXIS_DIRECTIONS
Axis directions supported by PROJ4J.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) static java.lang.String
axisOrder(org.opengis.referencing.cs.CoordinateSystem cs)
Returns the axis order of the given coordinate system.Projection
convert(org.opengis.parameter.ParameterValueGroup src)
Returns the given parameters as a PROJ4J implementation.CRSFactory
convert(org.opengis.referencing.crs.CRSAuthorityFactory src)
Returns the given authority factory as a PROJ4J implementation.CoordinateReferenceSystem
convert(org.opengis.referencing.crs.SingleCRS src)
Returns the given CRS as a PROJ4J implementation.Ellipsoid
convert(org.opengis.referencing.datum.Ellipsoid src)
Returns the given ellipsoid as a PROJ4J implementation.Datum
convert(org.opengis.referencing.datum.GeodeticDatum src)
Returns the given datum as a PROJ4J implementation.PrimeMeridian
convert(org.opengis.referencing.datum.PrimeMeridian src)
Returns the given prime meridian as a PROJ4J implementation.CoordinateTransform
convert(org.opengis.referencing.operation.CoordinateOperation src)
Returns the given coordinate operation as a PROJ4J implementation.CoordinateTransformFactory
convert(org.opengis.referencing.operation.CoordinateOperationFactory src)
Returns the given coordinate operation factory as a PROJ4J implementation.private static java.lang.String
getAlias(org.opengis.referencing.IdentifiedObject src, java.lang.String scope)
Returns the first alias of the given identified object which is in the given scope.private static java.lang.String
getName(org.opengis.referencing.IdentifiedObject src)
{@return the name of the given identified object}.private static java.lang.String
getNameOrAlias(org.opengis.referencing.IdentifiedObject src, java.lang.String[] scopes)
Returns the primary name or the first alias having one of the the given name spaces.Registry
getRegistry()
{@return the registry to use for creating PROJ4J objects from a name}.private static java.lang.String
getVendorName(org.opengis.util.Factory factory)
Returns the name of the implementer of the given factory.
-
-
-
Field Detail
-
PROJ_NAMESPACES
private static final java.lang.String[] PROJ_NAMESPACES
Possible name spaces for PROJ4J operation methods, case-insensitive.
-
OGC_NAMESPACES
private static final java.lang.String[] OGC_NAMESPACES
Possible name spaces for OGC parameters, case-insensitive. ESRI parameters are usually the same as OGC parameters except for the case.
-
SUPPORTED_AXIS_DIRECTIONS
private static final java.util.Set<org.opengis.referencing.cs.AxisDirection> SUPPORTED_AXIS_DIRECTIONS
Axis directions supported by PROJ4J. The PROJ4J code for each axis direction is the first letter of the name of code list value, converted to lower case.
-
registry
protected Registry registry
A registry for creatingProjection
instances if needed. Ifnull
, a default instance will be created when first needed.- See Also:
getRegistry()
-
DEFAULT
static final Importer DEFAULT
Default instance used byWrappers.proj4j(…)
methods.
-
-
Constructor Detail
-
Importer
public Importer()
Creates a default instance.
-
Importer
public Importer(Registry registry)
Creates an importer which will use the given registry.- Parameters:
registry
- a registry for creatingProjection
instances, ornull
for default
-
-
Method Detail
-
getRegistry
public Registry getRegistry()
{@return the registry to use for creating PROJ4J objects from a name}. If no registry was specified at construction time, a default instance is created the first time that this method is invoked.
-
convert
public CRSFactory convert(org.opengis.referencing.crs.CRSAuthorityFactory src)
Returns the given authority factory as a PROJ4J implementation. This method returns the backing implementation. If the given factory is not backed by a PROJ4J implementation, then the current implementation throws an exception.- Parameters:
src
- the object to unwrap or convert, ornull
- Returns:
- the PROJ4J implementation, or
null
if the given object was null - Throws:
UnconvertibleInstanceException
- if the given object cannot be unwrapped or converted
-
convert
public CoordinateReferenceSystem convert(org.opengis.referencing.crs.SingleCRS src)
Returns the given CRS as a PROJ4J implementation. This method tries to return the backing implementation if possible, or otherwise copies the properties in a new PROJ4J instance.- Parameters:
src
- the object to unwrap or convert, ornull
- Returns:
- the PROJ4J implementation, or
null
if the given object was null - Throws:
UnconvertibleInstanceException
- if the given object cannot be unwrapped or converted
-
axisOrder
static java.lang.String axisOrder(org.opengis.referencing.cs.CoordinateSystem cs)
Returns the axis order of the given coordinate system.- Parameters:
cs
- the coordinate system for which to get the axis order- Returns:
- the 3-letters code of axis order to be given to
AxisOrder.fromString(String)
. - Throws:
UnconvertibleInstanceException
- if the coordinate system uses an unsupported axis order
-
convert
public Datum convert(org.opengis.referencing.datum.GeodeticDatum src)
Returns the given datum as a PROJ4J implementation. This method tries to return the backing implementation if possible, or otherwise copies the properties in a new PROJ4J instance.- Parameters:
src
- the object to unwrap or convert, ornull
- Returns:
- the PROJ4J implementation, or
null
if the given object was null - Throws:
UnconvertibleInstanceException
- if the given object cannot be unwrapped or converted
-
convert
public Ellipsoid convert(org.opengis.referencing.datum.Ellipsoid src)
Returns the given ellipsoid as a PROJ4J implementation. This method tries to return the backing implementation if possible, or otherwise copies the properties in a new PROJ4J instance.- Parameters:
src
- the object to unwrap or convert, ornull
- Returns:
- the PROJ4J implementation, or
null
if the given object was null - Throws:
UnconvertibleInstanceException
- if the given object cannot be unwrapped or converted
-
convert
public PrimeMeridian convert(org.opengis.referencing.datum.PrimeMeridian src)
Returns the given prime meridian as a PROJ4J implementation. This method tries to return the backing implementation if possible, or an equivalent PROJ4J instance otherwise.- Parameters:
src
- the object to unwrap, ornull
- Returns:
- the PROJ4J implementation, or
null
if the given object was null - Throws:
UnconvertibleInstanceException
- if the given object cannot be unwrapped or converted
-
convert
public Projection convert(org.opengis.parameter.ParameterValueGroup src)
Returns the given parameters as a PROJ4J implementation. This method tries to return the backing implementation if possible, or an equivalent PROJ4J instance otherwise.- Parameters:
src
- the object to unwrap, ornull
- Returns:
- the PROJ4J implementation, or
null
if the given object was null - Throws:
UnconvertibleInstanceException
- if the given object cannot be unwrapped or converted
-
convert
public CoordinateTransformFactory convert(org.opengis.referencing.operation.CoordinateOperationFactory src)
Returns the given coordinate operation factory as a PROJ4J implementation. This method returns the backing implementation. If the given factory is not backed by a PROJ4J implementation, then the current implementation throws an exception.- Parameters:
src
- the object to unwrap or convert, ornull
- Returns:
- the PROJ4J implementation, or
null
if the given object was null - Throws:
UnconvertibleInstanceException
- if the given object cannot be unwrapped or converted
-
convert
public CoordinateTransform convert(org.opengis.referencing.operation.CoordinateOperation src)
Returns the given coordinate operation as a PROJ4J implementation. This method returns the backing implementation. If the given factory is not backed by a PROJ4J implementation, then the current implementation throws an exception.- Parameters:
src
- the object to unwrap or convert, ornull
- Returns:
- the PROJ4J implementation, or
null
if the given object was null - Throws:
UnconvertibleInstanceException
- if the given object cannot be unwrapped or converted
-
getVendorName
private static java.lang.String getVendorName(org.opengis.util.Factory factory)
Returns the name of the implementer of the given factory. This is used for error messages.- Parameters:
factory
- the factory for which to get the implementer name- Returns:
- name of the implementer of the given factory
-
getName
private static java.lang.String getName(org.opengis.referencing.IdentifiedObject src)
{@return the name of the given identified object}. This method is null-safe. Null safety is theoretically not necessary because the name is mandatory, but we try to be safe.- Parameters:
src
- the object for which to get the name, ornull
-
getAlias
private static java.lang.String getAlias(org.opengis.referencing.IdentifiedObject src, java.lang.String scope)
Returns the first alias of the given identified object which is in the given scope. Aliases are often used for abbreviations.- Parameters:
src
- the object for which to get an alias, ornull
scope
- scope of the alias to get, ornull
for the first alias regardless is scope- Returns:
- the first alias, or
null
if none
-
getNameOrAlias
private static java.lang.String getNameOrAlias(org.opengis.referencing.IdentifiedObject src, java.lang.String[] scopes)
Returns the primary name or the first alias having one of the the given name spaces. If no name or alias is found, then the first non-null name or alias is returned.- Parameters:
src
- the object for which to get a name or alias in the given name spacesscopes
- the desired name spaces, case-insensitive- Returns:
- the first name in one of the given name space if any, or an arbitrary name otherwise
-
-