Remove goog.isDef from more formats

This commit is contained in:
Tim Schaub
2015-09-21 06:32:20 +09:00
parent b0fe36e609
commit d7ca176362
10 changed files with 99 additions and 98 deletions

View File

@@ -1914,6 +1914,8 @@ olx.format.WFSOptions.prototype.schemaLocation;
* maxFeatures: (number|undefined),
* geometryName: (string|undefined),
* propertyNames: (Array.<string>|undefined),
* startIndex: (number|undefined),
* count: (number|undefined),
* bbox: (ol.Extent|undefined)}}
* @api
*/

View File

@@ -42,9 +42,9 @@ ol.format.Feature.prototype.getExtensions = goog.abstractMethod;
*/
ol.format.Feature.prototype.getReadOptions = function(source, opt_options) {
var options;
if (goog.isDef(opt_options)) {
if (opt_options) {
options = {
dataProjection: goog.isDef(opt_options.dataProjection) ?
dataProjection: opt_options.dataProjection ?
opt_options.dataProjection : this.readProjection(source),
featureProjection: opt_options.featureProjection
};
@@ -64,7 +64,7 @@ ol.format.Feature.prototype.getReadOptions = function(source, opt_options) {
*/
ol.format.Feature.prototype.adaptOptions = function(options) {
var updatedOptions;
if (goog.isDef(options)) {
if (options) {
updatedOptions = {
featureProjection: options.featureProjection,
dataProjection: goog.isDefAndNotNull(options.dataProjection) ?
@@ -161,9 +161,9 @@ ol.format.Feature.prototype.writeGeometry = goog.abstractMethod;
*/
ol.format.Feature.transformWithOptions = function(
geometry, write, opt_options) {
var featureProjection = goog.isDef(opt_options) ?
var featureProjection = opt_options ?
ol.proj.get(opt_options.featureProjection) : null;
var dataProjection = goog.isDef(opt_options) ?
var dataProjection = opt_options ?
ol.proj.get(opt_options.dataProjection) : null;
if (!goog.isNull(featureProjection) && !goog.isNull(dataProjection) &&
!ol.proj.equivalent(featureProjection, dataProjection)) {

View File

@@ -22,7 +22,7 @@ goog.require('ol.xml');
*/
ol.format.GML2 = function(opt_options) {
var options = /** @type {olx.format.GMLOptions} */
(goog.isDef(opt_options) ? opt_options : {});
(opt_options ? opt_options : {});
goog.base(this, options);
@@ -33,7 +33,7 @@ ol.format.GML2 = function(opt_options) {
/**
* @inheritDoc
*/
this.schemaLocation = goog.isDef(options.schemaLocation) ?
this.schemaLocation = options.schemaLocation ?
options.schemaLocation : ol.format.GML2.schemaLocation_;
};
@@ -127,7 +127,7 @@ ol.format.GML2.prototype.innerBoundaryIsParser_ =
var flatLinearRing = ol.xml.pushParseAndPop(
/** @type {Array.<number>|undefined} */ (undefined),
this.RING_PARSERS, node, objectStack, this);
if (goog.isDef(flatLinearRing)) {
if (flatLinearRing) {
var flatLinearRings = /** @type {Array.<Array.<number>>} */
(objectStack[objectStack.length - 1]);
goog.asserts.assert(goog.isArray(flatLinearRings),
@@ -153,7 +153,7 @@ ol.format.GML2.prototype.outerBoundaryIsParser_ =
var flatLinearRing = ol.xml.pushParseAndPop(
/** @type {Array.<number>|undefined} */ (undefined),
this.RING_PARSERS, node, objectStack, this);
if (goog.isDef(flatLinearRing)) {
if (flatLinearRing) {
var flatLinearRings = /** @type {Array.<Array.<number>>} */
(objectStack[objectStack.length - 1]);
goog.asserts.assert(goog.isArray(flatLinearRings),

View File

@@ -41,7 +41,7 @@ goog.require('ol.xml');
*/
ol.format.GMLBase = function(opt_options) {
var options = /** @type {olx.format.GMLOptions} */
(goog.isDef(opt_options) ? opt_options : {});
(opt_options ? opt_options : {});
/**
* @protected
@@ -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 (!goog.isDef(featureType) && goog.isDefAndNotNull(node.childNodes)) {
if (!featureType && goog.isDefAndNotNull(node.childNodes)) {
featureType = [], featureNS = {};
for (i = 0, ii = node.childNodes.length; i < ii; ++i) {
var child = node.childNodes[i];
@@ -162,7 +162,7 @@ ol.format.GMLBase.prototype.readFeaturesInternal = function(node, objectStack) {
}
features = ol.xml.pushParseAndPop([], parsersNS, node, objectStack);
}
if (!goog.isDef(features)) {
if (!features) {
features = [];
}
return features;
@@ -222,7 +222,7 @@ ol.format.GMLBase.prototype.readFeatureElement = function(node, objectStack) {
}
}
var feature = new ol.Feature(values);
if (goog.isDef(geometryName)) {
if (geometryName) {
feature.setGeometryName(geometryName);
}
if (fid) {
@@ -266,7 +266,7 @@ ol.format.GMLBase.prototype.readMultiPoint = function(node, objectStack) {
var coordinates = ol.xml.pushParseAndPop(
/** @type {Array.<Array.<number>>} */ ([]),
this.MULTIPOINT_PARSERS_, node, objectStack, this);
if (goog.isDef(coordinates)) {
if (coordinates) {
return new ol.geom.MultiPoint(coordinates);
} else {
return undefined;
@@ -287,7 +287,7 @@ ol.format.GMLBase.prototype.readMultiLineString = function(node, objectStack) {
var lineStrings = ol.xml.pushParseAndPop(
/** @type {Array.<ol.geom.LineString>} */ ([]),
this.MULTILINESTRING_PARSERS_, node, objectStack, this);
if (goog.isDef(lineStrings)) {
if (lineStrings) {
var multiLineString = new ol.geom.MultiLineString(null);
multiLineString.setLineStrings(lineStrings);
return multiLineString;
@@ -310,7 +310,7 @@ ol.format.GMLBase.prototype.readMultiPolygon = function(node, objectStack) {
var polygons = ol.xml.pushParseAndPop(
/** @type {Array.<ol.geom.Polygon>} */ ([]),
this.MULTIPOLYGON_PARSERS_, node, objectStack, this);
if (goog.isDef(polygons)) {
if (polygons) {
var multiPolygon = new ol.geom.MultiPolygon(null);
multiPolygon.setPolygons(polygons);
return multiPolygon;
@@ -426,7 +426,7 @@ ol.format.GMLBase.prototype.readLinearRing = function(node, objectStack) {
'localName should be LinearRing');
var flatCoordinates =
this.readFlatCoordinatesFromNode_(node, objectStack);
if (goog.isDef(flatCoordinates)) {
if (flatCoordinates) {
var ring = new ol.geom.LinearRing(null);
ring.setFlatCoordinates(ol.geom.GeometryLayout.XYZ, flatCoordinates);
return ring;
@@ -449,7 +449,7 @@ ol.format.GMLBase.prototype.readPolygon = function(node, objectStack) {
var flatLinearRings = ol.xml.pushParseAndPop(
/** @type {Array.<Array.<number>>} */ ([null]),
this.FLAT_LINEAR_RINGS_PARSERS_, node, objectStack, this);
if (goog.isDef(flatLinearRings) &&
if (flatLinearRings &&
!goog.isNull(flatLinearRings[0])) {
var polygon = new ol.geom.Polygon(null);
var flatCoordinates = flatLinearRings[0];
@@ -588,8 +588,8 @@ ol.format.GMLBase.prototype.RING_PARSERS = Object({
ol.format.GMLBase.prototype.readGeometryFromNode =
function(node, opt_options) {
var geometry = this.readGeometryElement(node,
[this.getReadOptions(node, goog.isDef(opt_options) ? opt_options : {})]);
return goog.isDef(geometry) ? geometry : null;
[this.getReadOptions(node, opt_options ? opt_options : {})]);
return geometry ? geometry : null;
};
@@ -614,7 +614,7 @@ ol.format.GMLBase.prototype.readFeaturesFromNode =
featureType: this.featureType,
featureNS: this.featureNS
};
if (goog.isDef(opt_options)) {
if (opt_options) {
goog.object.extend(options, this.getReadOptions(node, opt_options));
}
return this.readFeaturesInternal(node, [options]);
@@ -625,6 +625,6 @@ ol.format.GMLBase.prototype.readFeaturesFromNode =
* @inheritDoc
*/
ol.format.GMLBase.prototype.readProjectionFromNode = function(node) {
return ol.proj.get(goog.isDef(this.srsName_) ? this.srsName_ :
return ol.proj.get(this.srsName_ ? this.srsName_ :
node.firstElementChild.getAttribute('srsName'));
};

View File

@@ -3,6 +3,7 @@ goog.provide('ol.format.WFS');
goog.require('goog.asserts');
goog.require('goog.dom.NodeType');
goog.require('goog.object');
goog.require('ol');
goog.require('ol.format.GML3');
goog.require('ol.format.GMLBase');
goog.require('ol.format.XMLFeature');
@@ -27,7 +28,7 @@ goog.require('ol.xml');
* @api stable
*/
ol.format.WFS = function(opt_options) {
var options = goog.isDef(opt_options) ? opt_options : {};
var options = opt_options ? opt_options : {};
/**
* @private
@@ -45,14 +46,14 @@ ol.format.WFS = function(opt_options) {
* @private
* @type {ol.format.GMLBase}
*/
this.gmlFormat_ = goog.isDef(options.gmlFormat) ?
this.gmlFormat_ = options.gmlFormat ?
options.gmlFormat : new ol.format.GML3();
/**
* @private
* @type {string}
*/
this.schemaLocation_ = goog.isDef(options.schemaLocation) ?
this.schemaLocation_ = options.schemaLocation ?
options.schemaLocation : ol.format.WFS.SCHEMA_LOCATION;
goog.base(this);
@@ -123,7 +124,7 @@ ol.format.WFS.prototype.readFeaturesFromNode = function(node, opt_options) {
'featureNS': this.featureNS_
};
goog.object.extend(context, this.getReadOptions(node,
goog.isDef(opt_options) ? opt_options : {}));
opt_options ? opt_options : {}));
var objectStack = [context];
this.gmlFormat_.FEATURE_COLLECTION_PARSERS[ol.format.GMLBase.GMLNS][
'featureMember'] =
@@ -131,7 +132,7 @@ ol.format.WFS.prototype.readFeaturesFromNode = function(node, opt_options) {
var features = ol.xml.pushParseAndPop([],
this.gmlFormat_.FEATURE_COLLECTION_PARSERS, node,
objectStack, this.gmlFormat_);
if (!goog.isDef(features)) {
if (!features) {
features = [];
}
return features;
@@ -414,14 +415,14 @@ ol.format.WFS.writeDelete_ = function(node, feature, objectStack) {
goog.asserts.assert(goog.isObject(context), 'context should be an Object');
var featureType = context['featureType'];
var featurePrefix = context['featurePrefix'];
featurePrefix = goog.isDef(featurePrefix) ? featurePrefix :
featurePrefix = featurePrefix ? featurePrefix :
ol.format.WFS.FEATURE_PREFIX;
var featureNS = context['featureNS'];
node.setAttribute('typeName', featurePrefix + ':' + featureType);
ol.xml.setAttributeNS(node, ol.format.WFS.XMLNS, 'xmlns:' + featurePrefix,
featureNS);
var fid = feature.getId();
if (goog.isDef(fid)) {
if (fid) {
ol.format.WFS.writeOgcFidFilter_(node, fid, objectStack);
}
};
@@ -438,19 +439,19 @@ ol.format.WFS.writeUpdate_ = function(node, feature, objectStack) {
goog.asserts.assert(goog.isObject(context), 'context should be an Object');
var featureType = context['featureType'];
var featurePrefix = context['featurePrefix'];
featurePrefix = goog.isDef(featurePrefix) ? featurePrefix :
featurePrefix = featurePrefix ? featurePrefix :
ol.format.WFS.FEATURE_PREFIX;
var featureNS = context['featureNS'];
node.setAttribute('typeName', featurePrefix + ':' + featureType);
ol.xml.setAttributeNS(node, ol.format.WFS.XMLNS, 'xmlns:' + featurePrefix,
featureNS);
var fid = feature.getId();
if (goog.isDef(fid)) {
if (fid) {
var keys = feature.getKeys();
var values = [];
for (var i = 0, ii = keys.length; i < ii; i++) {
var value = feature.get(keys[i]);
if (goog.isDef(value)) {
if (ol.isDef(value)) {
values.push({name: keys[i], value: value});
}
}
@@ -495,13 +496,13 @@ ol.format.WFS.writeProperty_ = function(node, pair, objectStack) {
* @private
*/
ol.format.WFS.writeNative_ = function(node, nativeElement, objectStack) {
if (goog.isDef(nativeElement.vendorId)) {
if (nativeElement.vendorId) {
node.setAttribute('vendorId', nativeElement.vendorId);
}
if (goog.isDef(nativeElement.safeToIgnore)) {
if (ol.isDef(nativeElement.safeToIgnore)) {
node.setAttribute('safeToIgnore', nativeElement.safeToIgnore);
}
if (goog.isDef(nativeElement.value)) {
if (ol.isDef(nativeElement.value)) {
ol.format.XSD.writeStringTextNode(node, nativeElement.value);
}
};
@@ -535,12 +536,12 @@ ol.format.WFS.writeQuery_ = function(node, featureType, objectStack) {
var featureNS = context['featureNS'];
var propertyNames = context['propertyNames'];
var srsName = context['srsName'];
var prefix = goog.isDef(featurePrefix) ? featurePrefix + ':' : '';
var prefix = featurePrefix ? featurePrefix + ':' : '';
node.setAttribute('typeName', prefix + featureType);
if (goog.isDef(srsName)) {
if (srsName) {
node.setAttribute('srsName', srsName);
}
if (goog.isDef(featureNS)) {
if (featureNS) {
ol.xml.setAttributeNS(node, ol.format.WFS.XMLNS, 'xmlns:' + featurePrefix,
featureNS);
}
@@ -551,7 +552,7 @@ ol.format.WFS.writeQuery_ = function(node, featureType, objectStack) {
ol.xml.makeSimpleNodeFactory('PropertyName'), propertyNames,
objectStack);
var bbox = context['bbox'];
if (goog.isDef(bbox)) {
if (bbox) {
var child = ol.xml.createElementNS('http://www.opengis.net/ogc', 'Filter');
ol.format.WFS.writeOgcBBOX_(child, bbox, objectStack);
node.appendChild(child);
@@ -632,23 +633,23 @@ ol.format.WFS.prototype.writeGetFeature = function(options) {
'GetFeature');
node.setAttribute('service', 'WFS');
node.setAttribute('version', '1.1.0');
if (goog.isDef(options)) {
if (goog.isDef(options.handle)) {
if (options) {
if (options.handle) {
node.setAttribute('handle', options.handle);
}
if (goog.isDef(options.outputFormat)) {
if (options.outputFormat) {
node.setAttribute('outputFormat', options.outputFormat);
}
if (goog.isDef(options.maxFeatures)) {
if (ol.isDef(options.maxFeatures)) {
node.setAttribute('maxFeatures', options.maxFeatures);
}
if (goog.isDef(options.resultType)) {
if (options.resultType) {
node.setAttribute('resultType', options.resultType);
}
if (goog.isDef(options.startIndex)) {
if (ol.isDef(options.startIndex)) {
node.setAttribute('startIndex', options.startIndex);
}
if (goog.isDef(options.count)) {
if (ol.isDef(options.count)) {
node.setAttribute('count', options.count);
}
}
@@ -657,13 +658,11 @@ ol.format.WFS.prototype.writeGetFeature = function(options) {
var context = {
node: node,
srsName: options.srsName,
featureNS: goog.isDef(options.featureNS) ?
options.featureNS : this.featureNS_,
featureNS: options.featureNS ? options.featureNS : this.featureNS_,
featurePrefix: options.featurePrefix,
geometryName: options.geometryName,
bbox: options.bbox,
propertyNames: goog.isDef(options.propertyNames) ?
options.propertyNames : []
propertyNames: options.propertyNames ? options.propertyNames : []
};
goog.asserts.assert(goog.isArray(options.featureTypes),
'options.featureTypes should be an array');
@@ -690,9 +689,9 @@ ol.format.WFS.prototype.writeTransaction = function(inserts, updates, deletes,
node.setAttribute('service', 'WFS');
node.setAttribute('version', '1.1.0');
var baseObj, obj;
if (goog.isDef(options)) {
baseObj = goog.isDef(options.gmlOptions) ? options.gmlOptions : {};
if (goog.isDef(options.handle)) {
if (options) {
baseObj = options.gmlOptions ? options.gmlOptions : {};
if (options.handle) {
node.setAttribute('handle', options.handle);
}
}
@@ -723,7 +722,7 @@ ol.format.WFS.prototype.writeTransaction = function(inserts, updates, deletes,
ol.xml.makeSimpleNodeFactory('Delete'), deletes,
objectStack);
}
if (goog.isDef(options.nativeElements)) {
if (options.nativeElements) {
ol.xml.pushSerializeAndPop({node: node, featureNS: options.featureNS,
featureType: options.featureType, featurePrefix: options.featurePrefix},
ol.format.WFS.TRANSACTION_SERIALIZERS_,

View File

@@ -1,6 +1,7 @@
goog.provide('ol.format.WKT');
goog.require('goog.asserts');
goog.require('ol');
goog.require('ol.Feature');
goog.require('ol.format.Feature');
goog.require('ol.format.TextFeature');
@@ -28,7 +29,7 @@ goog.require('ol.geom.Polygon');
*/
ol.format.WKT = function(opt_options) {
var options = goog.isDef(opt_options) ? opt_options : {};
var options = opt_options ? opt_options : {};
goog.base(this);
@@ -37,8 +38,8 @@ ol.format.WKT = function(opt_options) {
* @type {boolean}
* @private
*/
this.splitCollection_ = goog.isDef(options.splitCollection) ?
options.splitCollection : false;
this.splitCollection_ = ol.isDef(options.splitCollection) ?
/** @type {boolean} */ (options.splitCollection) : false;
};
goog.inherits(ol.format.WKT, ol.format.TextFeature);
@@ -167,8 +168,7 @@ ol.format.WKT.encodeMultiPolygonGeometry_ = function(geom) {
ol.format.WKT.encode_ = function(geom) {
var type = geom.getType();
var geometryEncoder = ol.format.WKT.GeometryEncoder_[type];
goog.asserts.assert(goog.isDef(geometryEncoder),
'geometryEncoder should be defined');
goog.asserts.assert(geometryEncoder, 'geometryEncoder should be defined');
var enc = geometryEncoder(geom);
type = type.toUpperCase();
if (enc.length === 0) {
@@ -225,7 +225,7 @@ ol.format.WKT.prototype.readFeature;
*/
ol.format.WKT.prototype.readFeatureFromText = function(text, opt_options) {
var geom = this.readGeometryFromText(text, opt_options);
if (goog.isDef(geom)) {
if (geom) {
var feature = new ol.Feature();
feature.setGeometry(geom);
return feature;
@@ -286,7 +286,7 @@ ol.format.WKT.prototype.readGeometry;
*/
ol.format.WKT.prototype.readGeometryFromText = function(text, opt_options) {
var geometry = this.parse_(text);
if (goog.isDef(geometry)) {
if (geometry) {
return /** @type {ol.geom.Geometry} */ (
ol.format.Feature.transformWithOptions(geometry, false, opt_options));
} else {
@@ -312,7 +312,7 @@ ol.format.WKT.prototype.writeFeature;
*/
ol.format.WKT.prototype.writeFeatureText = function(feature, opt_options) {
var geometry = feature.getGeometry();
if (goog.isDef(geometry)) {
if (geometry) {
return this.writeGeometryText(geometry, opt_options);
}
return '';
@@ -427,7 +427,7 @@ ol.format.WKT.Lexer.prototype.isAlpha_ = function(c) {
* @private
*/
ol.format.WKT.Lexer.prototype.isNumeric_ = function(c, opt_decimal) {
var decimal = goog.isDef(opt_decimal) ? opt_decimal : false;
var decimal = ol.isDef(opt_decimal) ? opt_decimal : false;
return c >= '0' && c <= '9' || c == '.' && !decimal;
};
@@ -603,7 +603,7 @@ ol.format.WKT.Parser.prototype.parseGeometry_ = function() {
} else {
var parser = ol.format.WKT.Parser.GeometryParser_[geomType];
var ctor = ol.format.WKT.Parser.GeometryConstructor_[geomType];
if (!goog.isDef(parser) || !goog.isDef(ctor)) {
if (!parser || !ctor) {
throw new Error('Invalid geometry type: ' + geomType);
}
var coordinates = parser.call(this);

View File

@@ -5,6 +5,7 @@ goog.require('goog.asserts');
goog.require('goog.dom.NodeType');
goog.require('goog.object');
goog.require('goog.string');
goog.require('ol');
goog.require('ol.format.XLink');
goog.require('ol.format.XML');
goog.require('ol.format.XSD');
@@ -74,7 +75,7 @@ ol.format.WMSCapabilities.prototype.readFromNode = function(node) {
var wmsCapabilityObject = ol.xml.pushParseAndPop({
'version': this.version
}, ol.format.WMSCapabilities.PARSERS_, node, []);
return goog.isDef(wmsCapabilityObject) ? wmsCapabilityObject : null;
return wmsCapabilityObject ? wmsCapabilityObject : null;
};
@@ -142,7 +143,7 @@ ol.format.WMSCapabilities.readEXGeographicBoundingBox_ =
{},
ol.format.WMSCapabilities.EX_GEOGRAPHIC_BOUNDING_BOX_PARSERS_,
node, objectStack);
if (!goog.isDef(geographicBoundingBox)) {
if (!geographicBoundingBox) {
return undefined;
}
var westBoundLongitude = /** @type {number|undefined} */
@@ -153,8 +154,8 @@ ol.format.WMSCapabilities.readEXGeographicBoundingBox_ =
(geographicBoundingBox['eastBoundLongitude']);
var northBoundLatitude = /** @type {number|undefined} */
(geographicBoundingBox['northBoundLatitude']);
if (!goog.isDef(westBoundLongitude) || !goog.isDef(southBoundLatitude) ||
!goog.isDef(eastBoundLongitude) || !goog.isDef(northBoundLatitude)) {
if (!ol.isDef(westBoundLongitude) || !ol.isDef(southBoundLatitude) ||
!ol.isDef(eastBoundLongitude) || !ol.isDef(northBoundLatitude)) {
return undefined;
}
return /** @type {ol.Extent} */ ([
@@ -297,46 +298,46 @@ ol.format.WMSCapabilities.readLayer_ = function(node, objectStack) {
var layerObject = /** @type {Object.<string,*>} */ (ol.xml.pushParseAndPop(
{}, ol.format.WMSCapabilities.LAYER_PARSERS_, node, objectStack));
if (!goog.isDef(layerObject)) {
if (!layerObject) {
return undefined;
}
var queryable =
ol.format.XSD.readBooleanString(node.getAttribute('queryable'));
if (!goog.isDef(queryable)) {
if (!ol.isDef(queryable)) {
queryable = parentLayerObject['queryable'];
}
layerObject['queryable'] = goog.isDef(queryable) ? queryable : false;
layerObject['queryable'] = ol.isDef(queryable) ? queryable : false;
var cascaded = ol.format.XSD.readNonNegativeIntegerString(
node.getAttribute('cascaded'));
if (!goog.isDef(cascaded)) {
if (!ol.isDef(cascaded)) {
cascaded = parentLayerObject['cascaded'];
}
layerObject['cascaded'] = cascaded;
var opaque = ol.format.XSD.readBooleanString(node.getAttribute('opaque'));
if (!goog.isDef(opaque)) {
if (!ol.isDef(opaque)) {
opaque = parentLayerObject['opaque'];
}
layerObject['opaque'] = goog.isDef(opaque) ? opaque : false;
layerObject['opaque'] = ol.isDef(opaque) ? opaque : false;
var noSubsets =
ol.format.XSD.readBooleanString(node.getAttribute('noSubsets'));
if (!goog.isDef(noSubsets)) {
if (!ol.isDef(noSubsets)) {
noSubsets = parentLayerObject['noSubsets'];
}
layerObject['noSubsets'] = goog.isDef(noSubsets) ? noSubsets : false;
layerObject['noSubsets'] = ol.isDef(noSubsets) ? noSubsets : false;
var fixedWidth =
ol.format.XSD.readDecimalString(node.getAttribute('fixedWidth'));
if (!goog.isDef(fixedWidth)) {
if (!fixedWidth) {
fixedWidth = parentLayerObject['fixedWidth'];
}
layerObject['fixedWidth'] = fixedWidth;
var fixedHeight =
ol.format.XSD.readDecimalString(node.getAttribute('fixedHeight'));
if (!goog.isDef(fixedHeight)) {
if (!fixedHeight) {
fixedHeight = parentLayerObject['fixedHeight'];
}
layerObject['fixedHeight'] = fixedHeight;
@@ -344,10 +345,9 @@ ol.format.WMSCapabilities.readLayer_ = function(node, objectStack) {
// See 7.2.4.8
var addKeys = ['Style', 'CRS', 'AuthorityURL'];
goog.array.forEach(addKeys, function(key) {
var parentValue = parentLayerObject[key];
if (goog.isDef(parentValue)) {
if (key in parentLayerObject) {
var childValue = goog.object.setIfUndefined(layerObject, key, []);
childValue = childValue.concat(parentValue);
childValue = childValue.concat(parentLayerObject[key]);
layerObject[key] = childValue;
}
});
@@ -355,8 +355,7 @@ ol.format.WMSCapabilities.readLayer_ = function(node, objectStack) {
var replaceKeys = ['EX_GeographicBoundingBox', 'BoundingBox', 'Dimension',
'Attribution', 'MinScaleDenominator', 'MaxScaleDenominator'];
goog.array.forEach(replaceKeys, function(key) {
var childValue = layerObject[key];
if (!goog.isDef(childValue)) {
if (!(key in layerObject)) {
var parentValue = parentLayerObject[key];
layerObject[key] = parentValue;
}
@@ -482,7 +481,7 @@ ol.format.WMSCapabilities.readSizedFormatOnlineresource_ =
'node.nodeType should be ELEMENT');
var formatOnlineresource =
ol.format.WMSCapabilities.readFormatOnlineresource_(node, objectStack);
if (goog.isDef(formatOnlineresource)) {
if (formatOnlineresource) {
var size = [
ol.format.XSD.readNonNegativeIntegerString(node.getAttribute('width')),
ol.format.XSD.readNonNegativeIntegerString(node.getAttribute('height'))
@@ -507,7 +506,7 @@ ol.format.WMSCapabilities.readAuthorityURL_ = function(node, objectStack) {
'localName should be AuthorityURL');
var authorityObject =
ol.format.WMSCapabilities.readFormatOnlineresource_(node, objectStack);
if (goog.isDef(authorityObject)) {
if (authorityObject) {
authorityObject['name'] = node.getAttribute('name');
return authorityObject;
}
@@ -528,7 +527,7 @@ ol.format.WMSCapabilities.readMetadataURL_ = function(node, objectStack) {
'localName should be MetadataURL');
var metadataObject =
ol.format.WMSCapabilities.readFormatOnlineresource_(node, objectStack);
if (goog.isDef(metadataObject)) {
if (metadataObject) {
metadataObject['type'] = node.getAttribute('type');
return metadataObject;
}

View File

@@ -102,7 +102,7 @@ ol.format.WMSGetFeatureInfo.prototype.readFeatures_ =
layer.namespaceURI = this.featureNS_;
var layerFeatures = ol.xml.pushParseAndPop(
[], parsersNS, layer, objectStack, this.gmlFormat_);
if (goog.isDef(layerFeatures)) {
if (layerFeatures) {
goog.array.extend(features, layerFeatures);
}
}, this);
@@ -111,7 +111,7 @@ ol.format.WMSGetFeatureInfo.prototype.readFeatures_ =
var gmlFeatures = ol.xml.pushParseAndPop([],
this.gmlFormat_.FEATURE_COLLECTION_PARSERS, node,
[{}], this.gmlFormat_);
if (goog.isDef(gmlFeatures)) {
if (gmlFeatures) {
features = gmlFeatures;
}
}
@@ -140,7 +140,7 @@ ol.format.WMSGetFeatureInfo.prototype.readFeaturesFromNode =
'featureType': this.featureType,
'featureNS': this.featureNS
};
if (goog.isDef(opt_options)) {
if (opt_options) {
goog.object.extend(options, this.getReadOptions(node, opt_options));
}
return this.readFeatures_(node, [options]);

View File

@@ -71,13 +71,13 @@ ol.format.WMTSCapabilities.prototype.readFromNode = function(node) {
this.version = goog.string.trim(node.getAttribute('version'));
goog.asserts.assertString(this.version, 'this.version should be a string');
var WMTSCapabilityObject = this.owsParser_.readFromNode(node);
if (!goog.isDef(WMTSCapabilityObject)) {
if (!WMTSCapabilityObject) {
return null;
}
WMTSCapabilityObject['version'] = this.version;
WMTSCapabilityObject = ol.xml.pushParseAndPop(WMTSCapabilityObject,
ol.format.WMTSCapabilities.PARSERS_, node, []);
return goog.isDef(WMTSCapabilityObject) ? WMTSCapabilityObject : null;
return WMTSCapabilityObject ? WMTSCapabilityObject : null;
};
@@ -134,7 +134,7 @@ ol.format.WMTSCapabilities.readTileMatrixSet_ = function(node, objectStack) {
ol.format.WMTSCapabilities.readStyle_ = function(node, objectStack) {
var style = ol.xml.pushParseAndPop({},
ol.format.WMTSCapabilities.STYLE_PARSERS_, node, objectStack);
if (!goog.isDef(style)) {
if (!style) {
return undefined;
}
var isDefault = node.getAttribute('isDefault') === 'true';
@@ -168,13 +168,13 @@ ol.format.WMTSCapabilities.readResourceUrl_ = function(node, objectStack) {
var template = node.getAttribute('template');
var resourceType = node.getAttribute('resourceType');
var resource = {};
if (goog.isDef(format)) {
if (format) {
resource['format'] = format;
}
if (goog.isDef(template)) {
if (template) {
resource['template'] = template;
}
if (goog.isDef(resourceType)) {
if (resourceType) {
resource['resourceType'] = resourceType;
}
return resource;
@@ -219,7 +219,7 @@ ol.format.WMTSCapabilities.readLegendUrl_ = function(node, objectStack) {
*/
ol.format.WMTSCapabilities.readCoordinates_ = function(node, objectStack) {
var coordinates = ol.format.XSD.readString(node).split(' ');
if (!goog.isDef(coordinates) || coordinates.length != 2) {
if (!coordinates || coordinates.length != 2) {
return undefined;
}
var x = +coordinates[0];

View File

@@ -2,6 +2,7 @@ goog.provide('ol.format.XSD');
goog.require('goog.asserts');
goog.require('goog.string');
goog.require('ol');
goog.require('ol.xml');
@@ -29,7 +30,7 @@ ol.format.XSD.readBoolean = function(node) {
ol.format.XSD.readBooleanString = function(string) {
var m = /^\s*(true|1)|(false|0)\s*$/.exec(string);
if (m) {
return goog.isDef(m[1]) || false;
return ol.isDef(m[1]) || false;
} else {
return undefined;
}
@@ -56,7 +57,7 @@ ol.format.XSD.readDateTime = function(node) {
if (m[7] != 'Z') {
var sign = m[8] == '-' ? -1 : 1;
dateTime += sign * 60 * parseInt(m[9], 10);
if (goog.isDef(m[10])) {
if (ol.isDef(m[10])) {
dateTime += sign * 60 * 60 * parseInt(m[10], 10);
}
}