Class: Projection

ol.proj.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 ol.proj namespace. You can use these in applications, but this is not required, as API params and options use ol.ProjectionLike which means the simple string code will suffice.

You can use 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(); see documentation. To set an alternative namespace for proj4, use ol.proj.setProj4.

new ol.proj.Projection(options)

src/ol/proj/projection.js, line 38
Name Type Description
options

Projection options.

Name Type Description
code string

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

units ol.proj.Units | string | undefined

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

extent ol.Extent | undefined

The validity extent for the SRS.

axisOrientation string | undefined

The axis orientation as specified in Proj4. The default is enu.

global boolean | undefined

Whether the projection is valid for the whole globe. Default is false.

metersPerUnit number | undefined

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

worldExtent ol.Extent | undefined

The world extent for the SRS.

getPointResolution function | undefined

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

Methods

getAxisOrientation(){string}

src/ol/proj/projection.js, line 202

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}

src/ol/proj/projection.js, line 144

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

Returns:
Code.

getExtent(){ol.Extent}

src/ol/proj/projection.js, line 154

Get the validity extent for this projection.

Returns:
Extent.

getMetersPerUnit(){number|undefined}

src/ol/proj/projection.js, line 176

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(){ol.proj.Units}

src/ol/proj/projection.js, line 164

Get the units of this projection.

Returns:
Units.

getWorldExtent(){ol.Extent}

src/ol/proj/projection.js, line 186

Get the world extent for this projection.

Returns:
Extent.

isGlobal(){boolean}

src/ol/proj/projection.js, line 212

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

Returns:
Whether the projection is global.

setExtent(extent)

src/ol/proj/projection.js, line 249

Set the validity extent for this projection.

Name Type Description
extent ol.Extent

Extent.

setGetPointResolution(func)

src/ol/proj/projection.js, line 272

Set the getPointResolution function (see ol.proj#getPointResolution for this projection.

Name Type Description
func function

Function

setGlobal(global)

src/ol/proj/projection.js, line 222

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)

src/ol/proj/projection.js, line 261

Set the world extent for this projection.

Name Type Description
worldExtent ol.Extent

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