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:
Tim Schaub
2014-05-02 11:47:59 -06:00
parent 1110da37e1
commit e448f100fd
4 changed files with 92 additions and 0 deletions

View File

@@ -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}
*/