# OpenLayers.Projection

Class for coordinate transforms between coordinate systems. Depends on the proj4js library. If proj4js is not available, then this is just an empty stub.

Summary

OpenLayers.Projection | Class for coordinate transforms between coordinate systems.
Properties |
proj | {Object} Proj4js.Proj instance.
projCode | {String}
titleRegEx | {RegExp} regular expression to strip the title from a proj4js definition
Constructor |
OpenLayers.Projection | This class offers several methods for interacting with a wrapped pro4js projection object.
Functions and Properties |
getCode | Get the string SRS code.
getUnits | Get the units string for the projection -- returns null if proj4js is not available.
toString | Convert projection to string (getCode wrapper).
equals | Test equality of two projection instances.
destroy | Destroy projection object.
transforms | Transforms is an object, with from properties, each of which may have a to property.
addTransform | Set a custom transform method between two projections.
transform | Transform a point coordinate from one projection to another.
nullTransform |

### Properties

### proj

{Object} Proj4js.Proj instance.

### projCode

{String}

### titleRegEx

{RegExp} regular expression to strip the title from a proj4js definition

### Constructor

### OpenLayers.Projection

This class offers several methods for interacting with a wrapped pro4js projection object.

#### Parameters

projCode | {String} A string identifying the Well Known Identifier for the projection.
options | {Object} An optional object to set additional properties on the layer.

#### Returns

{OpenLayers.Projection} A projection object.

### Functions and Properties

### getCode

> getCode: function()

Get the string SRS code.

#### Returns

{String} The SRS code.

### getUnits

> getUnits: function()

Get the units string for the projection -- returns null if proj4js is not available.

#### Returns

{String} The units abbreviation.

### toString

> toString: function()

Convert projection to string (getCode wrapper).

#### Returns

{String} The projection code.

### equals

> equals: function( | projection | )

Test equality of two projection instances. Determines equality based soley on the projection code.

#### Returns

{Boolean} The two projections are equivalent.

### destroy

> destroy: function()

Destroy projection object.

### transforms

Transforms is an object, with from properties, each of which may have a to property. This allows you to define projections without requiring support for proj4js to be included.

This object has keys which correspond to a ‘source’ projection object. The keys should be strings, corresponding to the projection.getCode() value. Each source projection object should have a set of destination projection keys included in the object.

Each value in the destination object should be a transformation function, where the function is expected to be passed an object with a .x and a .y property. The function should return the object, with the .x and .y transformed according to the transformation function.

Note | Properties on this object should not be set directly. To add a transform method to this object, use the addTransform method. For an example of usage, see the OpenLayers.Layer.SphericalMercator file.

### addTransform

> OpenLayers.Projection.addTransform = function( | from,
> | to,
> | method | )

Set a custom transform method between two projections. Use this method in cases where the proj4js lib is not available or where custom projections need to be handled.

#### Parameters

from | {String} The code for the source projection
to | {String} the code for the destination projection
method | {Function} A function that takes a point as an argument and transforms that point from the source to the destination projection in place. The original point should be modified.

### transform

> OpenLayers.Projection.transform = function( | point,
> | source,
> | dest | )

Transform a point coordinate from one projection to another. Note that the input point is transformed in place.

#### Parameters

point | {OpenLayers.Geometry.Point | Object} An object with x and y properties representing coordinates in those dimensions.
source | {OpenLayers.Projection} Source map coordinate system
dest | {OpenLayers.Projection} Destination map coordinate system

#### Returns

point | {object} A transformed coordinate. The original point is modified.

### nullTransform

> OpenLayers.Projection.nullTransform = function( | point | )

A null transformation | useful for defining projection aliases when proj4js is not available:

>     OpenLayers.Projection.addTransform("EPSG:4326", "EPSG:3857",
>         OpenLayers.Layer.SphericalMercator.projectForward);
>     OpenLayers.Projection.addTransform("EPSG:3857", "EPSG:3857",
>         OpenLayers.Layer.SphericalMercator.projectInverse);
>     OpenLayers.Projection.addTransform("EPSG:3857", "EPSG:900913",
>         OpenLayers.Projection.nullTransform);
>     OpenLayers.Projection.addTransform("EPSG:900913", "EPSG:3857",
>         OpenLayers.Projection.nullTransform);

> getCode: function()

Get the string SRS code.

> getUnits: function()

Get the units string for the projection -- returns null if proj4js is not available.

> toString: function()

Convert projection to string (getCode wrapper).

> equals: function( | projection | )

Test equality of two projection instances.

> destroy: function()

Destroy projection object.

> OpenLayers.Projection.addTransform = function( | from,
> | to,
> | method | )

Set a custom transform method between two projections.

> OpenLayers.Projection.transform = function( | point,
> | source,
> | dest | )

Transform a point coordinate from one projection to another.

> OpenLayers.Projection.nullTransform = function( | point | )

This class offers several methods for interacting with a wrapped pro4js projection object.
Point geometry class.
Close