Toward natural JavaScript syntax
This commit is contained in:
@@ -46,28 +46,26 @@ ol.format.GML3 = function(opt_options) {
|
||||
* @private
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.surface_ = ol.isDef(options.surface) ?
|
||||
/** @type {boolean} */ (options.surface) : false;
|
||||
this.surface_ = options.surface !== undefined ? options.surface : false;
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.curve_ = ol.isDef(options.curve) ?
|
||||
/** @type {boolean} */ (options.curve) : false;
|
||||
this.curve_ = options.curve !== undefined ? options.curve : false;
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.multiCurve_ = ol.isDef(options.multiCurve) ?
|
||||
/** @type {boolean} */ (options.multiCurve) : true;
|
||||
this.multiCurve_ = options.multiCurve !== undefined ?
|
||||
options.multiCurve : true;
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.multiSurface_ = ol.isDef(options.multiSurface) ?
|
||||
this.multiSurface_ = options.multiSurface !== undefined ?
|
||||
/** @type {boolean} */ (options.multiSurface) : true;
|
||||
|
||||
/**
|
||||
@@ -787,11 +785,11 @@ ol.format.GML3.prototype.RING_NODE_FACTORY_ =
|
||||
var parentNode = context.node;
|
||||
goog.asserts.assert(goog.isObject(context), 'context should be an Object');
|
||||
var exteriorWritten = context['exteriorWritten'];
|
||||
if (!ol.isDef(exteriorWritten)) {
|
||||
if (exteriorWritten === undefined) {
|
||||
context['exteriorWritten'] = true;
|
||||
}
|
||||
return ol.xml.createElementNS(parentNode.namespaceURI,
|
||||
ol.isDef(exteriorWritten) ? 'interior' : 'exterior');
|
||||
exteriorWritten !== undefined ? 'interior' : 'exterior');
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -89,8 +89,8 @@ ol.format.KML = function(opt_options) {
|
||||
* @private
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.extractStyles_ = ol.isDef(options.extractStyles) ?
|
||||
/** @type {boolean} */ (options.extractStyles) : true;
|
||||
this.extractStyles_ = options.extractStyles !== undefined ?
|
||||
options.extractStyles : true;
|
||||
|
||||
/**
|
||||
* @private
|
||||
@@ -441,7 +441,7 @@ ol.format.KML.readVec2_ = function(node) {
|
||||
*/
|
||||
ol.format.KML.readScale_ = function(node) {
|
||||
var number = ol.format.XSD.readDecimal(node);
|
||||
if (ol.isDef(number)) {
|
||||
if (number !== undefined) {
|
||||
return Math.sqrt(number);
|
||||
} else {
|
||||
return undefined;
|
||||
@@ -517,7 +517,7 @@ ol.format.KML.IconStyleParser_ = function(node, objectStack) {
|
||||
(IconObject['x']);
|
||||
var y = /** @type {number|undefined} */
|
||||
(IconObject['y']);
|
||||
if (ol.isDef(x) && ol.isDef(y)) {
|
||||
if (x !== undefined && y !== undefined) {
|
||||
offset = [x, y];
|
||||
}
|
||||
|
||||
@@ -526,14 +526,14 @@ ol.format.KML.IconStyleParser_ = function(node, objectStack) {
|
||||
(IconObject['w']);
|
||||
var h = /** @type {number|undefined} */
|
||||
(IconObject['h']);
|
||||
if (ol.isDef(w) && ol.isDef(h)) {
|
||||
if (w !== undefined && h !== undefined) {
|
||||
size = [w, h];
|
||||
}
|
||||
|
||||
var rotation;
|
||||
var heading = /** @type {number} */
|
||||
(object['heading']);
|
||||
if (ol.isDef(heading)) {
|
||||
if (heading !== undefined) {
|
||||
rotation = goog.math.toRadians(heading);
|
||||
}
|
||||
|
||||
@@ -648,12 +648,12 @@ ol.format.KML.PolyStyleParser_ = function(node, objectStack) {
|
||||
});
|
||||
styleObject['fillStyle'] = fillStyle;
|
||||
var fill = /** @type {boolean|undefined} */ (object['fill']);
|
||||
if (ol.isDef(fill)) {
|
||||
if (fill !== undefined) {
|
||||
styleObject['fill'] = fill;
|
||||
}
|
||||
var outline =
|
||||
/** @type {boolean|undefined} */ (object['outline']);
|
||||
if (ol.isDef(outline)) {
|
||||
if (outline !== undefined) {
|
||||
styleObject['outline'] = outline;
|
||||
}
|
||||
};
|
||||
@@ -1018,7 +1018,7 @@ ol.format.KML.readStyle_ = function(node, objectStack) {
|
||||
styleObject, 'fillStyle', ol.format.KML.DEFAULT_FILL_STYLE_));
|
||||
var fill = /** @type {boolean|undefined} */
|
||||
(styleObject['fill']);
|
||||
if (ol.isDef(fill) && !fill) {
|
||||
if (fill !== undefined && !fill) {
|
||||
fillStyle = null;
|
||||
}
|
||||
var imageStyle = /** @type {ol.style.Image} */ (goog.object.get(
|
||||
@@ -1029,7 +1029,7 @@ ol.format.KML.readStyle_ = function(node, objectStack) {
|
||||
styleObject, 'strokeStyle', ol.format.KML.DEFAULT_STROKE_STYLE_));
|
||||
var outline = /** @type {boolean|undefined} */
|
||||
(styleObject['outline']);
|
||||
if (ol.isDef(outline) && !outline) {
|
||||
if (outline !== undefined && !outline) {
|
||||
strokeStyle = null;
|
||||
}
|
||||
return [new ol.style.Style({
|
||||
@@ -1061,7 +1061,7 @@ ol.format.KML.setCommonGeometryProperties_ = function(multiGeometry,
|
||||
geometry = geometries[i];
|
||||
extrudes[i] = geometry.get('extrude');
|
||||
altitudeModes[i] = geometry.get('altitudeMode');
|
||||
hasExtrude = hasExtrude || ol.isDef(extrudes[i]);
|
||||
hasExtrude = hasExtrude || extrudes[i] !== undefined;
|
||||
hasAltitudeMode = hasAltitudeMode || altitudeModes[i];
|
||||
}
|
||||
if (hasExtrude) {
|
||||
|
||||
@@ -451,7 +451,7 @@ ol.format.WFS.writeUpdate_ = function(node, feature, objectStack) {
|
||||
var values = [];
|
||||
for (var i = 0, ii = keys.length; i < ii; i++) {
|
||||
var value = feature.get(keys[i]);
|
||||
if (ol.isDef(value)) {
|
||||
if (value !== undefined) {
|
||||
values.push({name: keys[i], value: value});
|
||||
}
|
||||
}
|
||||
@@ -499,10 +499,10 @@ ol.format.WFS.writeNative_ = function(node, nativeElement, objectStack) {
|
||||
if (nativeElement.vendorId) {
|
||||
node.setAttribute('vendorId', nativeElement.vendorId);
|
||||
}
|
||||
if (ol.isDef(nativeElement.safeToIgnore)) {
|
||||
if (nativeElement.safeToIgnore !== undefined) {
|
||||
node.setAttribute('safeToIgnore', nativeElement.safeToIgnore);
|
||||
}
|
||||
if (ol.isDef(nativeElement.value)) {
|
||||
if (nativeElement.value !== undefined) {
|
||||
ol.format.XSD.writeStringTextNode(node, nativeElement.value);
|
||||
}
|
||||
};
|
||||
@@ -640,16 +640,16 @@ ol.format.WFS.prototype.writeGetFeature = function(options) {
|
||||
if (options.outputFormat) {
|
||||
node.setAttribute('outputFormat', options.outputFormat);
|
||||
}
|
||||
if (ol.isDef(options.maxFeatures)) {
|
||||
if (options.maxFeatures !== undefined) {
|
||||
node.setAttribute('maxFeatures', options.maxFeatures);
|
||||
}
|
||||
if (options.resultType) {
|
||||
node.setAttribute('resultType', options.resultType);
|
||||
}
|
||||
if (ol.isDef(options.startIndex)) {
|
||||
if (options.startIndex !== undefined) {
|
||||
node.setAttribute('startIndex', options.startIndex);
|
||||
}
|
||||
if (ol.isDef(options.count)) {
|
||||
if (options.count !== undefined) {
|
||||
node.setAttribute('count', options.count);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,8 +38,8 @@ ol.format.WKT = function(opt_options) {
|
||||
* @type {boolean}
|
||||
* @private
|
||||
*/
|
||||
this.splitCollection_ = ol.isDef(options.splitCollection) ?
|
||||
/** @type {boolean} */ (options.splitCollection) : false;
|
||||
this.splitCollection_ = options.splitCollection !== undefined ?
|
||||
options.splitCollection : false;
|
||||
|
||||
};
|
||||
goog.inherits(ol.format.WKT, ol.format.TextFeature);
|
||||
@@ -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 = ol.isDef(opt_decimal) ? opt_decimal : false;
|
||||
var decimal = opt_decimal !== undefined ? opt_decimal : false;
|
||||
return c >= '0' && c <= '9' || c == '.' && !decimal;
|
||||
};
|
||||
|
||||
|
||||
@@ -154,8 +154,8 @@ ol.format.WMSCapabilities.readEXGeographicBoundingBox_ =
|
||||
(geographicBoundingBox['eastBoundLongitude']);
|
||||
var northBoundLatitude = /** @type {number|undefined} */
|
||||
(geographicBoundingBox['northBoundLatitude']);
|
||||
if (!ol.isDef(westBoundLongitude) || !ol.isDef(southBoundLatitude) ||
|
||||
!ol.isDef(eastBoundLongitude) || !ol.isDef(northBoundLatitude)) {
|
||||
if (westBoundLongitude === undefined || southBoundLatitude === undefined ||
|
||||
eastBoundLongitude === undefined || northBoundLatitude === undefined) {
|
||||
return undefined;
|
||||
}
|
||||
return /** @type {ol.Extent} */ ([
|
||||
@@ -303,30 +303,30 @@ ol.format.WMSCapabilities.readLayer_ = function(node, objectStack) {
|
||||
}
|
||||
var queryable =
|
||||
ol.format.XSD.readBooleanString(node.getAttribute('queryable'));
|
||||
if (!ol.isDef(queryable)) {
|
||||
if (queryable === undefined) {
|
||||
queryable = parentLayerObject['queryable'];
|
||||
}
|
||||
layerObject['queryable'] = ol.isDef(queryable) ? queryable : false;
|
||||
layerObject['queryable'] = queryable !== undefined ? queryable : false;
|
||||
|
||||
var cascaded = ol.format.XSD.readNonNegativeIntegerString(
|
||||
node.getAttribute('cascaded'));
|
||||
if (!ol.isDef(cascaded)) {
|
||||
if (cascaded === undefined) {
|
||||
cascaded = parentLayerObject['cascaded'];
|
||||
}
|
||||
layerObject['cascaded'] = cascaded;
|
||||
|
||||
var opaque = ol.format.XSD.readBooleanString(node.getAttribute('opaque'));
|
||||
if (!ol.isDef(opaque)) {
|
||||
if (opaque === undefined) {
|
||||
opaque = parentLayerObject['opaque'];
|
||||
}
|
||||
layerObject['opaque'] = ol.isDef(opaque) ? opaque : false;
|
||||
layerObject['opaque'] = opaque !== undefined ? opaque : false;
|
||||
|
||||
var noSubsets =
|
||||
ol.format.XSD.readBooleanString(node.getAttribute('noSubsets'));
|
||||
if (!ol.isDef(noSubsets)) {
|
||||
if (noSubsets === undefined) {
|
||||
noSubsets = parentLayerObject['noSubsets'];
|
||||
}
|
||||
layerObject['noSubsets'] = ol.isDef(noSubsets) ? noSubsets : false;
|
||||
layerObject['noSubsets'] = noSubsets !== undefined ? noSubsets : false;
|
||||
|
||||
var fixedWidth =
|
||||
ol.format.XSD.readDecimalString(node.getAttribute('fixedWidth'));
|
||||
|
||||
@@ -30,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 ol.isDef(m[1]) || false;
|
||||
return m[1] !== undefined || false;
|
||||
} else {
|
||||
return undefined;
|
||||
}
|
||||
@@ -57,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 (ol.isDef(m[10])) {
|
||||
if (m[10] !== undefined) {
|
||||
dateTime += sign * 60 * 60 * parseInt(m[10], 10);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user