Class Importer
java.lang.Object
org.locationtech.proj4j.geoapi.Importer
Builder of PROJ4J objects from GeoAPI objects. If the GeoAPI object has been created by a
call to a
Wrappers.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 an UnconvertibleInstanceException
is thrown.-
Field Summary
FieldsModifier and TypeFieldDescription(package private) static final ImporterDefault instance used byWrappers.proj4j(…)methods.private static final String[]Possible name spaces for OGC parameters, case-insensitive.private static final String[]Possible name spaces for PROJ4J operation methods, case-insensitive.protected RegistryA registry for creatingProjectioninstances if needed.private static final Set<org.opengis.referencing.cs.AxisDirection> Axis directions supported by PROJ4J. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) static StringaxisOrder(org.opengis.referencing.cs.CoordinateSystem cs) Returns the axis order of the given coordinate system.convert(org.opengis.parameter.ParameterValueGroup src) Returns the given parameters as a PROJ4J implementation.convert(org.opengis.referencing.crs.CRSAuthorityFactory src) Returns the given authority factory as a PROJ4J implementation.convert(org.opengis.referencing.crs.SingleCRS src) Returns the given CRS as a PROJ4J implementation.convert(org.opengis.referencing.datum.Ellipsoid src) Returns the given ellipsoid as a PROJ4J implementation.convert(org.opengis.referencing.datum.GeodeticDatum src) Returns the given datum as a PROJ4J implementation.convert(org.opengis.referencing.datum.PrimeMeridian src) Returns the given prime meridian as a PROJ4J implementation.convert(org.opengis.referencing.operation.CoordinateOperation src) Returns the given coordinate operation as a PROJ4J implementation.convert(org.opengis.referencing.operation.CoordinateOperationFactory src) Returns the given coordinate operation factory as a PROJ4J implementation.private static StringReturns the first alias of the given identified object which is in the given scope.private static StringgetName(org.opengis.referencing.IdentifiedObject src) Returns the name of the given identified object.private static StringgetNameOrAlias(org.opengis.referencing.IdentifiedObject src, String[] scopes) Returns the primary name or the first alias having one of the the given name spaces.Returns the registry to use for creating PROJ4J objects from a name.private static StringgetVendorName(org.opengis.util.Factory factory) Returns the name of the implementer of the given factory.
-
Field Details
-
PROJ_NAMESPACES
Possible name spaces for PROJ4J operation methods, case-insensitive. -
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
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
A registry for creatingProjectioninstances if needed. Ifnull, a default instance will be created when first needed.- See Also:
-
DEFAULT
Default instance used byWrappers.proj4j(…)methods.
-
-
Constructor Details
-
Importer
public Importer()Creates a default instance. -
Importer
Creates an importer which will use the given registry.- Parameters:
registry- a registry for creatingProjectioninstances, ornullfor default
-
-
Method Details
-
getRegistry
Returns 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.- Returns:
- the registry to use for creating PROJ4J objects from a name
-
convert
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
nullif the given object was null - Throws:
UnconvertibleInstanceException- if the given object cannot be unwrapped or converted
-
convert
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
nullif the given object was null - Throws:
UnconvertibleInstanceException- if the given object cannot be unwrapped or converted
-
axisOrder
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
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
nullif the given object was null - Throws:
UnconvertibleInstanceException- if the given object cannot be unwrapped or converted
-
convert
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
nullif the given object was null - Throws:
UnconvertibleInstanceException- if the given object cannot be unwrapped or converted
-
convert
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
nullif the given object was null - Throws:
UnconvertibleInstanceException- if the given object cannot be unwrapped or converted
-
convert
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
nullif 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
nullif the given object was null - Throws:
UnconvertibleInstanceException- if the given object cannot be unwrapped or converted
-
convert
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
nullif the given object was null - Throws:
UnconvertibleInstanceException- if the given object cannot be unwrapped or converted
-
getVendorName
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
Returns 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- Returns:
- the name of the given identified object
-
getAlias
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, ornullscope- scope of the alias to get, ornullfor the first alias regardless is scope- Returns:
- the first alias, or
nullif none
-
getNameOrAlias
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
-