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), * maxFeatures: (number|undefined),
* geometryName: (string|undefined), * geometryName: (string|undefined),
* propertyNames: (Array.<string>|undefined), * propertyNames: (Array.<string>|undefined),
* startIndex: (number|undefined),
* count: (number|undefined),
* bbox: (ol.Extent|undefined)}} * bbox: (ol.Extent|undefined)}}
* @api * @api
*/ */

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -102,7 +102,7 @@ ol.format.WMSGetFeatureInfo.prototype.readFeatures_ =
layer.namespaceURI = this.featureNS_; layer.namespaceURI = this.featureNS_;
var layerFeatures = ol.xml.pushParseAndPop( var layerFeatures = ol.xml.pushParseAndPop(
[], parsersNS, layer, objectStack, this.gmlFormat_); [], parsersNS, layer, objectStack, this.gmlFormat_);
if (goog.isDef(layerFeatures)) { if (layerFeatures) {
goog.array.extend(features, layerFeatures); goog.array.extend(features, layerFeatures);
} }
}, this); }, this);
@@ -111,7 +111,7 @@ ol.format.WMSGetFeatureInfo.prototype.readFeatures_ =
var gmlFeatures = ol.xml.pushParseAndPop([], var gmlFeatures = ol.xml.pushParseAndPop([],
this.gmlFormat_.FEATURE_COLLECTION_PARSERS, node, this.gmlFormat_.FEATURE_COLLECTION_PARSERS, node,
[{}], this.gmlFormat_); [{}], this.gmlFormat_);
if (goog.isDef(gmlFeatures)) { if (gmlFeatures) {
features = gmlFeatures; features = gmlFeatures;
} }
} }
@@ -140,7 +140,7 @@ ol.format.WMSGetFeatureInfo.prototype.readFeaturesFromNode =
'featureType': this.featureType, 'featureType': this.featureType,
'featureNS': this.featureNS 'featureNS': this.featureNS
}; };
if (goog.isDef(opt_options)) { if (opt_options) {
goog.object.extend(options, this.getReadOptions(node, opt_options)); goog.object.extend(options, this.getReadOptions(node, opt_options));
} }
return this.readFeatures_(node, [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')); this.version = goog.string.trim(node.getAttribute('version'));
goog.asserts.assertString(this.version, 'this.version should be a string'); goog.asserts.assertString(this.version, 'this.version should be a string');
var WMTSCapabilityObject = this.owsParser_.readFromNode(node); var WMTSCapabilityObject = this.owsParser_.readFromNode(node);
if (!goog.isDef(WMTSCapabilityObject)) { if (!WMTSCapabilityObject) {
return null; return null;
} }
WMTSCapabilityObject['version'] = this.version; WMTSCapabilityObject['version'] = this.version;
WMTSCapabilityObject = ol.xml.pushParseAndPop(WMTSCapabilityObject, WMTSCapabilityObject = ol.xml.pushParseAndPop(WMTSCapabilityObject,
ol.format.WMTSCapabilities.PARSERS_, node, []); 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) { ol.format.WMTSCapabilities.readStyle_ = function(node, objectStack) {
var style = ol.xml.pushParseAndPop({}, var style = ol.xml.pushParseAndPop({},
ol.format.WMTSCapabilities.STYLE_PARSERS_, node, objectStack); ol.format.WMTSCapabilities.STYLE_PARSERS_, node, objectStack);
if (!goog.isDef(style)) { if (!style) {
return undefined; return undefined;
} }
var isDefault = node.getAttribute('isDefault') === 'true'; var isDefault = node.getAttribute('isDefault') === 'true';
@@ -168,13 +168,13 @@ ol.format.WMTSCapabilities.readResourceUrl_ = function(node, objectStack) {
var template = node.getAttribute('template'); var template = node.getAttribute('template');
var resourceType = node.getAttribute('resourceType'); var resourceType = node.getAttribute('resourceType');
var resource = {}; var resource = {};
if (goog.isDef(format)) { if (format) {
resource['format'] = format; resource['format'] = format;
} }
if (goog.isDef(template)) { if (template) {
resource['template'] = template; resource['template'] = template;
} }
if (goog.isDef(resourceType)) { if (resourceType) {
resource['resourceType'] = resourceType; resource['resourceType'] = resourceType;
} }
return resource; return resource;
@@ -219,7 +219,7 @@ ol.format.WMTSCapabilities.readLegendUrl_ = function(node, objectStack) {
*/ */
ol.format.WMTSCapabilities.readCoordinates_ = function(node, objectStack) { ol.format.WMTSCapabilities.readCoordinates_ = function(node, objectStack) {
var coordinates = ol.format.XSD.readString(node).split(' '); var coordinates = ol.format.XSD.readString(node).split(' ');
if (!goog.isDef(coordinates) || coordinates.length != 2) { if (!coordinates || coordinates.length != 2) {
return undefined; return undefined;
} }
var x = +coordinates[0]; var x = +coordinates[0];

View File

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