Improve type checking with cast

This commit is contained in:
Tom Payne
2013-11-10 02:21:13 +01:00
parent b46c38626b
commit d10fb12f27
+2 -1
View File
@@ -151,6 +151,7 @@ ol.geom.Geometry.prototype.getType = goog.abstractMethod;
*/ */
ol.geom.Geometry.prototype.setLayout = ol.geom.Geometry.prototype.setLayout =
function(layout, coordinates, nesting) { function(layout, coordinates, nesting) {
/** @type {number} */
var stride; var stride;
if (goog.isDef(layout)) { if (goog.isDef(layout)) {
if (layout == ol.geom.Layout.XY) { if (layout == ol.geom.Layout.XY) {
@@ -175,7 +176,7 @@ ol.geom.Geometry.prototype.setLayout =
coordinates = coordinates[0]; coordinates = coordinates[0];
} }
} }
stride = coordinates.length; stride = (/** @type {Array} */ (coordinates)).length;
if (stride == 2) { if (stride == 2) {
layout = ol.geom.Layout.XY; layout = ol.geom.Layout.XY;
} else if (stride == 3) { } else if (stride == 3) {