diff --git a/src/ol/format/esrijsonformat.js b/src/ol/format/esrijsonformat.js index aae2124455..340453c6ea 100644 --- a/src/ol/format/esrijsonformat.js +++ b/src/ol/format/esrijsonformat.js @@ -32,7 +32,7 @@ goog.require('ol.proj'); */ ol.format.EsriJSON = function(opt_options) { - var options = goog.isDef(opt_options) ? opt_options : {}; + var options = opt_options ? opt_options : {}; goog.base(this); @@ -80,9 +80,9 @@ ol.format.EsriJSON.readGeometry_ = function(object, opt_options) { 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]; - goog.asserts.assert(goog.isDef(geometryReader), + goog.asserts.assert(geometryReader, 'geometryReader should be defined'); return /** @type {ol.geom.Geometry} */ ( ol.format.Feature.transformWithOptions( @@ -490,19 +490,19 @@ ol.format.EsriJSON.prototype.readFeatureFromObject = function( var geometry = ol.format.EsriJSON.readGeometry_(esriJSONFeature.geometry, opt_options); var feature = new ol.Feature(); - if (goog.isDef(this.geometryName_)) { + if (this.geometryName_) { feature.setGeometryName(this.geometryName_); } feature.setGeometry(geometry); - if (goog.isDef(opt_options) && goog.isDef(opt_options.idField) && - goog.isDef(esriJSONFeature.attributes[opt_options.idField])) { + if (opt_options && opt_options.idField && + esriJSONFeature.attributes[opt_options.idField]) { goog.asserts.assert( goog.isNumber(esriJSONFeature.attributes[opt_options.idField]), 'objectIdFieldName value should be a number'); feature.setId(/** @type {number} */( esriJSONFeature.attributes[opt_options.idField])); } - if (goog.isDef(esriJSONFeature.attributes)) { + if (esriJSONFeature.attributes) { feature.setProperties(esriJSONFeature.attributes); } return feature; @@ -515,7 +515,7 @@ ol.format.EsriJSON.prototype.readFeatureFromObject = function( ol.format.EsriJSON.prototype.readFeaturesFromObject = function( object, opt_options) { var esriJSONObject = /** @type {EsriJSONObject} */ (object); - var options = goog.isDef(opt_options) ? opt_options : {}; + var options = opt_options ? opt_options : {}; if (goog.isDefAndNotNull(esriJSONObject.features)) { var esriJSONFeatureCollection = /** @type {EsriJSONFeatureCollection} */ (object); @@ -591,8 +591,7 @@ ol.format.EsriJSON.prototype.readProjectionFromObject = function(object) { */ ol.format.EsriJSON.writeGeometry_ = function(geometry, opt_options) { var geometryWriter = ol.format.EsriJSON.GEOMETRY_WRITERS_[geometry.getType()]; - goog.asserts.assert(goog.isDef(geometryWriter), - 'geometryWriter should be defined'); + goog.asserts.assert(geometryWriter, 'geometryWriter should be defined'); return geometryWriter(/** @type {ol.geom.Geometry} */ ( ol.format.Feature.transformWithOptions(geometry, true, opt_options)), opt_options); @@ -662,7 +661,7 @@ ol.format.EsriJSON.prototype.writeFeatureObject = function( } else { object['attributes'] = {}; } - if (goog.isDef(opt_options) && goog.isDef(opt_options.featureProjection)) { + if (opt_options && opt_options.featureProjection) { object['spatialReference'] = /** @type {EsriJSONCRS} */({ wkid: ol.proj.get( opt_options.featureProjection).getCode().split(':').pop() diff --git a/src/ol/format/geojsonformat.js b/src/ol/format/geojsonformat.js index 6926fc5036..30925927af 100644 --- a/src/ol/format/geojsonformat.js +++ b/src/ol/format/geojsonformat.js @@ -31,7 +31,7 @@ goog.require('ol.proj'); */ ol.format.GeoJSON = function(opt_options) { - var options = goog.isDef(opt_options) ? opt_options : {}; + var options = opt_options ? opt_options : {}; goog.base(this); @@ -73,8 +73,7 @@ ol.format.GeoJSON.readGeometry_ = function(object, opt_options) { return null; } var geometryReader = ol.format.GeoJSON.GEOMETRY_READERS_[object.type]; - goog.asserts.assert(goog.isDef(geometryReader), - 'geometryReader should be defined'); + goog.asserts.assert(geometryReader, 'geometryReader should be defined'); return /** @type {ol.geom.Geometry} */ ( ol.format.Feature.transformWithOptions( geometryReader(object), false, opt_options)); @@ -183,8 +182,7 @@ ol.format.GeoJSON.readPolygonGeometry_ = function(object) { */ ol.format.GeoJSON.writeGeometry_ = function(geometry, opt_options) { var geometryWriter = ol.format.GeoJSON.GEOMETRY_WRITERS_[geometry.getType()]; - goog.asserts.assert(goog.isDef(geometryWriter), - 'geometryWriter should be defined'); + goog.asserts.assert(geometryWriter, 'geometryWriter should be defined'); return geometryWriter(/** @type {ol.geom.Geometry} */ ( ol.format.Feature.transformWithOptions(geometry, true, opt_options)), opt_options); @@ -284,7 +282,7 @@ ol.format.GeoJSON.writeMultiPolygonGeometry_ = function(geometry, opt_options) { goog.asserts.assertInstanceof(geometry, ol.geom.MultiPolygon, 'geometry should be an ol.geom.MultiPolygon'); var right; - if (goog.isDef(opt_options)) { + if (opt_options) { right = opt_options.rightHanded; } return /** @type {GeoJSONGeometry} */ ({ @@ -320,7 +318,7 @@ ol.format.GeoJSON.writePolygonGeometry_ = function(geometry, opt_options) { goog.asserts.assertInstanceof(geometry, ol.geom.Polygon, 'geometry should be an ol.geom.Polygon'); var right; - if (goog.isDef(opt_options)) { + if (opt_options) { right = opt_options.rightHanded; } return /** @type {GeoJSONGeometry} */ ({ @@ -408,14 +406,14 @@ ol.format.GeoJSON.prototype.readFeatureFromObject = function( var geometry = ol.format.GeoJSON.readGeometry_(geoJSONFeature.geometry, opt_options); var feature = new ol.Feature(); - if (goog.isDef(this.geometryName_)) { + if (this.geometryName_) { feature.setGeometryName(this.geometryName_); } feature.setGeometry(geometry); - if (goog.isDef(geoJSONFeature.id)) { + if (geoJSONFeature.id) { feature.setId(geoJSONFeature.id); } - if (goog.isDef(geoJSONFeature.properties)) { + if (geoJSONFeature.properties) { feature.setProperties(geoJSONFeature.properties); } return feature; diff --git a/src/ol/format/gml/gml3format.js b/src/ol/format/gml/gml3format.js index 6dcff97b7b..b0fd244e62 100644 --- a/src/ol/format/gml/gml3format.js +++ b/src/ol/format/gml/gml3format.js @@ -5,6 +5,7 @@ goog.require('goog.array'); goog.require('goog.asserts'); goog.require('goog.dom.NodeType'); goog.require('goog.object'); +goog.require('ol'); goog.require('ol.Feature'); goog.require('ol.extent'); goog.require('ol.format.Feature'); @@ -37,7 +38,7 @@ goog.require('ol.xml'); */ ol.format.GML3 = function(opt_options) { var options = /** @type {olx.format.GMLOptions} */ - (goog.isDef(opt_options) ? opt_options : {}); + (opt_options ? opt_options : {}); goog.base(this, options); @@ -45,34 +46,34 @@ ol.format.GML3 = function(opt_options) { * @private * @type {boolean} */ - this.surface_ = goog.isDef(options.surface) ? - options.surface : false; + this.surface_ = ol.isDef(options.surface) ? + /** @type {boolean} */ (options.surface) : false; /** * @private * @type {boolean} */ - this.curve_ = goog.isDef(options.curve) ? - options.curve : false; + this.curve_ = ol.isDef(options.curve) ? + /** @type {boolean} */ (options.curve) : false; /** * @private * @type {boolean} */ - this.multiCurve_ = goog.isDef(options.multiCurve) ? - options.multiCurve : true; + this.multiCurve_ = ol.isDef(options.multiCurve) ? + /** @type {boolean} */ (options.multiCurve) : true; /** * @private * @type {boolean} */ - this.multiSurface_ = goog.isDef(options.multiSurface) ? - options.multiSurface : true; + this.multiSurface_ = ol.isDef(options.multiSurface) ? + /** @type {boolean} */ (options.multiSurface) : true; /** * @inheritDoc */ - this.schemaLocation = goog.isDef(options.schemaLocation) ? + this.schemaLocation = options.schemaLocation ? options.schemaLocation : ol.format.GML3.schemaLocation_; }; @@ -103,7 +104,7 @@ ol.format.GML3.prototype.readMultiCurve_ = function(node, objectStack) { var lineStrings = ol.xml.pushParseAndPop( /** @type {Array.} */ ([]), this.MULTICURVE_PARSERS_, node, objectStack, this); - if (goog.isDef(lineStrings)) { + if (lineStrings) { var multiLineString = new ol.geom.MultiLineString(null); multiLineString.setLineStrings(lineStrings); return multiLineString; @@ -127,7 +128,7 @@ ol.format.GML3.prototype.readMultiSurface_ = function(node, objectStack) { var polygons = ol.xml.pushParseAndPop( /** @type {Array.} */ ([]), this.MULTISURFACE_PARSERS_, node, objectStack, this); - if (goog.isDef(polygons)) { + if (polygons) { var multiPolygon = new ol.geom.MultiPolygon(null); multiPolygon.setPolygons(polygons); return multiPolygon; @@ -251,7 +252,7 @@ ol.format.GML3.prototype.interiorParser_ = function(node, objectStack) { var flatLinearRing = ol.xml.pushParseAndPop( /** @type {Array.|undefined} */ (undefined), this.RING_PARSERS, node, objectStack, this); - if (goog.isDef(flatLinearRing)) { + if (flatLinearRing) { var flatLinearRings = /** @type {Array.>} */ (objectStack[objectStack.length - 1]); goog.asserts.assert(goog.isArray(flatLinearRings), @@ -276,7 +277,7 @@ ol.format.GML3.prototype.exteriorParser_ = function(node, objectStack) { var flatLinearRing = ol.xml.pushParseAndPop( /** @type {Array.|undefined} */ (undefined), this.RING_PARSERS, node, objectStack, this); - if (goog.isDef(flatLinearRing)) { + if (flatLinearRing) { var flatLinearRings = /** @type {Array.>} */ (objectStack[objectStack.length - 1]); goog.asserts.assert(goog.isArray(flatLinearRings), @@ -302,8 +303,7 @@ ol.format.GML3.prototype.readSurface_ = function(node, objectStack) { var flatLinearRings = ol.xml.pushParseAndPop( /** @type {Array.>} */ ([null]), this.SURFACE_PARSERS_, node, objectStack, this); - if (goog.isDef(flatLinearRings) && - !goog.isNull(flatLinearRings[0])) { + if (flatLinearRings && !goog.isNull(flatLinearRings[0])) { var polygon = new ol.geom.Polygon(null); var flatCoordinates = flatLinearRings[0]; var ends = [flatCoordinates.length]; @@ -334,7 +334,7 @@ ol.format.GML3.prototype.readCurve_ = function(node, objectStack) { var flatCoordinates = ol.xml.pushParseAndPop( /** @type {Array.} */ ([null]), this.CURVE_PARSERS_, node, objectStack, this); - if (goog.isDef(flatCoordinates)) { + if (flatCoordinates) { var lineString = new ol.geom.LineString(null); lineString.setFlatCoordinates(ol.geom.GeometryLayout.XYZ, flatCoordinates); return lineString; @@ -741,7 +741,7 @@ ol.format.GML3.prototype.writeEnvelope = function(node, extent, objectStack) { var context = objectStack[objectStack.length - 1]; goog.asserts.assert(goog.isObject(context), 'context should be an Object'); var srsName = context['srsName']; - if (goog.isDef(srsName)) { + if (srsName) { node.setAttribute('srsName', srsName); } var keys = ['lowerCorner', 'upperCorner']; @@ -787,11 +787,11 @@ ol.format.GML3.prototype.RING_NODE_FACTORY_ = var parentNode = context.node; goog.asserts.assert(goog.isObject(context), 'context should be an Object'); var exteriorWritten = context['exteriorWritten']; - if (!goog.isDef(exteriorWritten)) { + if (!ol.isDef(exteriorWritten)) { context['exteriorWritten'] = true; } 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'); var child = this.GEOMETRY_NODE_FACTORY_( polygon, objectStack); - if (goog.isDef(child)) { + if (child) { node.appendChild(child); this.writeSurfaceOrPolygon_(child, polygon, objectStack); } @@ -979,7 +979,7 @@ ol.format.GML3.prototype.writeLineStringOrCurveMember_ = var context = objectStack[objectStack.length - 1]; goog.asserts.assert(goog.isObject(context), 'context should be an Object'); var child = this.GEOMETRY_NODE_FACTORY_(line, objectStack); - if (goog.isDef(child)) { + if (child) { node.appendChild(child); this.writeCurveOrLineString_(child, line, objectStack); } @@ -1028,7 +1028,7 @@ ol.format.GML3.prototype.writeGeometryElement = item.node = node; var value; if (goog.isArray(geometry)) { - if (goog.isDef(context.dataProjection)) { + if (context.dataProjection) { value = ol.proj.transformExtent( geometry, context.featureProjection, context.dataProjection); } else { @@ -1055,14 +1055,14 @@ ol.format.GML3.prototype.writeGeometryElement = ol.format.GML3.prototype.writeFeatureElement = function(node, feature, objectStack) { var fid = feature.getId(); - if (goog.isDef(fid)) { + if (fid) { node.setAttribute('fid', fid); } var context = objectStack[objectStack.length - 1]; goog.asserts.assert(goog.isObject(context), 'context should be an Object'); var featureNS = context['featureNS']; var geometryName = feature.getGeometryName(); - if (!goog.isDef(context.serializers)) { + if (!context.serializers) { context.serializers = {}; context.serializers[featureNS] = {}; } @@ -1293,7 +1293,7 @@ ol.format.GML3.prototype.writeGeometryNode = function(geometry, opt_options) { var context = {node: geom, srsName: this.srsName, curve: this.curve_, surface: this.surface_, multiSurface: this.multiSurface_, multiCurve: this.multiCurve_}; - if (goog.isDef(opt_options)) { + if (opt_options) { goog.object.extend(context, opt_options); } this.writeGeometryElement(geom, geometry, [context]); @@ -1336,7 +1336,7 @@ ol.format.GML3.prototype.writeFeaturesNode = function(features, opt_options) { featureNS: this.featureNS, featureType: this.featureType }; - if (goog.isDef(opt_options)) { + if (opt_options) { goog.object.extend(context, opt_options); } this.writeFeatureMembers_(node, features, [context]); diff --git a/src/ol/format/gpxformat.js b/src/ol/format/gpxformat.js index fabb0f6b72..2da803bf43 100644 --- a/src/ol/format/gpxformat.js +++ b/src/ol/format/gpxformat.js @@ -27,7 +27,7 @@ goog.require('ol.xml'); */ ol.format.GPX = function(opt_options) { - var options = goog.isDef(opt_options) ? opt_options : {}; + var options = opt_options ? opt_options : {}; goog.base(this); @@ -130,7 +130,7 @@ ol.format.GPX.parseRtePt_ = function(node, objectStack) { goog.asserts.assert(node.localName == 'rtept', 'localName should be rtept'); var values = ol.xml.pushParseAndPop( {}, ol.format.GPX.RTEPT_PARSERS_, node, objectStack); - if (goog.isDef(values)) { + if (values) { var rteValues = /** @type {Object} */ (objectStack[objectStack.length - 1]); var flatCoordinates = /** @type {Array.} */ (rteValues['flatCoordinates']); @@ -150,7 +150,7 @@ ol.format.GPX.parseTrkPt_ = function(node, objectStack) { goog.asserts.assert(node.localName == 'trkpt', 'localName should be trkpt'); var values = ol.xml.pushParseAndPop( {}, ol.format.GPX.TRKPT_PARSERS_, node, objectStack); - if (goog.isDef(values)) { + if (values) { var trkValues = /** @type {Object} */ (objectStack[objectStack.length - 1]); var flatCoordinates = /** @type {Array.} */ (trkValues['flatCoordinates']); @@ -192,7 +192,7 @@ ol.format.GPX.readRte_ = function(node, objectStack) { var values = ol.xml.pushParseAndPop({ 'flatCoordinates': [] }, ol.format.GPX.RTE_PARSERS_, node, objectStack); - if (!goog.isDef(values)) { + if (!values) { return undefined; } var flatCoordinates = /** @type {Array.} */ @@ -222,7 +222,7 @@ ol.format.GPX.readTrk_ = function(node, objectStack) { 'flatCoordinates': [], 'ends': [] }, ol.format.GPX.TRK_PARSERS_, node, objectStack); - if (!goog.isDef(values)) { + if (!values) { return undefined; } var flatCoordinates = /** @type {Array.} */ @@ -253,7 +253,7 @@ ol.format.GPX.readWpt_ = function(node, objectStack) { var options = /** @type {olx.format.ReadOptions} */ (objectStack[0]); var values = ol.xml.pushParseAndPop( {}, ol.format.GPX.WPT_PARSERS_, node, objectStack); - if (!goog.isDef(values)) { + if (!values) { return undefined; } 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) { var feature = features[i]; - if (goog.isDef(this.readExtensions_)) { + if (this.readExtensions_) { var extensionsNode = feature.get('extensionsNode_') || null; this.readExtensions_(feature, extensionsNode); } @@ -453,11 +453,11 @@ ol.format.GPX.prototype.readFeatureFromNode = function(node, opt_options) { return null; } var featureReader = ol.format.GPX.FEATURE_READER_[node.localName]; - if (!goog.isDef(featureReader)) { + if (!featureReader) { return null; } var feature = featureReader(node, [this.getReadOptions(node, opt_options)]); - if (!goog.isDef(feature)) { + if (!feature) { return null; } this.handleReadExtensions_([feature]); @@ -490,7 +490,7 @@ ol.format.GPX.prototype.readFeaturesFromNode = function(node, opt_options) { var features = ol.xml.pushParseAndPop( /** @type {Array.} */ ([]), ol.format.GPX.GPX_PARSERS_, node, [this.getReadOptions(node, opt_options)]); - if (goog.isDef(features)) { + if (features) { this.handleReadExtensions_(features); return features; } else { @@ -588,7 +588,7 @@ ol.format.GPX.writeRte_ = function(node, feature, objectStack) { var properties = feature.getProperties(); var context = {node: node, 'properties': properties}; var geometry = feature.getGeometry(); - if (goog.isDef(geometry)) { + if (geometry) { goog.asserts.assertInstanceof(geometry, ol.geom.LineString, 'geometry should be an 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 context = {node: node, 'properties': properties}; var geometry = feature.getGeometry(); - if (goog.isDef(geometry)) { + if (geometry) { goog.asserts.assertInstanceof(geometry, ol.geom.MultiLineString, 'geometry should be an 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'); context['properties'] = feature.getProperties(); var geometry = feature.getGeometry(); - if (goog.isDef(geometry)) { + if (geometry) { goog.asserts.assertInstanceof(geometry, ol.geom.Point, 'geometry should be an 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, 'value should be an ol.Feature'); var geometry = value.getGeometry(); - if (goog.isDef(geometry)) { + if (geometry) { var parentNode = objectStack[objectStack.length - 1].node; goog.asserts.assert(ol.xml.isNode(parentNode), 'parentNode should be an XML node'); diff --git a/src/ol/format/igcformat.js b/src/ol/format/igcformat.js index 08fd284084..8a2f7a0bb4 100644 --- a/src/ol/format/igcformat.js +++ b/src/ol/format/igcformat.js @@ -36,7 +36,7 @@ ol.format.IGCZ = { */ ol.format.IGC = function(opt_options) { - var options = goog.isDef(opt_options) ? opt_options : {}; + var options = opt_options ? opt_options : {}; goog.base(this); @@ -49,7 +49,7 @@ ol.format.IGC = function(opt_options) { * @private * @type {ol.format.IGCZ} */ - this.altitudeMode_ = goog.isDef(options.altitudeMode) ? + this.altitudeMode_ = options.altitudeMode ? options.altitudeMode : ol.format.IGCZ.NONE; }; diff --git a/src/ol/format/jsonfeatureformat.js b/src/ol/format/jsonfeatureformat.js index 0ef66bc725..5016f02d3d 100644 --- a/src/ol/format/jsonfeatureformat.js +++ b/src/ol/format/jsonfeatureformat.js @@ -32,7 +32,7 @@ ol.format.JSONFeature.prototype.getObject_ = function(source) { return source; } else if (goog.isString(source)) { var object = goog.json.parse(source); - return goog.isDef(object) ? object : null; + return object ? object : null; } else { goog.asserts.fail(); return null; diff --git a/src/ol/format/kmlformat.js b/src/ol/format/kmlformat.js index e718ff199a..9371fb20d2 100644 --- a/src/ol/format/kmlformat.js +++ b/src/ol/format/kmlformat.js @@ -13,6 +13,7 @@ goog.require('goog.dom.NodeType'); goog.require('goog.math'); goog.require('goog.object'); goog.require('goog.string'); +goog.require('ol'); goog.require('ol.Feature'); goog.require('ol.FeatureStyleFunction'); goog.require('ol.color'); @@ -68,7 +69,7 @@ ol.format.KMLGxTrackObject_; */ ol.format.KML = function(opt_options) { - var options = goog.isDef(opt_options) ? opt_options : {}; + var options = opt_options ? opt_options : {}; goog.base(this); @@ -81,15 +82,15 @@ ol.format.KML = function(opt_options) { * @private * @type {Array.} */ - this.defaultStyle_ = goog.isDef(options.defaultStyle) ? + this.defaultStyle_ = options.defaultStyle ? options.defaultStyle : ol.format.KML.DEFAULT_STYLE_ARRAY_; /** * @private * @type {boolean} */ - this.extractStyles_ = goog.isDef(options.extractStyles) ? - options.extractStyles : true; + this.extractStyles_ = ol.isDef(options.extractStyles) ? + /** @type {boolean} */ (options.extractStyles) : true; /** * @private @@ -296,10 +297,10 @@ ol.format.KML.createFeatureStyleFunction_ = function( * @this {ol.Feature} */ function(resolution) { - if (goog.isDef(style)) { + if (style) { return style; } - if (goog.isDef(styleUrl)) { + if (styleUrl) { return ol.format.KML.findStyle_(styleUrl, defaultStyle, sharedStyles); } return defaultStyle; @@ -440,7 +441,7 @@ ol.format.KML.readVec2_ = function(node) { */ ol.format.KML.readScale_ = function(node) { var number = ol.format.XSD.readDecimal(node); - if (goog.isDef(number)) { + if (ol.isDef(number)) { return Math.sqrt(number); } else { return undefined; @@ -479,7 +480,7 @@ ol.format.KML.IconStyleParser_ = function(node, objectStack) { // FIXME httpQuery var object = ol.xml.pushParseAndPop( {}, ol.format.KML.ICON_STYLE_PARSERS_, node, objectStack); - if (!goog.isDef(object)) { + if (!object) { return; } var styleObject = /** @type {Object} */ (objectStack[objectStack.length - 1]); @@ -489,7 +490,7 @@ ol.format.KML.IconStyleParser_ = function(node, objectStack) { var src; var href = /** @type {string|undefined} */ (IconObject['href']); - if (goog.isDef(href)) { + if (href) { src = href; } else { src = ol.format.KML.DEFAULT_IMAGE_STYLE_SRC_; @@ -497,7 +498,7 @@ ol.format.KML.IconStyleParser_ = function(node, objectStack) { var anchor, anchorXUnits, anchorYUnits; var hotSpot = /** @type {ol.format.KMLVec2_|undefined} */ (object['hotSpot']); - if (goog.isDef(hotSpot)) { + if (hotSpot) { anchor = [hotSpot.x, hotSpot.y]; anchorXUnits = hotSpot.xunits; anchorYUnits = hotSpot.yunits; @@ -516,7 +517,7 @@ ol.format.KML.IconStyleParser_ = function(node, objectStack) { (IconObject['x']); var y = /** @type {number|undefined} */ (IconObject['y']); - if (goog.isDef(x) && goog.isDef(y)) { + if (ol.isDef(x) && ol.isDef(y)) { offset = [x, y]; } @@ -525,14 +526,14 @@ ol.format.KML.IconStyleParser_ = function(node, objectStack) { (IconObject['w']); var h = /** @type {number|undefined} */ (IconObject['h']); - if (goog.isDef(w) && goog.isDef(h)) { + if (ol.isDef(w) && ol.isDef(h)) { size = [w, h]; } var rotation; - var heading = /** @type {number|undefined} */ + var heading = /** @type {number} */ (object['heading']); - if (goog.isDef(heading)) { + if (ol.isDef(heading)) { rotation = goog.math.toRadians(heading); } @@ -572,7 +573,7 @@ ol.format.KML.LabelStyleParser_ = function(node, objectStack) { // FIXME colorMode var object = ol.xml.pushParseAndPop( {}, ol.format.KML.LABEL_STYLE_PARSERS_, node, objectStack); - if (!goog.isDef(object)) { + if (!object) { return; } var styleObject = objectStack[objectStack.length - 1]; @@ -607,7 +608,7 @@ ol.format.KML.LineStyleParser_ = function(node, objectStack) { // FIXME gx:labelVisibility var object = ol.xml.pushParseAndPop( {}, ol.format.KML.LINE_STYLE_PARSERS_, node, objectStack); - if (!goog.isDef(object)) { + if (!object) { return; } var styleObject = objectStack[objectStack.length - 1]; @@ -635,7 +636,7 @@ ol.format.KML.PolyStyleParser_ = function(node, objectStack) { // FIXME colorMode var object = ol.xml.pushParseAndPop( {}, ol.format.KML.POLY_STYLE_PARSERS_, node, objectStack); - if (!goog.isDef(object)) { + if (!object) { return; } var styleObject = objectStack[objectStack.length - 1]; @@ -647,12 +648,12 @@ ol.format.KML.PolyStyleParser_ = function(node, objectStack) { }); styleObject['fillStyle'] = fillStyle; var fill = /** @type {boolean|undefined} */ (object['fill']); - if (goog.isDef(fill)) { + if (ol.isDef(fill)) { styleObject['fill'] = fill; } var outline = /** @type {boolean|undefined} */ (object['outline']); - if (goog.isDef(outline)) { + if (ol.isDef(outline)) { styleObject['outline'] = outline; } }; @@ -723,7 +724,7 @@ ol.format.KML.readGxMultiTrack_ = function(node, objectStack) { var lineStrings = ol.xml.pushParseAndPop( /** @type {Array.} */ ([]), ol.format.KML.GX_MULTITRACK_GEOMETRY_PARSERS_, node, objectStack); - if (!goog.isDef(lineStrings)) { + if (!lineStrings) { return undefined; } var multiLineString = new ol.geom.MultiLineString(null); @@ -750,7 +751,7 @@ ol.format.KML.readGxTrack_ = function(node, objectStack) { flatCoordinates: [], whens: [] }), ol.format.KML.GX_TRACK_PARSERS_, node, objectStack); - if (!goog.isDef(gxTrackObject)) { + if (!gxTrackObject) { return undefined; } 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'); var iconObject = ol.xml.pushParseAndPop( {}, ol.format.KML.ICON_PARSERS_, node, objectStack); - if (goog.isDef(iconObject)) { + if (iconObject) { return iconObject; } else { return null; @@ -819,7 +820,7 @@ ol.format.KML.readLineString_ = function(node, objectStack) { objectStack); var flatCoordinates = ol.format.KML.readFlatCoordinatesFromNode_(node, objectStack); - if (goog.isDef(flatCoordinates)) { + if (flatCoordinates) { var lineString = new ol.geom.LineString(null); lineString.setFlatCoordinates(ol.geom.GeometryLayout.XYZ, flatCoordinates); lineString.setProperties(properties); @@ -846,7 +847,7 @@ ol.format.KML.readLinearRing_ = function(node, objectStack) { objectStack); var flatCoordinates = ol.format.KML.readFlatCoordinatesFromNode_(node, objectStack); - if (goog.isDef(flatCoordinates)) { + if (flatCoordinates) { var polygon = new ol.geom.Polygon(null); polygon.setFlatCoordinates(ol.geom.GeometryLayout.XYZ, flatCoordinates, [flatCoordinates.length]); @@ -872,7 +873,7 @@ ol.format.KML.readMultiGeometry_ = function(node, objectStack) { var geometries = ol.xml.pushParseAndPop( /** @type {Array.} */ ([]), ol.format.KML.MULTI_GEOMETRY_PARSERS_, node, objectStack); - if (!goog.isDef(geometries)) { + if (!geometries) { return null; } 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'); var styleObject = ol.xml.pushParseAndPop( {}, ol.format.KML.STYLE_PARSERS_, node, objectStack); - if (!goog.isDef(styleObject)) { + if (!styleObject) { return null; } var fillStyle = /** @type {ol.style.Fill} */ (goog.object.get( styleObject, 'fillStyle', ol.format.KML.DEFAULT_FILL_STYLE_)); var fill = /** @type {boolean|undefined} */ (styleObject['fill']); - if (goog.isDef(fill) && !fill) { + if (ol.isDef(fill) && !fill) { fillStyle = null; } 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_)); var outline = /** @type {boolean|undefined} */ (styleObject['outline']); - if (goog.isDef(outline) && !outline) { + if (ol.isDef(outline) && !outline) { strokeStyle = null; } return [new ol.style.Style({ @@ -1060,8 +1061,8 @@ ol.format.KML.setCommonGeometryProperties_ = function(multiGeometry, geometry = geometries[i]; extrudes[i] = geometry.get('extrude'); altitudeModes[i] = geometry.get('altitudeMode'); - hasExtrude = hasExtrude || goog.isDef(extrudes[i]); - hasAltitudeMode = hasAltitudeMode || goog.isDef(altitudeModes[i]); + hasExtrude = hasExtrude || ol.isDef(extrudes[i]); + hasAltitudeMode = hasAltitudeMode || altitudeModes[i]; } if (hasExtrude) { multiGeometry.set('extrude', extrudes); @@ -1085,7 +1086,7 @@ ol.format.KML.DataParser_ = function(node, objectStack) { if (!goog.isNull(name)) { var data = ol.xml.pushParseAndPop( undefined, ol.format.KML.DATA_PARSERS_, node, objectStack); - if (goog.isDef(data)) { + if (data) { var featureObject = /** @type {Object} */ (objectStack[objectStack.length - 1]); 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'); var pairObject = ol.xml.pushParseAndPop( {}, ol.format.KML.PAIR_PARSERS_, node, objectStack); - if (!goog.isDef(pairObject)) { + if (!pairObject) { return; } var key = /** @type {string|undefined} */ (pairObject['key']); - if (goog.isDef(key) && key == 'normal') { + if (key && key == 'normal') { var styleUrl = /** @type {string|undefined} */ (pairObject['styleUrl']); - if (goog.isDef(styleUrl)) { + if (styleUrl) { objectStack[objectStack.length - 1] = styleUrl; } var Style = /** @type {ol.style.Style} */ (pairObject['Style']); - if (goog.isDef(Style)) { + if (Style) { objectStack[objectStack.length - 1] = Style; } } @@ -1152,7 +1153,7 @@ ol.format.KML.PlacemarkStyleMapParser_ = function(node, objectStack) { goog.asserts.assert(node.localName == 'StyleMap', 'localName should be StyleMap'); var styleMapValue = ol.format.KML.readStyleMapValue_(node, objectStack); - if (!goog.isDef(styleMapValue)) { + if (!styleMapValue) { return; } var placemarkObject = objectStack[objectStack.length - 1]; @@ -1215,7 +1216,7 @@ ol.format.KML.innerBoundaryIsParser_ = function(node, objectStack) { var flatLinearRing = ol.xml.pushParseAndPop( /** @type {Array.|undefined} */ (undefined), ol.format.KML.INNER_BOUNDARY_IS_PARSERS_, node, objectStack); - if (goog.isDef(flatLinearRing)) { + if (flatLinearRing) { var flatLinearRings = /** @type {Array.>} */ (objectStack[objectStack.length - 1]); goog.asserts.assert(goog.isArray(flatLinearRings), @@ -1240,7 +1241,7 @@ ol.format.KML.outerBoundaryIsParser_ = function(node, objectStack) { var flatLinearRing = ol.xml.pushParseAndPop( /** @type {Array.|undefined} */ (undefined), ol.format.KML.OUTER_BOUNDARY_IS_PARSERS_, node, objectStack); - if (goog.isDef(flatLinearRing)) { + if (flatLinearRing) { var flatLinearRings = /** @type {Array.>} */ (objectStack[objectStack.length - 1]); goog.asserts.assert(goog.isArray(flatLinearRings), @@ -1285,16 +1286,16 @@ ol.format.KML.whenParser_ = function(node, objectStack) { var m = re.exec(s); if (m) { var year = parseInt(m[1], 10); - var month = goog.isDef(m[3]) ? parseInt(m[3], 10) - 1 : 0; - var day = goog.isDef(m[5]) ? parseInt(m[5], 10) : 1; - var hour = goog.isDef(m[7]) ? parseInt(m[7], 10) : 0; - var minute = goog.isDef(m[8]) ? parseInt(m[8], 10) : 0; - var second = goog.isDef(m[9]) ? parseInt(m[9], 10) : 0; + var month = m[3] ? parseInt(m[3], 10) - 1 : 0; + var day = m[5] ? parseInt(m[5], 10) : 1; + var hour = m[7] ? parseInt(m[7], 10) : 0; + var minute = m[8] ? parseInt(m[8], 10) : 0; + var second = m[9] ? parseInt(m[9], 10) : 0; 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; when += sign * 60 * parseInt(m[12], 10); - if (goog.isDef(m[13])) { + if (m[13]) { 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.} */ ([]), parsersNS, node, objectStack, this); - if (goog.isDef(features)) { + if (features) { return features; } else { return undefined; @@ -1671,7 +1672,7 @@ ol.format.KML.prototype.readPlacemark_ = function(node, objectStack) { 'localName should be Placemark'); var object = ol.xml.pushParseAndPop({'geometry': null}, ol.format.KML.PLACEMARK_PARSERS_, node, objectStack); - if (!goog.isDef(object)) { + if (!object) { return undefined; } var feature = new ol.Feature(); @@ -1717,7 +1718,7 @@ ol.format.KML.prototype.readSharedStyle_ = function(node, objectStack) { var id = node.getAttribute('id'); if (!goog.isNull(id)) { var style = ol.format.KML.readStyle_(node, objectStack); - if (goog.isDef(style)) { + if (style) { var styleUri; if (goog.isDefAndNotNull(node.baseURI)) { styleUri = goog.Uri.resolve(node.baseURI, '#' + id).toString(); @@ -1745,7 +1746,7 @@ ol.format.KML.prototype.readSharedStyleMap_ = function(node, objectStack) { return; } var styleMapValue = ol.format.KML.readStyleMapValue_(node, objectStack); - if (!goog.isDef(styleMapValue)) { + if (!styleMapValue) { return; } var styleUri; @@ -1783,7 +1784,7 @@ ol.format.KML.prototype.readFeatureFromNode = function(node, opt_options) { 'localName should be Placemark'); var feature = this.readPlacemark_( node, [this.getReadOptions(node, opt_options)]); - if (goog.isDef(feature)) { + if (feature) { return feature; } else { return null; @@ -1817,7 +1818,7 @@ ol.format.KML.prototype.readFeaturesFromNode = function(node, opt_options) { if (localName == 'Document' || localName == 'Folder') { features = this.readDocumentOrFolder_( node, [this.getReadOptions(node, opt_options)]); - if (goog.isDef(features)) { + if (features) { return features; } else { return []; @@ -1825,7 +1826,7 @@ ol.format.KML.prototype.readFeaturesFromNode = function(node, opt_options) { } else if (localName == 'Placemark') { var feature = this.readPlacemark_( node, [this.getReadOptions(node, opt_options)]); - if (goog.isDef(feature)) { + if (feature) { return [feature]; } else { return []; @@ -1836,7 +1837,7 @@ ol.format.KML.prototype.readFeaturesFromNode = function(node, opt_options) { for (n = node.firstElementChild; !goog.isNull(n); n = n.nextElementSibling) { var fs = this.readFeaturesFromNode(n, opt_options); - if (goog.isDef(fs)) { + if (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) { if (n.nodeType == goog.dom.NodeType.ELEMENT) { var name = this.readNameFromNode(n); - if (goog.isDef(name)) { + if (name) { return name; } } @@ -1907,7 +1908,7 @@ ol.format.KML.prototype.readNameFromNode = function(node) { localName == 'Placemark' || localName == 'kml')) { var name = this.readNameFromNode(n); - if (goog.isDef(name)) { + if (name) { return name; } } @@ -2165,7 +2166,7 @@ ol.format.KML.writeLabelStyle_ = function(node, style, objectStack) { properties['color'] = fill.getColor(); } var scale = style.getScale(); - if (goog.isDef(scale) && scale !== 1) { + if (scale && scale !== 1) { properties['scale'] = scale; } 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) var properties = feature.getProperties(); var styleFunction = feature.getStyleFunction(); - if (goog.isDef(styleFunction)) { + if (styleFunction) { // FIXME the styles returned by the style function are supposed to be // resolution-independent here var styles = styleFunction.call(feature, 0); diff --git a/src/ol/format/osmxmlformat.js b/src/ol/format/osmxmlformat.js index d6cb8733b4..f45ca8211d 100644 --- a/src/ol/format/osmxmlformat.js +++ b/src/ol/format/osmxmlformat.js @@ -223,7 +223,7 @@ ol.format.OSMXML.prototype.readFeaturesFromNode = function(node, opt_options) { nodes: {}, features: [] }, ol.format.OSMXML.PARSERS_, node, [options]); - if (goog.isDef(state.features)) { + if (state.features) { return state.features; } } diff --git a/src/ol/format/owsformat.js b/src/ol/format/owsformat.js index 30090069a9..1ebd2df650 100644 --- a/src/ol/format/owsformat.js +++ b/src/ol/format/owsformat.js @@ -44,7 +44,7 @@ ol.format.OWS.prototype.readFromNode = function(node) { 'node.nodeType should be ELEMENT'); var owsObject = ol.xml.pushParseAndPop({}, 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', 'localName should be Constraint'); var name = node.getAttribute('name'); - if (!goog.isDef(name)) { + if (!name) { return undefined; } return ol.xml.pushParseAndPop({'name': name}, @@ -143,7 +143,7 @@ ol.format.OWS.readGet_ = function(node, objectStack) { 'node.nodeType should be ELEMENT'); goog.asserts.assert(node.localName == 'Get', 'localName should be Get'); var href = ol.format.XLink.readHref(node); - if (!goog.isDef(href)) { + if (!href) { return undefined; } return ol.xml.pushParseAndPop({'href': href}, @@ -180,7 +180,7 @@ ol.format.OWS.readOperation_ = function(node, objectStack) { var name = node.getAttribute('name'); var value = ol.xml.pushParseAndPop({}, ol.format.OWS.OPERATION_PARSERS_, node, objectStack); - if (!goog.isDef(value)) { + if (!value) { return undefined; } var object = /** @type {Object} */ diff --git a/src/ol/format/polylineformat.js b/src/ol/format/polylineformat.js index a8d369d1f6..8bba501ee9 100644 --- a/src/ol/format/polylineformat.js +++ b/src/ol/format/polylineformat.js @@ -26,7 +26,7 @@ goog.require('ol.proj'); */ ol.format.Polyline = function(opt_options) { - var options = goog.isDef(opt_options) ? opt_options : {}; + var options = opt_options ? opt_options : {}; goog.base(this); @@ -39,13 +39,13 @@ ol.format.Polyline = function(opt_options) { * @private * @type {number} */ - this.factor_ = goog.isDef(options.factor) ? options.factor : 1e5; + this.factor_ = options.factor ? options.factor : 1e5; /** * @private * @type {ol.geom.GeometryLayout} */ - this.geometryLayout_ = goog.isDef(options.geometryLayout) ? + this.geometryLayout_ = options.geometryLayout ? options.geometryLayout : ol.geom.GeometryLayout.XY; }; goog.inherits(ol.format.Polyline, ol.format.TextFeature); @@ -65,7 +65,7 @@ goog.inherits(ol.format.Polyline, ol.format.TextFeature); * @api */ 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 lastNumbers = new Array(stride); @@ -100,7 +100,7 @@ ol.format.Polyline.encodeDeltas = function(numbers, stride, opt_factor) { * @api */ 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; /** @type {Array.} */ @@ -137,7 +137,7 @@ ol.format.Polyline.decodeDeltas = function(encoded, stride, opt_factor) { * @api */ 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; for (i = 0, ii = numbers.length; i < ii; ++i) { numbers[i] = Math.round(numbers[i] * factor); @@ -157,7 +157,7 @@ ol.format.Polyline.encodeFloats = function(numbers, opt_factor) { * @api */ 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 i, ii; for (i = 0, ii = numbers.length; i < ii; ++i) { diff --git a/src/ol/format/topojsonformat.js b/src/ol/format/topojsonformat.js index cf85306a49..d8a30b34e5 100644 --- a/src/ol/format/topojsonformat.js +++ b/src/ol/format/topojsonformat.js @@ -26,7 +26,7 @@ goog.require('ol.proj'); */ ol.format.TopoJSON = function(opt_options) { - var options = goog.isDef(opt_options) ? opt_options : {}; + var options = opt_options ? opt_options : {}; goog.base(this); @@ -251,8 +251,7 @@ ol.format.TopoJSON.readFeatureFromGeometry_ = function(object, arcs, var geometry; var type = object.type; var geometryReader = ol.format.TopoJSON.GEOMETRY_READERS_[type]; - goog.asserts.assert(goog.isDef(geometryReader), - 'geometryReader should be defined'); + goog.asserts.assert(geometryReader, 'geometryReader should be defined'); if ((type === 'Point') || (type === 'MultiPoint')) { geometry = geometryReader(object, scale, translate); } else { @@ -261,10 +260,10 @@ ol.format.TopoJSON.readFeatureFromGeometry_ = function(object, arcs, var feature = new ol.Feature(); feature.setGeometry(/** @type {ol.geom.Geometry} */ ( ol.format.Feature.transformWithOptions(geometry, false, opt_options))); - if (goog.isDef(object.id)) { + if (object.id) { feature.setId(object.id); } - if (goog.isDef(object.properties)) { + if (object.properties) { feature.setProperties(object.properties); } return feature; @@ -290,13 +289,13 @@ ol.format.TopoJSON.prototype.readFeaturesFromObject = function( if (object.type == 'Topology') { var topoJSONTopology = /** @type {TopoJSONTopology} */ (object); var transform, scale = null, translate = null; - if (goog.isDef(topoJSONTopology.transform)) { + if (topoJSONTopology.transform) { transform = topoJSONTopology.transform; scale = transform.scale; translate = transform.translate; } var arcs = topoJSONTopology.arcs; - if (goog.isDef(transform)) { + if (transform) { ol.format.TopoJSON.transformArcs_(arcs, scale, translate); } /** @type {Array.} */