ol/proj/Projection~Projection
import Projection from 'ol/proj/Projection.js';
In most cases, you should not need to create instances of this class. Instead, where projection information is required, you can use a string projection code or identifier (e.g. EPSG:4326) instead of a projection instance.
The library includes support for transforming coordinates between the following projections:
WGS 84 / Geographic - Using codes EPSG:4326, CRS:84, urn:ogc:def:crs:EPSG:6.6:4326, urn:ogc:def:crs:OGC:1.3:CRS84, urn:ogc:def:crs:OGC:2:84, http://www.opengis.net/gml/srs/epsg.xml#4326, or urn:x-ogc:def:crs:EPSG:4326 WGS 84 / Spherical Mercator - Using codes EPSG:3857, EPSG:102100, EPSG:102113, EPSG:900913, urn:ogc:def:crs:EPSG:6.18:3:3857, or http://www.opengis.net/gml/srs/epsg.xml#3857 WGS 84 / UTM zones - Using codes EPSG:32601 through EPSG:32660 for northern zones and EPSG:32701 through EPSG:32760 for southern zones. Note that the built-in UTM transforms are lower accuracy (with errors on the order of 0.1 m) than those that you might get in a library like proj4js.
For additional projection support, or to use higher accuracy transforms than the built-in ones, you can use the proj4js library. With proj4js, after adding any new projection definitions, call the register function.
You can use the get function to retrieve a projection instance for one of the registered projections.
-
new Projection(options)
-
Name Type Description codestring The SRS identifier code, e.g.
EPSG:4326.unitsUnits | undefined Units. Required unless a proj4 projection is defined for
code.extentExtent | undefined The validity extent for the SRS.
axisOrientationstring (defaults to 'enu') The axis orientation as specified in Proj4.
globalboolean (defaults to false) Whether the projection is valid for the whole globe.
metersPerUnitnumber | undefined The meters per unit for the SRS. If not provided, the
unitsare used to get the meters per unit from theMETERS_PER_UNITlookup table.worldExtentExtent | undefined The world extent for the SRS.
getPointResolutionGetPointResolution | undefined Function to determine resolution at a point. The function is called with a
numberview resolution and aCoordinateas arguments, and returns thenumberresolution in projection units at the passed coordinate. If this isundefined, the defaultgetPointResolutionfunction will be used.
Methods
-
getAxisOrientation(){string}
-
Get the axis orientation of this projection. Example values are: enu - the default easting, northing, elevation. neu - northing, easting, up - useful for "lat/long" geographic coordinates, or south orientated transverse mercator. wnu - westing, northing, up - some planetary coordinate systems have "west positive" coordinate systems
Returns:
Axis orientation.
-
getCode(){string}
-
Get the code for this projection, e.g. 'EPSG:4326'.
Returns:
Code.
-
getExtent(){Extent}
-
Get the validity extent for this projection.
Returns:
Extent.
-
getMetersPerUnit(){number | undefined}
-
Get the amount of meters per unit of this projection. If the projection is not configured with
metersPerUnitor a units identifier, the return isundefined.Returns:
Meters.
-
getUnits(){Units}
-
Get the units of this projection.
Returns:
Units.
-
getWorldExtent(){Extent}
-
Get the world extent for this projection.
Returns:
Extent.
-
isGlobal(){boolean}
-
Is this projection a global projection which spans the whole world?
Returns:
Whether the projection is global.
-
setExtent(extent)
-
Set the validity extent for this projection.
Name Type Description extentExtent Extent.
-
setGetPointResolution(func)
-
Set the getPointResolution function (see
getPointResolutionfor this projection.Name Type Description funcfunction Function
-
setGlobal(global)
-
Set if the projection is a global projection which spans the whole world
Name Type Description globalboolean Whether the projection is global.
-
setWorldExtent(worldExtent)
-
Set the world extent for this projection.
Name Type Description worldExtentExtent World extent [minlon, minlat, maxlon, maxlat].
© 2005-present, OpenLayers Contributors All rights reserved.Licensed under the BSD 2-Clause License.
https://openlayers.org/en/latest/apidoc/module-ol_proj_Projection-Projection.html