Add a transform method to geometries
This accepts CRS identifiers for source and destination, transforms the geometry in place, and returns a reference to the geometry.
This commit is contained in:
@@ -4,6 +4,7 @@ goog.provide('ol.geom.GeometryType');
|
||||
goog.require('goog.asserts');
|
||||
goog.require('goog.functions');
|
||||
goog.require('ol.Observable');
|
||||
goog.require('ol.proj');
|
||||
|
||||
|
||||
/**
|
||||
@@ -166,6 +167,24 @@ ol.geom.Geometry.prototype.getType = goog.abstractMethod;
|
||||
ol.geom.Geometry.prototype.applyTransform = goog.abstractMethod;
|
||||
|
||||
|
||||
/**
|
||||
* Transform a geometry from one coordinate reference system to another.
|
||||
* Modifies the geometry in place.
|
||||
*
|
||||
* @param {ol.proj.ProjectionLike} source The current projection. Can be a
|
||||
* string identifier or a {@link ol.proj.Projection} object.
|
||||
* @param {ol.proj.ProjectionLike} destination The desired projection. Can be a
|
||||
* string identifier or a {@link ol.proj.Projection} object.
|
||||
* @return {ol.geom.Geometry} This geometry. Note that original geometry is
|
||||
* modified in place.
|
||||
* @todo api
|
||||
*/
|
||||
ol.geom.Geometry.prototype.transform = function(source, destination) {
|
||||
this.applyTransform(ol.proj.getTransform(source, destination));
|
||||
return this;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @typedef {ol.Coordinate}
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user