Check arguments passed to ol.geom.Polygon#setFlatCoordinates

This commit is contained in:
Tom Payne
2014-03-10 15:01:40 +01:00
parent 6cadc2b9ab
commit 23dc855c2f

View File

@@ -1,5 +1,6 @@
goog.provide('ol.geom.Polygon');
goog.require('goog.asserts');
goog.require('ol.extent');
goog.require('ol.geom.GeometryType');
goog.require('ol.geom.LinearRing');
@@ -257,6 +258,13 @@ ol.geom.Polygon.prototype.setCoordinates = function(coordinates, opt_layout) {
*/
ol.geom.Polygon.prototype.setFlatCoordinates =
function(layout, flatCoordinates, ends) {
if (goog.isNull(flatCoordinates)) {
goog.asserts.assert(!goog.isNull(ends) && ends.length === 0);
} else if (ends.length === 0) {
goog.asserts.assert(flatCoordinates.length === 0);
} else {
goog.asserts.assert(flatCoordinates.length == ends[ends.length - 1]);
}
this.setFlatCoordinatesInternal(layout, flatCoordinates);
this.ends_ = ends;
this.dispatchChangeEvent();