Class CrsRegistry


  • public class CrsRegistry
    extends Object
    A repository for CoordinateReferenceSystems.

    Currently, the registry is limited to EPSG-defined coordinate reference systems.

    Author:
    Karel Maesen, Geovise BVBA creation-date: 8/2/11
    • Constructor Detail

      • CrsRegistry

        public CrsRegistry()
    • Method Detail

      • getCoordinateReferenceSystemForEPSG

        public static CoordinateReferenceSystem<?> getCoordinateReferenceSystemForEPSG​(int epsgCode,
                                                                                       CoordinateReferenceSystem<?> fallback)
        returns the CoordinateReferenceSystem for the specified EPSG code.
        Parameters:
        epsgCode - the EPSG code
        fallback - the coordinate
        Returns:
        the CoordinateReferenceSystem corresponding to the specified EPSG code, or null if no such system is registered.
      • getCoordinateReferenceSystem

        public static CoordinateReferenceSystem<?> getCoordinateReferenceSystem​(CrsId crsId,
                                                                                CoordinateReferenceSystem<?> fallback)
        returns the CoordinateReferenceSystem for the specified CrsId
        Parameters:
        crsId - the identifier for the Coordinate Reference System
        fallback - the coordinate
        Returns:
        the CoordinateReferenceSystem corresponding to the specified EPSG code, or null if no such system is registered.
      • ifAbsentReturnProjected2D

        public static CoordinateReferenceSystem<?> ifAbsentReturnProjected2D​(int epsgCode)
        Returns the registered coordinate reference system, or when unavailable in the registry, create a new Projected 2D system and register this on-the-fly.
        Parameters:
        epsgCode - the code to look up
        Returns:
        a CoordinateReferenceSystem with the specified epsg code
      • ifAbsentReturnGeographic2D

        public static CoordinateReferenceSystem<?> ifAbsentReturnGeographic2D​(int epsgCode)
        Returns the registered coordinate reference system, or when unavailable in the registry, create a new Geographic 2D system and register this on-the-fly.
        Parameters:
        epsgCode - the code to look up
        Returns:
        a CoordinateReferenceSystem with the specified epsg code
      • computeIfAbsent

        public static CoordinateReferenceSystem<?> computeIfAbsent​(CrsId crsId,
                                                                   Function<? super CrsId,​? extends CoordinateReferenceSystem<? extends Position>> buildCrs)
        Returns the registered coordinate reference system, or when unavailable in the registry, create a new reference system and register it on-the-fly.
        Parameters:
        crsId - the CrsId for the Coordinate reference system
        buildCrs - the function that builds a new Coordinate Reference System, if none is available in this Registry
        Returns:
        the current (existing or computed) coordinate reference system identified by the specified CrsId identifier
      • registerCoordinateReferenceSystem

        public static void registerCoordinateReferenceSystem​(CoordinateReferenceSystem<?> crs)
        Registers a CoordinateReferenceSystem in the registry.
        Parameters:
        crs - the CoordinateReferenceSystem to register
      • registerCoordinateReferenceSystem

        public static void registerCoordinateReferenceSystem​(CrsId id,
                                                             CoordinateReferenceSystem<?> crs)
        Registers a CoordinateReferenceSystem in the registry under the specified (pseudo-)EPSG code.
        Parameters:
        id - the CrsId under which to register this CoordinateReferenceSystem
        crs - the CoordinateReferenceSystem to register
      • hasCoordinateReferenceSystemForEPSG

        public static boolean hasCoordinateReferenceSystemForEPSG​(int epsgCode)
        Determine if the registry contains the CoordinateReferenceSystem identified by its SRID
        Parameters:
        epsgCode - the SRID to look up
        Returns:
        true iff the registry has a corresponding CoordinateReferenceSystem
      • getCrsIdForEPSG

        public static CrsId getCrsIdForEPSG​(int epsgCode)
        Returns the CrsId for the specified EPSG Code.
        Parameters:
        epsgCode - the EPSG code
        Returns:
        the CrsId corresponding to the specified EPSG code, or null if no such system is registered.