Class Importer

java.lang.Object
org.locationtech.proj4j.geoapi.Importer

public class Importer extends Object
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.
Author:
Martin Desruisseaux (Geomatys)
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected Registry
    A registry for creating Projection instances if needed.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a default instance.
    Importer(Registry registry)
    Creates an importer which will use the given registry.
  • Method Summary

    Modifier and Type
    Method
    Description
    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.
    Returns the registry to use for creating PROJ4J objects from a name.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • registry

      protected Registry registry
      A registry for creating Projection instances if needed. If null, a default instance will be created when first needed.
      See Also:
  • Constructor Details

    • 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 creating Projection instances, or null for default
  • Method Details

    • getRegistry

      public Registry 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

      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, or null
      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, or null
      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 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, or null
      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, or null
      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, or null
      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, or null
      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, or null
      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, or null
      Returns:
      the PROJ4J implementation, or null if the given object was null
      Throws:
      UnconvertibleInstanceException - if the given object cannot be unwrapped or converted