Class Projections
- java.lang.Object
-
- org.openstreetmap.josm.data.projection.Projections
-
public final class Projections extends java.lang.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 classProjections.ProjectionDefinitionClass to hold information about one projection.
-
Field Summary
Fields Modifier and Type Field Description private static java.util.Set<java.lang.String>allCodesprivate static java.util.Map<java.lang.String,Datum>datumsprivate static java.util.Map<java.lang.String,Ellipsoid>ellipsoidsprivate static java.util.Map<java.lang.String,Projections.ProjectionDefinition>initsprivate static java.util.Map<java.lang.String,NTV2GridShiftFileWrapper>nadgridsprivate static java.util.Map<java.lang.String,Projection>projectionsByCodeCacheprivate static java.util.Map<java.lang.String,java.util.function.Supplier<Projection>>projectionSuppliersByCodeprivate static java.util.Map<java.lang.String,ProjFactory>projsRegistry for custom projection should be compatible to PROJ.4
-
Constructor Summary
Constructors Modifier Constructor Description privateProjections()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description private static ProjectioncomputeProjectionByCode(java.lang.String code)static java.util.Collection<java.lang.String>getAllBaseProjectionIds()Get a list of ids of all registered base projections.static java.util.Collection<java.lang.String>getAllProjectionCodes()Get a list of all supported projection codes.static ProjgetBaseProjection(java.lang.String id)Get a base projection by id.static DatumgetDatum(java.lang.String id)Get a geodetic datum by id.static EllipsoidgetEllipsoid(java.lang.String id)Get an ellipsoid by id.static java.lang.StringgetInit(java.lang.String code)Get the projection definition string for the given code.static NTV2GridShiftFileWrappergetNTV2Grid(java.lang.String id)Get a NTV2 grid database by id.static ProjectiongetProjectionByCode(java.lang.String code)Get a projection by code.static java.lang.StringlistDatums()Replies the list of datums as string (comma separated).static java.lang.StringlistEllipsoids()Replies the list of ellipsoids as string (comma separated).private static java.lang.StringlistKeys(java.util.Map<java.lang.String,?> map)static java.lang.StringlistNadgrids()Replies the list of nadgrids as string (comma separated).static java.lang.StringlistProjs()Replies the list of projections as string (comma separated).private static voidloadNadgrids(java.lang.String definition)static java.util.List<Projections.ProjectionDefinition>loadProjectionDefinitions(java.io.BufferedReader r)Load projection definitions from file.static java.util.List<Projections.ProjectionDefinition>loadProjectionDefinitions(java.lang.String path)Load projection definitions from file.static voidregisterBaseProjection(java.lang.String id, java.lang.Class<? extends Proj> projClass, java.lang.String origin)Plugins can register additional base projections.static voidregisterBaseProjection(java.lang.String id, ProjFactory fac, java.lang.String origin)Plugins can register additional base projections.static voidregisterProjectionSupplier(java.lang.String code, java.util.function.Supplier<Projection> supplier)Register a projection supplier, that is, a factory class for projections.
-
-
-
Field Detail
-
allCodes
private static final java.util.Set<java.lang.String> allCodes
-
projectionSuppliersByCode
private static final java.util.Map<java.lang.String,java.util.function.Supplier<Projection>> projectionSuppliersByCode
-
projectionsByCodeCache
private static final java.util.Map<java.lang.String,Projection> projectionsByCodeCache
-
projs
private static final java.util.Map<java.lang.String,ProjFactory> projs
Registry for custom projection should be compatible to PROJ.4
-
ellipsoids
private static final java.util.Map<java.lang.String,Ellipsoid> ellipsoids
-
nadgrids
private static final java.util.Map<java.lang.String,NTV2GridShiftFileWrapper> nadgrids
-
inits
private static final java.util.Map<java.lang.String,Projections.ProjectionDefinition> inits
-
-
Constructor Detail
-
Projections
private Projections()
-
-
Method Detail
-
loadNadgrids
private static void loadNadgrids(java.lang.String definition)
-
registerBaseProjection
public static void registerBaseProjection(java.lang.String id, ProjFactory fac, java.lang.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(java.lang.String id, java.lang.Class<? extends Proj> projClass, java.lang.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(java.lang.String code, java.util.function.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(java.lang.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(java.lang.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(java.lang.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(java.lang.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 java.lang.String getInit(java.lang.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 java.util.List<Projections.ProjectionDefinition> loadProjectionDefinitions(java.lang.String path) throws java.io.IOException
Load projection definitions from file.- Parameters:
path- the path- Returns:
- projection definitions
- Throws:
java.io.IOException- in case of I/O error
-
loadProjectionDefinitions
public static java.util.List<Projections.ProjectionDefinition> loadProjectionDefinitions(java.io.BufferedReader r) throws java.io.IOException
Load projection definitions from file.- Parameters:
r- the reader- Returns:
- projection definitions
- Throws:
java.io.IOException- in case of I/O error
-
getProjectionByCode
public static Projection getProjectionByCode(java.lang.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(java.lang.String code)
-
getAllProjectionCodes
public static java.util.Collection<java.lang.String> getAllProjectionCodes()
Get a list of all supported projection codes.- Returns:
- all supported projection codes
- See Also:
getProjectionByCode(java.lang.String)
-
getAllBaseProjectionIds
public static java.util.Collection<java.lang.String> getAllBaseProjectionIds()
Get a list of ids of all registered base projections.- Returns:
- all registered base projection ids
- See Also:
getBaseProjection(java.lang.String)
-
listKeys
private static java.lang.String listKeys(java.util.Map<java.lang.String,?> map)
-
listProjs
public static java.lang.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 java.lang.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 java.lang.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 java.lang.String listNadgrids()
Replies the list of nadgrids as string (comma separated).- Returns:
- the list of nadgrids as string (comma separated)
- Since:
- 8533
-
-