Remove unnecessary goog.isDefAndNotNull() calls
This commit is contained in:
@@ -60,15 +60,15 @@ ol.format.EsriJSON.readGeometry_ = function(object, opt_options) {
|
||||
var type;
|
||||
if (goog.isNumber(object.x) && goog.isNumber(object.y)) {
|
||||
type = ol.geom.GeometryType.POINT;
|
||||
} else if (goog.isDefAndNotNull(object.points)) {
|
||||
} else if (object.points) {
|
||||
type = ol.geom.GeometryType.MULTI_POINT;
|
||||
} else if (goog.isDefAndNotNull(object.paths)) {
|
||||
} else if (object.paths) {
|
||||
if (object.paths.length === 1) {
|
||||
type = ol.geom.GeometryType.LINE_STRING;
|
||||
} else {
|
||||
type = ol.geom.GeometryType.MULTI_LINE_STRING;
|
||||
}
|
||||
} else if (goog.isDefAndNotNull(object.rings)) {
|
||||
} else if (object.rings) {
|
||||
var layout = ol.format.EsriJSON.getGeometryLayout_(object);
|
||||
var rings = ol.format.EsriJSON.convertRings_(object.rings, layout);
|
||||
object = /** @type {EsriJSONGeometry} */(goog.object.clone(object));
|
||||
@@ -149,13 +149,13 @@ ol.format.EsriJSON.readPointGeometry_ = function(object) {
|
||||
goog.asserts.assert(goog.isNumber(object.x), 'object.x should be number');
|
||||
goog.asserts.assert(goog.isNumber(object.y), 'object.y should be number');
|
||||
var point;
|
||||
if (goog.isDefAndNotNull(object.m) && goog.isDefAndNotNull(object.z)) {
|
||||
if (object.m !== undefined && object.z !== undefined) {
|
||||
point = new ol.geom.Point([object.x, object.y, object.z, object.m],
|
||||
ol.geom.GeometryLayout.XYZM);
|
||||
} else if (goog.isDefAndNotNull(object.z)) {
|
||||
} else if (object.z !== undefined) {
|
||||
point = new ol.geom.Point([object.x, object.y, object.z],
|
||||
ol.geom.GeometryLayout.XYZ);
|
||||
} else if (goog.isDefAndNotNull(object.m)) {
|
||||
} else if (object.m !== undefined) {
|
||||
point = new ol.geom.Point([object.x, object.y, object.m],
|
||||
ol.geom.GeometryLayout.XYM);
|
||||
} else {
|
||||
@@ -219,8 +219,7 @@ ol.format.EsriJSON.getGeometryLayout_ = function(object) {
|
||||
* @return {ol.geom.Geometry} MultiPoint.
|
||||
*/
|
||||
ol.format.EsriJSON.readMultiPointGeometry_ = function(object) {
|
||||
goog.asserts.assert(goog.isDefAndNotNull(object.points),
|
||||
'object.points should be defined');
|
||||
goog.asserts.assert(object.points, 'object.points should be defined');
|
||||
var layout = ol.format.EsriJSON.getGeometryLayout_(object);
|
||||
return new ol.geom.MultiPoint(object.points, layout);
|
||||
};
|
||||
@@ -232,7 +231,7 @@ ol.format.EsriJSON.readMultiPointGeometry_ = function(object) {
|
||||
* @return {ol.geom.Geometry} MultiPolygon.
|
||||
*/
|
||||
ol.format.EsriJSON.readMultiPolygonGeometry_ = function(object) {
|
||||
goog.asserts.assert(goog.isDefAndNotNull(object.rings));
|
||||
goog.asserts.assert(object.rings);
|
||||
goog.asserts.assert(object.rings.length > 1,
|
||||
'object.rings should have length larger than 1');
|
||||
var layout = ol.format.EsriJSON.getGeometryLayout_(object);
|
||||
@@ -248,7 +247,7 @@ ol.format.EsriJSON.readMultiPolygonGeometry_ = function(object) {
|
||||
* @return {ol.geom.Geometry} Polygon.
|
||||
*/
|
||||
ol.format.EsriJSON.readPolygonGeometry_ = function(object) {
|
||||
goog.asserts.assert(goog.isDefAndNotNull(object.rings));
|
||||
goog.asserts.assert(object.rings);
|
||||
var layout = ol.format.EsriJSON.getGeometryLayout_(object);
|
||||
return new ol.geom.Polygon(object.rings, layout);
|
||||
};
|
||||
@@ -483,10 +482,9 @@ ol.format.EsriJSON.prototype.readFeatures;
|
||||
ol.format.EsriJSON.prototype.readFeatureFromObject = function(
|
||||
object, opt_options) {
|
||||
var esriJSONFeature = /** @type {EsriJSONFeature} */ (object);
|
||||
goog.asserts.assert(goog.isDefAndNotNull(esriJSONFeature.geometry) ||
|
||||
goog.isDefAndNotNull(esriJSONFeature.compressedGeometry) ||
|
||||
goog.isDefAndNotNull(esriJSONFeature.attributes),
|
||||
'geometry, compressedGeometry or attributes should be defined');
|
||||
goog.asserts.assert(esriJSONFeature.geometry ||
|
||||
esriJSONFeature.attributes,
|
||||
'geometry or attributes should be defined');
|
||||
var geometry = ol.format.EsriJSON.readGeometry_(esriJSONFeature.geometry,
|
||||
opt_options);
|
||||
var feature = new ol.Feature();
|
||||
@@ -516,7 +514,7 @@ ol.format.EsriJSON.prototype.readFeaturesFromObject = function(
|
||||
object, opt_options) {
|
||||
var esriJSONObject = /** @type {EsriJSONObject} */ (object);
|
||||
var options = opt_options ? opt_options : {};
|
||||
if (goog.isDefAndNotNull(esriJSONObject.features)) {
|
||||
if (esriJSONObject.features) {
|
||||
var esriJSONFeatureCollection = /** @type {EsriJSONFeatureCollection} */
|
||||
(object);
|
||||
/** @type {Array.<ol.Feature>} */
|
||||
@@ -573,8 +571,7 @@ ol.format.EsriJSON.prototype.readProjection;
|
||||
*/
|
||||
ol.format.EsriJSON.prototype.readProjectionFromObject = function(object) {
|
||||
var esriJSONObject = /** @type {EsriJSONObject} */ (object);
|
||||
if (goog.isDefAndNotNull(esriJSONObject.spatialReference) &&
|
||||
goog.isDefAndNotNull(esriJSONObject.spatialReference.wkid)) {
|
||||
if (esriJSONObject.spatialReference && esriJSONObject.spatialReference.wkid) {
|
||||
var crs = esriJSONObject.spatialReference.wkid;
|
||||
return ol.proj.get('EPSG:' + crs);
|
||||
} else {
|
||||
|
||||
@@ -67,7 +67,7 @@ ol.format.Feature.prototype.adaptOptions = function(options) {
|
||||
if (options) {
|
||||
updatedOptions = {
|
||||
featureProjection: options.featureProjection,
|
||||
dataProjection: goog.isDefAndNotNull(options.dataProjection) ?
|
||||
dataProjection: options.dataProjection ?
|
||||
options.dataProjection : this.defaultDataProjection,
|
||||
rightHanded: options.rightHanded
|
||||
};
|
||||
|
||||
@@ -38,7 +38,7 @@ ol.format.GeoJSON = function(opt_options) {
|
||||
* @inheritDoc
|
||||
*/
|
||||
this.defaultDataProjection = ol.proj.get(
|
||||
goog.isDefAndNotNull(options.defaultDataProjection) ?
|
||||
options.defaultDataProjection ?
|
||||
options.defaultDataProjection : 'EPSG:4326');
|
||||
|
||||
|
||||
|
||||
@@ -804,7 +804,7 @@ ol.format.GML3.prototype.writeSurfaceOrPolygon_ =
|
||||
var context = objectStack[objectStack.length - 1];
|
||||
goog.asserts.assert(goog.isObject(context), 'context should be an Object');
|
||||
var srsName = context['srsName'];
|
||||
if (node.nodeName !== 'PolygonPatch' && goog.isDefAndNotNull(srsName)) {
|
||||
if (node.nodeName !== 'PolygonPatch' && srsName) {
|
||||
node.setAttribute('srsName', srsName);
|
||||
}
|
||||
if (node.nodeName === 'Polygon' || node.nodeName === 'PolygonPatch') {
|
||||
@@ -834,8 +834,7 @@ ol.format.GML3.prototype.writeCurveOrLineString_ =
|
||||
var context = objectStack[objectStack.length - 1];
|
||||
goog.asserts.assert(goog.isObject(context), 'context should be an Object');
|
||||
var srsName = context['srsName'];
|
||||
if (node.nodeName !== 'LineStringSegment' &&
|
||||
goog.isDefAndNotNull(srsName)) {
|
||||
if (node.nodeName !== 'LineStringSegment' && srsName) {
|
||||
node.setAttribute('srsName', srsName);
|
||||
}
|
||||
if (node.nodeName === 'LineString' ||
|
||||
|
||||
@@ -116,7 +116,7 @@ ol.format.GMLBase.prototype.readFeaturesInternal = function(node, objectStack) {
|
||||
var featureType = context['featureType'];
|
||||
var featureNS = context['featureNS'];
|
||||
var i, ii, prefix = 'p', defaultPrefix = 'p0';
|
||||
if (!featureType && goog.isDefAndNotNull(node.childNodes)) {
|
||||
if (!featureType && node.childNodes) {
|
||||
featureType = [], featureNS = {};
|
||||
for (i = 0, ii = node.childNodes.length; i < ii; ++i) {
|
||||
var child = node.childNodes[i];
|
||||
|
||||
@@ -394,7 +394,7 @@ ol.format.KML.readFlatCoordinates_ = function(node) {
|
||||
*/
|
||||
ol.format.KML.readStyleUrl_ = function(node) {
|
||||
var s = goog.string.trim(ol.xml.getAllTextContent(node, false));
|
||||
if (goog.isDefAndNotNull(node.baseURI)) {
|
||||
if (node.baseURI) {
|
||||
return goog.Uri.resolve(node.baseURI, s).toString();
|
||||
} else {
|
||||
return s;
|
||||
@@ -410,7 +410,7 @@ ol.format.KML.readStyleUrl_ = function(node) {
|
||||
*/
|
||||
ol.format.KML.readURI_ = function(node) {
|
||||
var s = ol.xml.getAllTextContent(node, false);
|
||||
if (goog.isDefAndNotNull(node.baseURI)) {
|
||||
if (node.baseURI) {
|
||||
return goog.Uri.resolve(node.baseURI, goog.string.trim(s)).toString();
|
||||
} else {
|
||||
return goog.string.trim(s);
|
||||
@@ -980,8 +980,7 @@ ol.format.KML.readPolygon_ = function(node, objectStack) {
|
||||
var flatLinearRings = ol.xml.pushParseAndPop(
|
||||
/** @type {Array.<Array.<number>>} */ ([null]),
|
||||
ol.format.KML.FLAT_LINEAR_RINGS_PARSERS_, node, objectStack);
|
||||
if (goog.isDefAndNotNull(flatLinearRings) &&
|
||||
!goog.isNull(flatLinearRings[0])) {
|
||||
if (flatLinearRings && !goog.isNull(flatLinearRings[0])) {
|
||||
var polygon = new ol.geom.Polygon(null);
|
||||
var flatCoordinates = flatLinearRings[0];
|
||||
var ends = [flatCoordinates.length];
|
||||
@@ -1721,7 +1720,7 @@ ol.format.KML.prototype.readSharedStyle_ = function(node, objectStack) {
|
||||
var style = ol.format.KML.readStyle_(node, objectStack);
|
||||
if (style) {
|
||||
var styleUri;
|
||||
if (goog.isDefAndNotNull(node.baseURI)) {
|
||||
if (node.baseURI) {
|
||||
styleUri = goog.Uri.resolve(node.baseURI, '#' + id).toString();
|
||||
} else {
|
||||
styleUri = '#' + id;
|
||||
@@ -1751,7 +1750,7 @@ ol.format.KML.prototype.readSharedStyleMap_ = function(node, objectStack) {
|
||||
return;
|
||||
}
|
||||
var styleUri;
|
||||
if (goog.isDefAndNotNull(node.baseURI)) {
|
||||
if (node.baseURI) {
|
||||
styleUri = goog.Uri.resolve(node.baseURI, '#' + id).toString();
|
||||
} else {
|
||||
styleUri = '#' + id;
|
||||
@@ -2267,7 +2266,7 @@ ol.format.KML.writePlacemark_ = function(node, feature, objectStack) {
|
||||
var /** @type {ol.xml.NodeStackItem} */ context = {node: node};
|
||||
|
||||
// set id
|
||||
if (goog.isDefAndNotNull(feature.getId())) {
|
||||
if (feature.getId()) {
|
||||
node.setAttribute('id', feature.getId());
|
||||
}
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ ol.format.TopoJSON = function(opt_options) {
|
||||
* @inheritDoc
|
||||
*/
|
||||
this.defaultDataProjection = ol.proj.get(
|
||||
goog.isDefAndNotNull(options.defaultDataProjection) ?
|
||||
options.defaultDataProjection ?
|
||||
options.defaultDataProjection : 'EPSG:4326');
|
||||
|
||||
};
|
||||
|
||||
@@ -475,7 +475,7 @@ ol.format.WFS.writeProperty_ = function(node, pair, objectStack) {
|
||||
var name = ol.xml.createElementNS('http://www.opengis.net/wfs', 'Name');
|
||||
node.appendChild(name);
|
||||
ol.format.XSD.writeStringTextNode(name, pair.name);
|
||||
if (goog.isDefAndNotNull(pair.value)) {
|
||||
if (pair.value !== undefined && pair.value !== null) {
|
||||
var value = ol.xml.createElementNS('http://www.opengis.net/wfs', 'Value');
|
||||
node.appendChild(value);
|
||||
if (pair.value instanceof ol.geom.Geometry) {
|
||||
@@ -768,8 +768,8 @@ ol.format.WFS.prototype.readProjectionFromNode = function(node) {
|
||||
goog.asserts.assert(node.localName == 'FeatureCollection',
|
||||
'localName should be FeatureCollection');
|
||||
|
||||
if (goog.isDefAndNotNull(node.firstElementChild) &&
|
||||
goog.isDefAndNotNull(node.firstElementChild.firstElementChild)) {
|
||||
if (node.firstElementChild &&
|
||||
node.firstElementChild.firstElementChild) {
|
||||
node = node.firstElementChild.firstElementChild;
|
||||
for (var n = node.firstElementChild; !goog.isNull(n);
|
||||
n = n.nextElementSibling) {
|
||||
|
||||
Reference in New Issue
Block a user