Class Projections
- java.lang.Object
-
- org.openstreetmap.josm.data.projection.Projections
-
public final class Projections extends Object
Class to manage projections. Use this class to query available projection or register new projections from a plugin.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Projections.ProjectionDefinition
Class to hold information about one projection.
-
Field Summary
Fields Modifier and Type Field Description private static Set<String>
allCodes
private static Map<String,Datum>
datums
private static Map<String,Ellipsoid>
ellipsoids
private static Map<String,Projections.ProjectionDefinition>
inits
private static Map<String,NTV2GridShiftFileWrapper>
nadgrids
private static Map<String,Projection>
projectionsByCodeCache
private static Map<String,Supplier<Projection>>
projectionSuppliersByCode
private static Map<String,ProjFactory>
projs
Registry for custom projection should be compatible to PROJ.4
-
Constructor Summary
Constructors Modifier Constructor Description private
Projections()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description private static Projection
computeProjectionByCode(String code)
static Collection<String>
getAllBaseProjectionIds()
Get a list of ids of all registered base projections.static Collection<String>
getAllProjectionCodes()
Get a list of all supported projection codes.static Proj
getBaseProjection(String id)
Get a base projection by id.static Datum
getDatum(String id)
Get a geodetic datum by id.static Ellipsoid
getEllipsoid(String id)
Get an ellipsoid by id.static String
getInit(String code)
Get the projection definition string for the given code.static NTV2GridShiftFileWrapper
getNTV2Grid(String id)
Get a NTV2 grid database by id.static Projection
getProjectionByCode(String code)
Get a projection by code.static String
listDatums()
Replies the list of datums as string (comma separated).static String
listEllipsoids()
Replies the list of ellipsoids as string (comma separated).private static String
listKeys(Map<String,?> map)
static String
listNadgrids()
Replies the list of nadgrids as string (comma separated).static String
listProjs()
Replies the list of projections as string (comma separated).private static void
loadNadgrids(String definition)
static List<Projections.ProjectionDefinition>
loadProjectionDefinitions(BufferedReader r)
Load projection definitions from file.static List<Projections.ProjectionDefinition>
loadProjectionDefinitions(String path)
Load projection definitions from file.static void
registerBaseProjection(String id, Class<? extends Proj> projClass, String origin)
Plugins can register additional base projections.static void
registerBaseProjection(String id, ProjFactory fac, String origin)
Plugins can register additional base projections.static void
registerProjectionSupplier(String code, Supplier<Projection> supplier)
Register a projection supplier, that is, a factory class for projections.
-
-
-
Field Detail
-
projectionSuppliersByCode
private static final Map<String,Supplier<Projection>> projectionSuppliersByCode
-
projectionsByCodeCache
private static final Map<String,Projection> projectionsByCodeCache
-
projs
private static final Map<String,ProjFactory> projs
Registry for custom projection should be compatible to PROJ.4
-
ellipsoids
private static final Map<String,Ellipsoid> ellipsoids
-
nadgrids
private static final Map<String,NTV2GridShiftFileWrapper> nadgrids
-
inits
private static final Map<String,Projections.ProjectionDefinition> inits
-
-
Constructor Detail
-
Projections
private Projections()
-
-
Method Detail
-
loadNadgrids
private static void loadNadgrids(String definition)
-
registerBaseProjection
public static void registerBaseProjection(String id, ProjFactory fac, String origin)
Plugins can register additional base projections.- Parameters:
id
- The "official" PROJ.4 id. In case the projection is not supported by PROJ.4, use some prefix, e.g. josm:myproj or gdal:otherproj.fac
- The base projection factory.origin
- Multiple plugins may implement the same base projection. Provide plugin name or similar string, so it be differentiated.
-
registerBaseProjection
public static void registerBaseProjection(String id, Class<? extends Proj> projClass, String origin)
Plugins can register additional base projections.- Parameters:
id
- The "official" PROJ.4 id. In case the projection is not supported by PROJ.4, use some prefix, e.g. josm:myproj or gdal:otherproj.projClass
- The base projection class.origin
- Multiple plugins may implement the same base projection. Provide plugin name or similar string, so it be differentiated.
-
registerProjectionSupplier
public static void registerProjectionSupplier(String code, Supplier<Projection> supplier)
Register a projection supplier, that is, a factory class for projections.- Parameters:
code
- the code of the projection that will be returnedsupplier
- a supplier to return a projection with given code- Since:
- 12786
-
getBaseProjection
public static Proj getBaseProjection(String id)
Get a base projection by id.- Parameters:
id
- the id, for example "lonlat" or "tmerc"- Returns:
- the corresponding base projection if the id is known, null otherwise
-
getEllipsoid
public static Ellipsoid getEllipsoid(String id)
Get an ellipsoid by id.- Parameters:
id
- the id, for example "bessel" or "WGS84"- Returns:
- the corresponding ellipsoid if the id is known, null otherwise
-
getDatum
public static Datum getDatum(String id)
Get a geodetic datum by id.- Parameters:
id
- the id, for example "potsdam" or "WGS84"- Returns:
- the corresponding datum if the id is known, null otherwise
-
getNTV2Grid
public static NTV2GridShiftFileWrapper getNTV2Grid(String id)
Get a NTV2 grid database by id.- Parameters:
id
- the id- Returns:
- the corresponding NTV2 grid if the id is known, null otherwise
-
getInit
public static String getInit(String code)
Get the projection definition string for the given code.- Parameters:
code
- the code- Returns:
- the string that can be processed by
CustomProjection
. Null, if the code isn't supported.
-
loadProjectionDefinitions
public static List<Projections.ProjectionDefinition> loadProjectionDefinitions(String path) throws IOException
Load projection definitions from file.- Parameters:
path
- the path- Returns:
- projection definitions
- Throws:
IOException
- in case of I/O error
-
loadProjectionDefinitions
public static List<Projections.ProjectionDefinition> loadProjectionDefinitions(BufferedReader r) throws IOException
Load projection definitions from file.- Parameters:
r
- the reader- Returns:
- projection definitions
- Throws:
IOException
- in case of I/O error
-
getProjectionByCode
public static Projection getProjectionByCode(String code)
Get a projection by code.- Parameters:
code
- the code, e.g. "EPSG:2026"- Returns:
- the corresponding projection, if the code is known, null otherwise
-
computeProjectionByCode
private static Projection computeProjectionByCode(String code)
-
getAllProjectionCodes
public static Collection<String> getAllProjectionCodes()
Get a list of all supported projection codes.- Returns:
- all supported projection codes
- See Also:
getProjectionByCode(java.lang.String)
-
getAllBaseProjectionIds
public static Collection<String> getAllBaseProjectionIds()
Get a list of ids of all registered base projections.- Returns:
- all registered base projection ids
- See Also:
getBaseProjection(java.lang.String)
-
listProjs
public static String listProjs()
Replies the list of projections as string (comma separated).- Returns:
- the list of projections as string (comma separated)
- Since:
- 8533
-
listEllipsoids
public static String listEllipsoids()
Replies the list of ellipsoids as string (comma separated).- Returns:
- the list of ellipsoids as string (comma separated)
- Since:
- 8533
-
listDatums
public static String listDatums()
Replies the list of datums as string (comma separated).- Returns:
- the list of datums as string (comma separated)
- Since:
- 8533
-
listNadgrids
public static String listNadgrids()
Replies the list of nadgrids as string (comma separated).- Returns:
- the list of nadgrids as string (comma separated)
- Since:
- 8533
-
-