Geometries inherit from ol.Observable

Because ol.Observable is now a struct, we have stricter type checking (hence the extra assertions).
This commit is contained in:
Tim Schaub
2013-12-13 14:18:10 -07:00
parent f1efb502ca
commit 5caa0eb659
5 changed files with 28 additions and 9 deletions
@@ -274,6 +274,7 @@ ol.renderer.canvas.Vector.prototype.renderPointFeatures_ =
}
for (j = 0, jj = components.length; j < jj; ++j) {
point = components[j];
goog.asserts.assertInstanceof(point, ol.geom.Point);
vec = [point.get(0), point.get(1), 0];
goog.vec.Mat4.multVec3(this.transform_, vec, vec);
context.drawImage(content, Math.round(vec[0] + xOffset),
@@ -406,6 +407,7 @@ ol.renderer.canvas.Vector.prototype.renderPolygonFeatures_ =
}
for (j = 0, jj = components.length; j < jj; ++j) {
poly = components[j];
goog.asserts.assertInstanceof(poly, ol.geom.Polygon);
rings = poly.getRings();
numRings = rings.length;
if (numRings > 0) {
@@ -537,9 +539,11 @@ ol.renderer.canvas.Vector.getLabelVectors = function(geometry) {
}
var type = geometry.getType();
if (type == ol.geom.GeometryType.POINT) {
goog.asserts.assertInstanceof(geometry, ol.geom.Point);
return [[geometry.get(0), geometry.get(1), 0]];
}
if (type == ol.geom.GeometryType.POLYGON) {
goog.asserts.assertInstanceof(geometry, ol.geom.Polygon);
var coordinates = geometry.getInteriorPoint();
return [[coordinates[0], coordinates[1], 0]];
}