Package org.geolatte.geom.crs
Class CrsRegistry
- java.lang.Object
-
- org.geolatte.geom.crs.CrsRegistry
-
public class CrsRegistry extends Object
A repository forCoordinateReferenceSystems.Currently, the registry is limited to EPSG-defined coordinate reference systems.
- Author:
- Karel Maesen, Geovise BVBA creation-date: 8/2/11
-
-
Constructor Summary
Constructors Constructor Description CrsRegistry()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description 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.static CoordinateReferenceSystem<?>getCoordinateReferenceSystem(CrsId crsId, CoordinateReferenceSystem<?> fallback)returns theCoordinateReferenceSystemfor the specifiedCrsIdstatic CoordinateReferenceSystem<?>getCoordinateReferenceSystemForEPSG(int epsgCode, CoordinateReferenceSystem<?> fallback)returns theCoordinateReferenceSystemfor the specified EPSG code.static CrsIdgetCrsIdForEPSG(int epsgCode)Returns theCrsIdfor the specified EPSG Code.static Geographic2DCoordinateReferenceSystemgetGeographicCoordinateReferenceSystemForEPSG(int epsgCode)static ProjectedCoordinateReferenceSystemgetProjectedCoordinateReferenceSystemForEPSG(int epsgCode)static booleanhasCoordinateReferenceSystemForEPSG(int epsgCode)Determine if the registry contains theCoordinateReferenceSystemidentified by its SRIDstatic 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.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.static voidregisterCoordinateReferenceSystem(CoordinateReferenceSystem<?> crs)Registers aCoordinateReferenceSystemin the registry.static voidregisterCoordinateReferenceSystem(CrsId id, CoordinateReferenceSystem<?> crs)Registers aCoordinateReferenceSystemin the registry under the specified (pseudo-)EPSG code.
-
-
-
Method Detail
-
getCoordinateReferenceSystemForEPSG
public static CoordinateReferenceSystem<?> getCoordinateReferenceSystemForEPSG(int epsgCode, CoordinateReferenceSystem<?> fallback)
returns theCoordinateReferenceSystemfor the specified EPSG code.- Parameters:
epsgCode- the EPSG codefallback- the coordinate- Returns:
- the
CoordinateReferenceSystemcorresponding to the specified EPSG code, or null if no such system is registered.
-
getCoordinateReferenceSystem
public static CoordinateReferenceSystem<?> getCoordinateReferenceSystem(CrsId crsId, CoordinateReferenceSystem<?> fallback)
returns theCoordinateReferenceSystemfor the specifiedCrsId- Parameters:
crsId- the identifier for the Coordinate Reference Systemfallback- the coordinate- Returns:
- the
CoordinateReferenceSystemcorresponding 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- theCrsIdfor the Coordinate reference systembuildCrs- 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
CrsIdidentifier
-
registerCoordinateReferenceSystem
public static void registerCoordinateReferenceSystem(CoordinateReferenceSystem<?> crs)
Registers aCoordinateReferenceSystemin the registry.- Parameters:
crs- theCoordinateReferenceSystemto register
-
registerCoordinateReferenceSystem
public static void registerCoordinateReferenceSystem(CrsId id, CoordinateReferenceSystem<?> crs)
Registers aCoordinateReferenceSystemin the registry under the specified (pseudo-)EPSG code.- Parameters:
id- theCrsIdunder which to register this CoordinateReferenceSystemcrs- theCoordinateReferenceSystemto register
-
hasCoordinateReferenceSystemForEPSG
public static boolean hasCoordinateReferenceSystemForEPSG(int epsgCode)
Determine if the registry contains theCoordinateReferenceSystemidentified by its SRID- Parameters:
epsgCode- the SRID to look up- Returns:
- true iff the registry has a corresponding
CoordinateReferenceSystem
-
getGeographicCoordinateReferenceSystemForEPSG
public static Geographic2DCoordinateReferenceSystem getGeographicCoordinateReferenceSystemForEPSG(int epsgCode)
-
getProjectedCoordinateReferenceSystemForEPSG
public static ProjectedCoordinateReferenceSystem getProjectedCoordinateReferenceSystemForEPSG(int epsgCode)
-
getCrsIdForEPSG
public static CrsId getCrsIdForEPSG(int epsgCode)
Returns theCrsIdfor the specified EPSG Code.- Parameters:
epsgCode- the EPSG code- Returns:
- the
CrsIdcorresponding to the specified EPSG code, or null if no such system is registered.
-
-