Add ol.geom.MultiPolygon#appendPolygon
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
@exportSymbol ol.geom.MultiPolygon
|
||||
@exportProperty ol.geom.MultiPolygon.prototype.appendPolygon
|
||||
@exportProperty ol.geom.MultiPolygon.prototype.clone
|
||||
@exportProperty ol.geom.MultiPolygon.prototype.getArea
|
||||
@exportProperty ol.geom.MultiPolygon.prototype.getCoordinates
|
||||
|
||||
@@ -72,6 +72,31 @@ ol.geom.MultiPolygon = function(coordinates, opt_layout) {
|
||||
goog.inherits(ol.geom.MultiPolygon, ol.geom.SimpleGeometry);
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.geom.Polygon} polygon Polygon.
|
||||
*/
|
||||
ol.geom.MultiPolygon.prototype.appendPolygon = function(polygon) {
|
||||
goog.asserts.assert(polygon.getLayout() == this.layout);
|
||||
/** @type {Array.<number>} */
|
||||
var ends;
|
||||
if (goog.isNull(this.flatCoordinates)) {
|
||||
this.flatCoordinates = polygon.getFlatCoordinates().slice();
|
||||
ends = polygon.getEnds().slice();
|
||||
this.endss_.push();
|
||||
} else {
|
||||
var offset = this.flatCoordinates.length;
|
||||
goog.array.extend(this.flatCoordinates, polygon.getFlatCoordinates());
|
||||
ends = polygon.getEnds().slice();
|
||||
var i, ii;
|
||||
for (i = 0, ii = ends.length; i < ii; ++i) {
|
||||
ends[i] += offset;
|
||||
}
|
||||
}
|
||||
this.endss_.push(ends);
|
||||
this.dispatchChangeEvent();
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user