Class: Projection

ol/proj/Projection~Projection


import Projection from 'ol/proj/Projection';

Projection definition class. One of these is created for each projection supported in the application and stored in the module:ol/proj namespace. You can use these in applications, but this is not required, as API params and options use module:ol/proj~ProjectionLike which means the simple string code will suffice.

You can use module:ol/proj~get to retrieve the object for a particular projection.

The library includes definitions for EPSG:4326 and EPSG:3857, together with the following aliases:

If you use proj4js, aliases can be added using proj4.defs(). After all required projection definitions are added, call the module:ol/proj/proj4~register function.

new Projection(options)

proj/Projection.js, line 59
Name Type Description
options

Projection options.

Name Type Description
code string

The SRS identifier code, e.g. EPSG:4326.

units module:ol/proj/Units | string

Units. Required unless a proj4 projection is defined for code.

extent module:ol/extent~Extent

The validity extent for the SRS.

axisOrientation string (defaults to 'enu')

The axis orientation as specified in Proj4.

global boolean (defaults to false)

Whether the projection is valid for the whole globe.

metersPerUnit number

The meters per unit for the SRS. If not provided, the units are used to get the meters per unit from the module:ol/proj/Units~METERS_PER_UNIT lookup table.

worldExtent module:ol/extent~Extent

The world extent for the SRS.

getPointResolution function

Function to determine resolution at a point. The function is called with a {number} view resolution and an {module:ol/coordinate~Coordinate} as arguments, and returns the {number} resolution in projection units at the passed coordinate. If this is undefined, the default module:ol/proj#getPointResolution function will be used.

Methods

getAxisOrientation(){string}

proj/Projection.js, line 197

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}

proj/Projection.js, line 144

Get the code for this projection, e.g. 'EPSG:4326'.

Returns:
Code.

getExtent(){module:ol/extent~Extent}

proj/Projection.js, line 153

Get the validity extent for this projection.

Returns:
Extent.

getMetersPerUnit(){number|undefined}

proj/Projection.js, line 173

Get the amount of meters per unit of this projection. If the projection is not configured with metersPerUnit or a units identifier, the return is undefined.

Returns:
Meters.

getUnits(){module:ol/proj/Units}

proj/Projection.js, line 162

Get the units of this projection.

Returns:
Units.

getWorldExtent(){module:ol/extent~Extent}

proj/Projection.js, line 182

Get the world extent for this projection.

Returns:
Extent.

isGlobal(){boolean}

proj/Projection.js, line 206

Is this projection a global projection which spans the whole world?

Returns:
Whether the projection is global.

setExtent(extent)

proj/Projection.js, line 239

Set the validity extent for this projection.

Name Type Description
extent module:ol/extent~Extent

Extent.

setGetPointResolution(func)

proj/Projection.js, line 260

Set the getPointResolution function (see module:ol/proj~getPointResolution for this projection.

Name Type Description
func function

Function

setGlobal(global)

proj/Projection.js, line 215

Set if the projection is a global projection which spans the whole world

Name Type Description
global boolean

Whether the projection is global.

setWorldExtent(worldExtent)

proj/Projection.js, line 250

Set the world extent for this projection.

Name Type Description
worldExtent module:ol/extent~Extent

World extent [minlon, minlat, maxlon, maxlat].