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

@@ -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;
}