Class Projections
java.lang.Object
org.openstreetmap.josm.data.projection.Projections
Class to manage projections.
Use this class to query available projection or register new projections from a plugin.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classClass to hold information about one projection. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final Map<String,Projections.ProjectionDefinition> private static final Map<String,NTV2GridShiftFileWrapper> private static final Map<String,Projection> private static final Map<String,Supplier<Projection>> private static final Map<String,ProjFactory> Registry for custom projection should be compatible to PROJ.4 -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static Projectionstatic Collection<String>Get a list of ids of all registered base projections.static Collection<String>Get a list of all supported projection codes.static ProjGet a base projection by id.static DatumGet a geodetic datum by id.static EllipsoidgetEllipsoid(String id) Get an ellipsoid by id.static StringGet the projection definition string for the given code.static NTV2GridShiftFileWrappergetNTV2Grid(String id) Get a NTV2 grid database by id.static ProjectiongetProjectionByCode(String code) Get a projection by code.static StringReplies the list of datums as string (comma separated).static StringReplies the list of ellipsoids as string (comma separated).private static Stringstatic StringReplies the list of nadgrids as string (comma separated).static StringReplies the list of projections as string (comma separated).private static voidloadNadgrids(String definition) static List<Projections.ProjectionDefinition>Load projection definitions from file.static List<Projections.ProjectionDefinition>Load projection definitions from file.static voidregisterBaseProjection(String id, Class<? extends Proj> projClass, String origin) Plugins can register additional base projections.static voidregisterBaseProjection(String id, ProjFactory fac, String origin) Plugins can register additional base projections.static voidregisterProjectionSupplier(String code, Supplier<Projection> supplier) Register a projection supplier, that is, a factory class for projections.
-
Field Details
-
allCodes
-
projectionSuppliersByCode
-
projectionsByCodeCache
-
projs
Registry for custom projection should be compatible to PROJ.4 -
ellipsoids
-
datums
-
nadgrids
-
inits
-
-
Constructor Details
-
Projections
private Projections()
-
-
Method Details
-
loadNadgrids
-
registerBaseProjection
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
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
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
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
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
Get a NTV2 grid database by id.- Parameters:
id- the id- Returns:
- the corresponding NTV2 grid if the id is known, null otherwise
-
getInit
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
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
-
getAllProjectionCodes
Get a list of all supported projection codes.- Returns:
- all supported projection codes
- See Also:
-
getAllBaseProjectionIds
Get a list of ids of all registered base projections.- Returns:
- all registered base projection ids
- See Also:
-
listKeys
-
listProjs
Replies the list of projections as string (comma separated).- Returns:
- the list of projections as string (comma separated)
- Since:
- 8533
-
listEllipsoids
Replies the list of ellipsoids as string (comma separated).- Returns:
- the list of ellipsoids as string (comma separated)
- Since:
- 8533
-
listDatums
Replies the list of datums as string (comma separated).- Returns:
- the list of datums as string (comma separated)
- Since:
- 8533
-
listNadgrids
Replies the list of nadgrids as string (comma separated).- Returns:
- the list of nadgrids as string (comma separated)
- Since:
- 8533
-