Remove goog.isNull in geom classes

This commit is contained in:
Marc Jansen
2015-09-29 15:18:56 +02:00
parent eb5088eb40
commit 3c4e663224
10 changed files with 38 additions and 38 deletions

View File

@@ -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.<number>} */
@@ -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();
};

View File

@@ -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) {

View File

@@ -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(

View File

@@ -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(

View File

@@ -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');

View File

@@ -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(

View File

@@ -95,7 +95,7 @@ ol.geom.MultiPolygon.prototype.appendPolygon = function(polygon) {
'layout of polygon should match layout');
/** @type {Array.<number>} */
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');

View File

@@ -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(

View File

@@ -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');

View File

@@ -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();