Remove goog.isDef from formats

This commit is contained in:
Tim Schaub
2015-09-21 05:51:45 +09:00
parent 5350e9ba37
commit 1fceb4a709
11 changed files with 138 additions and 141 deletions

View File

@@ -32,7 +32,7 @@ goog.require('ol.proj');
*/ */
ol.format.EsriJSON = function(opt_options) { ol.format.EsriJSON = function(opt_options) {
var options = goog.isDef(opt_options) ? opt_options : {}; var options = opt_options ? opt_options : {};
goog.base(this); goog.base(this);
@@ -80,9 +80,9 @@ ol.format.EsriJSON.readGeometry_ = function(object, opt_options) {
object.rings = rings; object.rings = rings;
} }
} }
goog.asserts.assert(goog.isDef(type), 'geometry type should be defined'); goog.asserts.assert(type, 'geometry type should be defined');
var geometryReader = ol.format.EsriJSON.GEOMETRY_READERS_[type]; var geometryReader = ol.format.EsriJSON.GEOMETRY_READERS_[type];
goog.asserts.assert(goog.isDef(geometryReader), goog.asserts.assert(geometryReader,
'geometryReader should be defined'); 'geometryReader should be defined');
return /** @type {ol.geom.Geometry} */ ( return /** @type {ol.geom.Geometry} */ (
ol.format.Feature.transformWithOptions( ol.format.Feature.transformWithOptions(
@@ -490,19 +490,19 @@ ol.format.EsriJSON.prototype.readFeatureFromObject = function(
var geometry = ol.format.EsriJSON.readGeometry_(esriJSONFeature.geometry, var geometry = ol.format.EsriJSON.readGeometry_(esriJSONFeature.geometry,
opt_options); opt_options);
var feature = new ol.Feature(); var feature = new ol.Feature();
if (goog.isDef(this.geometryName_)) { if (this.geometryName_) {
feature.setGeometryName(this.geometryName_); feature.setGeometryName(this.geometryName_);
} }
feature.setGeometry(geometry); feature.setGeometry(geometry);
if (goog.isDef(opt_options) && goog.isDef(opt_options.idField) && if (opt_options && opt_options.idField &&
goog.isDef(esriJSONFeature.attributes[opt_options.idField])) { esriJSONFeature.attributes[opt_options.idField]) {
goog.asserts.assert( goog.asserts.assert(
goog.isNumber(esriJSONFeature.attributes[opt_options.idField]), goog.isNumber(esriJSONFeature.attributes[opt_options.idField]),
'objectIdFieldName value should be a number'); 'objectIdFieldName value should be a number');
feature.setId(/** @type {number} */( feature.setId(/** @type {number} */(
esriJSONFeature.attributes[opt_options.idField])); esriJSONFeature.attributes[opt_options.idField]));
} }
if (goog.isDef(esriJSONFeature.attributes)) { if (esriJSONFeature.attributes) {
feature.setProperties(esriJSONFeature.attributes); feature.setProperties(esriJSONFeature.attributes);
} }
return feature; return feature;
@@ -515,7 +515,7 @@ ol.format.EsriJSON.prototype.readFeatureFromObject = function(
ol.format.EsriJSON.prototype.readFeaturesFromObject = function( ol.format.EsriJSON.prototype.readFeaturesFromObject = function(
object, opt_options) { object, opt_options) {
var esriJSONObject = /** @type {EsriJSONObject} */ (object); var esriJSONObject = /** @type {EsriJSONObject} */ (object);
var options = goog.isDef(opt_options) ? opt_options : {}; var options = opt_options ? opt_options : {};
if (goog.isDefAndNotNull(esriJSONObject.features)) { if (goog.isDefAndNotNull(esriJSONObject.features)) {
var esriJSONFeatureCollection = /** @type {EsriJSONFeatureCollection} */ var esriJSONFeatureCollection = /** @type {EsriJSONFeatureCollection} */
(object); (object);
@@ -591,8 +591,7 @@ ol.format.EsriJSON.prototype.readProjectionFromObject = function(object) {
*/ */
ol.format.EsriJSON.writeGeometry_ = function(geometry, opt_options) { ol.format.EsriJSON.writeGeometry_ = function(geometry, opt_options) {
var geometryWriter = ol.format.EsriJSON.GEOMETRY_WRITERS_[geometry.getType()]; var geometryWriter = ol.format.EsriJSON.GEOMETRY_WRITERS_[geometry.getType()];
goog.asserts.assert(goog.isDef(geometryWriter), goog.asserts.assert(geometryWriter, 'geometryWriter should be defined');
'geometryWriter should be defined');
return geometryWriter(/** @type {ol.geom.Geometry} */ ( return geometryWriter(/** @type {ol.geom.Geometry} */ (
ol.format.Feature.transformWithOptions(geometry, true, opt_options)), ol.format.Feature.transformWithOptions(geometry, true, opt_options)),
opt_options); opt_options);
@@ -662,7 +661,7 @@ ol.format.EsriJSON.prototype.writeFeatureObject = function(
} else { } else {
object['attributes'] = {}; object['attributes'] = {};
} }
if (goog.isDef(opt_options) && goog.isDef(opt_options.featureProjection)) { if (opt_options && opt_options.featureProjection) {
object['spatialReference'] = /** @type {EsriJSONCRS} */({ object['spatialReference'] = /** @type {EsriJSONCRS} */({
wkid: ol.proj.get( wkid: ol.proj.get(
opt_options.featureProjection).getCode().split(':').pop() opt_options.featureProjection).getCode().split(':').pop()

View File

@@ -31,7 +31,7 @@ goog.require('ol.proj');
*/ */
ol.format.GeoJSON = function(opt_options) { ol.format.GeoJSON = function(opt_options) {
var options = goog.isDef(opt_options) ? opt_options : {}; var options = opt_options ? opt_options : {};
goog.base(this); goog.base(this);
@@ -73,8 +73,7 @@ ol.format.GeoJSON.readGeometry_ = function(object, opt_options) {
return null; return null;
} }
var geometryReader = ol.format.GeoJSON.GEOMETRY_READERS_[object.type]; var geometryReader = ol.format.GeoJSON.GEOMETRY_READERS_[object.type];
goog.asserts.assert(goog.isDef(geometryReader), goog.asserts.assert(geometryReader, 'geometryReader should be defined');
'geometryReader should be defined');
return /** @type {ol.geom.Geometry} */ ( return /** @type {ol.geom.Geometry} */ (
ol.format.Feature.transformWithOptions( ol.format.Feature.transformWithOptions(
geometryReader(object), false, opt_options)); geometryReader(object), false, opt_options));
@@ -183,8 +182,7 @@ ol.format.GeoJSON.readPolygonGeometry_ = function(object) {
*/ */
ol.format.GeoJSON.writeGeometry_ = function(geometry, opt_options) { ol.format.GeoJSON.writeGeometry_ = function(geometry, opt_options) {
var geometryWriter = ol.format.GeoJSON.GEOMETRY_WRITERS_[geometry.getType()]; var geometryWriter = ol.format.GeoJSON.GEOMETRY_WRITERS_[geometry.getType()];
goog.asserts.assert(goog.isDef(geometryWriter), goog.asserts.assert(geometryWriter, 'geometryWriter should be defined');
'geometryWriter should be defined');
return geometryWriter(/** @type {ol.geom.Geometry} */ ( return geometryWriter(/** @type {ol.geom.Geometry} */ (
ol.format.Feature.transformWithOptions(geometry, true, opt_options)), ol.format.Feature.transformWithOptions(geometry, true, opt_options)),
opt_options); opt_options);
@@ -284,7 +282,7 @@ ol.format.GeoJSON.writeMultiPolygonGeometry_ = function(geometry, opt_options) {
goog.asserts.assertInstanceof(geometry, ol.geom.MultiPolygon, goog.asserts.assertInstanceof(geometry, ol.geom.MultiPolygon,
'geometry should be an ol.geom.MultiPolygon'); 'geometry should be an ol.geom.MultiPolygon');
var right; var right;
if (goog.isDef(opt_options)) { if (opt_options) {
right = opt_options.rightHanded; right = opt_options.rightHanded;
} }
return /** @type {GeoJSONGeometry} */ ({ return /** @type {GeoJSONGeometry} */ ({
@@ -320,7 +318,7 @@ ol.format.GeoJSON.writePolygonGeometry_ = function(geometry, opt_options) {
goog.asserts.assertInstanceof(geometry, ol.geom.Polygon, goog.asserts.assertInstanceof(geometry, ol.geom.Polygon,
'geometry should be an ol.geom.Polygon'); 'geometry should be an ol.geom.Polygon');
var right; var right;
if (goog.isDef(opt_options)) { if (opt_options) {
right = opt_options.rightHanded; right = opt_options.rightHanded;
} }
return /** @type {GeoJSONGeometry} */ ({ return /** @type {GeoJSONGeometry} */ ({
@@ -408,14 +406,14 @@ ol.format.GeoJSON.prototype.readFeatureFromObject = function(
var geometry = ol.format.GeoJSON.readGeometry_(geoJSONFeature.geometry, var geometry = ol.format.GeoJSON.readGeometry_(geoJSONFeature.geometry,
opt_options); opt_options);
var feature = new ol.Feature(); var feature = new ol.Feature();
if (goog.isDef(this.geometryName_)) { if (this.geometryName_) {
feature.setGeometryName(this.geometryName_); feature.setGeometryName(this.geometryName_);
} }
feature.setGeometry(geometry); feature.setGeometry(geometry);
if (goog.isDef(geoJSONFeature.id)) { if (geoJSONFeature.id) {
feature.setId(geoJSONFeature.id); feature.setId(geoJSONFeature.id);
} }
if (goog.isDef(geoJSONFeature.properties)) { if (geoJSONFeature.properties) {
feature.setProperties(geoJSONFeature.properties); feature.setProperties(geoJSONFeature.properties);
} }
return feature; return feature;

View File

@@ -5,6 +5,7 @@ goog.require('goog.array');
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.Feature'); goog.require('ol.Feature');
goog.require('ol.extent'); goog.require('ol.extent');
goog.require('ol.format.Feature'); goog.require('ol.format.Feature');
@@ -37,7 +38,7 @@ goog.require('ol.xml');
*/ */
ol.format.GML3 = function(opt_options) { ol.format.GML3 = 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);
@@ -45,34 +46,34 @@ ol.format.GML3 = function(opt_options) {
* @private * @private
* @type {boolean} * @type {boolean}
*/ */
this.surface_ = goog.isDef(options.surface) ? this.surface_ = ol.isDef(options.surface) ?
options.surface : false; /** @type {boolean} */ (options.surface) : false;
/** /**
* @private * @private
* @type {boolean} * @type {boolean}
*/ */
this.curve_ = goog.isDef(options.curve) ? this.curve_ = ol.isDef(options.curve) ?
options.curve : false; /** @type {boolean} */ (options.curve) : false;
/** /**
* @private * @private
* @type {boolean} * @type {boolean}
*/ */
this.multiCurve_ = goog.isDef(options.multiCurve) ? this.multiCurve_ = ol.isDef(options.multiCurve) ?
options.multiCurve : true; /** @type {boolean} */ (options.multiCurve) : true;
/** /**
* @private * @private
* @type {boolean} * @type {boolean}
*/ */
this.multiSurface_ = goog.isDef(options.multiSurface) ? this.multiSurface_ = ol.isDef(options.multiSurface) ?
options.multiSurface : true; /** @type {boolean} */ (options.multiSurface) : true;
/** /**
* @inheritDoc * @inheritDoc
*/ */
this.schemaLocation = goog.isDef(options.schemaLocation) ? this.schemaLocation = options.schemaLocation ?
options.schemaLocation : ol.format.GML3.schemaLocation_; options.schemaLocation : ol.format.GML3.schemaLocation_;
}; };
@@ -103,7 +104,7 @@ ol.format.GML3.prototype.readMultiCurve_ = function(node, objectStack) {
var lineStrings = ol.xml.pushParseAndPop( var lineStrings = ol.xml.pushParseAndPop(
/** @type {Array.<ol.geom.LineString>} */ ([]), /** @type {Array.<ol.geom.LineString>} */ ([]),
this.MULTICURVE_PARSERS_, node, objectStack, this); this.MULTICURVE_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;
@@ -127,7 +128,7 @@ ol.format.GML3.prototype.readMultiSurface_ = function(node, objectStack) {
var polygons = ol.xml.pushParseAndPop( var polygons = ol.xml.pushParseAndPop(
/** @type {Array.<ol.geom.Polygon>} */ ([]), /** @type {Array.<ol.geom.Polygon>} */ ([]),
this.MULTISURFACE_PARSERS_, node, objectStack, this); this.MULTISURFACE_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;
@@ -251,7 +252,7 @@ ol.format.GML3.prototype.interiorParser_ = function(node, objectStack) {
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),
@@ -276,7 +277,7 @@ ol.format.GML3.prototype.exteriorParser_ = function(node, objectStack) {
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),
@@ -302,8 +303,7 @@ ol.format.GML3.prototype.readSurface_ = function(node, objectStack) {
var flatLinearRings = ol.xml.pushParseAndPop( var flatLinearRings = ol.xml.pushParseAndPop(
/** @type {Array.<Array.<number>>} */ ([null]), /** @type {Array.<Array.<number>>} */ ([null]),
this.SURFACE_PARSERS_, node, objectStack, this); this.SURFACE_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];
var ends = [flatCoordinates.length]; var ends = [flatCoordinates.length];
@@ -334,7 +334,7 @@ ol.format.GML3.prototype.readCurve_ = function(node, objectStack) {
var flatCoordinates = ol.xml.pushParseAndPop( var flatCoordinates = ol.xml.pushParseAndPop(
/** @type {Array.<number>} */ ([null]), /** @type {Array.<number>} */ ([null]),
this.CURVE_PARSERS_, node, objectStack, this); this.CURVE_PARSERS_, node, objectStack, this);
if (goog.isDef(flatCoordinates)) { if (flatCoordinates) {
var lineString = new ol.geom.LineString(null); var lineString = new ol.geom.LineString(null);
lineString.setFlatCoordinates(ol.geom.GeometryLayout.XYZ, flatCoordinates); lineString.setFlatCoordinates(ol.geom.GeometryLayout.XYZ, flatCoordinates);
return lineString; return lineString;
@@ -741,7 +741,7 @@ ol.format.GML3.prototype.writeEnvelope = function(node, extent, objectStack) {
var context = objectStack[objectStack.length - 1]; var context = objectStack[objectStack.length - 1];
goog.asserts.assert(goog.isObject(context), 'context should be an Object'); goog.asserts.assert(goog.isObject(context), 'context should be an Object');
var srsName = context['srsName']; var srsName = context['srsName'];
if (goog.isDef(srsName)) { if (srsName) {
node.setAttribute('srsName', srsName); node.setAttribute('srsName', srsName);
} }
var keys = ['lowerCorner', 'upperCorner']; var keys = ['lowerCorner', 'upperCorner'];
@@ -787,11 +787,11 @@ ol.format.GML3.prototype.RING_NODE_FACTORY_ =
var parentNode = context.node; var parentNode = context.node;
goog.asserts.assert(goog.isObject(context), 'context should be an Object'); goog.asserts.assert(goog.isObject(context), 'context should be an Object');
var exteriorWritten = context['exteriorWritten']; var exteriorWritten = context['exteriorWritten'];
if (!goog.isDef(exteriorWritten)) { if (!ol.isDef(exteriorWritten)) {
context['exteriorWritten'] = true; context['exteriorWritten'] = true;
} }
return ol.xml.createElementNS(parentNode.namespaceURI, return ol.xml.createElementNS(parentNode.namespaceURI,
goog.isDef(exteriorWritten) ? 'interior' : 'exterior'); ol.isDef(exteriorWritten) ? 'interior' : 'exterior');
}; };
@@ -947,7 +947,7 @@ ol.format.GML3.prototype.writeSurfaceOrPolygonMember_ =
goog.asserts.assert(goog.isObject(context), 'context should be an Object'); goog.asserts.assert(goog.isObject(context), 'context should be an Object');
var child = this.GEOMETRY_NODE_FACTORY_( var child = this.GEOMETRY_NODE_FACTORY_(
polygon, objectStack); polygon, objectStack);
if (goog.isDef(child)) { if (child) {
node.appendChild(child); node.appendChild(child);
this.writeSurfaceOrPolygon_(child, polygon, objectStack); this.writeSurfaceOrPolygon_(child, polygon, objectStack);
} }
@@ -979,7 +979,7 @@ ol.format.GML3.prototype.writeLineStringOrCurveMember_ =
var context = objectStack[objectStack.length - 1]; var context = objectStack[objectStack.length - 1];
goog.asserts.assert(goog.isObject(context), 'context should be an Object'); goog.asserts.assert(goog.isObject(context), 'context should be an Object');
var child = this.GEOMETRY_NODE_FACTORY_(line, objectStack); var child = this.GEOMETRY_NODE_FACTORY_(line, objectStack);
if (goog.isDef(child)) { if (child) {
node.appendChild(child); node.appendChild(child);
this.writeCurveOrLineString_(child, line, objectStack); this.writeCurveOrLineString_(child, line, objectStack);
} }
@@ -1028,7 +1028,7 @@ ol.format.GML3.prototype.writeGeometryElement =
item.node = node; item.node = node;
var value; var value;
if (goog.isArray(geometry)) { if (goog.isArray(geometry)) {
if (goog.isDef(context.dataProjection)) { if (context.dataProjection) {
value = ol.proj.transformExtent( value = ol.proj.transformExtent(
geometry, context.featureProjection, context.dataProjection); geometry, context.featureProjection, context.dataProjection);
} else { } else {
@@ -1055,14 +1055,14 @@ ol.format.GML3.prototype.writeGeometryElement =
ol.format.GML3.prototype.writeFeatureElement = ol.format.GML3.prototype.writeFeatureElement =
function(node, feature, objectStack) { function(node, feature, objectStack) {
var fid = feature.getId(); var fid = feature.getId();
if (goog.isDef(fid)) { if (fid) {
node.setAttribute('fid', fid); node.setAttribute('fid', fid);
} }
var context = objectStack[objectStack.length - 1]; var context = objectStack[objectStack.length - 1];
goog.asserts.assert(goog.isObject(context), 'context should be an Object'); goog.asserts.assert(goog.isObject(context), 'context should be an Object');
var featureNS = context['featureNS']; var featureNS = context['featureNS'];
var geometryName = feature.getGeometryName(); var geometryName = feature.getGeometryName();
if (!goog.isDef(context.serializers)) { if (!context.serializers) {
context.serializers = {}; context.serializers = {};
context.serializers[featureNS] = {}; context.serializers[featureNS] = {};
} }
@@ -1293,7 +1293,7 @@ ol.format.GML3.prototype.writeGeometryNode = function(geometry, opt_options) {
var context = {node: geom, srsName: this.srsName, var context = {node: geom, srsName: this.srsName,
curve: this.curve_, surface: this.surface_, curve: this.curve_, surface: this.surface_,
multiSurface: this.multiSurface_, multiCurve: this.multiCurve_}; multiSurface: this.multiSurface_, multiCurve: this.multiCurve_};
if (goog.isDef(opt_options)) { if (opt_options) {
goog.object.extend(context, opt_options); goog.object.extend(context, opt_options);
} }
this.writeGeometryElement(geom, geometry, [context]); this.writeGeometryElement(geom, geometry, [context]);
@@ -1336,7 +1336,7 @@ ol.format.GML3.prototype.writeFeaturesNode = function(features, opt_options) {
featureNS: this.featureNS, featureNS: this.featureNS,
featureType: this.featureType featureType: this.featureType
}; };
if (goog.isDef(opt_options)) { if (opt_options) {
goog.object.extend(context, opt_options); goog.object.extend(context, opt_options);
} }
this.writeFeatureMembers_(node, features, [context]); this.writeFeatureMembers_(node, features, [context]);

View File

@@ -27,7 +27,7 @@ goog.require('ol.xml');
*/ */
ol.format.GPX = function(opt_options) { ol.format.GPX = function(opt_options) {
var options = goog.isDef(opt_options) ? opt_options : {}; var options = opt_options ? opt_options : {};
goog.base(this); goog.base(this);
@@ -130,7 +130,7 @@ ol.format.GPX.parseRtePt_ = function(node, objectStack) {
goog.asserts.assert(node.localName == 'rtept', 'localName should be rtept'); goog.asserts.assert(node.localName == 'rtept', 'localName should be rtept');
var values = ol.xml.pushParseAndPop( var values = ol.xml.pushParseAndPop(
{}, ol.format.GPX.RTEPT_PARSERS_, node, objectStack); {}, ol.format.GPX.RTEPT_PARSERS_, node, objectStack);
if (goog.isDef(values)) { if (values) {
var rteValues = /** @type {Object} */ (objectStack[objectStack.length - 1]); var rteValues = /** @type {Object} */ (objectStack[objectStack.length - 1]);
var flatCoordinates = /** @type {Array.<number>} */ var flatCoordinates = /** @type {Array.<number>} */
(rteValues['flatCoordinates']); (rteValues['flatCoordinates']);
@@ -150,7 +150,7 @@ ol.format.GPX.parseTrkPt_ = function(node, objectStack) {
goog.asserts.assert(node.localName == 'trkpt', 'localName should be trkpt'); goog.asserts.assert(node.localName == 'trkpt', 'localName should be trkpt');
var values = ol.xml.pushParseAndPop( var values = ol.xml.pushParseAndPop(
{}, ol.format.GPX.TRKPT_PARSERS_, node, objectStack); {}, ol.format.GPX.TRKPT_PARSERS_, node, objectStack);
if (goog.isDef(values)) { if (values) {
var trkValues = /** @type {Object} */ (objectStack[objectStack.length - 1]); var trkValues = /** @type {Object} */ (objectStack[objectStack.length - 1]);
var flatCoordinates = /** @type {Array.<number>} */ var flatCoordinates = /** @type {Array.<number>} */
(trkValues['flatCoordinates']); (trkValues['flatCoordinates']);
@@ -192,7 +192,7 @@ ol.format.GPX.readRte_ = function(node, objectStack) {
var values = ol.xml.pushParseAndPop({ var values = ol.xml.pushParseAndPop({
'flatCoordinates': [] 'flatCoordinates': []
}, ol.format.GPX.RTE_PARSERS_, node, objectStack); }, ol.format.GPX.RTE_PARSERS_, node, objectStack);
if (!goog.isDef(values)) { if (!values) {
return undefined; return undefined;
} }
var flatCoordinates = /** @type {Array.<number>} */ var flatCoordinates = /** @type {Array.<number>} */
@@ -222,7 +222,7 @@ ol.format.GPX.readTrk_ = function(node, objectStack) {
'flatCoordinates': [], 'flatCoordinates': [],
'ends': [] 'ends': []
}, ol.format.GPX.TRK_PARSERS_, node, objectStack); }, ol.format.GPX.TRK_PARSERS_, node, objectStack);
if (!goog.isDef(values)) { if (!values) {
return undefined; return undefined;
} }
var flatCoordinates = /** @type {Array.<number>} */ var flatCoordinates = /** @type {Array.<number>} */
@@ -253,7 +253,7 @@ ol.format.GPX.readWpt_ = function(node, objectStack) {
var options = /** @type {olx.format.ReadOptions} */ (objectStack[0]); var options = /** @type {olx.format.ReadOptions} */ (objectStack[0]);
var values = ol.xml.pushParseAndPop( var values = ol.xml.pushParseAndPop(
{}, ol.format.GPX.WPT_PARSERS_, node, objectStack); {}, ol.format.GPX.WPT_PARSERS_, node, objectStack);
if (!goog.isDef(values)) { if (!values) {
return undefined; return undefined;
} }
var coordinates = ol.format.GPX.appendCoordinate_([], node, values); var coordinates = ol.format.GPX.appendCoordinate_([], node, values);
@@ -422,7 +422,7 @@ ol.format.GPX.prototype.handleReadExtensions_ = function(features) {
} }
for (var i = 0, ii = features.length; i < ii; ++i) { for (var i = 0, ii = features.length; i < ii; ++i) {
var feature = features[i]; var feature = features[i];
if (goog.isDef(this.readExtensions_)) { if (this.readExtensions_) {
var extensionsNode = feature.get('extensionsNode_') || null; var extensionsNode = feature.get('extensionsNode_') || null;
this.readExtensions_(feature, extensionsNode); this.readExtensions_(feature, extensionsNode);
} }
@@ -453,11 +453,11 @@ ol.format.GPX.prototype.readFeatureFromNode = function(node, opt_options) {
return null; return null;
} }
var featureReader = ol.format.GPX.FEATURE_READER_[node.localName]; var featureReader = ol.format.GPX.FEATURE_READER_[node.localName];
if (!goog.isDef(featureReader)) { if (!featureReader) {
return null; return null;
} }
var feature = featureReader(node, [this.getReadOptions(node, opt_options)]); var feature = featureReader(node, [this.getReadOptions(node, opt_options)]);
if (!goog.isDef(feature)) { if (!feature) {
return null; return null;
} }
this.handleReadExtensions_([feature]); this.handleReadExtensions_([feature]);
@@ -490,7 +490,7 @@ ol.format.GPX.prototype.readFeaturesFromNode = function(node, opt_options) {
var features = ol.xml.pushParseAndPop( var features = ol.xml.pushParseAndPop(
/** @type {Array.<ol.Feature>} */ ([]), ol.format.GPX.GPX_PARSERS_, /** @type {Array.<ol.Feature>} */ ([]), ol.format.GPX.GPX_PARSERS_,
node, [this.getReadOptions(node, opt_options)]); node, [this.getReadOptions(node, opt_options)]);
if (goog.isDef(features)) { if (features) {
this.handleReadExtensions_(features); this.handleReadExtensions_(features);
return features; return features;
} else { } else {
@@ -588,7 +588,7 @@ ol.format.GPX.writeRte_ = function(node, feature, objectStack) {
var properties = feature.getProperties(); var properties = feature.getProperties();
var context = {node: node, 'properties': properties}; var context = {node: node, 'properties': properties};
var geometry = feature.getGeometry(); var geometry = feature.getGeometry();
if (goog.isDef(geometry)) { if (geometry) {
goog.asserts.assertInstanceof(geometry, ol.geom.LineString, goog.asserts.assertInstanceof(geometry, ol.geom.LineString,
'geometry should be an ol.geom.LineString'); 'geometry should be an ol.geom.LineString');
geometry = /** @type {ol.geom.LineString} */ geometry = /** @type {ol.geom.LineString} */
@@ -616,7 +616,7 @@ ol.format.GPX.writeTrk_ = function(node, feature, objectStack) {
var properties = feature.getProperties(); var properties = feature.getProperties();
var context = {node: node, 'properties': properties}; var context = {node: node, 'properties': properties};
var geometry = feature.getGeometry(); var geometry = feature.getGeometry();
if (goog.isDef(geometry)) { if (geometry) {
goog.asserts.assertInstanceof(geometry, ol.geom.MultiLineString, goog.asserts.assertInstanceof(geometry, ol.geom.MultiLineString,
'geometry should be an ol.geom.MultiLineString'); 'geometry should be an ol.geom.MultiLineString');
geometry = /** @type {ol.geom.MultiLineString} */ geometry = /** @type {ol.geom.MultiLineString} */
@@ -659,7 +659,7 @@ ol.format.GPX.writeWpt_ = 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');
context['properties'] = feature.getProperties(); context['properties'] = feature.getProperties();
var geometry = feature.getGeometry(); var geometry = feature.getGeometry();
if (goog.isDef(geometry)) { if (geometry) {
goog.asserts.assertInstanceof(geometry, ol.geom.Point, goog.asserts.assertInstanceof(geometry, ol.geom.Point,
'geometry should be an ol.geom.Point'); 'geometry should be an ol.geom.Point');
geometry = /** @type {ol.geom.Point} */ geometry = /** @type {ol.geom.Point} */
@@ -838,7 +838,7 @@ ol.format.GPX.GPX_NODE_FACTORY_ = function(value, objectStack, opt_nodeName) {
goog.asserts.assertInstanceof(value, ol.Feature, goog.asserts.assertInstanceof(value, ol.Feature,
'value should be an ol.Feature'); 'value should be an ol.Feature');
var geometry = value.getGeometry(); var geometry = value.getGeometry();
if (goog.isDef(geometry)) { if (geometry) {
var parentNode = objectStack[objectStack.length - 1].node; var parentNode = objectStack[objectStack.length - 1].node;
goog.asserts.assert(ol.xml.isNode(parentNode), goog.asserts.assert(ol.xml.isNode(parentNode),
'parentNode should be an XML node'); 'parentNode should be an XML node');

View File

@@ -36,7 +36,7 @@ ol.format.IGCZ = {
*/ */
ol.format.IGC = function(opt_options) { ol.format.IGC = function(opt_options) {
var options = goog.isDef(opt_options) ? opt_options : {}; var options = opt_options ? opt_options : {};
goog.base(this); goog.base(this);
@@ -49,7 +49,7 @@ ol.format.IGC = function(opt_options) {
* @private * @private
* @type {ol.format.IGCZ} * @type {ol.format.IGCZ}
*/ */
this.altitudeMode_ = goog.isDef(options.altitudeMode) ? this.altitudeMode_ = options.altitudeMode ?
options.altitudeMode : ol.format.IGCZ.NONE; options.altitudeMode : ol.format.IGCZ.NONE;
}; };

View File

@@ -32,7 +32,7 @@ ol.format.JSONFeature.prototype.getObject_ = function(source) {
return source; return source;
} else if (goog.isString(source)) { } else if (goog.isString(source)) {
var object = goog.json.parse(source); var object = goog.json.parse(source);
return goog.isDef(object) ? object : null; return object ? object : null;
} else { } else {
goog.asserts.fail(); goog.asserts.fail();
return null; return null;

View File

@@ -13,6 +13,7 @@ goog.require('goog.dom.NodeType');
goog.require('goog.math'); goog.require('goog.math');
goog.require('goog.object'); goog.require('goog.object');
goog.require('goog.string'); goog.require('goog.string');
goog.require('ol');
goog.require('ol.Feature'); goog.require('ol.Feature');
goog.require('ol.FeatureStyleFunction'); goog.require('ol.FeatureStyleFunction');
goog.require('ol.color'); goog.require('ol.color');
@@ -68,7 +69,7 @@ ol.format.KMLGxTrackObject_;
*/ */
ol.format.KML = function(opt_options) { ol.format.KML = function(opt_options) {
var options = goog.isDef(opt_options) ? opt_options : {}; var options = opt_options ? opt_options : {};
goog.base(this); goog.base(this);
@@ -81,15 +82,15 @@ ol.format.KML = function(opt_options) {
* @private * @private
* @type {Array.<ol.style.Style>} * @type {Array.<ol.style.Style>}
*/ */
this.defaultStyle_ = goog.isDef(options.defaultStyle) ? this.defaultStyle_ = options.defaultStyle ?
options.defaultStyle : ol.format.KML.DEFAULT_STYLE_ARRAY_; options.defaultStyle : ol.format.KML.DEFAULT_STYLE_ARRAY_;
/** /**
* @private * @private
* @type {boolean} * @type {boolean}
*/ */
this.extractStyles_ = goog.isDef(options.extractStyles) ? this.extractStyles_ = ol.isDef(options.extractStyles) ?
options.extractStyles : true; /** @type {boolean} */ (options.extractStyles) : true;
/** /**
* @private * @private
@@ -296,10 +297,10 @@ ol.format.KML.createFeatureStyleFunction_ = function(
* @this {ol.Feature} * @this {ol.Feature}
*/ */
function(resolution) { function(resolution) {
if (goog.isDef(style)) { if (style) {
return style; return style;
} }
if (goog.isDef(styleUrl)) { if (styleUrl) {
return ol.format.KML.findStyle_(styleUrl, defaultStyle, sharedStyles); return ol.format.KML.findStyle_(styleUrl, defaultStyle, sharedStyles);
} }
return defaultStyle; return defaultStyle;
@@ -440,7 +441,7 @@ ol.format.KML.readVec2_ = function(node) {
*/ */
ol.format.KML.readScale_ = function(node) { ol.format.KML.readScale_ = function(node) {
var number = ol.format.XSD.readDecimal(node); var number = ol.format.XSD.readDecimal(node);
if (goog.isDef(number)) { if (ol.isDef(number)) {
return Math.sqrt(number); return Math.sqrt(number);
} else { } else {
return undefined; return undefined;
@@ -479,7 +480,7 @@ ol.format.KML.IconStyleParser_ = function(node, objectStack) {
// FIXME httpQuery // FIXME httpQuery
var object = ol.xml.pushParseAndPop( var object = ol.xml.pushParseAndPop(
{}, ol.format.KML.ICON_STYLE_PARSERS_, node, objectStack); {}, ol.format.KML.ICON_STYLE_PARSERS_, node, objectStack);
if (!goog.isDef(object)) { if (!object) {
return; return;
} }
var styleObject = /** @type {Object} */ (objectStack[objectStack.length - 1]); var styleObject = /** @type {Object} */ (objectStack[objectStack.length - 1]);
@@ -489,7 +490,7 @@ ol.format.KML.IconStyleParser_ = function(node, objectStack) {
var src; var src;
var href = /** @type {string|undefined} */ var href = /** @type {string|undefined} */
(IconObject['href']); (IconObject['href']);
if (goog.isDef(href)) { if (href) {
src = href; src = href;
} else { } else {
src = ol.format.KML.DEFAULT_IMAGE_STYLE_SRC_; src = ol.format.KML.DEFAULT_IMAGE_STYLE_SRC_;
@@ -497,7 +498,7 @@ ol.format.KML.IconStyleParser_ = function(node, objectStack) {
var anchor, anchorXUnits, anchorYUnits; var anchor, anchorXUnits, anchorYUnits;
var hotSpot = /** @type {ol.format.KMLVec2_|undefined} */ var hotSpot = /** @type {ol.format.KMLVec2_|undefined} */
(object['hotSpot']); (object['hotSpot']);
if (goog.isDef(hotSpot)) { if (hotSpot) {
anchor = [hotSpot.x, hotSpot.y]; anchor = [hotSpot.x, hotSpot.y];
anchorXUnits = hotSpot.xunits; anchorXUnits = hotSpot.xunits;
anchorYUnits = hotSpot.yunits; anchorYUnits = hotSpot.yunits;
@@ -516,7 +517,7 @@ ol.format.KML.IconStyleParser_ = function(node, objectStack) {
(IconObject['x']); (IconObject['x']);
var y = /** @type {number|undefined} */ var y = /** @type {number|undefined} */
(IconObject['y']); (IconObject['y']);
if (goog.isDef(x) && goog.isDef(y)) { if (ol.isDef(x) && ol.isDef(y)) {
offset = [x, y]; offset = [x, y];
} }
@@ -525,14 +526,14 @@ ol.format.KML.IconStyleParser_ = function(node, objectStack) {
(IconObject['w']); (IconObject['w']);
var h = /** @type {number|undefined} */ var h = /** @type {number|undefined} */
(IconObject['h']); (IconObject['h']);
if (goog.isDef(w) && goog.isDef(h)) { if (ol.isDef(w) && ol.isDef(h)) {
size = [w, h]; size = [w, h];
} }
var rotation; var rotation;
var heading = /** @type {number|undefined} */ var heading = /** @type {number} */
(object['heading']); (object['heading']);
if (goog.isDef(heading)) { if (ol.isDef(heading)) {
rotation = goog.math.toRadians(heading); rotation = goog.math.toRadians(heading);
} }
@@ -572,7 +573,7 @@ ol.format.KML.LabelStyleParser_ = function(node, objectStack) {
// FIXME colorMode // FIXME colorMode
var object = ol.xml.pushParseAndPop( var object = ol.xml.pushParseAndPop(
{}, ol.format.KML.LABEL_STYLE_PARSERS_, node, objectStack); {}, ol.format.KML.LABEL_STYLE_PARSERS_, node, objectStack);
if (!goog.isDef(object)) { if (!object) {
return; return;
} }
var styleObject = objectStack[objectStack.length - 1]; var styleObject = objectStack[objectStack.length - 1];
@@ -607,7 +608,7 @@ ol.format.KML.LineStyleParser_ = function(node, objectStack) {
// FIXME gx:labelVisibility // FIXME gx:labelVisibility
var object = ol.xml.pushParseAndPop( var object = ol.xml.pushParseAndPop(
{}, ol.format.KML.LINE_STYLE_PARSERS_, node, objectStack); {}, ol.format.KML.LINE_STYLE_PARSERS_, node, objectStack);
if (!goog.isDef(object)) { if (!object) {
return; return;
} }
var styleObject = objectStack[objectStack.length - 1]; var styleObject = objectStack[objectStack.length - 1];
@@ -635,7 +636,7 @@ ol.format.KML.PolyStyleParser_ = function(node, objectStack) {
// FIXME colorMode // FIXME colorMode
var object = ol.xml.pushParseAndPop( var object = ol.xml.pushParseAndPop(
{}, ol.format.KML.POLY_STYLE_PARSERS_, node, objectStack); {}, ol.format.KML.POLY_STYLE_PARSERS_, node, objectStack);
if (!goog.isDef(object)) { if (!object) {
return; return;
} }
var styleObject = objectStack[objectStack.length - 1]; var styleObject = objectStack[objectStack.length - 1];
@@ -647,12 +648,12 @@ ol.format.KML.PolyStyleParser_ = function(node, objectStack) {
}); });
styleObject['fillStyle'] = fillStyle; styleObject['fillStyle'] = fillStyle;
var fill = /** @type {boolean|undefined} */ (object['fill']); var fill = /** @type {boolean|undefined} */ (object['fill']);
if (goog.isDef(fill)) { if (ol.isDef(fill)) {
styleObject['fill'] = fill; styleObject['fill'] = fill;
} }
var outline = var outline =
/** @type {boolean|undefined} */ (object['outline']); /** @type {boolean|undefined} */ (object['outline']);
if (goog.isDef(outline)) { if (ol.isDef(outline)) {
styleObject['outline'] = outline; styleObject['outline'] = outline;
} }
}; };
@@ -723,7 +724,7 @@ ol.format.KML.readGxMultiTrack_ = function(node, objectStack) {
var lineStrings = ol.xml.pushParseAndPop( var lineStrings = ol.xml.pushParseAndPop(
/** @type {Array.<ol.geom.LineString>} */ ([]), /** @type {Array.<ol.geom.LineString>} */ ([]),
ol.format.KML.GX_MULTITRACK_GEOMETRY_PARSERS_, node, objectStack); ol.format.KML.GX_MULTITRACK_GEOMETRY_PARSERS_, node, objectStack);
if (!goog.isDef(lineStrings)) { if (!lineStrings) {
return undefined; return undefined;
} }
var multiLineString = new ol.geom.MultiLineString(null); var multiLineString = new ol.geom.MultiLineString(null);
@@ -750,7 +751,7 @@ ol.format.KML.readGxTrack_ = function(node, objectStack) {
flatCoordinates: [], flatCoordinates: [],
whens: [] whens: []
}), ol.format.KML.GX_TRACK_PARSERS_, node, objectStack); }), ol.format.KML.GX_TRACK_PARSERS_, node, objectStack);
if (!goog.isDef(gxTrackObject)) { if (!gxTrackObject) {
return undefined; return undefined;
} }
var flatCoordinates = gxTrackObject.flatCoordinates; var flatCoordinates = gxTrackObject.flatCoordinates;
@@ -781,7 +782,7 @@ ol.format.KML.readIcon_ = function(node, objectStack) {
goog.asserts.assert(node.localName == 'Icon', 'localName should be Icon'); goog.asserts.assert(node.localName == 'Icon', 'localName should be Icon');
var iconObject = ol.xml.pushParseAndPop( var iconObject = ol.xml.pushParseAndPop(
{}, ol.format.KML.ICON_PARSERS_, node, objectStack); {}, ol.format.KML.ICON_PARSERS_, node, objectStack);
if (goog.isDef(iconObject)) { if (iconObject) {
return iconObject; return iconObject;
} else { } else {
return null; return null;
@@ -819,7 +820,7 @@ ol.format.KML.readLineString_ = function(node, objectStack) {
objectStack); objectStack);
var flatCoordinates = var flatCoordinates =
ol.format.KML.readFlatCoordinatesFromNode_(node, objectStack); ol.format.KML.readFlatCoordinatesFromNode_(node, objectStack);
if (goog.isDef(flatCoordinates)) { if (flatCoordinates) {
var lineString = new ol.geom.LineString(null); var lineString = new ol.geom.LineString(null);
lineString.setFlatCoordinates(ol.geom.GeometryLayout.XYZ, flatCoordinates); lineString.setFlatCoordinates(ol.geom.GeometryLayout.XYZ, flatCoordinates);
lineString.setProperties(properties); lineString.setProperties(properties);
@@ -846,7 +847,7 @@ ol.format.KML.readLinearRing_ = function(node, objectStack) {
objectStack); objectStack);
var flatCoordinates = var flatCoordinates =
ol.format.KML.readFlatCoordinatesFromNode_(node, objectStack); ol.format.KML.readFlatCoordinatesFromNode_(node, objectStack);
if (goog.isDef(flatCoordinates)) { if (flatCoordinates) {
var polygon = new ol.geom.Polygon(null); var polygon = new ol.geom.Polygon(null);
polygon.setFlatCoordinates(ol.geom.GeometryLayout.XYZ, flatCoordinates, polygon.setFlatCoordinates(ol.geom.GeometryLayout.XYZ, flatCoordinates,
[flatCoordinates.length]); [flatCoordinates.length]);
@@ -872,7 +873,7 @@ ol.format.KML.readMultiGeometry_ = function(node, objectStack) {
var geometries = ol.xml.pushParseAndPop( var geometries = ol.xml.pushParseAndPop(
/** @type {Array.<ol.geom.Geometry>} */ ([]), /** @type {Array.<ol.geom.Geometry>} */ ([]),
ol.format.KML.MULTI_GEOMETRY_PARSERS_, node, objectStack); ol.format.KML.MULTI_GEOMETRY_PARSERS_, node, objectStack);
if (!goog.isDef(geometries)) { if (!geometries) {
return null; return null;
} }
if (geometries.length === 0) { if (geometries.length === 0) {
@@ -1010,14 +1011,14 @@ ol.format.KML.readStyle_ = function(node, objectStack) {
goog.asserts.assert(node.localName == 'Style', 'localName should be Style'); goog.asserts.assert(node.localName == 'Style', 'localName should be Style');
var styleObject = ol.xml.pushParseAndPop( var styleObject = ol.xml.pushParseAndPop(
{}, ol.format.KML.STYLE_PARSERS_, node, objectStack); {}, ol.format.KML.STYLE_PARSERS_, node, objectStack);
if (!goog.isDef(styleObject)) { if (!styleObject) {
return null; return null;
} }
var fillStyle = /** @type {ol.style.Fill} */ (goog.object.get( var fillStyle = /** @type {ol.style.Fill} */ (goog.object.get(
styleObject, 'fillStyle', ol.format.KML.DEFAULT_FILL_STYLE_)); styleObject, 'fillStyle', ol.format.KML.DEFAULT_FILL_STYLE_));
var fill = /** @type {boolean|undefined} */ var fill = /** @type {boolean|undefined} */
(styleObject['fill']); (styleObject['fill']);
if (goog.isDef(fill) && !fill) { if (ol.isDef(fill) && !fill) {
fillStyle = null; fillStyle = null;
} }
var imageStyle = /** @type {ol.style.Image} */ (goog.object.get( var imageStyle = /** @type {ol.style.Image} */ (goog.object.get(
@@ -1028,7 +1029,7 @@ ol.format.KML.readStyle_ = function(node, objectStack) {
styleObject, 'strokeStyle', ol.format.KML.DEFAULT_STROKE_STYLE_)); styleObject, 'strokeStyle', ol.format.KML.DEFAULT_STROKE_STYLE_));
var outline = /** @type {boolean|undefined} */ var outline = /** @type {boolean|undefined} */
(styleObject['outline']); (styleObject['outline']);
if (goog.isDef(outline) && !outline) { if (ol.isDef(outline) && !outline) {
strokeStyle = null; strokeStyle = null;
} }
return [new ol.style.Style({ return [new ol.style.Style({
@@ -1060,8 +1061,8 @@ ol.format.KML.setCommonGeometryProperties_ = function(multiGeometry,
geometry = geometries[i]; geometry = geometries[i];
extrudes[i] = geometry.get('extrude'); extrudes[i] = geometry.get('extrude');
altitudeModes[i] = geometry.get('altitudeMode'); altitudeModes[i] = geometry.get('altitudeMode');
hasExtrude = hasExtrude || goog.isDef(extrudes[i]); hasExtrude = hasExtrude || ol.isDef(extrudes[i]);
hasAltitudeMode = hasAltitudeMode || goog.isDef(altitudeModes[i]); hasAltitudeMode = hasAltitudeMode || altitudeModes[i];
} }
if (hasExtrude) { if (hasExtrude) {
multiGeometry.set('extrude', extrudes); multiGeometry.set('extrude', extrudes);
@@ -1085,7 +1086,7 @@ ol.format.KML.DataParser_ = function(node, objectStack) {
if (!goog.isNull(name)) { if (!goog.isNull(name)) {
var data = ol.xml.pushParseAndPop( var data = ol.xml.pushParseAndPop(
undefined, ol.format.KML.DATA_PARSERS_, node, objectStack); undefined, ol.format.KML.DATA_PARSERS_, node, objectStack);
if (goog.isDef(data)) { if (data) {
var featureObject = var featureObject =
/** @type {Object} */ (objectStack[objectStack.length - 1]); /** @type {Object} */ (objectStack[objectStack.length - 1]);
goog.asserts.assert(goog.isObject(featureObject), goog.asserts.assert(goog.isObject(featureObject),
@@ -1121,20 +1122,20 @@ ol.format.KML.PairDataParser_ = function(node, objectStack) {
goog.asserts.assert(node.localName == 'Pair', 'localName should be Pair'); goog.asserts.assert(node.localName == 'Pair', 'localName should be Pair');
var pairObject = ol.xml.pushParseAndPop( var pairObject = ol.xml.pushParseAndPop(
{}, ol.format.KML.PAIR_PARSERS_, node, objectStack); {}, ol.format.KML.PAIR_PARSERS_, node, objectStack);
if (!goog.isDef(pairObject)) { if (!pairObject) {
return; return;
} }
var key = /** @type {string|undefined} */ var key = /** @type {string|undefined} */
(pairObject['key']); (pairObject['key']);
if (goog.isDef(key) && key == 'normal') { if (key && key == 'normal') {
var styleUrl = /** @type {string|undefined} */ var styleUrl = /** @type {string|undefined} */
(pairObject['styleUrl']); (pairObject['styleUrl']);
if (goog.isDef(styleUrl)) { if (styleUrl) {
objectStack[objectStack.length - 1] = styleUrl; objectStack[objectStack.length - 1] = styleUrl;
} }
var Style = /** @type {ol.style.Style} */ var Style = /** @type {ol.style.Style} */
(pairObject['Style']); (pairObject['Style']);
if (goog.isDef(Style)) { if (Style) {
objectStack[objectStack.length - 1] = Style; objectStack[objectStack.length - 1] = Style;
} }
} }
@@ -1152,7 +1153,7 @@ ol.format.KML.PlacemarkStyleMapParser_ = function(node, objectStack) {
goog.asserts.assert(node.localName == 'StyleMap', goog.asserts.assert(node.localName == 'StyleMap',
'localName should be StyleMap'); 'localName should be StyleMap');
var styleMapValue = ol.format.KML.readStyleMapValue_(node, objectStack); var styleMapValue = ol.format.KML.readStyleMapValue_(node, objectStack);
if (!goog.isDef(styleMapValue)) { if (!styleMapValue) {
return; return;
} }
var placemarkObject = objectStack[objectStack.length - 1]; var placemarkObject = objectStack[objectStack.length - 1];
@@ -1215,7 +1216,7 @@ ol.format.KML.innerBoundaryIsParser_ = function(node, objectStack) {
var flatLinearRing = ol.xml.pushParseAndPop( var flatLinearRing = ol.xml.pushParseAndPop(
/** @type {Array.<number>|undefined} */ (undefined), /** @type {Array.<number>|undefined} */ (undefined),
ol.format.KML.INNER_BOUNDARY_IS_PARSERS_, node, objectStack); ol.format.KML.INNER_BOUNDARY_IS_PARSERS_, node, objectStack);
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),
@@ -1240,7 +1241,7 @@ ol.format.KML.outerBoundaryIsParser_ = function(node, objectStack) {
var flatLinearRing = ol.xml.pushParseAndPop( var flatLinearRing = ol.xml.pushParseAndPop(
/** @type {Array.<number>|undefined} */ (undefined), /** @type {Array.<number>|undefined} */ (undefined),
ol.format.KML.OUTER_BOUNDARY_IS_PARSERS_, node, objectStack); ol.format.KML.OUTER_BOUNDARY_IS_PARSERS_, node, objectStack);
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),
@@ -1285,16 +1286,16 @@ ol.format.KML.whenParser_ = function(node, objectStack) {
var m = re.exec(s); var m = re.exec(s);
if (m) { if (m) {
var year = parseInt(m[1], 10); var year = parseInt(m[1], 10);
var month = goog.isDef(m[3]) ? parseInt(m[3], 10) - 1 : 0; var month = m[3] ? parseInt(m[3], 10) - 1 : 0;
var day = goog.isDef(m[5]) ? parseInt(m[5], 10) : 1; var day = m[5] ? parseInt(m[5], 10) : 1;
var hour = goog.isDef(m[7]) ? parseInt(m[7], 10) : 0; var hour = m[7] ? parseInt(m[7], 10) : 0;
var minute = goog.isDef(m[8]) ? parseInt(m[8], 10) : 0; var minute = m[8] ? parseInt(m[8], 10) : 0;
var second = goog.isDef(m[9]) ? parseInt(m[9], 10) : 0; var second = m[9] ? parseInt(m[9], 10) : 0;
var when = Date.UTC(year, month, day, hour, minute, second); var when = Date.UTC(year, month, day, hour, minute, second);
if (goog.isDef(m[10]) && m[10] != 'Z') { if (m[10] && m[10] != 'Z') {
var sign = m[11] == '-' ? -1 : 1; var sign = m[11] == '-' ? -1 : 1;
when += sign * 60 * parseInt(m[12], 10); when += sign * 60 * parseInt(m[12], 10);
if (goog.isDef(m[13])) { if (m[13]) {
when += sign * 60 * 60 * parseInt(m[13], 10); when += sign * 60 * 60 * parseInt(m[13], 10);
} }
} }
@@ -1650,7 +1651,7 @@ ol.format.KML.prototype.readDocumentOrFolder_ = function(node, objectStack) {
}); });
var features = ol.xml.pushParseAndPop(/** @type {Array.<ol.Feature>} */ ([]), var features = ol.xml.pushParseAndPop(/** @type {Array.<ol.Feature>} */ ([]),
parsersNS, node, objectStack, this); parsersNS, node, objectStack, this);
if (goog.isDef(features)) { if (features) {
return features; return features;
} else { } else {
return undefined; return undefined;
@@ -1671,7 +1672,7 @@ ol.format.KML.prototype.readPlacemark_ = function(node, objectStack) {
'localName should be Placemark'); 'localName should be Placemark');
var object = ol.xml.pushParseAndPop({'geometry': null}, var object = ol.xml.pushParseAndPop({'geometry': null},
ol.format.KML.PLACEMARK_PARSERS_, node, objectStack); ol.format.KML.PLACEMARK_PARSERS_, node, objectStack);
if (!goog.isDef(object)) { if (!object) {
return undefined; return undefined;
} }
var feature = new ol.Feature(); var feature = new ol.Feature();
@@ -1717,7 +1718,7 @@ ol.format.KML.prototype.readSharedStyle_ = function(node, objectStack) {
var id = node.getAttribute('id'); var id = node.getAttribute('id');
if (!goog.isNull(id)) { if (!goog.isNull(id)) {
var style = ol.format.KML.readStyle_(node, objectStack); var style = ol.format.KML.readStyle_(node, objectStack);
if (goog.isDef(style)) { if (style) {
var styleUri; var styleUri;
if (goog.isDefAndNotNull(node.baseURI)) { if (goog.isDefAndNotNull(node.baseURI)) {
styleUri = goog.Uri.resolve(node.baseURI, '#' + id).toString(); styleUri = goog.Uri.resolve(node.baseURI, '#' + id).toString();
@@ -1745,7 +1746,7 @@ ol.format.KML.prototype.readSharedStyleMap_ = function(node, objectStack) {
return; return;
} }
var styleMapValue = ol.format.KML.readStyleMapValue_(node, objectStack); var styleMapValue = ol.format.KML.readStyleMapValue_(node, objectStack);
if (!goog.isDef(styleMapValue)) { if (!styleMapValue) {
return; return;
} }
var styleUri; var styleUri;
@@ -1783,7 +1784,7 @@ ol.format.KML.prototype.readFeatureFromNode = function(node, opt_options) {
'localName should be Placemark'); 'localName should be Placemark');
var feature = this.readPlacemark_( var feature = this.readPlacemark_(
node, [this.getReadOptions(node, opt_options)]); node, [this.getReadOptions(node, opt_options)]);
if (goog.isDef(feature)) { if (feature) {
return feature; return feature;
} else { } else {
return null; return null;
@@ -1817,7 +1818,7 @@ ol.format.KML.prototype.readFeaturesFromNode = function(node, opt_options) {
if (localName == 'Document' || localName == 'Folder') { if (localName == 'Document' || localName == 'Folder') {
features = this.readDocumentOrFolder_( features = this.readDocumentOrFolder_(
node, [this.getReadOptions(node, opt_options)]); node, [this.getReadOptions(node, opt_options)]);
if (goog.isDef(features)) { if (features) {
return features; return features;
} else { } else {
return []; return [];
@@ -1825,7 +1826,7 @@ ol.format.KML.prototype.readFeaturesFromNode = function(node, opt_options) {
} else if (localName == 'Placemark') { } else if (localName == 'Placemark') {
var feature = this.readPlacemark_( var feature = this.readPlacemark_(
node, [this.getReadOptions(node, opt_options)]); node, [this.getReadOptions(node, opt_options)]);
if (goog.isDef(feature)) { if (feature) {
return [feature]; return [feature];
} else { } else {
return []; return [];
@@ -1836,7 +1837,7 @@ ol.format.KML.prototype.readFeaturesFromNode = function(node, opt_options) {
for (n = node.firstElementChild; !goog.isNull(n); for (n = node.firstElementChild; !goog.isNull(n);
n = n.nextElementSibling) { n = n.nextElementSibling) {
var fs = this.readFeaturesFromNode(n, opt_options); var fs = this.readFeaturesFromNode(n, opt_options);
if (goog.isDef(fs)) { if (fs) {
goog.array.extend(features, fs); goog.array.extend(features, fs);
} }
} }
@@ -1878,7 +1879,7 @@ ol.format.KML.prototype.readNameFromDocument = function(doc) {
for (n = doc.firstChild; !goog.isNull(n); n = n.nextSibling) { for (n = doc.firstChild; !goog.isNull(n); n = n.nextSibling) {
if (n.nodeType == goog.dom.NodeType.ELEMENT) { if (n.nodeType == goog.dom.NodeType.ELEMENT) {
var name = this.readNameFromNode(n); var name = this.readNameFromNode(n);
if (goog.isDef(name)) { if (name) {
return name; return name;
} }
} }
@@ -1907,7 +1908,7 @@ ol.format.KML.prototype.readNameFromNode = function(node) {
localName == 'Placemark' || localName == 'Placemark' ||
localName == 'kml')) { localName == 'kml')) {
var name = this.readNameFromNode(n); var name = this.readNameFromNode(n);
if (goog.isDef(name)) { if (name) {
return name; return name;
} }
} }
@@ -2165,7 +2166,7 @@ ol.format.KML.writeLabelStyle_ = function(node, style, objectStack) {
properties['color'] = fill.getColor(); properties['color'] = fill.getColor();
} }
var scale = style.getScale(); var scale = style.getScale();
if (goog.isDef(scale) && scale !== 1) { if (scale && scale !== 1) {
properties['scale'] = scale; properties['scale'] = scale;
} }
var parentNode = objectStack[objectStack.length - 1].node; var parentNode = objectStack[objectStack.length - 1].node;
@@ -2272,7 +2273,7 @@ ol.format.KML.writePlacemark_ = function(node, feature, objectStack) {
// serialize properties (properties unknown to KML are not serialized) // serialize properties (properties unknown to KML are not serialized)
var properties = feature.getProperties(); var properties = feature.getProperties();
var styleFunction = feature.getStyleFunction(); var styleFunction = feature.getStyleFunction();
if (goog.isDef(styleFunction)) { if (styleFunction) {
// FIXME the styles returned by the style function are supposed to be // FIXME the styles returned by the style function are supposed to be
// resolution-independent here // resolution-independent here
var styles = styleFunction.call(feature, 0); var styles = styleFunction.call(feature, 0);

View File

@@ -223,7 +223,7 @@ ol.format.OSMXML.prototype.readFeaturesFromNode = function(node, opt_options) {
nodes: {}, nodes: {},
features: [] features: []
}, ol.format.OSMXML.PARSERS_, node, [options]); }, ol.format.OSMXML.PARSERS_, node, [options]);
if (goog.isDef(state.features)) { if (state.features) {
return state.features; return state.features;
} }
} }

View File

@@ -44,7 +44,7 @@ ol.format.OWS.prototype.readFromNode = function(node) {
'node.nodeType should be ELEMENT'); 'node.nodeType should be ELEMENT');
var owsObject = ol.xml.pushParseAndPop({}, var owsObject = ol.xml.pushParseAndPop({},
ol.format.OWS.PARSERS_, node, []); ol.format.OWS.PARSERS_, node, []);
return goog.isDef(owsObject) ? owsObject : null; return owsObject ? owsObject : null;
}; };
@@ -92,7 +92,7 @@ ol.format.OWS.readConstraint_ = function(node, objectStack) {
goog.asserts.assert(node.localName == 'Constraint', goog.asserts.assert(node.localName == 'Constraint',
'localName should be Constraint'); 'localName should be Constraint');
var name = node.getAttribute('name'); var name = node.getAttribute('name');
if (!goog.isDef(name)) { if (!name) {
return undefined; return undefined;
} }
return ol.xml.pushParseAndPop({'name': name}, return ol.xml.pushParseAndPop({'name': name},
@@ -143,7 +143,7 @@ ol.format.OWS.readGet_ = function(node, objectStack) {
'node.nodeType should be ELEMENT'); 'node.nodeType should be ELEMENT');
goog.asserts.assert(node.localName == 'Get', 'localName should be Get'); goog.asserts.assert(node.localName == 'Get', 'localName should be Get');
var href = ol.format.XLink.readHref(node); var href = ol.format.XLink.readHref(node);
if (!goog.isDef(href)) { if (!href) {
return undefined; return undefined;
} }
return ol.xml.pushParseAndPop({'href': href}, return ol.xml.pushParseAndPop({'href': href},
@@ -180,7 +180,7 @@ ol.format.OWS.readOperation_ = function(node, objectStack) {
var name = node.getAttribute('name'); var name = node.getAttribute('name');
var value = ol.xml.pushParseAndPop({}, var value = ol.xml.pushParseAndPop({},
ol.format.OWS.OPERATION_PARSERS_, node, objectStack); ol.format.OWS.OPERATION_PARSERS_, node, objectStack);
if (!goog.isDef(value)) { if (!value) {
return undefined; return undefined;
} }
var object = /** @type {Object} */ var object = /** @type {Object} */

View File

@@ -26,7 +26,7 @@ goog.require('ol.proj');
*/ */
ol.format.Polyline = function(opt_options) { ol.format.Polyline = function(opt_options) {
var options = goog.isDef(opt_options) ? opt_options : {}; var options = opt_options ? opt_options : {};
goog.base(this); goog.base(this);
@@ -39,13 +39,13 @@ ol.format.Polyline = function(opt_options) {
* @private * @private
* @type {number} * @type {number}
*/ */
this.factor_ = goog.isDef(options.factor) ? options.factor : 1e5; this.factor_ = options.factor ? options.factor : 1e5;
/** /**
* @private * @private
* @type {ol.geom.GeometryLayout} * @type {ol.geom.GeometryLayout}
*/ */
this.geometryLayout_ = goog.isDef(options.geometryLayout) ? this.geometryLayout_ = options.geometryLayout ?
options.geometryLayout : ol.geom.GeometryLayout.XY; options.geometryLayout : ol.geom.GeometryLayout.XY;
}; };
goog.inherits(ol.format.Polyline, ol.format.TextFeature); goog.inherits(ol.format.Polyline, ol.format.TextFeature);
@@ -65,7 +65,7 @@ goog.inherits(ol.format.Polyline, ol.format.TextFeature);
* @api * @api
*/ */
ol.format.Polyline.encodeDeltas = function(numbers, stride, opt_factor) { ol.format.Polyline.encodeDeltas = function(numbers, stride, opt_factor) {
var factor = goog.isDef(opt_factor) ? opt_factor : 1e5; var factor = opt_factor ? opt_factor : 1e5;
var d; var d;
var lastNumbers = new Array(stride); var lastNumbers = new Array(stride);
@@ -100,7 +100,7 @@ ol.format.Polyline.encodeDeltas = function(numbers, stride, opt_factor) {
* @api * @api
*/ */
ol.format.Polyline.decodeDeltas = function(encoded, stride, opt_factor) { ol.format.Polyline.decodeDeltas = function(encoded, stride, opt_factor) {
var factor = goog.isDef(opt_factor) ? opt_factor : 1e5; var factor = opt_factor ? opt_factor : 1e5;
var d; var d;
/** @type {Array.<number>} */ /** @type {Array.<number>} */
@@ -137,7 +137,7 @@ ol.format.Polyline.decodeDeltas = function(encoded, stride, opt_factor) {
* @api * @api
*/ */
ol.format.Polyline.encodeFloats = function(numbers, opt_factor) { ol.format.Polyline.encodeFloats = function(numbers, opt_factor) {
var factor = goog.isDef(opt_factor) ? opt_factor : 1e5; var factor = opt_factor ? opt_factor : 1e5;
var i, ii; var i, ii;
for (i = 0, ii = numbers.length; i < ii; ++i) { for (i = 0, ii = numbers.length; i < ii; ++i) {
numbers[i] = Math.round(numbers[i] * factor); numbers[i] = Math.round(numbers[i] * factor);
@@ -157,7 +157,7 @@ ol.format.Polyline.encodeFloats = function(numbers, opt_factor) {
* @api * @api
*/ */
ol.format.Polyline.decodeFloats = function(encoded, opt_factor) { ol.format.Polyline.decodeFloats = function(encoded, opt_factor) {
var factor = goog.isDef(opt_factor) ? opt_factor : 1e5; var factor = opt_factor ? opt_factor : 1e5;
var numbers = ol.format.Polyline.decodeSignedIntegers(encoded); var numbers = ol.format.Polyline.decodeSignedIntegers(encoded);
var i, ii; var i, ii;
for (i = 0, ii = numbers.length; i < ii; ++i) { for (i = 0, ii = numbers.length; i < ii; ++i) {

View File

@@ -26,7 +26,7 @@ goog.require('ol.proj');
*/ */
ol.format.TopoJSON = function(opt_options) { ol.format.TopoJSON = function(opt_options) {
var options = goog.isDef(opt_options) ? opt_options : {}; var options = opt_options ? opt_options : {};
goog.base(this); goog.base(this);
@@ -251,8 +251,7 @@ ol.format.TopoJSON.readFeatureFromGeometry_ = function(object, arcs,
var geometry; var geometry;
var type = object.type; var type = object.type;
var geometryReader = ol.format.TopoJSON.GEOMETRY_READERS_[type]; var geometryReader = ol.format.TopoJSON.GEOMETRY_READERS_[type];
goog.asserts.assert(goog.isDef(geometryReader), goog.asserts.assert(geometryReader, 'geometryReader should be defined');
'geometryReader should be defined');
if ((type === 'Point') || (type === 'MultiPoint')) { if ((type === 'Point') || (type === 'MultiPoint')) {
geometry = geometryReader(object, scale, translate); geometry = geometryReader(object, scale, translate);
} else { } else {
@@ -261,10 +260,10 @@ ol.format.TopoJSON.readFeatureFromGeometry_ = function(object, arcs,
var feature = new ol.Feature(); var feature = new ol.Feature();
feature.setGeometry(/** @type {ol.geom.Geometry} */ ( feature.setGeometry(/** @type {ol.geom.Geometry} */ (
ol.format.Feature.transformWithOptions(geometry, false, opt_options))); ol.format.Feature.transformWithOptions(geometry, false, opt_options)));
if (goog.isDef(object.id)) { if (object.id) {
feature.setId(object.id); feature.setId(object.id);
} }
if (goog.isDef(object.properties)) { if (object.properties) {
feature.setProperties(object.properties); feature.setProperties(object.properties);
} }
return feature; return feature;
@@ -290,13 +289,13 @@ ol.format.TopoJSON.prototype.readFeaturesFromObject = function(
if (object.type == 'Topology') { if (object.type == 'Topology') {
var topoJSONTopology = /** @type {TopoJSONTopology} */ (object); var topoJSONTopology = /** @type {TopoJSONTopology} */ (object);
var transform, scale = null, translate = null; var transform, scale = null, translate = null;
if (goog.isDef(topoJSONTopology.transform)) { if (topoJSONTopology.transform) {
transform = topoJSONTopology.transform; transform = topoJSONTopology.transform;
scale = transform.scale; scale = transform.scale;
translate = transform.translate; translate = transform.translate;
} }
var arcs = topoJSONTopology.arcs; var arcs = topoJSONTopology.arcs;
if (goog.isDef(transform)) { if (transform) {
ol.format.TopoJSON.transformArcs_(arcs, scale, translate); ol.format.TopoJSON.transformArcs_(arcs, scale, translate);
} }
/** @type {Array.<ol.Feature>} */ /** @type {Array.<ol.Feature>} */