Add ol.geom.Geometry#transform

This commit is contained in:
Tom Payne
2013-11-09 01:49:17 +01:00
parent 5bca792288
commit e4623af4df
5 changed files with 74 additions and 0 deletions

View File

@@ -114,3 +114,9 @@ ol.geom.Geometry.prototype.getStride = function() {
* @return {ol.geom.GeometryType} Geometry type.
*/
ol.geom.Geometry.prototype.getType = goog.abstractMethod;
/**
* @param {ol.TransformFunction} transformFn Transform.
*/
ol.geom.Geometry.prototype.transform = goog.abstractMethod;

View File

@@ -62,3 +62,16 @@ ol.geom.LineString.prototype.setCoordinates = function(coordinates) {
this.coordinates_ = coordinates;
this.dispatchChangeEvent();
};
/**
* @inheritDoc
*/
ol.geom.LineString.prototype.transform = function(transformFn) {
var coordinates = this.coordinates_;
var i, ii;
for (i = 0, ii = coordinates.length; i < ii; ++i) {
var coordinate = coordinates[i];
transformFn(coordinate, coordinate, 2);
}
};

View File

@@ -65,3 +65,20 @@ ol.geom.MultiLineString.prototype.getType = function() {
ol.geom.MultiLineString.prototype.setCoordinatess = function(coordinatess) {
this.coordinatess_ = coordinatess;
};
/**
* @inheritDoc
*/
ol.geom.MultiLineString.prototype.transform = function(transformFn) {
var coordinatess = this.coordinatess_;
var i, ii;
for (i = 0, ii = coordinatess.length; i < ii; ++i) {
var coordinates = coordinatess[i];
var j, jj;
for (j = 0, jj = coordinates.length; j < jj; ++j) {
var coordinate = coordinates[j];
transformFn(coordinate, coordinate, 2);
}
}
};

View File

@@ -65,3 +65,24 @@ ol.geom.MultiPolygon.prototype.setRingss = function(ringss) {
this.ringss_ = ringss;
this.dispatchChangeEvent();
};
/**
* @inheritDoc
*/
ol.geom.MultiPolygon.prototype.transform = function(transformFn) {
var ringss = this.ringss_;
var i, ii;
for (i = 0, ii = ringss.length; i < ii; ++i) {
var rings = ringss[i];
var j, jj;
for (j = 0, jj = rings.length; j < jj; ++j) {
var coordinates = rings[j];
var k, kk;
for (k = 0, kk = coordinates.length; k < kk; ++k) {
var coordinate = coordinates[k];
transformFn(coordinate, coordinate, 2);
}
}
}
};

View File

@@ -61,3 +61,20 @@ ol.geom.Polygon.prototype.setRings = function(rings) {
this.rings_ = rings;
this.dispatchChangeEvent();
};
/**
* @inheritDoc
*/
ol.geom.Polygon.prototype.transform = function(transformFn) {
var rings = this.rings_;
var i, ii;
for (i = 0, ii = rings.length; i < ii; ++i) {
var coordinates = rings[i];
var j, jj;
for (j = 0, jj = coordinates.length; j < jj; ++j) {
var coordinate = coordinates[j];
transformFn(coordinate, coordinate, 2);
}
}
};