Add assert messages for all assertions up until ol.renderer.vector.
This commit is contained in:
@@ -140,7 +140,8 @@ ol.geom.Circle.prototype.getType = function() {
|
||||
*/
|
||||
ol.geom.Circle.prototype.setCenter = function(center) {
|
||||
var stride = this.stride;
|
||||
goog.asserts.assert(center.length == stride);
|
||||
goog.asserts.assert(center.length == stride,
|
||||
'center array length should match stride');
|
||||
var radius = this.flatCoordinates[stride] - this.flatCoordinates[0];
|
||||
var flatCoordinates = center.slice();
|
||||
flatCoordinates[stride] = flatCoordinates[0] + radius;
|
||||
@@ -199,7 +200,8 @@ ol.geom.Circle.prototype.setFlatCoordinates =
|
||||
* @api
|
||||
*/
|
||||
ol.geom.Circle.prototype.setRadius = function(radius) {
|
||||
goog.asserts.assert(!goog.isNull(this.flatCoordinates));
|
||||
goog.asserts.assert(!goog.isNull(this.flatCoordinates),
|
||||
'this.flatCoordinates cannot be null');
|
||||
this.flatCoordinates[this.stride] = this.flatCoordinates[0] + radius;
|
||||
this.changed();
|
||||
};
|
||||
|
||||
@@ -153,7 +153,7 @@ ol.geom.flat.closest.getClosestPoint = function(flatCoordinates, offset, end,
|
||||
return minSquaredDistance;
|
||||
}
|
||||
}
|
||||
goog.asserts.assert(maxDelta > 0);
|
||||
goog.asserts.assert(maxDelta > 0, 'maxDelta should be larger than 0');
|
||||
var tmpPoint = goog.isDef(opt_tmpPoint) ? opt_tmpPoint : [NaN, NaN];
|
||||
var index = offset + stride;
|
||||
while (index < end) {
|
||||
|
||||
@@ -67,7 +67,7 @@ ol.geom.flat.contains.linearRingContainsXY =
|
||||
*/
|
||||
ol.geom.flat.contains.linearRingsContainsXY =
|
||||
function(flatCoordinates, offset, ends, stride, x, y) {
|
||||
goog.asserts.assert(ends.length > 0);
|
||||
goog.asserts.assert(ends.length > 0, 'ends should not be an empty array');
|
||||
if (ends.length === 0) {
|
||||
return false;
|
||||
}
|
||||
@@ -97,7 +97,7 @@ ol.geom.flat.contains.linearRingsContainsXY =
|
||||
*/
|
||||
ol.geom.flat.contains.linearRingssContainsXY =
|
||||
function(flatCoordinates, offset, endss, stride, x, y) {
|
||||
goog.asserts.assert(endss.length > 0);
|
||||
goog.asserts.assert(endss.length > 0, 'endss should not be an empty array');
|
||||
if (endss.length === 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -12,7 +12,8 @@ goog.require('goog.asserts');
|
||||
*/
|
||||
ol.geom.flat.deflate.coordinate =
|
||||
function(flatCoordinates, offset, coordinate, stride) {
|
||||
goog.asserts.assert(coordinate.length == stride);
|
||||
goog.asserts.assert(coordinate.length == stride,
|
||||
'length of the coordinate array should match stride');
|
||||
var i, ii;
|
||||
for (i = 0, ii = coordinate.length; i < ii; ++i) {
|
||||
flatCoordinates[offset++] = coordinate[i];
|
||||
@@ -33,7 +34,8 @@ ol.geom.flat.deflate.coordinates =
|
||||
var i, ii;
|
||||
for (i = 0, ii = coordinates.length; i < ii; ++i) {
|
||||
var coordinate = coordinates[i];
|
||||
goog.asserts.assert(coordinate.length == stride);
|
||||
goog.asserts.assert(coordinate.length == stride,
|
||||
'length of coordinate array should match stride');
|
||||
var j;
|
||||
for (j = 0; j < stride; ++j) {
|
||||
flatCoordinates[offset++] = coordinate[j];
|
||||
|
||||
@@ -19,7 +19,8 @@ ol.geom.flat.flip.flipXY =
|
||||
dest = opt_dest;
|
||||
destOffset = goog.isDef(opt_destOffset) ? opt_destOffset : 0;
|
||||
} else {
|
||||
goog.asserts.assert(!goog.isDef(opt_destOffset));
|
||||
goog.asserts.assert(!goog.isDef(opt_destOffset),
|
||||
'opt_destOffSet should be defined');
|
||||
dest = [];
|
||||
destOffset = 0;
|
||||
}
|
||||
|
||||
@@ -69,7 +69,8 @@ ol.geom.flat.geodesic.line_ =
|
||||
// segment.
|
||||
flatCoordinates.push(b[0], b[1]);
|
||||
key = fracB.toString();
|
||||
goog.asserts.assert(!goog.object.containsKey(fractions, key));
|
||||
goog.asserts.assert(!goog.object.containsKey(fractions, key),
|
||||
'fractions object should contain key : ' + key);
|
||||
fractions[key] = true;
|
||||
} else {
|
||||
// Otherwise, we need to subdivide the current line segment. Split it
|
||||
@@ -79,7 +80,8 @@ ol.geom.flat.geodesic.line_ =
|
||||
geoStack.push(geoB, geoM, geoM, geoA);
|
||||
}
|
||||
}
|
||||
goog.asserts.assert(maxIterations > 0);
|
||||
goog.asserts.assert(maxIterations > 0,
|
||||
'maxIterations should be more than 0');
|
||||
|
||||
return flatCoordinates;
|
||||
};
|
||||
|
||||
@@ -79,7 +79,8 @@ ol.geom.flat.interiorpoint.linearRings = function(flatCoordinates, offset,
|
||||
*/
|
||||
ol.geom.flat.interiorpoint.linearRingss =
|
||||
function(flatCoordinates, offset, endss, stride, flatCenters) {
|
||||
goog.asserts.assert(2 * endss.length == flatCenters.length);
|
||||
goog.asserts.assert(2 * endss.length == flatCenters.length,
|
||||
'endss.length times 2 should be flatCenters.length');
|
||||
var interiorPoints = [];
|
||||
var i, ii;
|
||||
for (i = 0, ii = endss.length; i < ii; ++i) {
|
||||
|
||||
@@ -17,12 +17,13 @@ goog.require('goog.math');
|
||||
ol.geom.flat.interpolate.lineString =
|
||||
function(flatCoordinates, offset, end, stride, fraction, opt_dest) {
|
||||
// FIXME interpolate extra dimensions
|
||||
goog.asserts.assert(0 <= fraction && fraction <= 1);
|
||||
goog.asserts.assert(0 <= fraction && fraction <= 1,
|
||||
'fraction should be in between 0 and 1');
|
||||
var pointX = NaN;
|
||||
var pointY = NaN;
|
||||
var n = (end - offset) / stride;
|
||||
if (n === 0) {
|
||||
goog.asserts.fail();
|
||||
goog.asserts.fail('n cannot be 0');
|
||||
} else if (n == 1) {
|
||||
pointX = flatCoordinates[offset];
|
||||
pointY = flatCoordinates[offset + 1];
|
||||
@@ -121,8 +122,8 @@ ol.geom.flat.lineStringCoordinateAtM =
|
||||
return flatCoordinates.slice((lo - 1) * stride, (lo - 1) * stride + stride);
|
||||
}
|
||||
var m1 = flatCoordinates[(lo + 1) * stride - 1];
|
||||
goog.asserts.assert(m0 < m);
|
||||
goog.asserts.assert(m <= m1);
|
||||
goog.asserts.assert(m0 < m, 'm0 should be less than m');
|
||||
goog.asserts.assert(m <= m1, 'm should be less than or equal to m1');
|
||||
var t = (m - m0) / (m1 - m0);
|
||||
coordinate = [];
|
||||
var i;
|
||||
@@ -131,7 +132,8 @@ ol.geom.flat.lineStringCoordinateAtM =
|
||||
flatCoordinates[lo * stride + i], t));
|
||||
}
|
||||
coordinate.push(m);
|
||||
goog.asserts.assert(coordinate.length == stride);
|
||||
goog.asserts.assert(coordinate.length == stride,
|
||||
'length of coordinate array should match stride');
|
||||
return coordinate;
|
||||
};
|
||||
|
||||
@@ -185,6 +187,7 @@ ol.geom.flat.lineStringsCoordinateAtM = function(
|
||||
}
|
||||
offset = end;
|
||||
}
|
||||
goog.asserts.fail();
|
||||
goog.asserts.fail(
|
||||
'ol.geom.flat.lineStringsCoordinateAtM should have returned');
|
||||
return null;
|
||||
};
|
||||
|
||||
@@ -111,7 +111,7 @@ ol.geom.flat.intersectsextent.linearRing =
|
||||
*/
|
||||
ol.geom.flat.intersectsextent.linearRings =
|
||||
function(flatCoordinates, offset, ends, stride, extent) {
|
||||
goog.asserts.assert(ends.length > 0);
|
||||
goog.asserts.assert(ends.length > 0, 'ends should not be an empty array');
|
||||
if (!ol.geom.flat.intersectsextent.linearRing(
|
||||
flatCoordinates, offset, ends[0], stride, extent)) {
|
||||
return false;
|
||||
@@ -140,7 +140,7 @@ ol.geom.flat.intersectsextent.linearRings =
|
||||
*/
|
||||
ol.geom.flat.intersectsextent.linearRingss =
|
||||
function(flatCoordinates, offset, endss, stride, extent) {
|
||||
goog.asserts.assert(endss.length > 0);
|
||||
goog.asserts.assert(endss.length > 0, 'endss should not be an empty array');
|
||||
var i, ii;
|
||||
for (i = 0, ii = endss.length; i < ii; ++i) {
|
||||
var ends = endss[i];
|
||||
|
||||
@@ -66,7 +66,8 @@ goog.inherits(ol.geom.LineString, ol.geom.SimpleGeometry);
|
||||
* @api stable
|
||||
*/
|
||||
ol.geom.LineString.prototype.appendCoordinate = function(coordinate) {
|
||||
goog.asserts.assert(coordinate.length == this.stride);
|
||||
goog.asserts.assert(coordinate.length == this.stride,
|
||||
'length of coordinate array should match stride');
|
||||
if (goog.isNull(this.flatCoordinates)) {
|
||||
this.flatCoordinates = coordinate.slice();
|
||||
} else {
|
||||
|
||||
@@ -59,7 +59,8 @@ goog.inherits(ol.geom.MultiLineString, ol.geom.SimpleGeometry);
|
||||
* @api stable
|
||||
*/
|
||||
ol.geom.MultiLineString.prototype.appendLineString = function(lineString) {
|
||||
goog.asserts.assert(lineString.getLayout() == this.layout);
|
||||
goog.asserts.assert(lineString.getLayout() == this.layout,
|
||||
'layout of lineString should match the layout');
|
||||
if (goog.isNull(this.flatCoordinates)) {
|
||||
this.flatCoordinates = lineString.getFlatCoordinates().slice();
|
||||
} else {
|
||||
@@ -164,7 +165,8 @@ ol.geom.MultiLineString.prototype.getEnds = function() {
|
||||
* @api stable
|
||||
*/
|
||||
ol.geom.MultiLineString.prototype.getLineString = function(index) {
|
||||
goog.asserts.assert(0 <= index && index < this.ends_.length);
|
||||
goog.asserts.assert(0 <= index && index < this.ends_.length,
|
||||
'index should be in between 0 and length of the this.ends_ array');
|
||||
if (index < 0 || this.ends_.length <= index) {
|
||||
return null;
|
||||
}
|
||||
@@ -285,11 +287,14 @@ ol.geom.MultiLineString.prototype.setCoordinates =
|
||||
ol.geom.MultiLineString.prototype.setFlatCoordinates =
|
||||
function(layout, flatCoordinates, ends) {
|
||||
if (goog.isNull(flatCoordinates)) {
|
||||
goog.asserts.assert(!goog.isNull(ends) && ends.length === 0);
|
||||
goog.asserts.assert(!goog.isNull(ends) && ends.length === 0,
|
||||
'ends cannot be null and ends.length should be 0');
|
||||
} else if (ends.length === 0) {
|
||||
goog.asserts.assert(flatCoordinates.length === 0);
|
||||
goog.asserts.assert(flatCoordinates.length === 0,
|
||||
'flatCoordinates should be an empty array');
|
||||
} else {
|
||||
goog.asserts.assert(flatCoordinates.length == ends[ends.length - 1]);
|
||||
goog.asserts.assert(flatCoordinates.length == ends[ends.length - 1],
|
||||
'length of flatCoordinates array should match the last value of ends');
|
||||
}
|
||||
this.setFlatCoordinatesInternal(layout, flatCoordinates);
|
||||
this.ends_ = ends;
|
||||
@@ -311,7 +316,8 @@ ol.geom.MultiLineString.prototype.setLineStrings = function(lineStrings) {
|
||||
layout = lineString.getLayout();
|
||||
} else {
|
||||
// FIXME better handle the case of non-matching layouts
|
||||
goog.asserts.assert(lineString.getLayout() == layout);
|
||||
goog.asserts.assert(lineString.getLayout() == layout,
|
||||
'layout of lineString should match layout');
|
||||
}
|
||||
goog.array.extend(flatCoordinates, lineString.getFlatCoordinates());
|
||||
ends.push(flatCoordinates.length);
|
||||
|
||||
@@ -35,7 +35,8 @@ goog.inherits(ol.geom.MultiPoint, ol.geom.SimpleGeometry);
|
||||
* @api stable
|
||||
*/
|
||||
ol.geom.MultiPoint.prototype.appendPoint = function(point) {
|
||||
goog.asserts.assert(point.getLayout() == this.layout);
|
||||
goog.asserts.assert(point.getLayout() == this.layout,
|
||||
'the layout of point should match layout');
|
||||
if (goog.isNull(this.flatCoordinates)) {
|
||||
this.flatCoordinates = point.getFlatCoordinates().slice();
|
||||
} else {
|
||||
@@ -102,7 +103,8 @@ ol.geom.MultiPoint.prototype.getCoordinates = function() {
|
||||
ol.geom.MultiPoint.prototype.getPoint = function(index) {
|
||||
var n = goog.isNull(this.flatCoordinates) ?
|
||||
0 : this.flatCoordinates.length / this.stride;
|
||||
goog.asserts.assert(0 <= index && index < n);
|
||||
goog.asserts.assert(0 <= index && index < n,
|
||||
'index should be in between 0 and n');
|
||||
if (index < 0 || n <= index) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -88,7 +88,8 @@ goog.inherits(ol.geom.MultiPolygon, ol.geom.SimpleGeometry);
|
||||
* @api stable
|
||||
*/
|
||||
ol.geom.MultiPolygon.prototype.appendPolygon = function(polygon) {
|
||||
goog.asserts.assert(polygon.getLayout() == this.layout);
|
||||
goog.asserts.assert(polygon.getLayout() == this.layout,
|
||||
'layout of polygon should match layout');
|
||||
/** @type {Array.<number>} */
|
||||
var ends;
|
||||
if (goog.isNull(this.flatCoordinates)) {
|
||||
@@ -270,7 +271,8 @@ ol.geom.MultiPolygon.prototype.getSimplifiedGeometryInternal =
|
||||
* @api stable
|
||||
*/
|
||||
ol.geom.MultiPolygon.prototype.getPolygon = function(index) {
|
||||
goog.asserts.assert(0 <= index && index < this.endss_.length);
|
||||
goog.asserts.assert(0 <= index && index < this.endss_.length,
|
||||
'index should be in between 0 and the length of this.endss_');
|
||||
if (index < 0 || this.endss_.length <= index) {
|
||||
return null;
|
||||
}
|
||||
@@ -379,13 +381,14 @@ ol.geom.MultiPolygon.prototype.setCoordinates =
|
||||
*/
|
||||
ol.geom.MultiPolygon.prototype.setFlatCoordinates =
|
||||
function(layout, flatCoordinates, endss) {
|
||||
goog.asserts.assert(!goog.isNull(endss));
|
||||
goog.asserts.assert(!goog.isNull(endss), 'endss cannot be null');
|
||||
if (goog.isNull(flatCoordinates) || flatCoordinates.length === 0) {
|
||||
goog.asserts.assert(endss.length === 0);
|
||||
goog.asserts.assert(endss.length === 0, 'the length of endss should be 0');
|
||||
} else {
|
||||
goog.asserts.assert(endss.length > 0);
|
||||
goog.asserts.assert(endss.length > 0, 'endss cannot be an empty array');
|
||||
var ends = endss[endss.length - 1];
|
||||
goog.asserts.assert(flatCoordinates.length == ends[ends.length - 1]);
|
||||
goog.asserts.assert(flatCoordinates.length == ends[ends.length - 1],
|
||||
'the length of flatCoordinates should be the last value of ends');
|
||||
}
|
||||
this.setFlatCoordinatesInternal(layout, flatCoordinates);
|
||||
this.endss_ = endss;
|
||||
@@ -407,7 +410,8 @@ ol.geom.MultiPolygon.prototype.setPolygons = function(polygons) {
|
||||
layout = polygon.getLayout();
|
||||
} else {
|
||||
// FIXME better handle the case of non-matching layouts
|
||||
goog.asserts.assert(polygon.getLayout() == layout);
|
||||
goog.asserts.assert(polygon.getLayout() == layout,
|
||||
'layout of polygon should be layout');
|
||||
}
|
||||
var offset = flatCoordinates.length;
|
||||
ends = polygon.getEnds();
|
||||
|
||||
+10
-5
@@ -87,7 +87,8 @@ goog.inherits(ol.geom.Polygon, ol.geom.SimpleGeometry);
|
||||
* @api stable
|
||||
*/
|
||||
ol.geom.Polygon.prototype.appendLinearRing = function(linearRing) {
|
||||
goog.asserts.assert(linearRing.getLayout() == this.layout);
|
||||
goog.asserts.assert(linearRing.getLayout() == this.layout,
|
||||
'layout of linearRing should match layout');
|
||||
if (goog.isNull(this.flatCoordinates)) {
|
||||
this.flatCoordinates = linearRing.getFlatCoordinates().slice();
|
||||
} else {
|
||||
@@ -233,7 +234,8 @@ ol.geom.Polygon.prototype.getLinearRingCount = function() {
|
||||
* @api stable
|
||||
*/
|
||||
ol.geom.Polygon.prototype.getLinearRing = function(index) {
|
||||
goog.asserts.assert(0 <= index && index < this.ends_.length);
|
||||
goog.asserts.assert(0 <= index && index < this.ends_.length,
|
||||
'index should be in between 0 and and length of this.ends_');
|
||||
if (index < 0 || this.ends_.length <= index) {
|
||||
return null;
|
||||
}
|
||||
@@ -353,11 +355,14 @@ 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);
|
||||
goog.asserts.assert(!goog.isNull(ends) && ends.length === 0,
|
||||
'ends cannot be null and should be an empty array');
|
||||
} else if (ends.length === 0) {
|
||||
goog.asserts.assert(flatCoordinates.length === 0);
|
||||
goog.asserts.assert(flatCoordinates.length === 0,
|
||||
'flatCoordinates should be an empty array');
|
||||
} else {
|
||||
goog.asserts.assert(flatCoordinates.length == ends[ends.length - 1]);
|
||||
goog.asserts.assert(flatCoordinates.length == ends[ends.length - 1],
|
||||
'the length of flatCoordinates should be the last entry of ends');
|
||||
}
|
||||
this.setFlatCoordinatesInternal(layout, flatCoordinates);
|
||||
this.ends_ = ends;
|
||||
|
||||
Reference in New Issue
Block a user