From 3c4e66322470a3b08b81c392f4e119fddba11e28 Mon Sep 17 00:00:00 2001 From: Marc Jansen Date: Tue, 29 Sep 2015 15:18:56 +0200 Subject: [PATCH] Remove goog.isNull in geom classes --- src/ol/geom/circle.js | 8 ++++---- src/ol/geom/geometrycollection.js | 4 ++-- src/ol/geom/linearring.js | 4 ++-- src/ol/geom/linestring.js | 6 +++--- src/ol/geom/multilinestring.js | 12 ++++++------ src/ol/geom/multipoint.js | 8 ++++---- src/ol/geom/multipolygon.js | 10 +++++----- src/ol/geom/point.js | 6 +++--- src/ol/geom/polygon.js | 12 ++++++------ src/ol/geom/simplegeometry.js | 6 +++--- 10 files changed, 38 insertions(+), 38 deletions(-) diff --git a/src/ol/geom/circle.js b/src/ol/geom/circle.js index 66eeb43c45..fd07b16a3a 100644 --- a/src/ol/geom/circle.js +++ b/src/ol/geom/circle.js @@ -189,11 +189,11 @@ ol.geom.Circle.prototype.setCenter = function(center) { */ ol.geom.Circle.prototype.setCenterAndRadius = function(center, radius, opt_layout) { - if (goog.isNull(center)) { + if (!center) { this.setFlatCoordinates(ol.geom.GeometryLayout.XY, null); } else { this.setLayout(opt_layout, center, 0); - if (goog.isNull(this.flatCoordinates)) { + if (!this.flatCoordinates) { this.flatCoordinates = []; } /** @type {Array.} */ @@ -228,8 +228,8 @@ ol.geom.Circle.prototype.setFlatCoordinates = * @api */ ol.geom.Circle.prototype.setRadius = function(radius) { - goog.asserts.assert(!goog.isNull(this.flatCoordinates), - 'this.flatCoordinates cannot be null'); + goog.asserts.assert(this.flatCoordinates, + 'truthy this.flatCoordinates expected'); this.flatCoordinates[this.stride] = this.flatCoordinates[0] + radius; this.changed(); }; diff --git a/src/ol/geom/geometrycollection.js b/src/ol/geom/geometrycollection.js index 548f389736..d81fd7a867 100644 --- a/src/ol/geom/geometrycollection.js +++ b/src/ol/geom/geometrycollection.js @@ -53,7 +53,7 @@ ol.geom.GeometryCollection.cloneGeometries_ = function(geometries) { */ ol.geom.GeometryCollection.prototype.unlistenGeometriesChange_ = function() { var i, ii; - if (goog.isNull(this.geometries_)) { + if (!this.geometries_) { return; } for (i = 0, ii = this.geometries_.length; i < ii; ++i) { @@ -69,7 +69,7 @@ ol.geom.GeometryCollection.prototype.unlistenGeometriesChange_ = function() { */ ol.geom.GeometryCollection.prototype.listenGeometriesChange_ = function() { var i, ii; - if (goog.isNull(this.geometries_)) { + if (!this.geometries_) { return; } for (i = 0, ii = this.geometries_.length; i < ii; ++i) { diff --git a/src/ol/geom/linearring.js b/src/ol/geom/linearring.js index ee9845648a..a78ad6439b 100644 --- a/src/ol/geom/linearring.js +++ b/src/ol/geom/linearring.js @@ -132,11 +132,11 @@ ol.geom.LinearRing.prototype.getType = function() { */ ol.geom.LinearRing.prototype.setCoordinates = function(coordinates, opt_layout) { - if (goog.isNull(coordinates)) { + if (!coordinates) { this.setFlatCoordinates(ol.geom.GeometryLayout.XY, null); } else { this.setLayout(opt_layout, coordinates, 1); - if (goog.isNull(this.flatCoordinates)) { + if (!this.flatCoordinates) { this.flatCoordinates = []; } this.flatCoordinates.length = ol.geom.flat.deflate.coordinates( diff --git a/src/ol/geom/linestring.js b/src/ol/geom/linestring.js index 68e596e5c2..39ac1fbc97 100644 --- a/src/ol/geom/linestring.js +++ b/src/ol/geom/linestring.js @@ -70,7 +70,7 @@ goog.inherits(ol.geom.LineString, ol.geom.SimpleGeometry); ol.geom.LineString.prototype.appendCoordinate = function(coordinate) { goog.asserts.assert(coordinate.length == this.stride, 'length of coordinate array should match stride'); - if (goog.isNull(this.flatCoordinates)) { + if (!this.flatCoordinates) { this.flatCoordinates = coordinate.slice(); } else { goog.array.extend(this.flatCoordinates, coordinate); @@ -235,11 +235,11 @@ ol.geom.LineString.prototype.intersectsExtent = function(extent) { */ ol.geom.LineString.prototype.setCoordinates = function(coordinates, opt_layout) { - if (goog.isNull(coordinates)) { + if (!coordinates) { this.setFlatCoordinates(ol.geom.GeometryLayout.XY, null); } else { this.setLayout(opt_layout, coordinates, 1); - if (goog.isNull(this.flatCoordinates)) { + if (!this.flatCoordinates) { this.flatCoordinates = []; } this.flatCoordinates.length = ol.geom.flat.deflate.coordinates( diff --git a/src/ol/geom/multilinestring.js b/src/ol/geom/multilinestring.js index a2d9dab185..f227330286 100644 --- a/src/ol/geom/multilinestring.js +++ b/src/ol/geom/multilinestring.js @@ -63,7 +63,7 @@ goog.inherits(ol.geom.MultiLineString, ol.geom.SimpleGeometry); ol.geom.MultiLineString.prototype.appendLineString = function(lineString) { goog.asserts.assert(lineString.getLayout() == this.layout, 'layout of lineString should match the layout'); - if (goog.isNull(this.flatCoordinates)) { + if (!this.flatCoordinates) { this.flatCoordinates = lineString.getFlatCoordinates().slice(); } else { goog.array.extend( @@ -270,11 +270,11 @@ ol.geom.MultiLineString.prototype.intersectsExtent = function(extent) { */ ol.geom.MultiLineString.prototype.setCoordinates = function(coordinates, opt_layout) { - if (goog.isNull(coordinates)) { + if (!coordinates) { this.setFlatCoordinates(ol.geom.GeometryLayout.XY, null, this.ends_); } else { this.setLayout(opt_layout, coordinates, 2); - if (goog.isNull(this.flatCoordinates)) { + if (!this.flatCoordinates) { this.flatCoordinates = []; } var ends = ol.geom.flat.deflate.coordinatess( @@ -292,9 +292,9 @@ 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, - 'ends cannot be null and ends.length should be 0'); + if (!flatCoordinates) { + goog.asserts.assert(ends && ends.length === 0, + 'ends must be truthy and ends.length should be 0'); } else if (ends.length === 0) { goog.asserts.assert(flatCoordinates.length === 0, 'flatCoordinates should be an empty array'); diff --git a/src/ol/geom/multipoint.js b/src/ol/geom/multipoint.js index ef1f0251b3..d559c72b4d 100644 --- a/src/ol/geom/multipoint.js +++ b/src/ol/geom/multipoint.js @@ -38,7 +38,7 @@ goog.inherits(ol.geom.MultiPoint, ol.geom.SimpleGeometry); ol.geom.MultiPoint.prototype.appendPoint = function(point) { goog.asserts.assert(point.getLayout() == this.layout, 'the layout of point should match layout'); - if (goog.isNull(this.flatCoordinates)) { + if (!this.flatCoordinates) { this.flatCoordinates = point.getFlatCoordinates().slice(); } else { goog.array.extend(this.flatCoordinates, point.getFlatCoordinates()); @@ -104,7 +104,7 @@ ol.geom.MultiPoint.prototype.getCoordinates = function() { * @api stable */ ol.geom.MultiPoint.prototype.getPoint = function(index) { - var n = goog.isNull(this.flatCoordinates) ? + var n = !this.flatCoordinates ? 0 : this.flatCoordinates.length / this.stride; goog.asserts.assert(0 <= index && index < n, 'index should be in between 0 and n'); @@ -175,11 +175,11 @@ ol.geom.MultiPoint.prototype.intersectsExtent = function(extent) { */ ol.geom.MultiPoint.prototype.setCoordinates = function(coordinates, opt_layout) { - if (goog.isNull(coordinates)) { + if (!coordinates) { this.setFlatCoordinates(ol.geom.GeometryLayout.XY, null); } else { this.setLayout(opt_layout, coordinates, 1); - if (goog.isNull(this.flatCoordinates)) { + if (!this.flatCoordinates) { this.flatCoordinates = []; } this.flatCoordinates.length = ol.geom.flat.deflate.coordinates( diff --git a/src/ol/geom/multipolygon.js b/src/ol/geom/multipolygon.js index 739f34cd5c..d166402045 100644 --- a/src/ol/geom/multipolygon.js +++ b/src/ol/geom/multipolygon.js @@ -95,7 +95,7 @@ ol.geom.MultiPolygon.prototype.appendPolygon = function(polygon) { 'layout of polygon should match layout'); /** @type {Array.} */ var ends; - if (goog.isNull(this.flatCoordinates)) { + if (!this.flatCoordinates) { this.flatCoordinates = polygon.getFlatCoordinates().slice(); ends = polygon.getEnds().slice(); this.endss_.push(); @@ -363,11 +363,11 @@ ol.geom.MultiPolygon.prototype.intersectsExtent = function(extent) { */ ol.geom.MultiPolygon.prototype.setCoordinates = function(coordinates, opt_layout) { - if (goog.isNull(coordinates)) { + if (!coordinates) { this.setFlatCoordinates(ol.geom.GeometryLayout.XY, null, this.endss_); } else { this.setLayout(opt_layout, coordinates, 3); - if (goog.isNull(this.flatCoordinates)) { + if (!this.flatCoordinates) { this.flatCoordinates = []; } var endss = ol.geom.flat.deflate.coordinatesss( @@ -391,8 +391,8 @@ ol.geom.MultiPolygon.prototype.setCoordinates = */ ol.geom.MultiPolygon.prototype.setFlatCoordinates = function(layout, flatCoordinates, endss) { - goog.asserts.assert(!goog.isNull(endss), 'endss cannot be null'); - if (goog.isNull(flatCoordinates) || flatCoordinates.length === 0) { + goog.asserts.assert(endss, 'endss must be truthy'); + if (!flatCoordinates || flatCoordinates.length === 0) { goog.asserts.assert(endss.length === 0, 'the length of endss should be 0'); } else { goog.asserts.assert(endss.length > 0, 'endss cannot be an empty array'); diff --git a/src/ol/geom/point.js b/src/ol/geom/point.js index 285ee4691d..862b5322df 100644 --- a/src/ol/geom/point.js +++ b/src/ol/geom/point.js @@ -66,7 +66,7 @@ ol.geom.Point.prototype.closestPointXY = * @api stable */ ol.geom.Point.prototype.getCoordinates = function() { - return goog.isNull(this.flatCoordinates) ? [] : this.flatCoordinates.slice(); + return !this.flatCoordinates ? [] : this.flatCoordinates.slice(); }; @@ -104,11 +104,11 @@ ol.geom.Point.prototype.intersectsExtent = function(extent) { * @api stable */ ol.geom.Point.prototype.setCoordinates = function(coordinates, opt_layout) { - if (goog.isNull(coordinates)) { + if (!coordinates) { this.setFlatCoordinates(ol.geom.GeometryLayout.XY, null); } else { this.setLayout(opt_layout, coordinates, 0); - if (goog.isNull(this.flatCoordinates)) { + if (!this.flatCoordinates) { this.flatCoordinates = []; } this.flatCoordinates.length = ol.geom.flat.deflate.coordinate( diff --git a/src/ol/geom/polygon.js b/src/ol/geom/polygon.js index bf23f93966..c72659fbe5 100644 --- a/src/ol/geom/polygon.js +++ b/src/ol/geom/polygon.js @@ -92,7 +92,7 @@ goog.inherits(ol.geom.Polygon, ol.geom.SimpleGeometry); ol.geom.Polygon.prototype.appendLinearRing = function(linearRing) { goog.asserts.assert(linearRing.getLayout() == this.layout, 'layout of linearRing should match layout'); - if (goog.isNull(this.flatCoordinates)) { + if (!this.flatCoordinates) { this.flatCoordinates = linearRing.getFlatCoordinates().slice(); } else { goog.array.extend(this.flatCoordinates, linearRing.getFlatCoordinates()); @@ -339,11 +339,11 @@ ol.geom.Polygon.prototype.intersectsExtent = function(extent) { * @api stable */ ol.geom.Polygon.prototype.setCoordinates = function(coordinates, opt_layout) { - if (goog.isNull(coordinates)) { + if (!coordinates) { this.setFlatCoordinates(ol.geom.GeometryLayout.XY, null, this.ends_); } else { this.setLayout(opt_layout, coordinates, 2); - if (goog.isNull(this.flatCoordinates)) { + if (!this.flatCoordinates) { this.flatCoordinates = []; } var ends = ol.geom.flat.deflate.coordinatess( @@ -361,9 +361,9 @@ 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, - 'ends cannot be null and should be an empty array'); + if (!flatCoordinates) { + goog.asserts.assert(ends && ends.length === 0, + 'ends must be an empty array'); } else if (ends.length === 0) { goog.asserts.assert(flatCoordinates.length === 0, 'flatCoordinates should be an empty array'); diff --git a/src/ol/geom/simplegeometry.js b/src/ol/geom/simplegeometry.js index 4da4b706ad..1ddb4e3c12 100644 --- a/src/ol/geom/simplegeometry.js +++ b/src/ol/geom/simplegeometry.js @@ -258,7 +258,7 @@ ol.geom.SimpleGeometry.prototype.setLayout = * @api stable */ ol.geom.SimpleGeometry.prototype.applyTransform = function(transformFn) { - if (!goog.isNull(this.flatCoordinates)) { + if (this.flatCoordinates) { transformFn(this.flatCoordinates, this.flatCoordinates, this.stride); this.changed(); } @@ -271,7 +271,7 @@ ol.geom.SimpleGeometry.prototype.applyTransform = function(transformFn) { */ ol.geom.SimpleGeometry.prototype.translate = function(deltaX, deltaY) { var flatCoordinates = this.getFlatCoordinates(); - if (!goog.isNull(flatCoordinates)) { + if (flatCoordinates) { var stride = this.getStride(); ol.geom.flat.transform.translate( flatCoordinates, 0, flatCoordinates.length, stride, @@ -290,7 +290,7 @@ ol.geom.SimpleGeometry.prototype.translate = function(deltaX, deltaY) { ol.geom.transformSimpleGeometry2D = function(simpleGeometry, transform, opt_dest) { var flatCoordinates = simpleGeometry.getFlatCoordinates(); - if (goog.isNull(flatCoordinates)) { + if (!flatCoordinates) { return null; } else { var stride = simpleGeometry.getStride();