Merge pull request #4129 from openlayers/no-is-def

Remove use of goog.isDef.
This commit is contained in:
Tim Schaub
2015-09-27 12:10:10 -06:00
172 changed files with 1237 additions and 1205 deletions
+22 -1
View File
@@ -1291,7 +1291,7 @@ olx.control.ScaleLineOptions.prototype.units;
/** /**
* @typedef {{duration: (number|undefined), * @typedef {{duration: (number|undefined),
* className: (string|undefined), * className: (string|undefined),
* label: (string|Node|undefined), * label: (string|Element|undefined),
* tipLabel: (string|undefined), * tipLabel: (string|undefined),
* target: (Element|undefined), * target: (Element|undefined),
* render: (function(ol.MapEvent)|undefined), * render: (function(ol.MapEvent)|undefined),
@@ -1914,6 +1914,8 @@ olx.format.WFSOptions.prototype.schemaLocation;
* maxFeatures: (number|undefined), * maxFeatures: (number|undefined),
* geometryName: (string|undefined), * geometryName: (string|undefined),
* propertyNames: (Array.<string>|undefined), * propertyNames: (Array.<string>|undefined),
* startIndex: (number|undefined),
* count: (number|undefined),
* bbox: (ol.Extent|undefined)}} * bbox: (ol.Extent|undefined)}}
* @api * @api
*/ */
@@ -1993,6 +1995,25 @@ olx.format.WFSWriteGetFeatureOptions.prototype.geometryName;
olx.format.WFSWriteGetFeatureOptions.prototype.propertyNames; olx.format.WFSWriteGetFeatureOptions.prototype.propertyNames;
/**
* Start index to use for WFS paging. This is a WFS 2.0 feature backported to
* WFS 1.1.0 by some Web Feature Services.
* @type {number|undefined}
* @api
*/
olx.format.WFSWriteGetFeatureOptions.prototype.startIndex;
/**
* Number of features to retrieve when paging. This is a WFS 2.0 feature
* backported to WFS 1.1.0 by some Web Feature Services. Please note that some
* Web Feature Services have repurposed `maxfeatures` instead.
* @type {number|undefined}
* @api
*/
olx.format.WFSWriteGetFeatureOptions.prototype.count;
/** /**
* Extent to use for the BBOX filter. * Extent to use for the BBOX filter.
* @type {ol.Extent|undefined} * @type {ol.Extent|undefined}
+15 -14
View File
@@ -1,5 +1,6 @@
goog.provide('ol.animation'); goog.provide('ol.animation');
goog.require('ol');
goog.require('ol.PreRenderFunction'); goog.require('ol.PreRenderFunction');
goog.require('ol.ViewHint'); goog.require('ol.ViewHint');
goog.require('ol.coordinate'); goog.require('ol.coordinate');
@@ -15,9 +16,9 @@ goog.require('ol.easing');
*/ */
ol.animation.bounce = function(options) { ol.animation.bounce = function(options) {
var resolution = options.resolution; var resolution = options.resolution;
var start = goog.isDef(options.start) ? options.start : goog.now(); var start = options.start ? options.start : goog.now();
var duration = goog.isDef(options.duration) ? options.duration : 1000; var duration = options.duration !== undefined ? options.duration : 1000;
var easing = goog.isDef(options.easing) ? var easing = options.easing ?
options.easing : ol.easing.upAndDown; options.easing : ol.easing.upAndDown;
return ( return (
/** /**
@@ -51,11 +52,11 @@ ol.animation.bounce = function(options) {
*/ */
ol.animation.pan = function(options) { ol.animation.pan = function(options) {
var source = options.source; var source = options.source;
var start = goog.isDef(options.start) ? options.start : goog.now(); var start = options.start ? options.start : goog.now();
var sourceX = source[0]; var sourceX = source[0];
var sourceY = source[1]; var sourceY = source[1];
var duration = goog.isDef(options.duration) ? options.duration : 1000; var duration = options.duration !== undefined ? options.duration : 1000;
var easing = goog.isDef(options.easing) ? var easing = options.easing ?
options.easing : ol.easing.inAndOut; options.easing : ol.easing.inAndOut;
return ( return (
/** /**
@@ -90,12 +91,12 @@ ol.animation.pan = function(options) {
* @api * @api
*/ */
ol.animation.rotate = function(options) { ol.animation.rotate = function(options) {
var sourceRotation = goog.isDef(options.rotation) ? options.rotation : 0; var sourceRotation = options.rotation ? options.rotation : 0;
var start = goog.isDef(options.start) ? options.start : goog.now(); var start = options.start ? options.start : goog.now();
var duration = goog.isDef(options.duration) ? options.duration : 1000; var duration = options.duration !== undefined ? options.duration : 1000;
var easing = goog.isDef(options.easing) ? var easing = options.easing ?
options.easing : ol.easing.inAndOut; options.easing : ol.easing.inAndOut;
var anchor = goog.isDef(options.anchor) ? var anchor = options.anchor ?
options.anchor : null; options.anchor : null;
return ( return (
@@ -137,9 +138,9 @@ ol.animation.rotate = function(options) {
*/ */
ol.animation.zoom = function(options) { ol.animation.zoom = function(options) {
var sourceResolution = options.resolution; var sourceResolution = options.resolution;
var start = goog.isDef(options.start) ? options.start : goog.now(); var start = options.start ? options.start : goog.now();
var duration = goog.isDef(options.duration) ? options.duration : 1000; var duration = options.duration !== undefined ? options.duration : 1000;
var easing = goog.isDef(options.easing) ? var easing = options.easing ?
options.easing : ol.easing.inAndOut; options.easing : ol.easing.inAndOut;
return ( return (
/** /**
+1 -2
View File
@@ -38,8 +38,7 @@ ol.Attribution = function(options) {
* @private * @private
* @type {Object.<string, Array.<ol.TileRange>>} * @type {Object.<string, Array.<ol.TileRange>>}
*/ */
this.tileRanges_ = goog.isDef(options.tileRanges) ? this.tileRanges_ = options.tileRanges ? options.tileRanges : null;
options.tileRanges : null;
}; };
+1 -1
View File
@@ -21,7 +21,7 @@ ol.CenterConstraint.createExtent = function(extent) {
* @return {ol.Coordinate|undefined} Center. * @return {ol.Coordinate|undefined} Center.
*/ */
function(center) { function(center) {
if (goog.isDef(center)) { if (center) {
return [ return [
goog.math.clamp(center[0], extent[0], extent[2]), goog.math.clamp(center[0], extent[0], extent[2]),
goog.math.clamp(center[1], extent[1], extent[3]) goog.math.clamp(center[1], extent[1], extent[3])
+1 -1
View File
@@ -91,7 +91,7 @@ ol.Collection = function(opt_array) {
* @private * @private
* @type {!Array.<T>} * @type {!Array.<T>}
*/ */
this.array_ = goog.isDef(opt_array) ? opt_array : []; this.array_ = opt_array ? opt_array : [];
this.updateLength_(); this.updateLength_();
+3 -3
View File
@@ -62,7 +62,7 @@ ol.color.rgbaColorRe_ =
ol.color.blend = function(dst, src, opt_color) { ol.color.blend = function(dst, src, opt_color) {
// http://en.wikipedia.org/wiki/Alpha_compositing // http://en.wikipedia.org/wiki/Alpha_compositing
// FIXME do we need to scale by 255? // FIXME do we need to scale by 255?
var out = goog.isDef(opt_color) ? opt_color : []; var out = opt_color ? opt_color : [];
var dstA = dst[3]; var dstA = dst[3];
var srcA = src[3]; var srcA = src[3];
if (dstA == 1) { if (dstA == 1) {
@@ -271,7 +271,7 @@ ol.color.isValid = function(color) {
* @return {ol.Color} Clamped color. * @return {ol.Color} Clamped color.
*/ */
ol.color.normalize = function(color, opt_color) { ol.color.normalize = function(color, opt_color) {
var result = goog.isDef(opt_color) ? opt_color : []; var result = opt_color ? opt_color : [];
result[0] = goog.math.clamp((color[0] + 0.5) | 0, 0, 255); result[0] = goog.math.clamp((color[0] + 0.5) | 0, 0, 255);
result[1] = goog.math.clamp((color[1] + 0.5) | 0, 0, 255); result[1] = goog.math.clamp((color[1] + 0.5) | 0, 0, 255);
result[2] = goog.math.clamp((color[2] + 0.5) | 0, 0, 255); result[2] = goog.math.clamp((color[2] + 0.5) | 0, 0, 255);
@@ -309,7 +309,7 @@ ol.color.toString = function(color) {
* @return {ol.Color} Transformed color. * @return {ol.Color} Transformed color.
*/ */
ol.color.transform = function(color, transform, opt_color) { ol.color.transform = function(color, transform, opt_color) {
var result = goog.isDef(opt_color) ? opt_color : []; var result = opt_color ? opt_color : [];
result = goog.vec.Mat4.multVec3(transform, color, result); result = goog.vec.Mat4.multVec3(transform, color, result);
goog.asserts.assert(goog.isArray(result), 'result should be an array'); goog.asserts.assert(goog.isArray(result), 'result should be an array');
result[3] = color[3]; result[3] = color[3];
+16 -12
View File
@@ -1,6 +1,7 @@
goog.provide('ol.color.Matrix'); goog.provide('ol.color.Matrix');
goog.require('goog.vec.Mat4'); goog.require('goog.vec.Mat4');
goog.require('ol');
@@ -165,39 +166,42 @@ ol.color.Matrix.makeSaturation = function(matrix, value) {
ol.color.Matrix.prototype.getMatrix = function( ol.color.Matrix.prototype.getMatrix = function(
brightness, contrast, hue, saturation) { brightness, contrast, hue, saturation) {
var colorMatrixDirty = false; var colorMatrixDirty = false;
if (goog.isDef(brightness) && brightness !== this.brightness_) { if (brightness !== undefined && brightness !== this.brightness_) {
ol.color.Matrix.makeBrightness(this.brightnessMatrix_, brightness); ol.color.Matrix.makeBrightness(this.brightnessMatrix_,
/** @type {number} */ (brightness));
this.brightness_ = brightness; this.brightness_ = brightness;
colorMatrixDirty = true; colorMatrixDirty = true;
} }
if (goog.isDef(contrast) && contrast !== this.contrast_) { if (contrast !== undefined && contrast !== this.contrast_) {
ol.color.Matrix.makeContrast(this.contrastMatrix_, contrast); ol.color.Matrix.makeContrast(this.contrastMatrix_,
/** @type {number} */ (contrast));
this.contrast_ = contrast; this.contrast_ = contrast;
colorMatrixDirty = true; colorMatrixDirty = true;
} }
if (goog.isDef(hue) && hue !== this.hue_) { if (hue !== undefined && hue !== this.hue_) {
ol.color.Matrix.makeHue(this.hueMatrix_, hue); ol.color.Matrix.makeHue(this.hueMatrix_, /** @type {number} */ (hue));
this.hue_ = hue; this.hue_ = hue;
colorMatrixDirty = true; colorMatrixDirty = true;
} }
if (goog.isDef(saturation) && saturation !== this.saturation_) { if (saturation !== undefined && saturation !== this.saturation_) {
ol.color.Matrix.makeSaturation(this.saturationMatrix_, saturation); ol.color.Matrix.makeSaturation(this.saturationMatrix_,
/** @type {number} */ (saturation));
this.saturation_ = saturation; this.saturation_ = saturation;
colorMatrixDirty = true; colorMatrixDirty = true;
} }
if (colorMatrixDirty) { if (colorMatrixDirty) {
var colorMatrix = this.colorMatrix_; var colorMatrix = this.colorMatrix_;
goog.vec.Mat4.makeIdentity(colorMatrix); goog.vec.Mat4.makeIdentity(colorMatrix);
if (goog.isDef(contrast)) { if (contrast !== undefined) {
goog.vec.Mat4.multMat(colorMatrix, this.contrastMatrix_, colorMatrix); goog.vec.Mat4.multMat(colorMatrix, this.contrastMatrix_, colorMatrix);
} }
if (goog.isDef(brightness)) { if (brightness !== undefined) {
goog.vec.Mat4.multMat(colorMatrix, this.brightnessMatrix_, colorMatrix); goog.vec.Mat4.multMat(colorMatrix, this.brightnessMatrix_, colorMatrix);
} }
if (goog.isDef(saturation)) { if (saturation !== undefined) {
goog.vec.Mat4.multMat(colorMatrix, this.saturationMatrix_, colorMatrix); goog.vec.Mat4.multMat(colorMatrix, this.saturationMatrix_, colorMatrix);
} }
if (goog.isDef(hue)) { if (hue !== undefined) {
goog.vec.Mat4.multMat(colorMatrix, this.hueMatrix_, colorMatrix); goog.vec.Mat4.multMat(colorMatrix, this.hueMatrix_, colorMatrix);
} }
} }
+10 -13
View File
@@ -10,6 +10,7 @@ goog.require('goog.events');
goog.require('goog.events.EventType'); goog.require('goog.events.EventType');
goog.require('goog.object'); goog.require('goog.object');
goog.require('goog.style'); goog.require('goog.style');
goog.require('ol');
goog.require('ol.Attribution'); goog.require('ol.Attribution');
goog.require('ol.control.Control'); goog.require('ol.control.Control');
goog.require('ol.css'); goog.require('ol.css');
@@ -31,7 +32,7 @@ goog.require('ol.source.Tile');
*/ */
ol.control.Attribution = function(opt_options) { ol.control.Attribution = function(opt_options) {
var options = goog.isDef(opt_options) ? opt_options : {}; var options = opt_options ? opt_options : {};
/** /**
* @private * @private
@@ -52,27 +53,24 @@ ol.control.Attribution = function(opt_options) {
* @private * @private
* @type {boolean} * @type {boolean}
*/ */
this.collapsed_ = goog.isDef(options.collapsed) ? options.collapsed : true; this.collapsed_ = options.collapsed !== undefined ? options.collapsed : true;
/** /**
* @private * @private
* @type {boolean} * @type {boolean}
*/ */
this.collapsible_ = goog.isDef(options.collapsible) ? this.collapsible_ = options.collapsible !== undefined ?
options.collapsible : true; options.collapsible : true;
if (!this.collapsible_) { if (!this.collapsible_) {
this.collapsed_ = false; this.collapsed_ = false;
} }
var className = goog.isDef(options.className) ? var className = options.className ? options.className : 'ol-attribution';
options.className : 'ol-attribution';
var tipLabel = goog.isDef(options.tipLabel) ? var tipLabel = options.tipLabel ? options.tipLabel : 'Attributions';
options.tipLabel : 'Attributions';
var collapseLabel = goog.isDef(options.collapseLabel) ? var collapseLabel = options.collapseLabel ? options.collapseLabel : '\u00BB';
options.collapseLabel : '\u00BB';
/** /**
* @private * @private
@@ -82,7 +80,7 @@ ol.control.Attribution = function(opt_options) {
goog.dom.createDom(goog.dom.TagName.SPAN, {}, collapseLabel) : goog.dom.createDom(goog.dom.TagName.SPAN, {}, collapseLabel) :
collapseLabel); collapseLabel);
var label = goog.isDef(options.label) ? options.label : 'i'; var label = options.label ? options.label : 'i';
/** /**
* @private * @private
@@ -116,8 +114,7 @@ ol.control.Attribution = function(opt_options) {
var element = goog.dom.createDom(goog.dom.TagName.DIV, var element = goog.dom.createDom(goog.dom.TagName.DIV,
cssClasses, this.ulElement_, button); cssClasses, this.ulElement_, button);
var render = goog.isDef(options.render) ? var render = options.render ? options.render : ol.control.Attribution.render;
options.render : ol.control.Attribution.render;
goog.base(this, { goog.base(this, {
element: element, element: element,
@@ -185,7 +182,7 @@ ol.control.Attribution.prototype.getSourceAttributions = function(frameState) {
continue; continue;
} }
tileRanges = frameState.usedTiles[sourceKey]; tileRanges = frameState.usedTiles[sourceKey];
if (goog.isDef(tileRanges)) { if (tileRanges) {
goog.asserts.assertInstanceof(source, ol.source.Tile, goog.asserts.assertInstanceof(source, ol.source.Tile,
'source should be an ol.source.Tile'); 'source should be an ol.source.Tile');
var tileGrid = source.getTileGridForProjection(projection); var tileGrid = source.getTileGridForProjection(projection);
+3 -3
View File
@@ -45,7 +45,7 @@ ol.control.Control = function(options) {
* @protected * @protected
* @type {Element} * @type {Element}
*/ */
this.element = goog.isDef(options.element) ? options.element : null; this.element = options.element ? options.element : null;
/** /**
* @private * @private
@@ -68,9 +68,9 @@ ol.control.Control = function(options) {
/** /**
* @type {function(ol.MapEvent)} * @type {function(ol.MapEvent)}
*/ */
this.render = goog.isDef(options.render) ? options.render : goog.nullFunction; this.render = options.render ? options.render : goog.nullFunction;
if (goog.isDef(options.target)) { if (options.target) {
this.setTarget(options.target); this.setTarget(options.target);
} }
+5 -6
View File
@@ -1,5 +1,6 @@
goog.provide('ol.control'); goog.provide('ol.control');
goog.require('ol');
goog.require('ol.Collection'); goog.require('ol.Collection');
goog.require('ol.control.Attribution'); goog.require('ol.control.Attribution');
goog.require('ol.control.Rotate'); goog.require('ol.control.Rotate');
@@ -20,23 +21,21 @@ goog.require('ol.control.Zoom');
*/ */
ol.control.defaults = function(opt_options) { ol.control.defaults = function(opt_options) {
var options = goog.isDef(opt_options) ? opt_options : {}; var options = opt_options ? opt_options : {};
var controls = new ol.Collection(); var controls = new ol.Collection();
var zoomControl = goog.isDef(options.zoom) ? var zoomControl = options.zoom !== undefined ? options.zoom : true;
options.zoom : true;
if (zoomControl) { if (zoomControl) {
controls.push(new ol.control.Zoom(options.zoomOptions)); controls.push(new ol.control.Zoom(options.zoomOptions));
} }
var rotateControl = goog.isDef(options.rotate) ? var rotateControl = options.rotate !== undefined ? options.rotate : true;
options.rotate : true;
if (rotateControl) { if (rotateControl) {
controls.push(new ol.control.Rotate(options.rotateOptions)); controls.push(new ol.control.Rotate(options.rotateOptions));
} }
var attributionControl = goog.isDef(options.attribution) ? var attributionControl = options.attribution !== undefined ?
options.attribution : true; options.attribution : true;
if (attributionControl) { if (attributionControl) {
controls.push(new ol.control.Attribution(options.attributionOptions)); controls.push(new ol.control.Attribution(options.attributionOptions));
+7 -9
View File
@@ -8,6 +8,7 @@ goog.require('goog.dom.fullscreen');
goog.require('goog.dom.fullscreen.EventType'); goog.require('goog.dom.fullscreen.EventType');
goog.require('goog.events'); goog.require('goog.events');
goog.require('goog.events.EventType'); goog.require('goog.events.EventType');
goog.require('ol');
goog.require('ol.control.Control'); goog.require('ol.control.Control');
goog.require('ol.css'); goog.require('ol.css');
@@ -28,16 +29,15 @@ goog.require('ol.css');
*/ */
ol.control.FullScreen = function(opt_options) { ol.control.FullScreen = function(opt_options) {
var options = goog.isDef(opt_options) ? opt_options : {}; var options = opt_options ? opt_options : {};
/** /**
* @private * @private
* @type {string} * @type {string}
*/ */
this.cssClassName_ = goog.isDef(options.className) ? this.cssClassName_ = options.className ? options.className : 'ol-full-screen';
options.className : 'ol-full-screen';
var label = goog.isDef(options.label) ? options.label : '\u2194'; var label = options.label ? options.label : '\u2194';
/** /**
* @private * @private
@@ -46,8 +46,7 @@ ol.control.FullScreen = function(opt_options) {
this.labelNode_ = /** @type {Node} */ (goog.isString(label) ? this.labelNode_ = /** @type {Node} */ (goog.isString(label) ?
goog.dom.createTextNode(label) : label); goog.dom.createTextNode(label) : label);
var labelActive = goog.isDef(options.labelActive) ? var labelActive = options.labelActive ? options.labelActive : '\u00d7';
options.labelActive : '\u00d7';
/** /**
* @private * @private
@@ -56,8 +55,7 @@ ol.control.FullScreen = function(opt_options) {
this.labelActiveNode_ = /** @type {Node} */ (goog.isString(labelActive) ? this.labelActiveNode_ = /** @type {Node} */ (goog.isString(labelActive) ?
goog.dom.createTextNode(labelActive) : labelActive); goog.dom.createTextNode(labelActive) : labelActive);
var tipLabel = goog.isDef(options.tipLabel) ? var tipLabel = options.tipLabel ? options.tipLabel : 'Toggle full-screen';
options.tipLabel : 'Toggle full-screen';
var button = goog.dom.createDom(goog.dom.TagName.BUTTON, { var button = goog.dom.createDom(goog.dom.TagName.BUTTON, {
'class': this.cssClassName_ + '-' + goog.dom.fullscreen.isFullScreen(), 'class': this.cssClassName_ + '-' + goog.dom.fullscreen.isFullScreen(),
'type': 'button', 'type': 'button',
@@ -85,7 +83,7 @@ ol.control.FullScreen = function(opt_options) {
* @private * @private
* @type {boolean} * @type {boolean}
*/ */
this.keys_ = goog.isDef(options.keys) ? options.keys : false; this.keys_ = options.keys !== undefined ? options.keys : false;
}; };
goog.inherits(ol.control.FullScreen, ol.control.Control); goog.inherits(ol.control.FullScreen, ol.control.Control);
+9 -11
View File
@@ -40,14 +40,13 @@ ol.control.MousePositionProperty = {
*/ */
ol.control.MousePosition = function(opt_options) { ol.control.MousePosition = function(opt_options) {
var options = goog.isDef(opt_options) ? opt_options : {}; var options = opt_options ? opt_options : {};
var className = goog.isDef(options.className) ? var className = options.className ? options.className : 'ol-mouse-position';
options.className : 'ol-mouse-position';
var element = goog.dom.createDom(goog.dom.TagName.DIV, className); var element = goog.dom.createDom(goog.dom.TagName.DIV, className);
var render = goog.isDef(options.render) ? var render = options.render ?
options.render : ol.control.MousePosition.render; options.render : ol.control.MousePosition.render;
goog.base(this, { goog.base(this, {
@@ -60,10 +59,10 @@ ol.control.MousePosition = function(opt_options) {
ol.Object.getChangeEventType(ol.control.MousePositionProperty.PROJECTION), ol.Object.getChangeEventType(ol.control.MousePositionProperty.PROJECTION),
this.handleProjectionChanged_, false, this); this.handleProjectionChanged_, false, this);
if (goog.isDef(options.coordinateFormat)) { if (options.coordinateFormat) {
this.setCoordinateFormat(options.coordinateFormat); this.setCoordinateFormat(options.coordinateFormat);
} }
if (goog.isDef(options.projection)) { if (options.projection) {
this.setProjection(ol.proj.get(options.projection)); this.setProjection(ol.proj.get(options.projection));
} }
@@ -71,8 +70,7 @@ ol.control.MousePosition = function(opt_options) {
* @private * @private
* @type {string} * @type {string}
*/ */
this.undefinedHTML_ = goog.isDef(options.undefinedHTML) ? this.undefinedHTML_ = options.undefinedHTML ? options.undefinedHTML : '';
options.undefinedHTML : '';
/** /**
* @private * @private
@@ -229,7 +227,7 @@ ol.control.MousePosition.prototype.updateHTML_ = function(pixel) {
if (!goog.isNull(pixel) && !goog.isNull(this.mapProjection_)) { if (!goog.isNull(pixel) && !goog.isNull(this.mapProjection_)) {
if (goog.isNull(this.transform_)) { if (goog.isNull(this.transform_)) {
var projection = this.getProjection(); var projection = this.getProjection();
if (goog.isDef(projection)) { if (projection) {
this.transform_ = ol.proj.getTransformFromProjections( this.transform_ = ol.proj.getTransformFromProjections(
this.mapProjection_, projection); this.mapProjection_, projection);
} else { } else {
@@ -241,14 +239,14 @@ ol.control.MousePosition.prototype.updateHTML_ = function(pixel) {
if (!goog.isNull(coordinate)) { if (!goog.isNull(coordinate)) {
this.transform_(coordinate, coordinate); this.transform_(coordinate, coordinate);
var coordinateFormat = this.getCoordinateFormat(); var coordinateFormat = this.getCoordinateFormat();
if (goog.isDef(coordinateFormat)) { if (coordinateFormat) {
html = coordinateFormat(coordinate); html = coordinateFormat(coordinate);
} else { } else {
html = coordinate.toString(); html = coordinate.toString();
} }
} }
} }
if (!goog.isDef(this.renderedHTML_) || html != this.renderedHTML_) { if (!this.renderedHTML_ || html != this.renderedHTML_) {
this.element.innerHTML = html; this.element.innerHTML = html;
this.renderedHTML_ = html; this.renderedHTML_ = html;
} }
+21 -24
View File
@@ -8,6 +8,7 @@ goog.require('goog.events');
goog.require('goog.events.EventType'); goog.require('goog.events.EventType');
goog.require('goog.math.Size'); goog.require('goog.math.Size');
goog.require('goog.style'); goog.require('goog.style');
goog.require('ol');
goog.require('ol.Collection'); goog.require('ol.Collection');
goog.require('ol.Map'); goog.require('ol.Map');
goog.require('ol.MapEventType'); goog.require('ol.MapEventType');
@@ -34,33 +35,30 @@ goog.require('ol.extent');
*/ */
ol.control.OverviewMap = function(opt_options) { ol.control.OverviewMap = function(opt_options) {
var options = goog.isDef(opt_options) ? opt_options : {}; var options = opt_options ? opt_options : {};
/** /**
* @type {boolean} * @type {boolean}
* @private * @private
*/ */
this.collapsed_ = goog.isDef(options.collapsed) ? options.collapsed : true; this.collapsed_ = options.collapsed !== undefined ? options.collapsed : true;
/** /**
* @private * @private
* @type {boolean} * @type {boolean}
*/ */
this.collapsible_ = goog.isDef(options.collapsible) ? this.collapsible_ = options.collapsible !== undefined ?
options.collapsible : true; options.collapsible : true;
if (!this.collapsible_) { if (!this.collapsible_) {
this.collapsed_ = false; this.collapsed_ = false;
} }
var className = goog.isDef(options.className) ? var className = options.className ? options.className : 'ol-overviewmap';
options.className : 'ol-overviewmap';
var tipLabel = goog.isDef(options.tipLabel) ? var tipLabel = options.tipLabel ? options.tipLabel : 'Overview map';
options.tipLabel : 'Overview map';
var collapseLabel = goog.isDef(options.collapseLabel) ? var collapseLabel = options.collapseLabel ? options.collapseLabel : '\u00AB';
options.collapseLabel : '\u00AB';
/** /**
* @private * @private
@@ -70,7 +68,7 @@ ol.control.OverviewMap = function(opt_options) {
goog.dom.createDom(goog.dom.TagName.SPAN, {}, collapseLabel) : goog.dom.createDom(goog.dom.TagName.SPAN, {}, collapseLabel) :
collapseLabel); collapseLabel);
var label = goog.isDef(options.label) ? options.label : '\u00BB'; var label = options.label ? options.label : '\u00BB';
/** /**
* @private * @private
@@ -103,7 +101,7 @@ ol.control.OverviewMap = function(opt_options) {
}); });
var ovmap = this.ovmap_; var ovmap = this.ovmap_;
if (goog.isDef(options.layers)) { if (options.layers) {
options.layers.forEach( options.layers.forEach(
/** /**
* @param {ol.layer.Layer} layer Layer. * @param {ol.layer.Layer} layer Layer.
@@ -133,8 +131,7 @@ ol.control.OverviewMap = function(opt_options) {
var element = goog.dom.createDom(goog.dom.TagName.DIV, var element = goog.dom.createDom(goog.dom.TagName.DIV,
cssClasses, ovmapDiv, button); cssClasses, ovmapDiv, button);
var render = goog.isDef(options.render) ? var render = options.render ? options.render : ol.control.OverviewMap.render;
options.render : ol.control.OverviewMap.render;
goog.base(this, { goog.base(this, {
element: element, element: element,
@@ -271,14 +268,14 @@ ol.control.OverviewMap.prototype.validateExtent_ = function() {
goog.asserts.assertArray(mapSize, 'mapSize should be an array'); goog.asserts.assertArray(mapSize, 'mapSize should be an array');
var view = map.getView(); var view = map.getView();
goog.asserts.assert(goog.isDef(view), 'view should be defined'); goog.asserts.assert(view, 'view should be defined');
var extent = view.calculateExtent(mapSize); var extent = view.calculateExtent(mapSize);
var ovmapSize = ovmap.getSize(); var ovmapSize = ovmap.getSize();
goog.asserts.assertArray(ovmapSize, 'ovmapSize should be an array'); goog.asserts.assertArray(ovmapSize, 'ovmapSize should be an array');
var ovview = ovmap.getView(); var ovview = ovmap.getView();
goog.asserts.assert(goog.isDef(ovview), 'ovview should be defined'); goog.asserts.assert(ovview, 'ovview should be defined');
var ovextent = ovview.calculateExtent(ovmapSize); var ovextent = ovview.calculateExtent(ovmapSize);
var topLeftPixel = var topLeftPixel =
@@ -320,14 +317,14 @@ ol.control.OverviewMap.prototype.resetExtent_ = function() {
goog.asserts.assertArray(mapSize, 'mapSize should be an array'); goog.asserts.assertArray(mapSize, 'mapSize should be an array');
var view = map.getView(); var view = map.getView();
goog.asserts.assert(goog.isDef(view), 'view should be defined'); goog.asserts.assert(view, 'view should be defined');
var extent = view.calculateExtent(mapSize); var extent = view.calculateExtent(mapSize);
var ovmapSize = ovmap.getSize(); var ovmapSize = ovmap.getSize();
goog.asserts.assertArray(ovmapSize, 'ovmapSize should be an array'); goog.asserts.assertArray(ovmapSize, 'ovmapSize should be an array');
var ovview = ovmap.getView(); var ovview = ovmap.getView();
goog.asserts.assert(goog.isDef(ovview), 'ovview should be defined'); goog.asserts.assert(ovview, 'ovview should be defined');
// get how many times the current map overview could hold different // get how many times the current map overview could hold different
// box sizes using the min and max ratio, pick the step in the middle used // box sizes using the min and max ratio, pick the step in the middle used
@@ -350,10 +347,10 @@ ol.control.OverviewMap.prototype.recenter_ = function() {
var ovmap = this.ovmap_; var ovmap = this.ovmap_;
var view = map.getView(); var view = map.getView();
goog.asserts.assert(goog.isDef(view), 'view should be defined'); goog.asserts.assert(view, 'view should be defined');
var ovview = ovmap.getView(); var ovview = ovmap.getView();
goog.asserts.assert(goog.isDef(ovview), 'ovview should be defined'); goog.asserts.assert(ovview, 'ovview should be defined');
ovview.setCenter(view.getCenter()); ovview.setCenter(view.getCenter());
}; };
@@ -375,16 +372,16 @@ ol.control.OverviewMap.prototype.updateBox_ = function() {
goog.asserts.assertArray(mapSize, 'mapSize should be an array'); goog.asserts.assertArray(mapSize, 'mapSize should be an array');
var view = map.getView(); var view = map.getView();
goog.asserts.assert(goog.isDef(view), 'view should be defined'); goog.asserts.assert(view, 'view should be defined');
var ovview = ovmap.getView(); var ovview = ovmap.getView();
goog.asserts.assert(goog.isDef(ovview), 'ovview should be defined'); goog.asserts.assert(ovview, 'ovview should be defined');
var ovmapSize = ovmap.getSize(); var ovmapSize = ovmap.getSize();
goog.asserts.assertArray(ovmapSize, 'ovmapSize should be an array'); goog.asserts.assertArray(ovmapSize, 'ovmapSize should be an array');
var rotation = view.getRotation(); var rotation = view.getRotation();
goog.asserts.assert(goog.isDef(rotation), 'rotation should be defined'); goog.asserts.assert(rotation !== undefined, 'rotation should be defined');
var overlay = this.boxOverlay_; var overlay = this.boxOverlay_;
var box = this.boxOverlay_.getElement(); var box = this.boxOverlay_.getElement();
@@ -419,11 +416,11 @@ ol.control.OverviewMap.prototype.calculateCoordinateRotate_ = function(
var map = this.getMap(); var map = this.getMap();
var view = map.getView(); var view = map.getView();
goog.asserts.assert(goog.isDef(view), 'view should be defined'); goog.asserts.assert(view, 'view should be defined');
var currentCenter = view.getCenter(); var currentCenter = view.getCenter();
if (goog.isDef(currentCenter)) { if (currentCenter) {
coordinateRotate = [ coordinateRotate = [
coordinate[0] - currentCenter[0], coordinate[0] - currentCenter[0],
coordinate[1] - currentCenter[1] coordinate[1] - currentCenter[1]
+10 -12
View File
@@ -6,6 +6,7 @@ goog.require('goog.dom.classlist');
goog.require('goog.events'); goog.require('goog.events');
goog.require('goog.events.EventType'); goog.require('goog.events.EventType');
goog.require('goog.math'); goog.require('goog.math');
goog.require('ol');
goog.require('ol.animation'); goog.require('ol.animation');
goog.require('ol.control.Control'); goog.require('ol.control.Control');
goog.require('ol.css'); goog.require('ol.css');
@@ -26,16 +27,15 @@ goog.require('ol.easing');
*/ */
ol.control.Rotate = function(opt_options) { ol.control.Rotate = function(opt_options) {
var options = goog.isDef(opt_options) ? opt_options : {}; var options = opt_options ? opt_options : {};
var className = goog.isDef(options.className) ? var className = options.className ?
options.className : 'ol-rotate'; options.className : 'ol-rotate';
var label = goog.isDef(options.label) ? var label = options.label ? options.label : '\u21E7';
options.label : '\u21E7';
/** /**
* @type {Node} * @type {Element}
* @private * @private
*/ */
this.label_ = null; this.label_ = null;
@@ -48,8 +48,7 @@ ol.control.Rotate = function(opt_options) {
goog.dom.classlist.add(this.label_, 'ol-compass'); goog.dom.classlist.add(this.label_, 'ol-compass');
} }
var tipLabel = goog.isDef(options.tipLabel) ? var tipLabel = options.tipLabel ? options.tipLabel : 'Reset rotation';
options.tipLabel : 'Reset rotation';
var button = goog.dom.createDom(goog.dom.TagName.BUTTON, { var button = goog.dom.createDom(goog.dom.TagName.BUTTON, {
'class': className + '-reset', 'class': className + '-reset',
@@ -64,8 +63,7 @@ ol.control.Rotate = function(opt_options) {
ol.css.CLASS_CONTROL; ol.css.CLASS_CONTROL;
var element = goog.dom.createDom(goog.dom.TagName.DIV, cssClasses, button); var element = goog.dom.createDom(goog.dom.TagName.DIV, cssClasses, button);
var render = goog.isDef(options.render) ? var render = options.render ? options.render : ol.control.Rotate.render;
options.render : ol.control.Rotate.render;
goog.base(this, { goog.base(this, {
element: element, element: element,
@@ -77,13 +75,13 @@ ol.control.Rotate = function(opt_options) {
* @type {number} * @type {number}
* @private * @private
*/ */
this.duration_ = goog.isDef(options.duration) ? options.duration : 250; this.duration_ = options.duration ? options.duration : 250;
/** /**
* @type {boolean} * @type {boolean}
* @private * @private
*/ */
this.autoHide_ = goog.isDef(options.autoHide) ? options.autoHide : true; this.autoHide_ = options.autoHide !== undefined ? options.autoHide : true;
/** /**
* @private * @private
@@ -127,7 +125,7 @@ ol.control.Rotate.prototype.resetNorth_ = function() {
while (currentRotation > Math.PI) { while (currentRotation > Math.PI) {
currentRotation -= 2 * Math.PI; currentRotation -= 2 * Math.PI;
} }
if (goog.isDef(currentRotation)) { if (currentRotation !== undefined) {
if (this.duration_ > 0) { if (this.duration_ > 0) {
map.beforeRender(ol.animation.rotate({ map.beforeRender(ol.animation.rotate({
rotation: currentRotation, rotation: currentRotation,
+6 -7
View File
@@ -8,6 +8,7 @@ goog.require('goog.dom.TagName');
goog.require('goog.events'); goog.require('goog.events');
goog.require('goog.math'); goog.require('goog.math');
goog.require('goog.style'); goog.require('goog.style');
goog.require('ol');
goog.require('ol.Object'); goog.require('ol.Object');
goog.require('ol.TransformFunction'); goog.require('ol.TransformFunction');
goog.require('ol.control.Control'); goog.require('ol.control.Control');
@@ -58,10 +59,9 @@ ol.control.ScaleLineUnits = {
*/ */
ol.control.ScaleLine = function(opt_options) { ol.control.ScaleLine = function(opt_options) {
var options = goog.isDef(opt_options) ? opt_options : {}; var options = opt_options ? opt_options : {};
var className = goog.isDef(options.className) ? var className = options.className ? options.className : 'ol-scale-line';
options.className : 'ol-scale-line';
/** /**
* @private * @private
@@ -87,7 +87,7 @@ ol.control.ScaleLine = function(opt_options) {
* @private * @private
* @type {number} * @type {number}
*/ */
this.minWidth_ = goog.isDef(options.minWidth) ? options.minWidth : 64; this.minWidth_ = options.minWidth !== undefined ? options.minWidth : 64;
/** /**
* @private * @private
@@ -113,8 +113,7 @@ ol.control.ScaleLine = function(opt_options) {
*/ */
this.toEPSG4326_ = null; this.toEPSG4326_ = null;
var render = goog.isDef(options.render) ? var render = options.render ? options.render : ol.control.ScaleLine.render;
options.render : ol.control.ScaleLine.render;
goog.base(this, { goog.base(this, {
element: this.element_, element: this.element_,
@@ -233,7 +232,7 @@ ol.control.ScaleLine.prototype.updateElement_ = function() {
} }
cosLatitude = Math.cos(goog.math.toRadians(this.toEPSG4326_(center)[1])); cosLatitude = Math.cos(goog.math.toRadians(this.toEPSG4326_(center)[1]));
var radius = ol.sphere.NORMAL.radius; var radius = ol.sphere.NORMAL.radius;
goog.asserts.assert(goog.isDef(ol.proj.METERS_PER_UNIT[projectionUnits]), goog.asserts.assert(ol.proj.METERS_PER_UNIT[projectionUnits],
'Meters per unit should be defined for the projection unit'); 'Meters per unit should be defined for the projection unit');
radius /= ol.proj.METERS_PER_UNIT[projectionUnits]; radius /= ol.proj.METERS_PER_UNIT[projectionUnits];
pointResolution *= 180 / (Math.PI * cosLatitude * radius); pointResolution *= 180 / (Math.PI * cosLatitude * radius);
+9 -11
View File
@@ -24,20 +24,18 @@ goog.require('ol.easing');
*/ */
ol.control.Zoom = function(opt_options) { ol.control.Zoom = function(opt_options) {
var options = goog.isDef(opt_options) ? opt_options : {}; var options = opt_options ? opt_options : {};
var className = goog.isDef(options.className) ? options.className : 'ol-zoom'; var className = options.className ? options.className : 'ol-zoom';
var delta = goog.isDef(options.delta) ? options.delta : 1; var delta = options.delta ? options.delta : 1;
var zoomInLabel = goog.isDef(options.zoomInLabel) ? var zoomInLabel = options.zoomInLabel ? options.zoomInLabel : '+';
options.zoomInLabel : '+'; var zoomOutLabel = options.zoomOutLabel ? options.zoomOutLabel : '\u2212';
var zoomOutLabel = goog.isDef(options.zoomOutLabel) ?
options.zoomOutLabel : '\u2212';
var zoomInTipLabel = goog.isDef(options.zoomInTipLabel) ? var zoomInTipLabel = options.zoomInTipLabel ?
options.zoomInTipLabel : 'Zoom in'; options.zoomInTipLabel : 'Zoom in';
var zoomOutTipLabel = goog.isDef(options.zoomOutTipLabel) ? var zoomOutTipLabel = options.zoomOutTipLabel ?
options.zoomOutTipLabel : 'Zoom out'; options.zoomOutTipLabel : 'Zoom out';
var inElement = goog.dom.createDom(goog.dom.TagName.BUTTON, { var inElement = goog.dom.createDom(goog.dom.TagName.BUTTON, {
@@ -81,7 +79,7 @@ ol.control.Zoom = function(opt_options) {
* @type {number} * @type {number}
* @private * @private
*/ */
this.duration_ = goog.isDef(options.duration) ? options.duration : 250; this.duration_ = options.duration ? options.duration : 250;
}; };
goog.inherits(ol.control.Zoom, ol.control.Control); goog.inherits(ol.control.Zoom, ol.control.Control);
@@ -111,7 +109,7 @@ ol.control.Zoom.prototype.zoomByDelta_ = function(delta) {
return; return;
} }
var currentResolution = view.getResolution(); var currentResolution = view.getResolution();
if (goog.isDef(currentResolution)) { if (currentResolution) {
if (this.duration_ > 0) { if (this.duration_ > 0) {
map.beforeRender(ol.animation.zoom({ map.beforeRender(ol.animation.zoom({
resolution: currentResolution, resolution: currentResolution,
+6 -8
View File
@@ -38,7 +38,7 @@ goog.require('ol.easing');
*/ */
ol.control.ZoomSlider = function(opt_options) { ol.control.ZoomSlider = function(opt_options) {
var options = goog.isDef(opt_options) ? opt_options : {}; var options = opt_options ? opt_options : {};
/** /**
* Will hold the current resolution of the view. * Will hold the current resolution of the view.
@@ -76,10 +76,9 @@ ol.control.ZoomSlider = function(opt_options) {
* @private * @private
* @type {number} * @type {number}
*/ */
this.duration_ = goog.isDef(options.duration) ? options.duration : 200; this.duration_ = options.duration ? options.duration : 200;
var className = goog.isDef(options.className) ? var className = options.className ? options.className : 'ol-zoomslider';
options.className : 'ol-zoomslider';
var thumbElement = goog.dom.createDom(goog.dom.TagName.DIV, var thumbElement = goog.dom.createDom(goog.dom.TagName.DIV,
[className + '-thumb', ol.css.CLASS_UNSELECTABLE]); [className + '-thumb', ol.css.CLASS_UNSELECTABLE]);
var containerElement = goog.dom.createDom(goog.dom.TagName.DIV, var containerElement = goog.dom.createDom(goog.dom.TagName.DIV,
@@ -105,8 +104,7 @@ ol.control.ZoomSlider = function(opt_options) {
goog.events.listen(thumbElement, goog.events.EventType.CLICK, goog.events.listen(thumbElement, goog.events.EventType.CLICK,
goog.events.Event.stopPropagation); goog.events.Event.stopPropagation);
var render = goog.isDef(options.render) ? var render = options.render ? options.render : ol.control.ZoomSlider.render;
options.render : ol.control.ZoomSlider.render;
goog.base(this, { goog.base(this, {
element: containerElement, element: containerElement,
@@ -205,7 +203,7 @@ ol.control.ZoomSlider.prototype.handleContainerClick_ = function(browserEvent) {
var map = this.getMap(); var map = this.getMap();
var view = map.getView(); var view = map.getView();
var currentResolution = view.getResolution(); var currentResolution = view.getResolution();
goog.asserts.assert(goog.isDef(currentResolution), goog.asserts.assert(currentResolution,
'currentResolution should be defined'); 'currentResolution should be defined');
map.beforeRender(ol.animation.zoom({ map.beforeRender(ol.animation.zoom({
resolution: currentResolution, resolution: currentResolution,
@@ -252,7 +250,7 @@ ol.control.ZoomSlider.prototype.handleDraggerEnd_ = function(event) {
var map = this.getMap(); var map = this.getMap();
var view = map.getView(); var view = map.getView();
view.setHint(ol.ViewHint.INTERACTING, -1); view.setHint(ol.ViewHint.INTERACTING, -1);
goog.asserts.assert(goog.isDef(this.currentResolution_), goog.asserts.assert(this.currentResolution_,
'this.currentResolution_ should be defined'); 'this.currentResolution_ should be defined');
map.beforeRender(ol.animation.zoom({ map.beforeRender(ol.animation.zoom({
resolution: this.currentResolution_, resolution: this.currentResolution_,
+6 -6
View File
@@ -21,19 +21,19 @@ goog.require('ol.css');
* @api stable * @api stable
*/ */
ol.control.ZoomToExtent = function(opt_options) { ol.control.ZoomToExtent = function(opt_options) {
var options = goog.isDef(opt_options) ? opt_options : {}; var options = opt_options ? opt_options : {};
/** /**
* @type {ol.Extent} * @type {ol.Extent}
* @private * @private
*/ */
this.extent_ = goog.isDef(options.extent) ? options.extent : null; this.extent_ = options.extent ? options.extent : null;
var className = goog.isDef(options.className) ? options.className : var className = options.className ? options.className :
'ol-zoom-extent'; 'ol-zoom-extent';
var label = goog.isDef(options.label) ? options.label : 'E'; var label = options.label ? options.label : 'E';
var tipLabel = goog.isDef(options.tipLabel) ? var tipLabel = options.tipLabel ?
options.tipLabel : 'Fit to extent'; options.tipLabel : 'Fit to extent';
var button = goog.dom.createDom(goog.dom.TagName.BUTTON, { var button = goog.dom.createDom(goog.dom.TagName.BUTTON, {
'type': 'button', 'type': 'button',
@@ -74,6 +74,6 @@ ol.control.ZoomToExtent.prototype.handleZoomToExtent_ = function() {
var extent = goog.isNull(this.extent_) ? var extent = goog.isNull(this.extent_) ?
view.getProjection().getExtent() : this.extent_; view.getProjection().getExtent() : this.extent_;
var size = map.getSize(); var size = map.getSize();
goog.asserts.assert(goog.isDef(size), 'size should be defined'); goog.asserts.assert(size, 'size should be defined');
view.fit(extent, size); view.fit(extent, size);
}; };
+2 -2
View File
@@ -164,7 +164,7 @@ ol.coordinate.degreesToStringHDMS_ = function(degrees, hemispheres) {
* @api stable * @api stable
*/ */
ol.coordinate.format = function(coordinate, template, opt_fractionDigits) { ol.coordinate.format = function(coordinate, template, opt_fractionDigits) {
if (goog.isDef(coordinate)) { if (coordinate) {
return template return template
.replace('{x}', coordinate[0].toFixed(opt_fractionDigits)) .replace('{x}', coordinate[0].toFixed(opt_fractionDigits))
.replace('{y}', coordinate[1].toFixed(opt_fractionDigits)); .replace('{y}', coordinate[1].toFixed(opt_fractionDigits));
@@ -295,7 +295,7 @@ ol.coordinate.squaredDistanceToSegment = function(coordinate, segment) {
* @api stable * @api stable
*/ */
ol.coordinate.toStringHDMS = function(coordinate) { ol.coordinate.toStringHDMS = function(coordinate) {
if (goog.isDef(coordinate)) { if (coordinate) {
return ol.coordinate.degreesToStringHDMS_(coordinate[1], 'NS') + ' ' + return ol.coordinate.degreesToStringHDMS_(coordinate[1], 'NS') + ' ' +
ol.coordinate.degreesToStringHDMS_(coordinate[0], 'EW'); ol.coordinate.degreesToStringHDMS_(coordinate[0], 'EW');
} else { } else {
+3 -2
View File
@@ -3,6 +3,7 @@ goog.provide('ol.DeviceOrientationProperty');
goog.require('goog.events'); goog.require('goog.events');
goog.require('goog.math'); goog.require('goog.math');
goog.require('ol');
goog.require('ol.Object'); goog.require('ol.Object');
goog.require('ol.has'); goog.require('ol.has');
@@ -79,7 +80,7 @@ ol.DeviceOrientation = function(opt_options) {
goog.base(this); goog.base(this);
var options = goog.isDef(opt_options) ? opt_options : {}; var options = opt_options ? opt_options : {};
/** /**
* @private * @private
@@ -91,7 +92,7 @@ ol.DeviceOrientation = function(opt_options) {
ol.Object.getChangeEventType(ol.DeviceOrientationProperty.TRACKING), ol.Object.getChangeEventType(ol.DeviceOrientationProperty.TRACKING),
this.handleTrackingChanged_, false, this); this.handleTrackingChanged_, false, this);
this.setTracking(goog.isDef(options.tracking) ? options.tracking : false); this.setTracking(options.tracking !== undefined ? options.tracking : false);
}; };
goog.inherits(ol.DeviceOrientation, ol.Object); goog.inherits(ol.DeviceOrientation, ol.Object);
+6 -6
View File
@@ -19,10 +19,10 @@ goog.require('ol');
*/ */
ol.dom.createCanvasContext2D = function(opt_width, opt_height) { ol.dom.createCanvasContext2D = function(opt_width, opt_height) {
var canvas = goog.dom.createElement(goog.dom.TagName.CANVAS); var canvas = goog.dom.createElement(goog.dom.TagName.CANVAS);
if (goog.isDef(opt_width)) { if (opt_width) {
canvas.width = opt_width; canvas.width = opt_width;
} }
if (goog.isDef(opt_height)) { if (opt_height) {
canvas.height = opt_height; canvas.height = opt_height;
} }
return canvas.getContext('2d'); return canvas.getContext('2d');
@@ -47,7 +47,7 @@ ol.dom.BrowserFeature = {
ol.dom.canUseCssTransform = (function() { ol.dom.canUseCssTransform = (function() {
var canUseCssTransform; var canUseCssTransform;
return function() { return function() {
if (!goog.isDef(canUseCssTransform)) { if (canUseCssTransform === undefined) {
goog.asserts.assert(!goog.isNull(document.body), goog.asserts.assert(!goog.isNull(document.body),
'document.body should not be null'); 'document.body should not be null');
if (!goog.global.getComputedStyle) { if (!goog.global.getComputedStyle) {
@@ -90,7 +90,7 @@ ol.dom.canUseCssTransform = (function() {
ol.dom.canUseCssTransform3D = (function() { ol.dom.canUseCssTransform3D = (function() {
var canUseCssTransform3D; var canUseCssTransform3D;
return function() { return function() {
if (!goog.isDef(canUseCssTransform3D)) { if (canUseCssTransform3D === undefined) {
goog.asserts.assert(!goog.isNull(document.body), goog.asserts.assert(!goog.isNull(document.body),
'document.body should not be null'); 'document.body should not be null');
if (!goog.global.getComputedStyle) { if (!goog.global.getComputedStyle) {
@@ -224,7 +224,7 @@ ol.dom.transformElement2D =
if (ol.dom.canUseCssTransform3D()) { if (ol.dom.canUseCssTransform3D()) {
var value3D; var value3D;
if (goog.isDef(opt_precision)) { if (opt_precision !== undefined) {
/** @type {Array.<string>} */ /** @type {Array.<string>} */
var strings3D = new Array(16); var strings3D = new Array(16);
for (i = 0; i < 16; ++i) { for (i = 0; i < 16; ++i) {
@@ -246,7 +246,7 @@ ol.dom.transformElement2D =
goog.vec.Mat4.getElement(transform, 1, 3) goog.vec.Mat4.getElement(transform, 1, 3)
]; ];
var value2D; var value2D;
if (goog.isDef(opt_precision)) { if (opt_precision !== undefined) {
/** @type {Array.<string>} */ /** @type {Array.<string>} */
var strings2D = new Array(6); var strings2D = new Array(6);
for (i = 0; i < 6; ++i) { for (i = 0; i < 6; ++i) {
+7 -8
View File
@@ -87,7 +87,7 @@ ol.extent.boundingExtentXYs_ = function(xs, ys, opt_extent) {
* @api stable * @api stable
*/ */
ol.extent.buffer = function(extent, value, opt_extent) { ol.extent.buffer = function(extent, value, opt_extent) {
if (goog.isDef(opt_extent)) { if (opt_extent) {
opt_extent[0] = extent[0] - value; opt_extent[0] = extent[0] - value;
opt_extent[1] = extent[1] - value; opt_extent[1] = extent[1] - value;
opt_extent[2] = extent[2] + value; opt_extent[2] = extent[2] + value;
@@ -112,7 +112,7 @@ ol.extent.buffer = function(extent, value, opt_extent) {
* @return {ol.Extent} The clone. * @return {ol.Extent} The clone.
*/ */
ol.extent.clone = function(extent, opt_extent) { ol.extent.clone = function(extent, opt_extent) {
if (goog.isDef(opt_extent)) { if (opt_extent) {
opt_extent[0] = extent[0]; opt_extent[0] = extent[0];
opt_extent[1] = extent[1]; opt_extent[1] = extent[1];
opt_extent[2] = extent[2]; opt_extent[2] = extent[2];
@@ -247,7 +247,7 @@ ol.extent.createEmpty = function() {
* @return {ol.Extent} Extent. * @return {ol.Extent} Extent.
*/ */
ol.extent.createOrUpdate = function(minX, minY, maxX, maxY, opt_extent) { ol.extent.createOrUpdate = function(minX, minY, maxX, maxY, opt_extent) {
if (goog.isDef(opt_extent)) { if (opt_extent) {
opt_extent[0] = minX; opt_extent[0] = minX;
opt_extent[1] = minY; opt_extent[1] = minY;
opt_extent[2] = maxX; opt_extent[2] = maxX;
@@ -545,7 +545,7 @@ ol.extent.getCorner = function(extent, corner) {
} else { } else {
goog.asserts.fail('Invalid corner: %s', corner); goog.asserts.fail('Invalid corner: %s', corner);
} }
goog.asserts.assert(goog.isDef(coordinate), 'coordinate should be defined'); goog.asserts.assert(coordinate, 'coordinate should be defined');
return coordinate; return coordinate;
}; };
@@ -624,8 +624,7 @@ ol.extent.getIntersectionArea = function(extent1, extent2) {
* @api stable * @api stable
*/ */
ol.extent.getIntersection = function(extent1, extent2, opt_extent) { ol.extent.getIntersection = function(extent1, extent2, opt_extent) {
var intersection = goog.isDef(opt_extent) ? var intersection = opt_extent ? opt_extent : ol.extent.createEmpty();
opt_extent : ol.extent.createEmpty();
if (ol.extent.intersects(extent1, extent2)) { if (ol.extent.intersects(extent1, extent2)) {
if (extent1[0] > extent2[0]) { if (extent1[0] > extent2[0]) {
intersection[0] = extent1[0]; intersection[0] = extent1[0];
@@ -760,7 +759,7 @@ ol.extent.normalize = function(extent, coordinate) {
* @return {ol.Extent} Extent. * @return {ol.Extent} Extent.
*/ */
ol.extent.returnOrUpdate = function(extent, opt_extent) { ol.extent.returnOrUpdate = function(extent, opt_extent) {
if (goog.isDef(opt_extent)) { if (opt_extent) {
opt_extent[0] = extent[0]; opt_extent[0] = extent[0];
opt_extent[1] = extent[1]; opt_extent[1] = extent[1];
opt_extent[2] = extent[2]; opt_extent[2] = extent[2];
@@ -886,7 +885,7 @@ ol.extent.applyTransform = function(extent, transformFn, opt_extent) {
* @return {ol.Extent} The transformed extent. * @return {ol.Extent} The transformed extent.
*/ */
ol.extent.transform2D = function(extent, transform, opt_extent) { ol.extent.transform2D = function(extent, transform, opt_extent) {
var dest = goog.isDef(opt_extent) ? opt_extent : []; var dest = opt_extent ? opt_extent : [];
var m00 = goog.vec.Mat4.getElement(transform, 0, 0); var m00 = goog.vec.Mat4.getElement(transform, 0, 0);
var m10 = goog.vec.Mat4.getElement(transform, 1, 0); var m10 = goog.vec.Mat4.getElement(transform, 1, 0);
var m01 = goog.vec.Mat4.getElement(transform, 0, 1); var m01 = goog.vec.Mat4.getElement(transform, 0, 1);
+2 -1
View File
@@ -5,6 +5,7 @@ goog.require('goog.asserts');
goog.require('goog.events'); goog.require('goog.events');
goog.require('goog.events.EventType'); goog.require('goog.events.EventType');
goog.require('goog.functions'); goog.require('goog.functions');
goog.require('ol');
goog.require('ol.Object'); goog.require('ol.Object');
goog.require('ol.geom.Geometry'); goog.require('ol.geom.Geometry');
goog.require('ol.style.Style'); goog.require('ol.style.Style');
@@ -96,7 +97,7 @@ ol.Feature = function(opt_geometryOrProperties) {
this, ol.Object.getChangeEventType(this.geometryName_), this, ol.Object.getChangeEventType(this.geometryName_),
this.handleGeometryChanged_, false, this); this.handleGeometryChanged_, false, this);
if (goog.isDef(opt_geometryOrProperties)) { if (opt_geometryOrProperties !== undefined) {
if (opt_geometryOrProperties instanceof ol.geom.Geometry || if (opt_geometryOrProperties instanceof ol.geom.Geometry ||
goog.isNull(opt_geometryOrProperties)) { goog.isNull(opt_geometryOrProperties)) {
var geometry = /** @type {ol.geom.Geometry} */ (opt_geometryOrProperties); var geometry = /** @type {ol.geom.Geometry} */ (opt_geometryOrProperties);
+10 -11
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()
+5 -5
View File
@@ -42,9 +42,9 @@ ol.format.Feature.prototype.getExtensions = goog.abstractMethod;
*/ */
ol.format.Feature.prototype.getReadOptions = function(source, opt_options) { ol.format.Feature.prototype.getReadOptions = function(source, opt_options) {
var options; var options;
if (goog.isDef(opt_options)) { if (opt_options) {
options = { options = {
dataProjection: goog.isDef(opt_options.dataProjection) ? dataProjection: opt_options.dataProjection ?
opt_options.dataProjection : this.readProjection(source), opt_options.dataProjection : this.readProjection(source),
featureProjection: opt_options.featureProjection featureProjection: opt_options.featureProjection
}; };
@@ -64,7 +64,7 @@ ol.format.Feature.prototype.getReadOptions = function(source, opt_options) {
*/ */
ol.format.Feature.prototype.adaptOptions = function(options) { ol.format.Feature.prototype.adaptOptions = function(options) {
var updatedOptions; var updatedOptions;
if (goog.isDef(options)) { if (options) {
updatedOptions = { updatedOptions = {
featureProjection: options.featureProjection, featureProjection: options.featureProjection,
dataProjection: goog.isDefAndNotNull(options.dataProjection) ? dataProjection: goog.isDefAndNotNull(options.dataProjection) ?
@@ -161,9 +161,9 @@ ol.format.Feature.prototype.writeGeometry = goog.abstractMethod;
*/ */
ol.format.Feature.transformWithOptions = function( ol.format.Feature.transformWithOptions = function(
geometry, write, opt_options) { geometry, write, opt_options) {
var featureProjection = goog.isDef(opt_options) ? var featureProjection = opt_options ?
ol.proj.get(opt_options.featureProjection) : null; ol.proj.get(opt_options.featureProjection) : null;
var dataProjection = goog.isDef(opt_options) ? var dataProjection = opt_options ?
ol.proj.get(opt_options.dataProjection) : null; ol.proj.get(opt_options.dataProjection) : null;
if (!goog.isNull(featureProjection) && !goog.isNull(dataProjection) && if (!goog.isNull(featureProjection) && !goog.isNull(dataProjection) &&
!ol.proj.equivalent(featureProjection, dataProjection)) { !ol.proj.equivalent(featureProjection, dataProjection)) {
+8 -10
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;
+4 -4
View File
@@ -22,7 +22,7 @@ goog.require('ol.xml');
*/ */
ol.format.GML2 = function(opt_options) { ol.format.GML2 = function(opt_options) {
var options = /** @type {olx.format.GMLOptions} */ var options = /** @type {olx.format.GMLOptions} */
(goog.isDef(opt_options) ? opt_options : {}); (opt_options ? opt_options : {});
goog.base(this, options); goog.base(this, options);
@@ -33,7 +33,7 @@ ol.format.GML2 = function(opt_options) {
/** /**
* @inheritDoc * @inheritDoc
*/ */
this.schemaLocation = goog.isDef(options.schemaLocation) ? this.schemaLocation = options.schemaLocation ?
options.schemaLocation : ol.format.GML2.schemaLocation_; options.schemaLocation : ol.format.GML2.schemaLocation_;
}; };
@@ -127,7 +127,7 @@ ol.format.GML2.prototype.innerBoundaryIsParser_ =
var flatLinearRing = ol.xml.pushParseAndPop( var flatLinearRing = ol.xml.pushParseAndPop(
/** @type {Array.<number>|undefined} */ (undefined), /** @type {Array.<number>|undefined} */ (undefined),
this.RING_PARSERS, node, objectStack, this); this.RING_PARSERS, node, objectStack, this);
if (goog.isDef(flatLinearRing)) { if (flatLinearRing) {
var flatLinearRings = /** @type {Array.<Array.<number>>} */ var flatLinearRings = /** @type {Array.<Array.<number>>} */
(objectStack[objectStack.length - 1]); (objectStack[objectStack.length - 1]);
goog.asserts.assert(goog.isArray(flatLinearRings), goog.asserts.assert(goog.isArray(flatLinearRings),
@@ -153,7 +153,7 @@ ol.format.GML2.prototype.outerBoundaryIsParser_ =
var flatLinearRing = ol.xml.pushParseAndPop( var flatLinearRing = ol.xml.pushParseAndPop(
/** @type {Array.<number>|undefined} */ (undefined), /** @type {Array.<number>|undefined} */ (undefined),
this.RING_PARSERS, node, objectStack, this); this.RING_PARSERS, node, objectStack, this);
if (goog.isDef(flatLinearRing)) { if (flatLinearRing) {
var flatLinearRings = /** @type {Array.<Array.<number>>} */ var flatLinearRings = /** @type {Array.<Array.<number>>} */
(objectStack[objectStack.length - 1]); (objectStack[objectStack.length - 1]);
goog.asserts.assert(goog.isArray(flatLinearRings), goog.asserts.assert(goog.isArray(flatLinearRings),
+24 -26
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,32 @@ ol.format.GML3 = function(opt_options) {
* @private * @private
* @type {boolean} * @type {boolean}
*/ */
this.surface_ = goog.isDef(options.surface) ? this.surface_ = options.surface !== undefined ? options.surface : false;
options.surface : false;
/** /**
* @private * @private
* @type {boolean} * @type {boolean}
*/ */
this.curve_ = goog.isDef(options.curve) ? this.curve_ = options.curve !== undefined ? options.curve : false;
options.curve : false;
/** /**
* @private * @private
* @type {boolean} * @type {boolean}
*/ */
this.multiCurve_ = goog.isDef(options.multiCurve) ? this.multiCurve_ = options.multiCurve !== undefined ?
options.multiCurve : true; options.multiCurve : true;
/** /**
* @private * @private
* @type {boolean} * @type {boolean}
*/ */
this.multiSurface_ = goog.isDef(options.multiSurface) ? this.multiSurface_ = options.multiSurface !== undefined ?
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 +102,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 +126,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 +250,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 +275,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 +301,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 +332,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 +739,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 +785,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 (exteriorWritten === undefined) {
context['exteriorWritten'] = true; context['exteriorWritten'] = true;
} }
return ol.xml.createElementNS(parentNode.namespaceURI, return ol.xml.createElementNS(parentNode.namespaceURI,
goog.isDef(exteriorWritten) ? 'interior' : 'exterior'); exteriorWritten !== undefined ? 'interior' : 'exterior');
}; };
@@ -947,7 +945,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 +977,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 +1026,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 +1053,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 +1291,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 +1334,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]);
+13 -13
View File
@@ -41,7 +41,7 @@ goog.require('ol.xml');
*/ */
ol.format.GMLBase = function(opt_options) { ol.format.GMLBase = function(opt_options) {
var options = /** @type {olx.format.GMLOptions} */ var options = /** @type {olx.format.GMLOptions} */
(goog.isDef(opt_options) ? opt_options : {}); (opt_options ? opt_options : {});
/** /**
* @protected * @protected
@@ -116,7 +116,7 @@ ol.format.GMLBase.prototype.readFeaturesInternal = function(node, objectStack) {
var featureType = context['featureType']; var featureType = context['featureType'];
var featureNS = context['featureNS']; var featureNS = context['featureNS'];
var i, ii, prefix = 'p', defaultPrefix = 'p0'; var i, ii, prefix = 'p', defaultPrefix = 'p0';
if (!goog.isDef(featureType) && goog.isDefAndNotNull(node.childNodes)) { if (!featureType && goog.isDefAndNotNull(node.childNodes)) {
featureType = [], featureNS = {}; featureType = [], featureNS = {};
for (i = 0, ii = node.childNodes.length; i < ii; ++i) { for (i = 0, ii = node.childNodes.length; i < ii; ++i) {
var child = node.childNodes[i]; var child = node.childNodes[i];
@@ -162,7 +162,7 @@ ol.format.GMLBase.prototype.readFeaturesInternal = function(node, objectStack) {
} }
features = ol.xml.pushParseAndPop([], parsersNS, node, objectStack); features = ol.xml.pushParseAndPop([], parsersNS, node, objectStack);
} }
if (!goog.isDef(features)) { if (!features) {
features = []; features = [];
} }
return features; return features;
@@ -222,7 +222,7 @@ ol.format.GMLBase.prototype.readFeatureElement = function(node, objectStack) {
} }
} }
var feature = new ol.Feature(values); var feature = new ol.Feature(values);
if (goog.isDef(geometryName)) { if (geometryName) {
feature.setGeometryName(geometryName); feature.setGeometryName(geometryName);
} }
if (fid) { if (fid) {
@@ -266,7 +266,7 @@ ol.format.GMLBase.prototype.readMultiPoint = function(node, objectStack) {
var coordinates = ol.xml.pushParseAndPop( var coordinates = ol.xml.pushParseAndPop(
/** @type {Array.<Array.<number>>} */ ([]), /** @type {Array.<Array.<number>>} */ ([]),
this.MULTIPOINT_PARSERS_, node, objectStack, this); this.MULTIPOINT_PARSERS_, node, objectStack, this);
if (goog.isDef(coordinates)) { if (coordinates) {
return new ol.geom.MultiPoint(coordinates); return new ol.geom.MultiPoint(coordinates);
} else { } else {
return undefined; return undefined;
@@ -287,7 +287,7 @@ ol.format.GMLBase.prototype.readMultiLineString = function(node, objectStack) {
var lineStrings = ol.xml.pushParseAndPop( var lineStrings = ol.xml.pushParseAndPop(
/** @type {Array.<ol.geom.LineString>} */ ([]), /** @type {Array.<ol.geom.LineString>} */ ([]),
this.MULTILINESTRING_PARSERS_, node, objectStack, this); this.MULTILINESTRING_PARSERS_, node, objectStack, this);
if (goog.isDef(lineStrings)) { if (lineStrings) {
var multiLineString = new ol.geom.MultiLineString(null); var multiLineString = new ol.geom.MultiLineString(null);
multiLineString.setLineStrings(lineStrings); multiLineString.setLineStrings(lineStrings);
return multiLineString; return multiLineString;
@@ -310,7 +310,7 @@ ol.format.GMLBase.prototype.readMultiPolygon = function(node, objectStack) {
var polygons = ol.xml.pushParseAndPop( var polygons = ol.xml.pushParseAndPop(
/** @type {Array.<ol.geom.Polygon>} */ ([]), /** @type {Array.<ol.geom.Polygon>} */ ([]),
this.MULTIPOLYGON_PARSERS_, node, objectStack, this); this.MULTIPOLYGON_PARSERS_, node, objectStack, this);
if (goog.isDef(polygons)) { if (polygons) {
var multiPolygon = new ol.geom.MultiPolygon(null); var multiPolygon = new ol.geom.MultiPolygon(null);
multiPolygon.setPolygons(polygons); multiPolygon.setPolygons(polygons);
return multiPolygon; return multiPolygon;
@@ -426,7 +426,7 @@ ol.format.GMLBase.prototype.readLinearRing = function(node, objectStack) {
'localName should be LinearRing'); 'localName should be LinearRing');
var flatCoordinates = var flatCoordinates =
this.readFlatCoordinatesFromNode_(node, objectStack); this.readFlatCoordinatesFromNode_(node, objectStack);
if (goog.isDef(flatCoordinates)) { if (flatCoordinates) {
var ring = new ol.geom.LinearRing(null); var ring = new ol.geom.LinearRing(null);
ring.setFlatCoordinates(ol.geom.GeometryLayout.XYZ, flatCoordinates); ring.setFlatCoordinates(ol.geom.GeometryLayout.XYZ, flatCoordinates);
return ring; return ring;
@@ -449,7 +449,7 @@ ol.format.GMLBase.prototype.readPolygon = function(node, objectStack) {
var flatLinearRings = ol.xml.pushParseAndPop( var flatLinearRings = ol.xml.pushParseAndPop(
/** @type {Array.<Array.<number>>} */ ([null]), /** @type {Array.<Array.<number>>} */ ([null]),
this.FLAT_LINEAR_RINGS_PARSERS_, node, objectStack, this); this.FLAT_LINEAR_RINGS_PARSERS_, node, objectStack, this);
if (goog.isDef(flatLinearRings) && if (flatLinearRings &&
!goog.isNull(flatLinearRings[0])) { !goog.isNull(flatLinearRings[0])) {
var polygon = new ol.geom.Polygon(null); var polygon = new ol.geom.Polygon(null);
var flatCoordinates = flatLinearRings[0]; var flatCoordinates = flatLinearRings[0];
@@ -588,8 +588,8 @@ ol.format.GMLBase.prototype.RING_PARSERS = Object({
ol.format.GMLBase.prototype.readGeometryFromNode = ol.format.GMLBase.prototype.readGeometryFromNode =
function(node, opt_options) { function(node, opt_options) {
var geometry = this.readGeometryElement(node, var geometry = this.readGeometryElement(node,
[this.getReadOptions(node, goog.isDef(opt_options) ? opt_options : {})]); [this.getReadOptions(node, opt_options ? opt_options : {})]);
return goog.isDef(geometry) ? geometry : null; return geometry ? geometry : null;
}; };
@@ -614,7 +614,7 @@ ol.format.GMLBase.prototype.readFeaturesFromNode =
featureType: this.featureType, featureType: this.featureType,
featureNS: this.featureNS featureNS: this.featureNS
}; };
if (goog.isDef(opt_options)) { if (opt_options) {
goog.object.extend(options, this.getReadOptions(node, opt_options)); goog.object.extend(options, this.getReadOptions(node, opt_options));
} }
return this.readFeaturesInternal(node, [options]); return this.readFeaturesInternal(node, [options]);
@@ -625,6 +625,6 @@ ol.format.GMLBase.prototype.readFeaturesFromNode =
* @inheritDoc * @inheritDoc
*/ */
ol.format.GMLBase.prototype.readProjectionFromNode = function(node) { ol.format.GMLBase.prototype.readProjectionFromNode = function(node) {
return ol.proj.get(goog.isDef(this.srsName_) ? this.srsName_ : return ol.proj.get(this.srsName_ ? this.srsName_ :
node.firstElementChild.getAttribute('srsName')); node.firstElementChild.getAttribute('srsName'));
}; };
+14 -14
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');
+2 -2
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;
}; };
+1 -1
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;
+57 -56
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,14 +82,14 @@ 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_ = options.extractStyles !== undefined ?
options.extractStyles : true; options.extractStyles : true;
/** /**
@@ -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 (number !== undefined) {
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 (x !== undefined && y !== undefined) {
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 (w !== undefined && h !== undefined) {
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 (heading !== undefined) {
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 (fill !== undefined) {
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 (outline !== undefined) {
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 (fill !== undefined && !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 (outline !== undefined && !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 || extrudes[i] !== undefined;
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);
+1 -1
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;
} }
} }
+4 -4
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} */
+7 -7
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) {
+6 -7
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>} */
+31 -32
View File
@@ -3,6 +3,7 @@ goog.provide('ol.format.WFS');
goog.require('goog.asserts'); goog.require('goog.asserts');
goog.require('goog.dom.NodeType'); goog.require('goog.dom.NodeType');
goog.require('goog.object'); goog.require('goog.object');
goog.require('ol');
goog.require('ol.format.GML3'); goog.require('ol.format.GML3');
goog.require('ol.format.GMLBase'); goog.require('ol.format.GMLBase');
goog.require('ol.format.XMLFeature'); goog.require('ol.format.XMLFeature');
@@ -27,7 +28,7 @@ goog.require('ol.xml');
* @api stable * @api stable
*/ */
ol.format.WFS = function(opt_options) { ol.format.WFS = function(opt_options) {
var options = goog.isDef(opt_options) ? opt_options : {}; var options = opt_options ? opt_options : {};
/** /**
* @private * @private
@@ -45,14 +46,14 @@ ol.format.WFS = function(opt_options) {
* @private * @private
* @type {ol.format.GMLBase} * @type {ol.format.GMLBase}
*/ */
this.gmlFormat_ = goog.isDef(options.gmlFormat) ? this.gmlFormat_ = options.gmlFormat ?
options.gmlFormat : new ol.format.GML3(); options.gmlFormat : new ol.format.GML3();
/** /**
* @private * @private
* @type {string} * @type {string}
*/ */
this.schemaLocation_ = goog.isDef(options.schemaLocation) ? this.schemaLocation_ = options.schemaLocation ?
options.schemaLocation : ol.format.WFS.SCHEMA_LOCATION; options.schemaLocation : ol.format.WFS.SCHEMA_LOCATION;
goog.base(this); goog.base(this);
@@ -123,7 +124,7 @@ ol.format.WFS.prototype.readFeaturesFromNode = function(node, opt_options) {
'featureNS': this.featureNS_ 'featureNS': this.featureNS_
}; };
goog.object.extend(context, this.getReadOptions(node, goog.object.extend(context, this.getReadOptions(node,
goog.isDef(opt_options) ? opt_options : {})); opt_options ? opt_options : {}));
var objectStack = [context]; var objectStack = [context];
this.gmlFormat_.FEATURE_COLLECTION_PARSERS[ol.format.GMLBase.GMLNS][ this.gmlFormat_.FEATURE_COLLECTION_PARSERS[ol.format.GMLBase.GMLNS][
'featureMember'] = 'featureMember'] =
@@ -131,7 +132,7 @@ ol.format.WFS.prototype.readFeaturesFromNode = function(node, opt_options) {
var features = ol.xml.pushParseAndPop([], var features = ol.xml.pushParseAndPop([],
this.gmlFormat_.FEATURE_COLLECTION_PARSERS, node, this.gmlFormat_.FEATURE_COLLECTION_PARSERS, node,
objectStack, this.gmlFormat_); objectStack, this.gmlFormat_);
if (!goog.isDef(features)) { if (!features) {
features = []; features = [];
} }
return features; return features;
@@ -414,14 +415,14 @@ ol.format.WFS.writeDelete_ = function(node, feature, objectStack) {
goog.asserts.assert(goog.isObject(context), 'context should be an Object'); goog.asserts.assert(goog.isObject(context), 'context should be an Object');
var featureType = context['featureType']; var featureType = context['featureType'];
var featurePrefix = context['featurePrefix']; var featurePrefix = context['featurePrefix'];
featurePrefix = goog.isDef(featurePrefix) ? featurePrefix : featurePrefix = featurePrefix ? featurePrefix :
ol.format.WFS.FEATURE_PREFIX; ol.format.WFS.FEATURE_PREFIX;
var featureNS = context['featureNS']; var featureNS = context['featureNS'];
node.setAttribute('typeName', featurePrefix + ':' + featureType); node.setAttribute('typeName', featurePrefix + ':' + featureType);
ol.xml.setAttributeNS(node, ol.format.WFS.XMLNS, 'xmlns:' + featurePrefix, ol.xml.setAttributeNS(node, ol.format.WFS.XMLNS, 'xmlns:' + featurePrefix,
featureNS); featureNS);
var fid = feature.getId(); var fid = feature.getId();
if (goog.isDef(fid)) { if (fid) {
ol.format.WFS.writeOgcFidFilter_(node, fid, objectStack); ol.format.WFS.writeOgcFidFilter_(node, fid, objectStack);
} }
}; };
@@ -438,19 +439,19 @@ ol.format.WFS.writeUpdate_ = function(node, feature, objectStack) {
goog.asserts.assert(goog.isObject(context), 'context should be an Object'); goog.asserts.assert(goog.isObject(context), 'context should be an Object');
var featureType = context['featureType']; var featureType = context['featureType'];
var featurePrefix = context['featurePrefix']; var featurePrefix = context['featurePrefix'];
featurePrefix = goog.isDef(featurePrefix) ? featurePrefix : featurePrefix = featurePrefix ? featurePrefix :
ol.format.WFS.FEATURE_PREFIX; ol.format.WFS.FEATURE_PREFIX;
var featureNS = context['featureNS']; var featureNS = context['featureNS'];
node.setAttribute('typeName', featurePrefix + ':' + featureType); node.setAttribute('typeName', featurePrefix + ':' + featureType);
ol.xml.setAttributeNS(node, ol.format.WFS.XMLNS, 'xmlns:' + featurePrefix, ol.xml.setAttributeNS(node, ol.format.WFS.XMLNS, 'xmlns:' + featurePrefix,
featureNS); featureNS);
var fid = feature.getId(); var fid = feature.getId();
if (goog.isDef(fid)) { if (fid) {
var keys = feature.getKeys(); var keys = feature.getKeys();
var values = []; var values = [];
for (var i = 0, ii = keys.length; i < ii; i++) { for (var i = 0, ii = keys.length; i < ii; i++) {
var value = feature.get(keys[i]); var value = feature.get(keys[i]);
if (goog.isDef(value)) { if (value !== undefined) {
values.push({name: keys[i], value: value}); values.push({name: keys[i], value: value});
} }
} }
@@ -495,13 +496,13 @@ ol.format.WFS.writeProperty_ = function(node, pair, objectStack) {
* @private * @private
*/ */
ol.format.WFS.writeNative_ = function(node, nativeElement, objectStack) { ol.format.WFS.writeNative_ = function(node, nativeElement, objectStack) {
if (goog.isDef(nativeElement.vendorId)) { if (nativeElement.vendorId) {
node.setAttribute('vendorId', nativeElement.vendorId); node.setAttribute('vendorId', nativeElement.vendorId);
} }
if (goog.isDef(nativeElement.safeToIgnore)) { if (nativeElement.safeToIgnore !== undefined) {
node.setAttribute('safeToIgnore', nativeElement.safeToIgnore); node.setAttribute('safeToIgnore', nativeElement.safeToIgnore);
} }
if (goog.isDef(nativeElement.value)) { if (nativeElement.value !== undefined) {
ol.format.XSD.writeStringTextNode(node, nativeElement.value); ol.format.XSD.writeStringTextNode(node, nativeElement.value);
} }
}; };
@@ -535,12 +536,12 @@ ol.format.WFS.writeQuery_ = function(node, featureType, objectStack) {
var featureNS = context['featureNS']; var featureNS = context['featureNS'];
var propertyNames = context['propertyNames']; var propertyNames = context['propertyNames'];
var srsName = context['srsName']; var srsName = context['srsName'];
var prefix = goog.isDef(featurePrefix) ? featurePrefix + ':' : ''; var prefix = featurePrefix ? featurePrefix + ':' : '';
node.setAttribute('typeName', prefix + featureType); node.setAttribute('typeName', prefix + featureType);
if (goog.isDef(srsName)) { if (srsName) {
node.setAttribute('srsName', srsName); node.setAttribute('srsName', srsName);
} }
if (goog.isDef(featureNS)) { if (featureNS) {
ol.xml.setAttributeNS(node, ol.format.WFS.XMLNS, 'xmlns:' + featurePrefix, ol.xml.setAttributeNS(node, ol.format.WFS.XMLNS, 'xmlns:' + featurePrefix,
featureNS); featureNS);
} }
@@ -551,7 +552,7 @@ ol.format.WFS.writeQuery_ = function(node, featureType, objectStack) {
ol.xml.makeSimpleNodeFactory('PropertyName'), propertyNames, ol.xml.makeSimpleNodeFactory('PropertyName'), propertyNames,
objectStack); objectStack);
var bbox = context['bbox']; var bbox = context['bbox'];
if (goog.isDef(bbox)) { if (bbox) {
var child = ol.xml.createElementNS('http://www.opengis.net/ogc', 'Filter'); var child = ol.xml.createElementNS('http://www.opengis.net/ogc', 'Filter');
ol.format.WFS.writeOgcBBOX_(child, bbox, objectStack); ol.format.WFS.writeOgcBBOX_(child, bbox, objectStack);
node.appendChild(child); node.appendChild(child);
@@ -632,23 +633,23 @@ ol.format.WFS.prototype.writeGetFeature = function(options) {
'GetFeature'); 'GetFeature');
node.setAttribute('service', 'WFS'); node.setAttribute('service', 'WFS');
node.setAttribute('version', '1.1.0'); node.setAttribute('version', '1.1.0');
if (goog.isDef(options)) { if (options) {
if (goog.isDef(options.handle)) { if (options.handle) {
node.setAttribute('handle', options.handle); node.setAttribute('handle', options.handle);
} }
if (goog.isDef(options.outputFormat)) { if (options.outputFormat) {
node.setAttribute('outputFormat', options.outputFormat); node.setAttribute('outputFormat', options.outputFormat);
} }
if (goog.isDef(options.maxFeatures)) { if (options.maxFeatures !== undefined) {
node.setAttribute('maxFeatures', options.maxFeatures); node.setAttribute('maxFeatures', options.maxFeatures);
} }
if (goog.isDef(options.resultType)) { if (options.resultType) {
node.setAttribute('resultType', options.resultType); node.setAttribute('resultType', options.resultType);
} }
if (goog.isDef(options.startIndex)) { if (options.startIndex !== undefined) {
node.setAttribute('startIndex', options.startIndex); node.setAttribute('startIndex', options.startIndex);
} }
if (goog.isDef(options.count)) { if (options.count !== undefined) {
node.setAttribute('count', options.count); node.setAttribute('count', options.count);
} }
} }
@@ -657,13 +658,11 @@ ol.format.WFS.prototype.writeGetFeature = function(options) {
var context = { var context = {
node: node, node: node,
srsName: options.srsName, srsName: options.srsName,
featureNS: goog.isDef(options.featureNS) ? featureNS: options.featureNS ? options.featureNS : this.featureNS_,
options.featureNS : this.featureNS_,
featurePrefix: options.featurePrefix, featurePrefix: options.featurePrefix,
geometryName: options.geometryName, geometryName: options.geometryName,
bbox: options.bbox, bbox: options.bbox,
propertyNames: goog.isDef(options.propertyNames) ? propertyNames: options.propertyNames ? options.propertyNames : []
options.propertyNames : []
}; };
goog.asserts.assert(goog.isArray(options.featureTypes), goog.asserts.assert(goog.isArray(options.featureTypes),
'options.featureTypes should be an array'); 'options.featureTypes should be an array');
@@ -690,9 +689,9 @@ ol.format.WFS.prototype.writeTransaction = function(inserts, updates, deletes,
node.setAttribute('service', 'WFS'); node.setAttribute('service', 'WFS');
node.setAttribute('version', '1.1.0'); node.setAttribute('version', '1.1.0');
var baseObj, obj; var baseObj, obj;
if (goog.isDef(options)) { if (options) {
baseObj = goog.isDef(options.gmlOptions) ? options.gmlOptions : {}; baseObj = options.gmlOptions ? options.gmlOptions : {};
if (goog.isDef(options.handle)) { if (options.handle) {
node.setAttribute('handle', options.handle); node.setAttribute('handle', options.handle);
} }
} }
@@ -723,7 +722,7 @@ ol.format.WFS.prototype.writeTransaction = function(inserts, updates, deletes,
ol.xml.makeSimpleNodeFactory('Delete'), deletes, ol.xml.makeSimpleNodeFactory('Delete'), deletes,
objectStack); objectStack);
} }
if (goog.isDef(options.nativeElements)) { if (options.nativeElements) {
ol.xml.pushSerializeAndPop({node: node, featureNS: options.featureNS, ol.xml.pushSerializeAndPop({node: node, featureNS: options.featureNS,
featureType: options.featureType, featurePrefix: options.featurePrefix}, featureType: options.featureType, featurePrefix: options.featurePrefix},
ol.format.WFS.TRANSACTION_SERIALIZERS_, ol.format.WFS.TRANSACTION_SERIALIZERS_,
+9 -9
View File
@@ -1,6 +1,7 @@
goog.provide('ol.format.WKT'); goog.provide('ol.format.WKT');
goog.require('goog.asserts'); goog.require('goog.asserts');
goog.require('ol');
goog.require('ol.Feature'); goog.require('ol.Feature');
goog.require('ol.format.Feature'); goog.require('ol.format.Feature');
goog.require('ol.format.TextFeature'); goog.require('ol.format.TextFeature');
@@ -28,7 +29,7 @@ goog.require('ol.geom.Polygon');
*/ */
ol.format.WKT = function(opt_options) { ol.format.WKT = function(opt_options) {
var options = goog.isDef(opt_options) ? opt_options : {}; var options = opt_options ? opt_options : {};
goog.base(this); goog.base(this);
@@ -37,7 +38,7 @@ ol.format.WKT = function(opt_options) {
* @type {boolean} * @type {boolean}
* @private * @private
*/ */
this.splitCollection_ = goog.isDef(options.splitCollection) ? this.splitCollection_ = options.splitCollection !== undefined ?
options.splitCollection : false; options.splitCollection : false;
}; };
@@ -167,8 +168,7 @@ ol.format.WKT.encodeMultiPolygonGeometry_ = function(geom) {
ol.format.WKT.encode_ = function(geom) { ol.format.WKT.encode_ = function(geom) {
var type = geom.getType(); var type = geom.getType();
var geometryEncoder = ol.format.WKT.GeometryEncoder_[type]; var geometryEncoder = ol.format.WKT.GeometryEncoder_[type];
goog.asserts.assert(goog.isDef(geometryEncoder), goog.asserts.assert(geometryEncoder, 'geometryEncoder should be defined');
'geometryEncoder should be defined');
var enc = geometryEncoder(geom); var enc = geometryEncoder(geom);
type = type.toUpperCase(); type = type.toUpperCase();
if (enc.length === 0) { if (enc.length === 0) {
@@ -225,7 +225,7 @@ ol.format.WKT.prototype.readFeature;
*/ */
ol.format.WKT.prototype.readFeatureFromText = function(text, opt_options) { ol.format.WKT.prototype.readFeatureFromText = function(text, opt_options) {
var geom = this.readGeometryFromText(text, opt_options); var geom = this.readGeometryFromText(text, opt_options);
if (goog.isDef(geom)) { if (geom) {
var feature = new ol.Feature(); var feature = new ol.Feature();
feature.setGeometry(geom); feature.setGeometry(geom);
return feature; return feature;
@@ -286,7 +286,7 @@ ol.format.WKT.prototype.readGeometry;
*/ */
ol.format.WKT.prototype.readGeometryFromText = function(text, opt_options) { ol.format.WKT.prototype.readGeometryFromText = function(text, opt_options) {
var geometry = this.parse_(text); var geometry = this.parse_(text);
if (goog.isDef(geometry)) { if (geometry) {
return /** @type {ol.geom.Geometry} */ ( return /** @type {ol.geom.Geometry} */ (
ol.format.Feature.transformWithOptions(geometry, false, opt_options)); ol.format.Feature.transformWithOptions(geometry, false, opt_options));
} else { } else {
@@ -312,7 +312,7 @@ ol.format.WKT.prototype.writeFeature;
*/ */
ol.format.WKT.prototype.writeFeatureText = function(feature, opt_options) { ol.format.WKT.prototype.writeFeatureText = function(feature, opt_options) {
var geometry = feature.getGeometry(); var geometry = feature.getGeometry();
if (goog.isDef(geometry)) { if (geometry) {
return this.writeGeometryText(geometry, opt_options); return this.writeGeometryText(geometry, opt_options);
} }
return ''; return '';
@@ -427,7 +427,7 @@ ol.format.WKT.Lexer.prototype.isAlpha_ = function(c) {
* @private * @private
*/ */
ol.format.WKT.Lexer.prototype.isNumeric_ = function(c, opt_decimal) { ol.format.WKT.Lexer.prototype.isNumeric_ = function(c, opt_decimal) {
var decimal = goog.isDef(opt_decimal) ? opt_decimal : false; var decimal = opt_decimal !== undefined ? opt_decimal : false;
return c >= '0' && c <= '9' || c == '.' && !decimal; return c >= '0' && c <= '9' || c == '.' && !decimal;
}; };
@@ -603,7 +603,7 @@ ol.format.WKT.Parser.prototype.parseGeometry_ = function() {
} else { } else {
var parser = ol.format.WKT.Parser.GeometryParser_[geomType]; var parser = ol.format.WKT.Parser.GeometryParser_[geomType];
var ctor = ol.format.WKT.Parser.GeometryConstructor_[geomType]; var ctor = ol.format.WKT.Parser.GeometryConstructor_[geomType];
if (!goog.isDef(parser) || !goog.isDef(ctor)) { if (!parser || !ctor) {
throw new Error('Invalid geometry type: ' + geomType); throw new Error('Invalid geometry type: ' + geomType);
} }
var coordinates = parser.call(this); var coordinates = parser.call(this);
+21 -22
View File
@@ -5,6 +5,7 @@ goog.require('goog.asserts');
goog.require('goog.dom.NodeType'); goog.require('goog.dom.NodeType');
goog.require('goog.object'); goog.require('goog.object');
goog.require('goog.string'); goog.require('goog.string');
goog.require('ol');
goog.require('ol.format.XLink'); goog.require('ol.format.XLink');
goog.require('ol.format.XML'); goog.require('ol.format.XML');
goog.require('ol.format.XSD'); goog.require('ol.format.XSD');
@@ -74,7 +75,7 @@ ol.format.WMSCapabilities.prototype.readFromNode = function(node) {
var wmsCapabilityObject = ol.xml.pushParseAndPop({ var wmsCapabilityObject = ol.xml.pushParseAndPop({
'version': this.version 'version': this.version
}, ol.format.WMSCapabilities.PARSERS_, node, []); }, ol.format.WMSCapabilities.PARSERS_, node, []);
return goog.isDef(wmsCapabilityObject) ? wmsCapabilityObject : null; return wmsCapabilityObject ? wmsCapabilityObject : null;
}; };
@@ -142,7 +143,7 @@ ol.format.WMSCapabilities.readEXGeographicBoundingBox_ =
{}, {},
ol.format.WMSCapabilities.EX_GEOGRAPHIC_BOUNDING_BOX_PARSERS_, ol.format.WMSCapabilities.EX_GEOGRAPHIC_BOUNDING_BOX_PARSERS_,
node, objectStack); node, objectStack);
if (!goog.isDef(geographicBoundingBox)) { if (!geographicBoundingBox) {
return undefined; return undefined;
} }
var westBoundLongitude = /** @type {number|undefined} */ var westBoundLongitude = /** @type {number|undefined} */
@@ -153,8 +154,8 @@ ol.format.WMSCapabilities.readEXGeographicBoundingBox_ =
(geographicBoundingBox['eastBoundLongitude']); (geographicBoundingBox['eastBoundLongitude']);
var northBoundLatitude = /** @type {number|undefined} */ var northBoundLatitude = /** @type {number|undefined} */
(geographicBoundingBox['northBoundLatitude']); (geographicBoundingBox['northBoundLatitude']);
if (!goog.isDef(westBoundLongitude) || !goog.isDef(southBoundLatitude) || if (westBoundLongitude === undefined || southBoundLatitude === undefined ||
!goog.isDef(eastBoundLongitude) || !goog.isDef(northBoundLatitude)) { eastBoundLongitude === undefined || northBoundLatitude === undefined) {
return undefined; return undefined;
} }
return /** @type {ol.Extent} */ ([ return /** @type {ol.Extent} */ ([
@@ -297,46 +298,46 @@ ol.format.WMSCapabilities.readLayer_ = function(node, objectStack) {
var layerObject = /** @type {Object.<string,*>} */ (ol.xml.pushParseAndPop( var layerObject = /** @type {Object.<string,*>} */ (ol.xml.pushParseAndPop(
{}, ol.format.WMSCapabilities.LAYER_PARSERS_, node, objectStack)); {}, ol.format.WMSCapabilities.LAYER_PARSERS_, node, objectStack));
if (!goog.isDef(layerObject)) { if (!layerObject) {
return undefined; return undefined;
} }
var queryable = var queryable =
ol.format.XSD.readBooleanString(node.getAttribute('queryable')); ol.format.XSD.readBooleanString(node.getAttribute('queryable'));
if (!goog.isDef(queryable)) { if (queryable === undefined) {
queryable = parentLayerObject['queryable']; queryable = parentLayerObject['queryable'];
} }
layerObject['queryable'] = goog.isDef(queryable) ? queryable : false; layerObject['queryable'] = queryable !== undefined ? queryable : false;
var cascaded = ol.format.XSD.readNonNegativeIntegerString( var cascaded = ol.format.XSD.readNonNegativeIntegerString(
node.getAttribute('cascaded')); node.getAttribute('cascaded'));
if (!goog.isDef(cascaded)) { if (cascaded === undefined) {
cascaded = parentLayerObject['cascaded']; cascaded = parentLayerObject['cascaded'];
} }
layerObject['cascaded'] = cascaded; layerObject['cascaded'] = cascaded;
var opaque = ol.format.XSD.readBooleanString(node.getAttribute('opaque')); var opaque = ol.format.XSD.readBooleanString(node.getAttribute('opaque'));
if (!goog.isDef(opaque)) { if (opaque === undefined) {
opaque = parentLayerObject['opaque']; opaque = parentLayerObject['opaque'];
} }
layerObject['opaque'] = goog.isDef(opaque) ? opaque : false; layerObject['opaque'] = opaque !== undefined ? opaque : false;
var noSubsets = var noSubsets =
ol.format.XSD.readBooleanString(node.getAttribute('noSubsets')); ol.format.XSD.readBooleanString(node.getAttribute('noSubsets'));
if (!goog.isDef(noSubsets)) { if (noSubsets === undefined) {
noSubsets = parentLayerObject['noSubsets']; noSubsets = parentLayerObject['noSubsets'];
} }
layerObject['noSubsets'] = goog.isDef(noSubsets) ? noSubsets : false; layerObject['noSubsets'] = noSubsets !== undefined ? noSubsets : false;
var fixedWidth = var fixedWidth =
ol.format.XSD.readDecimalString(node.getAttribute('fixedWidth')); ol.format.XSD.readDecimalString(node.getAttribute('fixedWidth'));
if (!goog.isDef(fixedWidth)) { if (!fixedWidth) {
fixedWidth = parentLayerObject['fixedWidth']; fixedWidth = parentLayerObject['fixedWidth'];
} }
layerObject['fixedWidth'] = fixedWidth; layerObject['fixedWidth'] = fixedWidth;
var fixedHeight = var fixedHeight =
ol.format.XSD.readDecimalString(node.getAttribute('fixedHeight')); ol.format.XSD.readDecimalString(node.getAttribute('fixedHeight'));
if (!goog.isDef(fixedHeight)) { if (!fixedHeight) {
fixedHeight = parentLayerObject['fixedHeight']; fixedHeight = parentLayerObject['fixedHeight'];
} }
layerObject['fixedHeight'] = fixedHeight; layerObject['fixedHeight'] = fixedHeight;
@@ -344,10 +345,9 @@ ol.format.WMSCapabilities.readLayer_ = function(node, objectStack) {
// See 7.2.4.8 // See 7.2.4.8
var addKeys = ['Style', 'CRS', 'AuthorityURL']; var addKeys = ['Style', 'CRS', 'AuthorityURL'];
goog.array.forEach(addKeys, function(key) { goog.array.forEach(addKeys, function(key) {
var parentValue = parentLayerObject[key]; if (key in parentLayerObject) {
if (goog.isDef(parentValue)) {
var childValue = goog.object.setIfUndefined(layerObject, key, []); var childValue = goog.object.setIfUndefined(layerObject, key, []);
childValue = childValue.concat(parentValue); childValue = childValue.concat(parentLayerObject[key]);
layerObject[key] = childValue; layerObject[key] = childValue;
} }
}); });
@@ -355,8 +355,7 @@ ol.format.WMSCapabilities.readLayer_ = function(node, objectStack) {
var replaceKeys = ['EX_GeographicBoundingBox', 'BoundingBox', 'Dimension', var replaceKeys = ['EX_GeographicBoundingBox', 'BoundingBox', 'Dimension',
'Attribution', 'MinScaleDenominator', 'MaxScaleDenominator']; 'Attribution', 'MinScaleDenominator', 'MaxScaleDenominator'];
goog.array.forEach(replaceKeys, function(key) { goog.array.forEach(replaceKeys, function(key) {
var childValue = layerObject[key]; if (!(key in layerObject)) {
if (!goog.isDef(childValue)) {
var parentValue = parentLayerObject[key]; var parentValue = parentLayerObject[key];
layerObject[key] = parentValue; layerObject[key] = parentValue;
} }
@@ -482,7 +481,7 @@ ol.format.WMSCapabilities.readSizedFormatOnlineresource_ =
'node.nodeType should be ELEMENT'); 'node.nodeType should be ELEMENT');
var formatOnlineresource = var formatOnlineresource =
ol.format.WMSCapabilities.readFormatOnlineresource_(node, objectStack); ol.format.WMSCapabilities.readFormatOnlineresource_(node, objectStack);
if (goog.isDef(formatOnlineresource)) { if (formatOnlineresource) {
var size = [ var size = [
ol.format.XSD.readNonNegativeIntegerString(node.getAttribute('width')), ol.format.XSD.readNonNegativeIntegerString(node.getAttribute('width')),
ol.format.XSD.readNonNegativeIntegerString(node.getAttribute('height')) ol.format.XSD.readNonNegativeIntegerString(node.getAttribute('height'))
@@ -507,7 +506,7 @@ ol.format.WMSCapabilities.readAuthorityURL_ = function(node, objectStack) {
'localName should be AuthorityURL'); 'localName should be AuthorityURL');
var authorityObject = var authorityObject =
ol.format.WMSCapabilities.readFormatOnlineresource_(node, objectStack); ol.format.WMSCapabilities.readFormatOnlineresource_(node, objectStack);
if (goog.isDef(authorityObject)) { if (authorityObject) {
authorityObject['name'] = node.getAttribute('name'); authorityObject['name'] = node.getAttribute('name');
return authorityObject; return authorityObject;
} }
@@ -528,7 +527,7 @@ ol.format.WMSCapabilities.readMetadataURL_ = function(node, objectStack) {
'localName should be MetadataURL'); 'localName should be MetadataURL');
var metadataObject = var metadataObject =
ol.format.WMSCapabilities.readFormatOnlineresource_(node, objectStack); ol.format.WMSCapabilities.readFormatOnlineresource_(node, objectStack);
if (goog.isDef(metadataObject)) { if (metadataObject) {
metadataObject['type'] = node.getAttribute('type'); metadataObject['type'] = node.getAttribute('type');
return metadataObject; return metadataObject;
} }
+3 -3
View File
@@ -102,7 +102,7 @@ ol.format.WMSGetFeatureInfo.prototype.readFeatures_ =
layer.namespaceURI = this.featureNS_; layer.namespaceURI = this.featureNS_;
var layerFeatures = ol.xml.pushParseAndPop( var layerFeatures = ol.xml.pushParseAndPop(
[], parsersNS, layer, objectStack, this.gmlFormat_); [], parsersNS, layer, objectStack, this.gmlFormat_);
if (goog.isDef(layerFeatures)) { if (layerFeatures) {
goog.array.extend(features, layerFeatures); goog.array.extend(features, layerFeatures);
} }
}, this); }, this);
@@ -111,7 +111,7 @@ ol.format.WMSGetFeatureInfo.prototype.readFeatures_ =
var gmlFeatures = ol.xml.pushParseAndPop([], var gmlFeatures = ol.xml.pushParseAndPop([],
this.gmlFormat_.FEATURE_COLLECTION_PARSERS, node, this.gmlFormat_.FEATURE_COLLECTION_PARSERS, node,
[{}], this.gmlFormat_); [{}], this.gmlFormat_);
if (goog.isDef(gmlFeatures)) { if (gmlFeatures) {
features = gmlFeatures; features = gmlFeatures;
} }
} }
@@ -140,7 +140,7 @@ ol.format.WMSGetFeatureInfo.prototype.readFeaturesFromNode =
'featureType': this.featureType, 'featureType': this.featureType,
'featureNS': this.featureNS 'featureNS': this.featureNS
}; };
if (goog.isDef(opt_options)) { if (opt_options) {
goog.object.extend(options, this.getReadOptions(node, opt_options)); goog.object.extend(options, this.getReadOptions(node, opt_options));
} }
return this.readFeatures_(node, [options]); return this.readFeatures_(node, [options]);
+7 -7
View File
@@ -71,13 +71,13 @@ ol.format.WMTSCapabilities.prototype.readFromNode = function(node) {
this.version = goog.string.trim(node.getAttribute('version')); this.version = goog.string.trim(node.getAttribute('version'));
goog.asserts.assertString(this.version, 'this.version should be a string'); goog.asserts.assertString(this.version, 'this.version should be a string');
var WMTSCapabilityObject = this.owsParser_.readFromNode(node); var WMTSCapabilityObject = this.owsParser_.readFromNode(node);
if (!goog.isDef(WMTSCapabilityObject)) { if (!WMTSCapabilityObject) {
return null; return null;
} }
WMTSCapabilityObject['version'] = this.version; WMTSCapabilityObject['version'] = this.version;
WMTSCapabilityObject = ol.xml.pushParseAndPop(WMTSCapabilityObject, WMTSCapabilityObject = ol.xml.pushParseAndPop(WMTSCapabilityObject,
ol.format.WMTSCapabilities.PARSERS_, node, []); ol.format.WMTSCapabilities.PARSERS_, node, []);
return goog.isDef(WMTSCapabilityObject) ? WMTSCapabilityObject : null; return WMTSCapabilityObject ? WMTSCapabilityObject : null;
}; };
@@ -134,7 +134,7 @@ ol.format.WMTSCapabilities.readTileMatrixSet_ = function(node, objectStack) {
ol.format.WMTSCapabilities.readStyle_ = function(node, objectStack) { ol.format.WMTSCapabilities.readStyle_ = function(node, objectStack) {
var style = ol.xml.pushParseAndPop({}, var style = ol.xml.pushParseAndPop({},
ol.format.WMTSCapabilities.STYLE_PARSERS_, node, objectStack); ol.format.WMTSCapabilities.STYLE_PARSERS_, node, objectStack);
if (!goog.isDef(style)) { if (!style) {
return undefined; return undefined;
} }
var isDefault = node.getAttribute('isDefault') === 'true'; var isDefault = node.getAttribute('isDefault') === 'true';
@@ -168,13 +168,13 @@ ol.format.WMTSCapabilities.readResourceUrl_ = function(node, objectStack) {
var template = node.getAttribute('template'); var template = node.getAttribute('template');
var resourceType = node.getAttribute('resourceType'); var resourceType = node.getAttribute('resourceType');
var resource = {}; var resource = {};
if (goog.isDef(format)) { if (format) {
resource['format'] = format; resource['format'] = format;
} }
if (goog.isDef(template)) { if (template) {
resource['template'] = template; resource['template'] = template;
} }
if (goog.isDef(resourceType)) { if (resourceType) {
resource['resourceType'] = resourceType; resource['resourceType'] = resourceType;
} }
return resource; return resource;
@@ -219,7 +219,7 @@ ol.format.WMTSCapabilities.readLegendUrl_ = function(node, objectStack) {
*/ */
ol.format.WMTSCapabilities.readCoordinates_ = function(node, objectStack) { ol.format.WMTSCapabilities.readCoordinates_ = function(node, objectStack) {
var coordinates = ol.format.XSD.readString(node).split(' '); var coordinates = ol.format.XSD.readString(node).split(' ');
if (!goog.isDef(coordinates) || coordinates.length != 2) { if (!coordinates || coordinates.length != 2) {
return undefined; return undefined;
} }
var x = +coordinates[0]; var x = +coordinates[0];
+3 -2
View File
@@ -2,6 +2,7 @@ goog.provide('ol.format.XSD');
goog.require('goog.asserts'); goog.require('goog.asserts');
goog.require('goog.string'); goog.require('goog.string');
goog.require('ol');
goog.require('ol.xml'); goog.require('ol.xml');
@@ -29,7 +30,7 @@ ol.format.XSD.readBoolean = function(node) {
ol.format.XSD.readBooleanString = function(string) { ol.format.XSD.readBooleanString = function(string) {
var m = /^\s*(true|1)|(false|0)\s*$/.exec(string); var m = /^\s*(true|1)|(false|0)\s*$/.exec(string);
if (m) { if (m) {
return goog.isDef(m[1]) || false; return m[1] !== undefined || false;
} else { } else {
return undefined; return undefined;
} }
@@ -56,7 +57,7 @@ ol.format.XSD.readDateTime = function(node) {
if (m[7] != 'Z') { if (m[7] != 'Z') {
var sign = m[8] == '-' ? -1 : 1; var sign = m[8] == '-' ? -1 : 1;
dateTime += sign * 60 * parseInt(m[9], 10); dateTime += sign * 60 * parseInt(m[9], 10);
if (goog.isDef(m[10])) { if (m[10] !== undefined) {
dateTime += sign * 60 * 60 * parseInt(m[10], 10); dateTime += sign * 60 * 60 * parseInt(m[10], 10);
} }
} }
+6 -6
View File
@@ -62,7 +62,7 @@ ol.Geolocation = function(opt_options) {
goog.base(this); goog.base(this);
var options = goog.isDef(opt_options) ? opt_options : {}; var options = opt_options || {};
/** /**
* The unprojected (EPSG:4326) device position. * The unprojected (EPSG:4326) device position.
@@ -90,14 +90,14 @@ ol.Geolocation = function(opt_options) {
this, ol.Object.getChangeEventType(ol.GeolocationProperty.TRACKING), this, ol.Object.getChangeEventType(ol.GeolocationProperty.TRACKING),
this.handleTrackingChanged_, false, this); this.handleTrackingChanged_, false, this);
if (goog.isDef(options.projection)) { if (options.projection !== undefined) {
this.setProjection(ol.proj.get(options.projection)); this.setProjection(ol.proj.get(options.projection));
} }
if (goog.isDef(options.trackingOptions)) { if (options.trackingOptions !== undefined) {
this.setTrackingOptions(options.trackingOptions); this.setTrackingOptions(options.trackingOptions);
} }
this.setTracking(goog.isDef(options.tracking) ? options.tracking : false); this.setTracking(options.tracking !== undefined ? options.tracking : false);
}; };
goog.inherits(ol.Geolocation, ol.Object); goog.inherits(ol.Geolocation, ol.Object);
@@ -134,12 +134,12 @@ ol.Geolocation.prototype.handleProjectionChanged_ = function() {
ol.Geolocation.prototype.handleTrackingChanged_ = function() { ol.Geolocation.prototype.handleTrackingChanged_ = function() {
if (ol.has.GEOLOCATION) { if (ol.has.GEOLOCATION) {
var tracking = this.getTracking(); var tracking = this.getTracking();
if (tracking && !goog.isDef(this.watchId_)) { if (tracking && this.watchId_ === undefined) {
this.watchId_ = goog.global.navigator.geolocation.watchPosition( this.watchId_ = goog.global.navigator.geolocation.watchPosition(
goog.bind(this.positionChange_, this), goog.bind(this.positionChange_, this),
goog.bind(this.positionError_, this), goog.bind(this.positionError_, this),
this.getTrackingOptions()); this.getTrackingOptions());
} else if (!tracking && goog.isDef(this.watchId_)) { } else if (!tracking && this.watchId_ !== undefined) {
goog.global.navigator.geolocation.clearWatch(this.watchId_); goog.global.navigator.geolocation.clearWatch(this.watchId_);
this.watchId_ = undefined; this.watchId_ = undefined;
} }
+1 -1
View File
@@ -23,7 +23,7 @@ goog.require('ol.proj');
*/ */
ol.geom.Circle = function(center, opt_radius, opt_layout) { ol.geom.Circle = function(center, opt_radius, opt_layout) {
goog.base(this); goog.base(this);
var radius = goog.isDef(opt_radius) ? opt_radius : 0; var radius = opt_radius ? opt_radius : 0;
this.setCenterAndRadius(center, radius, opt_layout); this.setCenterAndRadius(center, radius, opt_layout);
}; };
goog.inherits(ol.geom.Circle, ol.geom.SimpleGeometry); goog.inherits(ol.geom.Circle, ol.geom.SimpleGeometry);
+3 -3
View File
@@ -154,7 +154,7 @@ ol.geom.flat.closest.getClosestPoint = function(flatCoordinates, offset, end,
} }
} }
goog.asserts.assert(maxDelta > 0, 'maxDelta should be larger than 0'); goog.asserts.assert(maxDelta > 0, 'maxDelta should be larger than 0');
var tmpPoint = goog.isDef(opt_tmpPoint) ? opt_tmpPoint : [NaN, NaN]; var tmpPoint = opt_tmpPoint ? opt_tmpPoint : [NaN, NaN];
var index = offset + stride; var index = offset + stride;
while (index < end) { while (index < end) {
ol.geom.flat.closest.point( ol.geom.flat.closest.point(
@@ -217,7 +217,7 @@ ol.geom.flat.closest.getClosestPoint = function(flatCoordinates, offset, end,
ol.geom.flat.closest.getsClosestPoint = function(flatCoordinates, offset, ends, ol.geom.flat.closest.getsClosestPoint = function(flatCoordinates, offset, ends,
stride, maxDelta, isRing, x, y, closestPoint, minSquaredDistance, stride, maxDelta, isRing, x, y, closestPoint, minSquaredDistance,
opt_tmpPoint) { opt_tmpPoint) {
var tmpPoint = goog.isDef(opt_tmpPoint) ? opt_tmpPoint : [NaN, NaN]; var tmpPoint = opt_tmpPoint ? opt_tmpPoint : [NaN, NaN];
var i, ii; var i, ii;
for (i = 0, ii = ends.length; i < ii; ++i) { for (i = 0, ii = ends.length; i < ii; ++i) {
var end = ends[i]; var end = ends[i];
@@ -247,7 +247,7 @@ ol.geom.flat.closest.getsClosestPoint = function(flatCoordinates, offset, ends,
ol.geom.flat.closest.getssClosestPoint = function(flatCoordinates, offset, ol.geom.flat.closest.getssClosestPoint = function(flatCoordinates, offset,
endss, stride, maxDelta, isRing, x, y, closestPoint, minSquaredDistance, endss, stride, maxDelta, isRing, x, y, closestPoint, minSquaredDistance,
opt_tmpPoint) { opt_tmpPoint) {
var tmpPoint = goog.isDef(opt_tmpPoint) ? opt_tmpPoint : [NaN, NaN]; var tmpPoint = opt_tmpPoint ? opt_tmpPoint : [NaN, NaN];
var i, ii; var i, ii;
for (i = 0, ii = endss.length; i < ii; ++i) { for (i = 0, ii = endss.length; i < ii; ++i) {
var ends = endss[i]; var ends = endss[i];
+2 -2
View File
@@ -55,7 +55,7 @@ ol.geom.flat.deflate.coordinates =
*/ */
ol.geom.flat.deflate.coordinatess = ol.geom.flat.deflate.coordinatess =
function(flatCoordinates, offset, coordinatess, stride, opt_ends) { function(flatCoordinates, offset, coordinatess, stride, opt_ends) {
var ends = goog.isDef(opt_ends) ? opt_ends : []; var ends = opt_ends ? opt_ends : [];
var i = 0; var i = 0;
var j, jj; var j, jj;
for (j = 0, jj = coordinatess.length; j < jj; ++j) { for (j = 0, jj = coordinatess.length; j < jj; ++j) {
@@ -79,7 +79,7 @@ ol.geom.flat.deflate.coordinatess =
*/ */
ol.geom.flat.deflate.coordinatesss = ol.geom.flat.deflate.coordinatesss =
function(flatCoordinates, offset, coordinatesss, stride, opt_endss) { function(flatCoordinates, offset, coordinatesss, stride, opt_endss) {
var endss = goog.isDef(opt_endss) ? opt_endss : []; var endss = opt_endss ? opt_endss : [];
var i = 0; var i = 0;
var j, jj; var j, jj;
for (j = 0, jj = coordinatesss.length; j < jj; ++j) { for (j = 0, jj = coordinatesss.length; j < jj; ++j) {
+3 -3
View File
@@ -15,11 +15,11 @@ goog.require('goog.asserts');
ol.geom.flat.flip.flipXY = ol.geom.flat.flip.flipXY =
function(flatCoordinates, offset, end, stride, opt_dest, opt_destOffset) { function(flatCoordinates, offset, end, stride, opt_dest, opt_destOffset) {
var dest, destOffset; var dest, destOffset;
if (goog.isDef(opt_dest)) { if (opt_dest !== undefined) {
dest = opt_dest; dest = opt_dest;
destOffset = goog.isDef(opt_destOffset) ? opt_destOffset : 0; destOffset = opt_destOffset !== undefined ? opt_destOffset : 0;
} else { } else {
goog.asserts.assert(!goog.isDef(opt_destOffset), goog.asserts.assert(opt_destOffset === undefined,
'opt_destOffSet should be defined'); 'opt_destOffSet should be defined');
dest = []; dest = [];
destOffset = 0; destOffset = 0;
+3 -3
View File
@@ -11,7 +11,7 @@ goog.provide('ol.geom.flat.inflate');
*/ */
ol.geom.flat.inflate.coordinates = ol.geom.flat.inflate.coordinates =
function(flatCoordinates, offset, end, stride, opt_coordinates) { function(flatCoordinates, offset, end, stride, opt_coordinates) {
var coordinates = goog.isDef(opt_coordinates) ? opt_coordinates : []; var coordinates = opt_coordinates !== undefined ? opt_coordinates : [];
var i = 0; var i = 0;
var j; var j;
for (j = offset; j < end; j += stride) { for (j = offset; j < end; j += stride) {
@@ -32,7 +32,7 @@ ol.geom.flat.inflate.coordinates =
*/ */
ol.geom.flat.inflate.coordinatess = ol.geom.flat.inflate.coordinatess =
function(flatCoordinates, offset, ends, stride, opt_coordinatess) { function(flatCoordinates, offset, ends, stride, opt_coordinatess) {
var coordinatess = goog.isDef(opt_coordinatess) ? opt_coordinatess : []; var coordinatess = opt_coordinatess !== undefined ? opt_coordinatess : [];
var i = 0; var i = 0;
var j, jj; var j, jj;
for (j = 0, jj = ends.length; j < jj; ++j) { for (j = 0, jj = ends.length; j < jj; ++j) {
@@ -57,7 +57,7 @@ ol.geom.flat.inflate.coordinatess =
*/ */
ol.geom.flat.inflate.coordinatesss = ol.geom.flat.inflate.coordinatesss =
function(flatCoordinates, offset, endss, stride, opt_coordinatesss) { function(flatCoordinates, offset, endss, stride, opt_coordinatesss) {
var coordinatesss = goog.isDef(opt_coordinatesss) ? opt_coordinatesss : []; var coordinatesss = opt_coordinatesss !== undefined ? opt_coordinatesss : [];
var i = 0; var i = 0;
var j, jj; var j, jj;
for (j = 0, jj = endss.length; j < jj; ++j) { for (j = 0, jj = endss.length; j < jj; ++j) {
+1 -1
View File
@@ -60,7 +60,7 @@ ol.geom.flat.interiorpoint.linearRings = function(flatCoordinates, offset,
// ring. Use the center of the the linear ring's extent. // ring. Use the center of the the linear ring's extent.
pointX = flatCenters[flatCentersOffset]; pointX = flatCenters[flatCentersOffset];
} }
if (goog.isDef(opt_dest)) { if (opt_dest) {
opt_dest.push(pointX, y); opt_dest.push(pointX, y);
return opt_dest; return opt_dest;
} else { } else {
+3 -2
View File
@@ -1,5 +1,6 @@
goog.provide('ol.geom.flat.orient'); goog.provide('ol.geom.flat.orient');
goog.require('ol');
goog.require('ol.geom.flat.reverse'); goog.require('ol.geom.flat.reverse');
@@ -43,7 +44,7 @@ ol.geom.flat.orient.linearRingIsClockwise =
*/ */
ol.geom.flat.orient.linearRingsAreOriented = ol.geom.flat.orient.linearRingsAreOriented =
function(flatCoordinates, offset, ends, stride, opt_right) { function(flatCoordinates, offset, ends, stride, opt_right) {
var right = goog.isDef(opt_right) ? opt_right : false; var right = opt_right !== undefined ? opt_right : false;
var i, ii; var i, ii;
for (i = 0, ii = ends.length; i < ii; ++i) { for (i = 0, ii = ends.length; i < ii; ++i) {
var end = ends[i]; var end = ends[i];
@@ -105,7 +106,7 @@ ol.geom.flat.orient.linearRingssAreOriented =
*/ */
ol.geom.flat.orient.orientLinearRings = ol.geom.flat.orient.orientLinearRings =
function(flatCoordinates, offset, ends, stride, opt_right) { function(flatCoordinates, offset, ends, stride, opt_right) {
var right = goog.isDef(opt_right) ? opt_right : false; var right = opt_right !== undefined ? opt_right : false;
var i, ii; var i, ii;
for (i = 0, ii = ends.length; i < ii; ++i) { for (i = 0, ii = ends.length; i < ii; ++i) {
var end = ends[i]; var end = ends[i];
+1 -1
View File
@@ -42,7 +42,7 @@ goog.require('ol.math');
*/ */
ol.geom.flat.simplify.lineString = function(flatCoordinates, offset, end, ol.geom.flat.simplify.lineString = function(flatCoordinates, offset, end,
stride, squaredTolerance, highQuality, opt_simplifiedFlatCoordinates) { stride, squaredTolerance, highQuality, opt_simplifiedFlatCoordinates) {
var simplifiedFlatCoordinates = goog.isDef(opt_simplifiedFlatCoordinates) ? var simplifiedFlatCoordinates = opt_simplifiedFlatCoordinates !== undefined ?
opt_simplifiedFlatCoordinates : []; opt_simplifiedFlatCoordinates : [];
if (!highQuality) { if (!highQuality) {
end = ol.geom.flat.simplify.radialDistance(flatCoordinates, offset, end, end = ol.geom.flat.simplify.radialDistance(flatCoordinates, offset, end,
+4 -4
View File
@@ -20,7 +20,7 @@ ol.geom.flat.transform.transform2D =
var m11 = goog.vec.Mat4.getElement(transform, 1, 1); var m11 = goog.vec.Mat4.getElement(transform, 1, 1);
var m03 = goog.vec.Mat4.getElement(transform, 0, 3); var m03 = goog.vec.Mat4.getElement(transform, 0, 3);
var m13 = goog.vec.Mat4.getElement(transform, 1, 3); var m13 = goog.vec.Mat4.getElement(transform, 1, 3);
var dest = goog.isDef(opt_dest) ? opt_dest : []; var dest = opt_dest ? opt_dest : [];
var i = 0; var i = 0;
var j; var j;
for (j = offset; j < end; j += stride) { for (j = offset; j < end; j += stride) {
@@ -29,7 +29,7 @@ ol.geom.flat.transform.transform2D =
dest[i++] = m00 * x + m01 * y + m03; dest[i++] = m00 * x + m01 * y + m03;
dest[i++] = m10 * x + m11 * y + m13; dest[i++] = m10 * x + m11 * y + m13;
} }
if (goog.isDef(opt_dest) && dest.length != i) { if (opt_dest && dest.length != i) {
dest.length = i; dest.length = i;
} }
return dest; return dest;
@@ -48,7 +48,7 @@ ol.geom.flat.transform.transform2D =
*/ */
ol.geom.flat.transform.translate = ol.geom.flat.transform.translate =
function(flatCoordinates, offset, end, stride, deltaX, deltaY, opt_dest) { function(flatCoordinates, offset, end, stride, deltaX, deltaY, opt_dest) {
var dest = goog.isDef(opt_dest) ? opt_dest : []; var dest = opt_dest ? opt_dest : [];
var i = 0; var i = 0;
var j, k; var j, k;
for (j = offset; j < end; j += stride) { for (j = offset; j < end; j += stride) {
@@ -58,7 +58,7 @@ ol.geom.flat.transform.translate =
dest[i++] = flatCoordinates[k]; dest[i++] = flatCoordinates[k];
} }
} }
if (goog.isDef(opt_dest) && dest.length != i) { if (opt_dest && dest.length != i) {
dest.length = i; dest.length = i;
} }
return dest; return dest;
+1 -2
View File
@@ -122,8 +122,7 @@ ol.geom.Geometry.prototype.closestPointXY = goog.abstractMethod;
* @api stable * @api stable
*/ */
ol.geom.Geometry.prototype.getClosestPoint = function(point, opt_closestPoint) { ol.geom.Geometry.prototype.getClosestPoint = function(point, opt_closestPoint) {
var closestPoint = goog.isDef(opt_closestPoint) ? var closestPoint = opt_closestPoint ? opt_closestPoint : [NaN, NaN];
opt_closestPoint : [NaN, NaN];
this.closestPointXY(point[0], point[1], closestPoint, Infinity); this.closestPointXY(point[0], point[1], closestPoint, Infinity);
return closestPoint; return closestPoint;
}; };
+1 -1
View File
@@ -26,7 +26,7 @@ ol.geom.GeometryCollection = function(opt_geometries) {
* @private * @private
* @type {Array.<ol.geom.Geometry>} * @type {Array.<ol.geom.Geometry>}
*/ */
this.geometries_ = goog.isDef(opt_geometries) ? opt_geometries : null; this.geometries_ = opt_geometries ? opt_geometries : null;
this.listenGeometriesChange_(); this.listenGeometriesChange_();
}; };
+2 -1
View File
@@ -2,6 +2,7 @@ goog.provide('ol.geom.LineString');
goog.require('goog.array'); goog.require('goog.array');
goog.require('goog.asserts'); goog.require('goog.asserts');
goog.require('ol');
goog.require('ol.extent'); goog.require('ol.extent');
goog.require('ol.geom.GeometryLayout'); goog.require('ol.geom.GeometryLayout');
goog.require('ol.geom.GeometryType'); goog.require('ol.geom.GeometryType');
@@ -148,7 +149,7 @@ ol.geom.LineString.prototype.getCoordinateAtM = function(m, opt_extrapolate) {
this.layout != ol.geom.GeometryLayout.XYZM) { this.layout != ol.geom.GeometryLayout.XYZM) {
return null; return null;
} }
var extrapolate = goog.isDef(opt_extrapolate) ? opt_extrapolate : false; var extrapolate = opt_extrapolate !== undefined ? opt_extrapolate : false;
return ol.geom.flat.lineStringCoordinateAtM(this.flatCoordinates, 0, return ol.geom.flat.lineStringCoordinateAtM(this.flatCoordinates, 0,
this.flatCoordinates.length, this.stride, m, extrapolate); this.flatCoordinates.length, this.stride, m, extrapolate);
}; };
+3 -2
View File
@@ -2,6 +2,7 @@ goog.provide('ol.geom.MultiLineString');
goog.require('goog.array'); goog.require('goog.array');
goog.require('goog.asserts'); goog.require('goog.asserts');
goog.require('ol');
goog.require('ol.extent'); goog.require('ol.extent');
goog.require('ol.geom.GeometryLayout'); goog.require('ol.geom.GeometryLayout');
goog.require('ol.geom.GeometryType'); goog.require('ol.geom.GeometryType');
@@ -135,8 +136,8 @@ ol.geom.MultiLineString.prototype.getCoordinateAtM =
this.flatCoordinates.length === 0) { this.flatCoordinates.length === 0) {
return null; return null;
} }
var extrapolate = goog.isDef(opt_extrapolate) ? opt_extrapolate : false; var extrapolate = opt_extrapolate !== undefined ? opt_extrapolate : false;
var interpolate = goog.isDef(opt_interpolate) ? opt_interpolate : false; var interpolate = opt_interpolate !== undefined ? opt_interpolate : false;
return ol.geom.flat.lineStringsCoordinateAtM(this.flatCoordinates, 0, return ol.geom.flat.lineStringsCoordinateAtM(this.flatCoordinates, 0,
this.ends_, this.stride, m, extrapolate, interpolate); this.ends_, this.stride, m, extrapolate, interpolate);
}; };
+2 -1
View File
@@ -3,6 +3,7 @@ goog.provide('ol.geom.MultiPolygon');
goog.require('goog.array'); goog.require('goog.array');
goog.require('goog.asserts'); goog.require('goog.asserts');
goog.require('goog.object'); goog.require('goog.object');
goog.require('ol');
goog.require('ol.extent'); goog.require('ol.extent');
goog.require('ol.geom.GeometryLayout'); goog.require('ol.geom.GeometryLayout');
goog.require('ol.geom.GeometryType'); goog.require('ol.geom.GeometryType');
@@ -182,7 +183,7 @@ ol.geom.MultiPolygon.prototype.getArea = function() {
*/ */
ol.geom.MultiPolygon.prototype.getCoordinates = function(opt_right) { ol.geom.MultiPolygon.prototype.getCoordinates = function(opt_right) {
var flatCoordinates; var flatCoordinates;
if (goog.isDef(opt_right)) { if (opt_right !== undefined) {
flatCoordinates = this.getOrientedFlatCoordinates().slice(); flatCoordinates = this.getOrientedFlatCoordinates().slice();
ol.geom.flat.orient.orientLinearRingss( ol.geom.flat.orient.orientLinearRingss(
flatCoordinates, 0, this.endss_, this.stride, opt_right); flatCoordinates, 0, this.endss_, this.stride, opt_right);
+5 -4
View File
@@ -3,6 +3,7 @@ goog.provide('ol.geom.Polygon');
goog.require('goog.array'); goog.require('goog.array');
goog.require('goog.asserts'); goog.require('goog.asserts');
goog.require('goog.math'); goog.require('goog.math');
goog.require('ol');
goog.require('ol.extent'); goog.require('ol.extent');
goog.require('ol.geom.GeometryLayout'); goog.require('ol.geom.GeometryLayout');
goog.require('ol.geom.GeometryType'); goog.require('ol.geom.GeometryType');
@@ -169,7 +170,7 @@ ol.geom.Polygon.prototype.getArea = function() {
*/ */
ol.geom.Polygon.prototype.getCoordinates = function(opt_right) { ol.geom.Polygon.prototype.getCoordinates = function(opt_right) {
var flatCoordinates; var flatCoordinates;
if (goog.isDef(opt_right)) { if (opt_right !== undefined) {
flatCoordinates = this.getOrientedFlatCoordinates().slice(); flatCoordinates = this.getOrientedFlatCoordinates().slice();
ol.geom.flat.orient.orientLinearRings( ol.geom.flat.orient.orientLinearRings(
flatCoordinates, 0, this.ends_, this.stride, opt_right); flatCoordinates, 0, this.ends_, this.stride, opt_right);
@@ -388,7 +389,7 @@ ol.geom.Polygon.prototype.setFlatCoordinates =
* @api stable * @api stable
*/ */
ol.geom.Polygon.circular = function(sphere, center, radius, opt_n) { ol.geom.Polygon.circular = function(sphere, center, radius, opt_n) {
var n = goog.isDef(opt_n) ? opt_n : 32; var n = opt_n ? opt_n : 32;
/** @type {Array.<number>} */ /** @type {Array.<number>} */
var flatCoordinates = []; var flatCoordinates = [];
var i; var i;
@@ -434,7 +435,7 @@ ol.geom.Polygon.fromExtent = function(extent) {
* @api * @api
*/ */
ol.geom.Polygon.fromCircle = function(circle, opt_sides, opt_angle) { ol.geom.Polygon.fromCircle = function(circle, opt_sides, opt_angle) {
var sides = goog.isDef(opt_sides) ? opt_sides : 32; var sides = opt_sides ? opt_sides : 32;
var stride = circle.getStride(); var stride = circle.getStride();
var layout = circle.getLayout(); var layout = circle.getLayout();
var polygon = new ol.geom.Polygon(null, layout); var polygon = new ol.geom.Polygon(null, layout);
@@ -462,7 +463,7 @@ ol.geom.Polygon.makeRegular = function(polygon, center, radius, opt_angle) {
var ends = polygon.getEnds(); var ends = polygon.getEnds();
goog.asserts.assert(ends.length === 1, 'only 1 ring is supported'); goog.asserts.assert(ends.length === 1, 'only 1 ring is supported');
var sides = flatCoordinates.length / stride - 1; var sides = flatCoordinates.length / stride - 1;
var startAngle = goog.isDef(opt_angle) ? opt_angle : 0; var startAngle = opt_angle ? opt_angle : 0;
var angle, coord, offset; var angle, coord, offset;
for (var i = 0; i <= sides; ++i) { for (var i = 0; i <= sides; ++i) {
offset = i * stride; offset = i * stride;
+1 -1
View File
@@ -232,7 +232,7 @@ ol.geom.SimpleGeometry.prototype.setLayout =
function(layout, coordinates, nesting) { function(layout, coordinates, nesting) {
/** @type {number} */ /** @type {number} */
var stride; var stride;
if (goog.isDef(layout)) { if (layout) {
stride = ol.geom.SimpleGeometry.getStrideForLayout(layout); stride = ol.geom.SimpleGeometry.getStrideForLayout(layout);
} else { } else {
var i; var i;
+15 -15
View File
@@ -20,7 +20,7 @@ goog.require('ol.style.Stroke');
*/ */
ol.Graticule = function(opt_options) { ol.Graticule = function(opt_options) {
var options = goog.isDef(opt_options) ? opt_options : {}; var options = opt_options || {};
/** /**
* @type {ol.Map} * @type {ol.Map}
@@ -86,14 +86,14 @@ ol.Graticule = function(opt_options) {
* @type {number} * @type {number}
* @private * @private
*/ */
this.targetSize_ = goog.isDef(options.targetSize) ? this.targetSize_ = options.targetSize !== undefined ?
options.targetSize : 100; options.targetSize : 100;
/** /**
* @type {number} * @type {number}
* @private * @private
*/ */
this.maxLines_ = goog.isDef(options.maxLines) ? options.maxLines : 100; this.maxLines_ = options.maxLines !== undefined ? options.maxLines : 100;
goog.asserts.assert(this.maxLines_ > 0, goog.asserts.assert(this.maxLines_ > 0,
'this.maxLines_ should be more than 0'); 'this.maxLines_ should be more than 0');
@@ -113,7 +113,7 @@ ol.Graticule = function(opt_options) {
* @type {ol.style.Stroke} * @type {ol.style.Stroke}
* @private * @private
*/ */
this.strokeStyle_ = goog.isDef(options.strokeStyle) ? this.strokeStyle_ = options.strokeStyle !== undefined ?
options.strokeStyle : ol.Graticule.DEFAULT_STROKE_STYLE_; options.strokeStyle : ol.Graticule.DEFAULT_STROKE_STYLE_;
/** /**
@@ -134,7 +134,7 @@ ol.Graticule = function(opt_options) {
*/ */
this.projectionCenterLonLat_ = null; this.projectionCenterLonLat_ = null;
this.setMap(goog.isDef(options.map) ? options.map : null); this.setMap(options.map !== undefined ? options.map : null);
}; };
@@ -346,7 +346,7 @@ ol.Graticule.prototype.getMeridian_ = function(lon, minLat, maxLat,
minLat, maxLat, this.projection_, squaredTolerance); minLat, maxLat, this.projection_, squaredTolerance);
goog.asserts.assert(flatCoordinates.length > 0, goog.asserts.assert(flatCoordinates.length > 0,
'flatCoordinates cannot be empty'); 'flatCoordinates cannot be empty');
var lineString = goog.isDef(this.meridians_[index]) ? var lineString = this.meridians_[index] !== undefined ?
this.meridians_[index] : new ol.geom.LineString(null); this.meridians_[index] : new ol.geom.LineString(null);
lineString.setFlatCoordinates(ol.geom.GeometryLayout.XY, flatCoordinates); lineString.setFlatCoordinates(ol.geom.GeometryLayout.XY, flatCoordinates);
return lineString; return lineString;
@@ -382,7 +382,7 @@ ol.Graticule.prototype.getParallel_ = function(lat, minLon, maxLon,
this.minLon_, this.maxLon_, this.projection_, squaredTolerance); this.minLon_, this.maxLon_, this.projection_, squaredTolerance);
goog.asserts.assert(flatCoordinates.length > 0, goog.asserts.assert(flatCoordinates.length > 0,
'flatCoordinates cannot be empty'); 'flatCoordinates cannot be empty');
var lineString = goog.isDef(this.parallels_[index]) ? var lineString = this.parallels_[index] !== undefined ?
this.parallels_[index] : new ol.geom.LineString(null); this.parallels_[index] : new ol.geom.LineString(null);
lineString.setFlatCoordinates(ol.geom.GeometryLayout.XY, flatCoordinates); lineString.setFlatCoordinates(ol.geom.GeometryLayout.XY, flatCoordinates);
return lineString; return lineString;
@@ -463,18 +463,18 @@ ol.Graticule.prototype.updateProjectionInfo_ = function(projection) {
var minLonP = worldExtentP[0]; var minLonP = worldExtentP[0];
goog.asserts.assert(!goog.isNull(extent), 'extent cannot be null'); goog.asserts.assert(!goog.isNull(extent), 'extent cannot be null');
goog.asserts.assert(goog.isDef(maxLat), 'maxLat should be defined'); goog.asserts.assert(maxLat !== undefined, 'maxLat should be defined');
goog.asserts.assert(goog.isDef(maxLon), 'maxLon should be defined'); goog.asserts.assert(maxLon !== undefined, 'maxLon should be defined');
goog.asserts.assert(goog.isDef(minLat), 'minLat should be defined'); goog.asserts.assert(minLat !== undefined, 'minLat should be defined');
goog.asserts.assert(goog.isDef(minLon), 'minLon should be defined'); goog.asserts.assert(minLon !== undefined, 'minLon should be defined');
goog.asserts.assert(goog.isDef(maxLatP), goog.asserts.assert(maxLatP !== undefined,
'projected maxLat should be defined'); 'projected maxLat should be defined');
goog.asserts.assert(goog.isDef(maxLonP), goog.asserts.assert(maxLonP !== undefined,
'projected maxLon should be defined'); 'projected maxLon should be defined');
goog.asserts.assert(goog.isDef(minLatP), goog.asserts.assert(minLatP !== undefined,
'projected minLat should be defined'); 'projected minLat should be defined');
goog.asserts.assert(goog.isDef(minLonP), goog.asserts.assert(minLonP !== undefined,
'projected minLon should be defined'); 'projected minLon should be defined');
this.maxLat_ = maxLat; this.maxLat_ = maxLat;
+1 -1
View File
@@ -44,7 +44,7 @@ ol.has.CANVAS = ol.ENABLE_CANVAS && (
if (goog.isNull(context)) { if (goog.isNull(context)) {
return false; return false;
} else { } else {
if (goog.isDef(context.setLineDash)) { if (context.setLineDash !== undefined) {
ol.has.CANVAS_LINE_DASH = true; ol.has.CANVAS_LINE_DASH = true;
} }
return true; return true;
+2 -2
View File
@@ -78,7 +78,7 @@ goog.inherits(ol.Image, ol.ImageBase);
* @api * @api
*/ */
ol.Image.prototype.getImage = function(opt_context) { ol.Image.prototype.getImage = function(opt_context) {
if (goog.isDef(opt_context)) { if (opt_context !== undefined) {
var image; var image;
var key = goog.getUid(opt_context); var key = goog.getUid(opt_context);
if (key in this.imageByContext_) { if (key in this.imageByContext_) {
@@ -114,7 +114,7 @@ ol.Image.prototype.handleImageError_ = function() {
* @private * @private
*/ */
ol.Image.prototype.handleImageLoad_ = function() { ol.Image.prototype.handleImageLoad_ = function() {
if (!goog.isDef(this.resolution)) { if (this.resolution === undefined) {
this.resolution = ol.extent.getHeight(this.extent) / this.image_.height; this.resolution = ol.extent.getHeight(this.extent) / this.image_.height;
} }
this.state = ol.ImageState.LOADED; this.state = ol.ImageState.LOADED;
+1 -1
View File
@@ -110,7 +110,7 @@ ol.ImageBase.prototype.getPixelRatio = function() {
* @return {number} Resolution. * @return {number} Resolution.
*/ */
ol.ImageBase.prototype.getResolution = function() { ol.ImageBase.prototype.getResolution = function() {
goog.asserts.assert(goog.isDef(this.resolution), 'resolution not yet set'); goog.asserts.assert(this.resolution !== undefined, 'resolution not yet set');
return this.resolution; return this.resolution;
}; };
+2 -2
View File
@@ -25,9 +25,9 @@ ol.ImageCanvas = function(extent, resolution, pixelRatio, attributions,
* @type {?ol.ImageCanvasLoader} * @type {?ol.ImageCanvasLoader}
* @private * @private
*/ */
this.loader_ = goog.isDef(opt_loader) ? opt_loader : null; this.loader_ = opt_loader !== undefined ? opt_loader : null;
var state = goog.isDef(opt_loader) ? var state = opt_loader !== undefined ?
ol.ImageState.IDLE : ol.ImageState.LOADED; ol.ImageState.IDLE : ol.ImageState.LOADED;
goog.base(this, extent, resolution, pixelRatio, state, attributions); goog.base(this, extent, resolution, pixelRatio, state, attributions);
+2 -2
View File
@@ -81,7 +81,7 @@ ol.ImageTile.prototype.disposeInternal = function() {
* @api * @api
*/ */
ol.ImageTile.prototype.getImage = function(opt_context) { ol.ImageTile.prototype.getImage = function(opt_context) {
if (goog.isDef(opt_context)) { if (opt_context !== undefined) {
var image; var image;
var key = goog.getUid(opt_context); var key = goog.getUid(opt_context);
if (key in this.imageByContext_) { if (key in this.imageByContext_) {
@@ -126,7 +126,7 @@ ol.ImageTile.prototype.handleImageError_ = function() {
*/ */
ol.ImageTile.prototype.handleImageLoad_ = function() { ol.ImageTile.prototype.handleImageLoad_ = function() {
if (ol.LEGACY_IE_SUPPORT && ol.IS_LEGACY_IE) { if (ol.LEGACY_IE_SUPPORT && ol.IS_LEGACY_IE) {
if (!goog.isDef(this.image_.naturalWidth)) { if (this.image_.naturalWidth === undefined) {
this.image_.naturalWidth = this.image_.width; this.image_.naturalWidth = this.image_.width;
this.image_.naturalHeight = this.image_.height; this.image_.naturalHeight = this.image_.height;
} }
@@ -18,13 +18,13 @@ goog.require('ol.interaction.Interaction');
*/ */
ol.interaction.DoubleClickZoom = function(opt_options) { ol.interaction.DoubleClickZoom = function(opt_options) {
var options = goog.isDef(opt_options) ? opt_options : {}; var options = opt_options ? opt_options : {};
/** /**
* @private * @private
* @type {number} * @type {number}
*/ */
this.delta_ = goog.isDef(options.delta) ? options.delta : 1; this.delta_ = options.delta ? options.delta : 1;
goog.base(this, { goog.base(this, {
handleEvent: ol.interaction.DoubleClickZoom.handleEvent handleEvent: ol.interaction.DoubleClickZoom.handleEvent
@@ -34,7 +34,7 @@ ol.interaction.DoubleClickZoom = function(opt_options) {
* @private * @private
* @type {number} * @type {number}
*/ */
this.duration_ = goog.isDef(options.duration) ? options.duration : 250; this.duration_ = options.duration ? options.duration : 250;
}; };
goog.inherits(ol.interaction.DoubleClickZoom, ol.interaction.Interaction); goog.inherits(ol.interaction.DoubleClickZoom, ol.interaction.Interaction);
+7 -7
View File
@@ -27,7 +27,7 @@ goog.require('ol.proj');
*/ */
ol.interaction.DragAndDrop = function(opt_options) { ol.interaction.DragAndDrop = function(opt_options) {
var options = goog.isDef(opt_options) ? opt_options : {}; var options = opt_options ? opt_options : {};
goog.base(this, { goog.base(this, {
handleEvent: ol.interaction.DragAndDrop.handleEvent handleEvent: ol.interaction.DragAndDrop.handleEvent
@@ -37,14 +37,14 @@ ol.interaction.DragAndDrop = function(opt_options) {
* @private * @private
* @type {Array.<function(new: ol.format.Feature)>} * @type {Array.<function(new: ol.format.Feature)>}
*/ */
this.formatConstructors_ = goog.isDef(options.formatConstructors) ? this.formatConstructors_ = options.formatConstructors ?
options.formatConstructors : []; options.formatConstructors : [];
/** /**
* @private * @private
* @type {ol.proj.Projection} * @type {ol.proj.Projection}
*/ */
this.projection_ = goog.isDef(options.projection) ? this.projection_ = options.projection ?
ol.proj.get(options.projection) : null; ol.proj.get(options.projection) : null;
/** /**
@@ -67,7 +67,7 @@ goog.inherits(ol.interaction.DragAndDrop, ol.interaction.Interaction);
* @inheritDoc * @inheritDoc
*/ */
ol.interaction.DragAndDrop.prototype.disposeInternal = function() { ol.interaction.DragAndDrop.prototype.disposeInternal = function() {
if (goog.isDef(this.dropListenKey_)) { if (this.dropListenKey_) {
goog.events.unlistenByKey(this.dropListenKey_); goog.events.unlistenByKey(this.dropListenKey_);
} }
goog.base(this, 'disposeInternal'); goog.base(this, 'disposeInternal');
@@ -104,7 +104,7 @@ ol.interaction.DragAndDrop.prototype.handleResult_ = function(file, result) {
var view = map.getView(); var view = map.getView();
goog.asserts.assert(!goog.isNull(view), 'view should not be null'); goog.asserts.assert(!goog.isNull(view), 'view should not be null');
projection = view.getProjection(); projection = view.getProjection();
goog.asserts.assert(goog.isDef(projection), goog.asserts.assert(projection !== undefined,
'projection should be defined'); 'projection should be defined');
} }
var formatConstructors = this.formatConstructors_; var formatConstructors = this.formatConstructors_;
@@ -150,7 +150,7 @@ ol.interaction.DragAndDrop.handleEvent = goog.functions.TRUE;
* @inheritDoc * @inheritDoc
*/ */
ol.interaction.DragAndDrop.prototype.setMap = function(map) { ol.interaction.DragAndDrop.prototype.setMap = function(map) {
if (goog.isDef(this.dropListenKey_)) { if (this.dropListenKey_) {
goog.events.unlistenByKey(this.dropListenKey_); goog.events.unlistenByKey(this.dropListenKey_);
this.dropListenKey_ = undefined; this.dropListenKey_ = undefined;
} }
@@ -158,7 +158,7 @@ ol.interaction.DragAndDrop.prototype.setMap = function(map) {
goog.dispose(this.fileDropHandler_); goog.dispose(this.fileDropHandler_);
this.fileDropHandler_ = null; this.fileDropHandler_ = null;
} }
goog.asserts.assert(!goog.isDef(this.dropListenKey_), goog.asserts.assert(this.dropListenKey_ === undefined,
'this.dropListenKey_ should be undefined'); 'this.dropListenKey_ should be undefined');
goog.base(this, 'setMap', map); goog.base(this, 'setMap', map);
if (!goog.isNull(map)) { if (!goog.isNull(map)) {
+3 -3
View File
@@ -91,13 +91,13 @@ ol.interaction.DragBox = function(opt_options) {
handleUpEvent: ol.interaction.DragBox.handleUpEvent_ handleUpEvent: ol.interaction.DragBox.handleUpEvent_
}); });
var options = goog.isDef(opt_options) ? opt_options : {}; var options = opt_options ? opt_options : {};
/** /**
* @private * @private
* @type {ol.style.Style} * @type {ol.style.Style}
*/ */
var style = goog.isDef(options.style) ? options.style : null; var style = options.style ? options.style : null;
/** /**
* @type {ol.render.Box} * @type {ol.render.Box}
@@ -115,7 +115,7 @@ ol.interaction.DragBox = function(opt_options) {
* @private * @private
* @type {ol.events.ConditionType} * @type {ol.events.ConditionType}
*/ */
this.condition_ = goog.isDef(options.condition) ? this.condition_ = options.condition ?
options.condition : ol.events.condition.always; options.condition : ol.events.condition.always;
}; };
+3 -3
View File
@@ -28,7 +28,7 @@ ol.interaction.DragPan = function(opt_options) {
handleUpEvent: ol.interaction.DragPan.handleUpEvent_ handleUpEvent: ol.interaction.DragPan.handleUpEvent_
}); });
var options = goog.isDef(opt_options) ? opt_options : {}; var options = opt_options ? opt_options : {};
/** /**
* @private * @private
@@ -51,7 +51,7 @@ ol.interaction.DragPan = function(opt_options) {
* @private * @private
* @type {ol.events.ConditionType} * @type {ol.events.ConditionType}
*/ */
this.condition_ = goog.isDef(options.condition) ? this.condition_ = options.condition ?
options.condition : ol.events.condition.noModifierKeys; options.condition : ol.events.condition.noModifierKeys;
/** /**
@@ -109,7 +109,7 @@ ol.interaction.DragPan.handleUpEvent_ = function(mapBrowserEvent) {
var distance = this.kinetic_.getDistance(); var distance = this.kinetic_.getDistance();
var angle = this.kinetic_.getAngle(); var angle = this.kinetic_.getAngle();
var center = view.getCenter(); var center = view.getCenter();
goog.asserts.assert(goog.isDef(center), 'center should be defined'); goog.asserts.assert(center !== undefined, 'center should be defined');
this.kineticPreRenderFn_ = this.kinetic_.pan(center); this.kineticPreRenderFn_ = this.kinetic_.pan(center);
map.beforeRender(this.kineticPreRenderFn_); map.beforeRender(this.kineticPreRenderFn_);
var centerpx = map.getPixelFromCoordinate(center); var centerpx = map.getPixelFromCoordinate(center);
@@ -1,6 +1,7 @@
goog.provide('ol.interaction.DragRotateAndZoom'); goog.provide('ol.interaction.DragRotateAndZoom');
goog.require('goog.math.Vec2'); goog.require('goog.math.Vec2');
goog.require('ol');
goog.require('ol.ViewHint'); goog.require('ol.ViewHint');
goog.require('ol.events.ConditionType'); goog.require('ol.events.ConditionType');
goog.require('ol.events.condition'); goog.require('ol.events.condition');
@@ -26,7 +27,7 @@ goog.require('ol.interaction.Pointer');
*/ */
ol.interaction.DragRotateAndZoom = function(opt_options) { ol.interaction.DragRotateAndZoom = function(opt_options) {
var options = goog.isDef(opt_options) ? opt_options : {}; var options = opt_options ? opt_options : {};
goog.base(this, { goog.base(this, {
handleDownEvent: ol.interaction.DragRotateAndZoom.handleDownEvent_, handleDownEvent: ol.interaction.DragRotateAndZoom.handleDownEvent_,
@@ -38,7 +39,7 @@ ol.interaction.DragRotateAndZoom = function(opt_options) {
* @private * @private
* @type {ol.events.ConditionType} * @type {ol.events.ConditionType}
*/ */
this.condition_ = goog.isDef(options.condition) ? this.condition_ = options.condition ?
options.condition : ol.events.condition.shiftKeyOnly; options.condition : ol.events.condition.shiftKeyOnly;
/** /**
@@ -63,7 +64,7 @@ ol.interaction.DragRotateAndZoom = function(opt_options) {
* @private * @private
* @type {number} * @type {number}
*/ */
this.duration_ = goog.isDef(options.duration) ? options.duration : 400; this.duration_ = options.duration ? options.duration : 400;
}; };
goog.inherits(ol.interaction.DragRotateAndZoom, ol.interaction.Pointer); goog.inherits(ol.interaction.DragRotateAndZoom, ol.interaction.Pointer);
@@ -89,17 +90,17 @@ ol.interaction.DragRotateAndZoom.handleDragEvent_ = function(mapBrowserEvent) {
var magnitude = delta.magnitude(); var magnitude = delta.magnitude();
var view = map.getView(); var view = map.getView();
map.render(); map.render();
if (goog.isDef(this.lastAngle_)) { if (this.lastAngle_ !== undefined) {
var angleDelta = theta - this.lastAngle_; var angleDelta = theta - this.lastAngle_;
ol.interaction.Interaction.rotateWithoutConstraints( ol.interaction.Interaction.rotateWithoutConstraints(
map, view, view.getRotation() - angleDelta); map, view, view.getRotation() - angleDelta);
} }
this.lastAngle_ = theta; this.lastAngle_ = theta;
if (goog.isDef(this.lastMagnitude_)) { if (this.lastMagnitude_ !== undefined) {
var resolution = this.lastMagnitude_ * (view.getResolution() / magnitude); var resolution = this.lastMagnitude_ * (view.getResolution() / magnitude);
ol.interaction.Interaction.zoomWithoutConstraints(map, view, resolution); ol.interaction.Interaction.zoomWithoutConstraints(map, view, resolution);
} }
if (goog.isDef(this.lastMagnitude_)) { if (this.lastMagnitude_ !== undefined) {
this.lastScaleDelta_ = this.lastMagnitude_ / magnitude; this.lastScaleDelta_ = this.lastMagnitude_ / magnitude;
} }
this.lastMagnitude_ = magnitude; this.lastMagnitude_ = magnitude;
+5 -4
View File
@@ -1,5 +1,6 @@
goog.provide('ol.interaction.DragRotate'); goog.provide('ol.interaction.DragRotate');
goog.require('ol');
goog.require('ol.ViewHint'); goog.require('ol.ViewHint');
goog.require('ol.events.ConditionType'); goog.require('ol.events.ConditionType');
goog.require('ol.events.condition'); goog.require('ol.events.condition');
@@ -23,7 +24,7 @@ goog.require('ol.interaction.Pointer');
*/ */
ol.interaction.DragRotate = function(opt_options) { ol.interaction.DragRotate = function(opt_options) {
var options = goog.isDef(opt_options) ? opt_options : {}; var options = opt_options ? opt_options : {};
goog.base(this, { goog.base(this, {
handleDownEvent: ol.interaction.DragRotate.handleDownEvent_, handleDownEvent: ol.interaction.DragRotate.handleDownEvent_,
@@ -35,7 +36,7 @@ ol.interaction.DragRotate = function(opt_options) {
* @private * @private
* @type {ol.events.ConditionType} * @type {ol.events.ConditionType}
*/ */
this.condition_ = goog.isDef(options.condition) ? this.condition_ = options.condition ?
options.condition : ol.events.condition.altShiftKeysOnly; options.condition : ol.events.condition.altShiftKeysOnly;
/** /**
@@ -48,7 +49,7 @@ ol.interaction.DragRotate = function(opt_options) {
* @private * @private
* @type {number} * @type {number}
*/ */
this.duration_ = goog.isDef(options.duration) ? options.duration : 250; this.duration_ = options.duration ? options.duration : 250;
}; };
goog.inherits(ol.interaction.DragRotate, ol.interaction.Pointer); goog.inherits(ol.interaction.DragRotate, ol.interaction.Pointer);
@@ -68,7 +69,7 @@ ol.interaction.DragRotate.handleDragEvent_ = function(mapBrowserEvent) {
var offset = mapBrowserEvent.pixel; var offset = mapBrowserEvent.pixel;
var theta = var theta =
Math.atan2(size[1] / 2 - offset[1], offset[0] - size[0] / 2); Math.atan2(size[1] / 2 - offset[1], offset[0] - size[0] / 2);
if (goog.isDef(this.lastAngle_)) { if (this.lastAngle_ !== undefined) {
var delta = theta - this.lastAngle_; var delta = theta - this.lastAngle_;
var view = map.getView(); var view = map.getView();
var rotation = view.getRotation(); var rotation = view.getRotation();
+7 -7
View File
@@ -23,22 +23,22 @@ goog.require('ol.style.Style');
* @api stable * @api stable
*/ */
ol.interaction.DragZoom = function(opt_options) { ol.interaction.DragZoom = function(opt_options) {
var options = goog.isDef(opt_options) ? opt_options : {}; var options = opt_options ? opt_options : {};
var condition = goog.isDef(options.condition) ? var condition = options.condition ?
options.condition : ol.events.condition.shiftKeyOnly; options.condition : ol.events.condition.shiftKeyOnly;
/** /**
* @private * @private
* @type {number} * @type {number}
*/ */
this.duration_ = goog.isDef(options.duration) ? options.duration : 200; this.duration_ = options.duration ? options.duration : 200;
/** /**
* @private * @private
* @type {ol.style.Style} * @type {ol.style.Style}
*/ */
var style = goog.isDef(options.style) ? var style = options.style ?
options.style : new ol.style.Style({ options.style : new ol.style.Style({
stroke: new ol.style.Stroke({ stroke: new ol.style.Stroke({
color: [0, 0, 255, 1] color: [0, 0, 255, 1]
@@ -64,7 +64,7 @@ ol.interaction.DragZoom.prototype.onBoxEnd = function() {
goog.asserts.assert(!goog.isNull(view), 'view should not be null'); goog.asserts.assert(!goog.isNull(view), 'view should not be null');
var size = map.getSize(); var size = map.getSize();
goog.asserts.assert(goog.isDef(size), 'size should be defined'); goog.asserts.assert(size !== undefined, 'size should be defined');
var extent = this.getGeometry().getExtent(); var extent = this.getGeometry().getExtent();
@@ -72,10 +72,10 @@ ol.interaction.DragZoom.prototype.onBoxEnd = function() {
view.getResolutionForExtent(extent, size)); view.getResolutionForExtent(extent, size));
var currentResolution = view.getResolution(); var currentResolution = view.getResolution();
goog.asserts.assert(goog.isDef(currentResolution), 'res should be defined'); goog.asserts.assert(currentResolution !== undefined, 'res should be defined');
var currentCenter = view.getCenter(); var currentCenter = view.getCenter();
goog.asserts.assert(goog.isDef(currentCenter), 'center should be defined'); goog.asserts.assert(currentCenter !== undefined, 'center should be defined');
map.beforeRender(ol.animation.zoom({ map.beforeRender(ol.animation.zoom({
resolution: currentResolution, resolution: currentResolution,
+19 -21
View File
@@ -112,22 +112,21 @@ ol.interaction.Draw = function(options) {
* @type {ol.source.Vector} * @type {ol.source.Vector}
* @private * @private
*/ */
this.source_ = goog.isDef(options.source) ? options.source : null; this.source_ = options.source ? options.source : null;
/** /**
* Target collection for drawn features. * Target collection for drawn features.
* @type {ol.Collection.<ol.Feature>} * @type {ol.Collection.<ol.Feature>}
* @private * @private
*/ */
this.features_ = goog.isDef(options.features) ? options.features : null; this.features_ = options.features ? options.features : null;
/** /**
* Pixel distance for snapping. * Pixel distance for snapping.
* @type {number} * @type {number}
* @private * @private
*/ */
this.snapTolerance_ = goog.isDef(options.snapTolerance) ? this.snapTolerance_ = options.snapTolerance ? options.snapTolerance : 12;
options.snapTolerance : 12;
/** /**
* Geometry type. * Geometry type.
@@ -150,7 +149,7 @@ ol.interaction.Draw = function(options) {
* @type {number} * @type {number}
* @private * @private
*/ */
this.minPoints_ = goog.isDef(options.minPoints) ? this.minPoints_ = options.minPoints ?
options.minPoints : options.minPoints :
(this.mode_ === ol.interaction.DrawMode.POLYGON ? 3 : 2); (this.mode_ === ol.interaction.DrawMode.POLYGON ? 3 : 2);
@@ -160,11 +159,10 @@ ol.interaction.Draw = function(options) {
* @type {number} * @type {number}
* @private * @private
*/ */
this.maxPoints_ = goog.isDef(options.maxPoints) ? this.maxPoints_ = options.maxPoints ? options.maxPoints : Infinity;
options.maxPoints : Infinity;
var geometryFunction = options.geometryFunction; var geometryFunction = options.geometryFunction;
if (!goog.isDef(geometryFunction)) { if (!geometryFunction) {
if (this.type_ === ol.geom.GeometryType.CIRCLE) { if (this.type_ === ol.geom.GeometryType.CIRCLE) {
/** /**
* @param {ol.Coordinate|Array.<ol.Coordinate>|Array.<Array.<ol.Coordinate>>} coordinates * @param {ol.Coordinate|Array.<ol.Coordinate>|Array.<Array.<ol.Coordinate>>} coordinates
@@ -172,7 +170,7 @@ ol.interaction.Draw = function(options) {
* @return {ol.geom.SimpleGeometry} * @return {ol.geom.SimpleGeometry}
*/ */
geometryFunction = function(coordinates, opt_geometry) { geometryFunction = function(coordinates, opt_geometry) {
var circle = goog.isDef(opt_geometry) ? opt_geometry : var circle = opt_geometry ? opt_geometry :
new ol.geom.Circle([NaN, NaN]); new ol.geom.Circle([NaN, NaN]);
goog.asserts.assertInstanceof(circle, ol.geom.Circle, goog.asserts.assertInstanceof(circle, ol.geom.Circle,
'geometry must be an ol.geom.Circle'); 'geometry must be an ol.geom.Circle');
@@ -198,7 +196,7 @@ ol.interaction.Draw = function(options) {
*/ */
geometryFunction = function(coordinates, opt_geometry) { geometryFunction = function(coordinates, opt_geometry) {
var geometry = opt_geometry; var geometry = opt_geometry;
if (goog.isDef(geometry)) { if (geometry) {
geometry.setCoordinates(coordinates); geometry.setCoordinates(coordinates);
} else { } else {
geometry = new Constructor(coordinates); geometry = new Constructor(coordinates);
@@ -264,7 +262,7 @@ ol.interaction.Draw = function(options) {
* @type {number} * @type {number}
* @private * @private
*/ */
this.squaredClickTolerance_ = goog.isDef(options.clickTolerance) ? this.squaredClickTolerance_ = options.clickTolerance ?
options.clickTolerance * options.clickTolerance : 36; options.clickTolerance * options.clickTolerance : 36;
/** /**
@@ -275,10 +273,10 @@ ol.interaction.Draw = function(options) {
this.overlay_ = new ol.layer.Vector({ this.overlay_ = new ol.layer.Vector({
source: new ol.source.Vector({ source: new ol.source.Vector({
useSpatialIndex: false, useSpatialIndex: false,
wrapX: goog.isDef(options.wrapX) ? options.wrapX : false wrapX: options.wrapX ? options.wrapX : false
}), }),
style: goog.isDef(options.style) ? style: options.style ? options.style :
options.style : ol.interaction.Draw.getDefaultStyleFunction() ol.interaction.Draw.getDefaultStyleFunction()
}); });
/** /**
@@ -292,14 +290,14 @@ ol.interaction.Draw = function(options) {
* @private * @private
* @type {ol.events.ConditionType} * @type {ol.events.ConditionType}
*/ */
this.condition_ = goog.isDef(options.condition) ? this.condition_ = options.condition ?
options.condition : ol.events.condition.noModifierKeys; options.condition : ol.events.condition.noModifierKeys;
/** /**
* @private * @private
* @type {ol.events.ConditionType} * @type {ol.events.ConditionType}
*/ */
this.freehandCondition_ = goog.isDef(options.freehandCondition) ? this.freehandCondition_ = options.freehandCondition ?
options.freehandCondition : ol.events.condition.shiftKeyOnly; options.freehandCondition : ol.events.condition.shiftKeyOnly;
goog.events.listen(this, goog.events.listen(this,
@@ -512,9 +510,9 @@ ol.interaction.Draw.prototype.startDrawing_ = function(event) {
new ol.geom.LineString(this.sketchLineCoords_)); new ol.geom.LineString(this.sketchLineCoords_));
} }
var geometry = this.geometryFunction_(this.sketchCoords_); var geometry = this.geometryFunction_(this.sketchCoords_);
goog.asserts.assert(goog.isDef(geometry), 'geometry should be defined'); goog.asserts.assert(geometry !== undefined, 'geometry should be defined');
this.sketchFeature_ = new ol.Feature(); this.sketchFeature_ = new ol.Feature();
if (goog.isDef(this.geometryName_)) { if (this.geometryName_) {
this.sketchFeature_.setGeometryName(this.geometryName_); this.sketchFeature_.setGeometryName(this.geometryName_);
} }
this.sketchFeature_.setGeometry(geometry); this.sketchFeature_.setGeometry(geometry);
@@ -806,11 +804,11 @@ ol.interaction.Draw.createRegularPolygon = function(opt_sides, opt_angle) {
var end = coordinates[1]; var end = coordinates[1];
var radius = Math.sqrt( var radius = Math.sqrt(
ol.coordinate.squaredDistance(center, end)); ol.coordinate.squaredDistance(center, end));
var geometry = goog.isDef(opt_geometry) ? opt_geometry : var geometry = opt_geometry ? opt_geometry :
ol.geom.Polygon.fromCircle(new ol.geom.Circle(center), opt_sides); ol.geom.Polygon.fromCircle(new ol.geom.Circle(center), opt_sides);
goog.asserts.assertInstanceof(geometry, ol.geom.Polygon, goog.asserts.assertInstanceof(geometry, ol.geom.Polygon,
'geometry must be a polygon'); 'geometry must be a polygon');
var angle = goog.isDef(opt_angle) ? opt_angle : var angle = opt_angle ? opt_angle :
Math.atan((end[1] - center[1]) / (end[0] - center[0])); Math.atan((end[1] - center[1]) / (end[0] - center[0]));
ol.geom.Polygon.makeRegular(geometry, center, radius, angle); ol.geom.Polygon.makeRegular(geometry, center, radius, angle);
return geometry; return geometry;
@@ -840,7 +838,7 @@ ol.interaction.Draw.getMode_ = function(type) {
} else if (type === ol.geom.GeometryType.CIRCLE) { } else if (type === ol.geom.GeometryType.CIRCLE) {
mode = ol.interaction.DrawMode.CIRCLE; mode = ol.interaction.DrawMode.CIRCLE;
} }
goog.asserts.assert(goog.isDef(mode), 'mode should be defined'); goog.asserts.assert(mode !== undefined, 'mode should be defined');
return mode; return mode;
}; };
+10 -9
View File
@@ -3,6 +3,7 @@
goog.provide('ol.interaction.Interaction'); goog.provide('ol.interaction.Interaction');
goog.provide('ol.interaction.InteractionProperty'); goog.provide('ol.interaction.InteractionProperty');
goog.require('ol');
goog.require('ol.MapBrowserEvent'); goog.require('ol.MapBrowserEvent');
goog.require('ol.Object'); goog.require('ol.Object');
goog.require('ol.animation'); goog.require('ol.animation');
@@ -107,8 +108,8 @@ ol.interaction.Interaction.prototype.setMap = function(map) {
*/ */
ol.interaction.Interaction.pan = function(map, view, delta, opt_duration) { ol.interaction.Interaction.pan = function(map, view, delta, opt_duration) {
var currentCenter = view.getCenter(); var currentCenter = view.getCenter();
if (goog.isDef(currentCenter)) { if (currentCenter) {
if (goog.isDef(opt_duration) && opt_duration > 0) { if (opt_duration && opt_duration > 0) {
map.beforeRender(ol.animation.pan({ map.beforeRender(ol.animation.pan({
source: currentCenter, source: currentCenter,
duration: opt_duration, duration: opt_duration,
@@ -149,14 +150,14 @@ ol.interaction.Interaction.rotateWithoutConstraints =
if (goog.isDefAndNotNull(rotation)) { if (goog.isDefAndNotNull(rotation)) {
var currentRotation = view.getRotation(); var currentRotation = view.getRotation();
var currentCenter = view.getCenter(); var currentCenter = view.getCenter();
if (goog.isDef(currentRotation) && goog.isDef(currentCenter) && if (currentRotation !== undefined && currentCenter &&
goog.isDef(opt_duration) && opt_duration > 0) { opt_duration && opt_duration > 0) {
map.beforeRender(ol.animation.rotate({ map.beforeRender(ol.animation.rotate({
rotation: currentRotation, rotation: currentRotation,
duration: opt_duration, duration: opt_duration,
easing: ol.easing.easeOut easing: ol.easing.easeOut
})); }));
if (goog.isDef(opt_anchor)) { if (opt_anchor) {
map.beforeRender(ol.animation.pan({ map.beforeRender(ol.animation.pan({
source: currentCenter, source: currentCenter,
duration: opt_duration, duration: opt_duration,
@@ -220,14 +221,14 @@ ol.interaction.Interaction.zoomWithoutConstraints =
if (goog.isDefAndNotNull(resolution)) { if (goog.isDefAndNotNull(resolution)) {
var currentResolution = view.getResolution(); var currentResolution = view.getResolution();
var currentCenter = view.getCenter(); var currentCenter = view.getCenter();
if (goog.isDef(currentResolution) && goog.isDef(currentCenter) && if (currentResolution !== undefined && currentCenter &&
goog.isDef(opt_duration) && opt_duration > 0) { opt_duration && opt_duration > 0) {
map.beforeRender(ol.animation.zoom({ map.beforeRender(ol.animation.zoom({
resolution: currentResolution, resolution: /** @type {number} */ (currentResolution),
duration: opt_duration, duration: opt_duration,
easing: ol.easing.easeOut easing: ol.easing.easeOut
})); }));
if (goog.isDef(opt_anchor)) { if (opt_anchor) {
map.beforeRender(ol.animation.pan({ map.beforeRender(ol.animation.pan({
source: currentCenter, source: currentCenter,
duration: opt_duration, duration: opt_duration,
+11 -13
View File
@@ -1,5 +1,6 @@
goog.provide('ol.interaction'); goog.provide('ol.interaction');
goog.require('ol');
goog.require('ol.Collection'); goog.require('ol.Collection');
goog.require('ol.Kinetic'); goog.require('ol.Kinetic');
goog.require('ol.interaction.DoubleClickZoom'); goog.require('ol.interaction.DoubleClickZoom');
@@ -41,19 +42,19 @@ goog.require('ol.interaction.PinchZoom');
*/ */
ol.interaction.defaults = function(opt_options) { ol.interaction.defaults = function(opt_options) {
var options = goog.isDef(opt_options) ? opt_options : {}; var options = opt_options ? opt_options : {};
var interactions = new ol.Collection(); var interactions = new ol.Collection();
var kinetic = new ol.Kinetic(-0.005, 0.05, 100); var kinetic = new ol.Kinetic(-0.005, 0.05, 100);
var altShiftDragRotate = goog.isDef(options.altShiftDragRotate) ? var altShiftDragRotate = options.altShiftDragRotate !== undefined ?
options.altShiftDragRotate : true; options.altShiftDragRotate : true;
if (altShiftDragRotate) { if (altShiftDragRotate) {
interactions.push(new ol.interaction.DragRotate()); interactions.push(new ol.interaction.DragRotate());
} }
var doubleClickZoom = goog.isDef(options.doubleClickZoom) ? var doubleClickZoom = options.doubleClickZoom !== undefined ?
options.doubleClickZoom : true; options.doubleClickZoom : true;
if (doubleClickZoom) { if (doubleClickZoom) {
interactions.push(new ol.interaction.DoubleClickZoom({ interactions.push(new ol.interaction.DoubleClickZoom({
@@ -62,30 +63,27 @@ ol.interaction.defaults = function(opt_options) {
})); }));
} }
var dragPan = goog.isDef(options.dragPan) ? var dragPan = options.dragPan !== undefined ? options.dragPan : true;
options.dragPan : true;
if (dragPan) { if (dragPan) {
interactions.push(new ol.interaction.DragPan({ interactions.push(new ol.interaction.DragPan({
kinetic: kinetic kinetic: kinetic
})); }));
} }
var pinchRotate = goog.isDef(options.pinchRotate) ? var pinchRotate = options.pinchRotate !== undefined ? options.pinchRotate :
options.pinchRotate : true; true;
if (pinchRotate) { if (pinchRotate) {
interactions.push(new ol.interaction.PinchRotate()); interactions.push(new ol.interaction.PinchRotate());
} }
var pinchZoom = goog.isDef(options.pinchZoom) ? var pinchZoom = options.pinchZoom !== undefined ? options.pinchZoom : true;
options.pinchZoom : true;
if (pinchZoom) { if (pinchZoom) {
interactions.push(new ol.interaction.PinchZoom({ interactions.push(new ol.interaction.PinchZoom({
duration: options.zoomDuration duration: options.zoomDuration
})); }));
} }
var keyboard = goog.isDef(options.keyboard) ? var keyboard = options.keyboard !== undefined ? options.keyboard : true;
options.keyboard : true;
if (keyboard) { if (keyboard) {
interactions.push(new ol.interaction.KeyboardPan()); interactions.push(new ol.interaction.KeyboardPan());
interactions.push(new ol.interaction.KeyboardZoom({ interactions.push(new ol.interaction.KeyboardZoom({
@@ -94,7 +92,7 @@ ol.interaction.defaults = function(opt_options) {
})); }));
} }
var mouseWheelZoom = goog.isDef(options.mouseWheelZoom) ? var mouseWheelZoom = options.mouseWheelZoom !== undefined ?
options.mouseWheelZoom : true; options.mouseWheelZoom : true;
if (mouseWheelZoom) { if (mouseWheelZoom) {
interactions.push(new ol.interaction.MouseWheelZoom({ interactions.push(new ol.interaction.MouseWheelZoom({
@@ -102,7 +100,7 @@ ol.interaction.defaults = function(opt_options) {
})); }));
} }
var shiftDragZoom = goog.isDef(options.shiftDragZoom) ? var shiftDragZoom = options.shiftDragZoom !== undefined ?
options.shiftDragZoom : true; options.shiftDragZoom : true;
if (shiftDragZoom) { if (shiftDragZoom) {
interactions.push(new ol.interaction.DragZoom()); interactions.push(new ol.interaction.DragZoom());
+7 -4
View File
@@ -4,6 +4,7 @@ goog.require('goog.asserts');
goog.require('goog.events.KeyCodes'); goog.require('goog.events.KeyCodes');
goog.require('goog.events.KeyHandler.EventType'); goog.require('goog.events.KeyHandler.EventType');
goog.require('goog.functions'); goog.require('goog.functions');
goog.require('ol');
goog.require('ol.coordinate'); goog.require('ol.coordinate');
goog.require('ol.events.ConditionType'); goog.require('ol.events.ConditionType');
goog.require('ol.events.condition'); goog.require('ol.events.condition');
@@ -34,13 +35,14 @@ ol.interaction.KeyboardPan = function(opt_options) {
handleEvent: ol.interaction.KeyboardPan.handleEvent handleEvent: ol.interaction.KeyboardPan.handleEvent
}); });
var options = goog.isDef(opt_options) ? opt_options : {}; var options = opt_options || {};
/** /**
* @private * @private
* @type {ol.events.ConditionType} * @type {ol.events.ConditionType}
*/ */
this.condition_ = goog.isDef(options.condition) ? options.condition : this.condition_ = options.condition !== undefined ?
options.condition :
goog.functions.and(ol.events.condition.noModifierKeys, goog.functions.and(ol.events.condition.noModifierKeys,
ol.events.condition.targetNotEditable); ol.events.condition.targetNotEditable);
@@ -48,13 +50,14 @@ ol.interaction.KeyboardPan = function(opt_options) {
* @private * @private
* @type {number} * @type {number}
*/ */
this.duration_ = goog.isDef(options.duration) ? options.duration : 100; this.duration_ = options.duration !== undefined ? options.duration : 100;
/** /**
* @private * @private
* @type {number} * @type {number}
*/ */
this.pixelDelta_ = goog.isDef(options.pixelDelta) ? options.pixelDelta : 128; this.pixelDelta_ = options.pixelDelta !== undefined ?
options.pixelDelta : 128;
}; };
goog.inherits(ol.interaction.KeyboardPan, ol.interaction.Interaction); goog.inherits(ol.interaction.KeyboardPan, ol.interaction.Interaction);
@@ -31,26 +31,26 @@ ol.interaction.KeyboardZoom = function(opt_options) {
handleEvent: ol.interaction.KeyboardZoom.handleEvent handleEvent: ol.interaction.KeyboardZoom.handleEvent
}); });
var options = goog.isDef(opt_options) ? opt_options : {}; var options = opt_options ? opt_options : {};
/** /**
* @private * @private
* @type {ol.events.ConditionType} * @type {ol.events.ConditionType}
*/ */
this.condition_ = goog.isDef(options.condition) ? options.condition : this.condition_ = options.condition ? options.condition :
ol.events.condition.targetNotEditable; ol.events.condition.targetNotEditable;
/** /**
* @private * @private
* @type {number} * @type {number}
*/ */
this.delta_ = goog.isDef(options.delta) ? options.delta : 1; this.delta_ = options.delta ? options.delta : 1;
/** /**
* @private * @private
* @type {number} * @type {number}
*/ */
this.duration_ = goog.isDef(options.duration) ? options.duration : 100; this.duration_ = options.duration ? options.duration : 100;
}; };
goog.inherits(ol.interaction.KeyboardZoom, ol.interaction.Interaction); goog.inherits(ol.interaction.KeyboardZoom, ol.interaction.Interaction);
+16 -13
View File
@@ -7,6 +7,7 @@ goog.require('goog.events');
goog.require('goog.events.Event'); goog.require('goog.events.Event');
goog.require('goog.events.EventType'); goog.require('goog.events.EventType');
goog.require('goog.functions'); goog.require('goog.functions');
goog.require('ol');
goog.require('ol.Collection'); goog.require('ol.Collection');
goog.require('ol.CollectionEventType'); goog.require('ol.CollectionEventType');
goog.require('ol.Feature'); goog.require('ol.Feature');
@@ -116,7 +117,7 @@ ol.interaction.Modify = function(options) {
* @type {ol.events.ConditionType} * @type {ol.events.ConditionType}
* @private * @private
*/ */
this.deleteCondition_ = goog.isDef(options.deleteCondition) ? this.deleteCondition_ = options.deleteCondition ?
options.deleteCondition : options.deleteCondition :
/** @type {ol.events.ConditionType} */ (goog.functions.and( /** @type {ol.events.ConditionType} */ (goog.functions.and(
ol.events.condition.noModifierKeys, ol.events.condition.noModifierKeys,
@@ -161,7 +162,7 @@ ol.interaction.Modify = function(options) {
* @type {number} * @type {number}
* @private * @private
*/ */
this.pixelTolerance_ = goog.isDef(options.pixelTolerance) ? this.pixelTolerance_ = options.pixelTolerance !== undefined ?
options.pixelTolerance : 10; options.pixelTolerance : 10;
/** /**
@@ -192,9 +193,9 @@ ol.interaction.Modify = function(options) {
this.overlay_ = new ol.layer.Vector({ this.overlay_ = new ol.layer.Vector({
source: new ol.source.Vector({ source: new ol.source.Vector({
useSpatialIndex: false, useSpatialIndex: false,
wrapX: goog.isDef(options.wrapX) ? options.wrapX : false wrapX: !!options.wrapX
}), }),
style: goog.isDef(options.style) ? options.style : style: options.style ? options.style :
ol.interaction.Modify.getDefaultStyleFunction(), ol.interaction.Modify.getDefaultStyleFunction(),
updateWhileAnimating: true, updateWhileAnimating: true,
updateWhileInteracting: true updateWhileInteracting: true
@@ -238,7 +239,7 @@ goog.inherits(ol.interaction.Modify, ol.interaction.Pointer);
*/ */
ol.interaction.Modify.prototype.addFeature_ = function(feature) { ol.interaction.Modify.prototype.addFeature_ = function(feature) {
var geometry = feature.getGeometry(); var geometry = feature.getGeometry();
if (goog.isDef(this.SEGMENT_WRITERS_[geometry.getType()])) { if (geometry.getType() in this.SEGMENT_WRITERS_) {
this.SEGMENT_WRITERS_[geometry.getType()].call(this, feature, geometry); this.SEGMENT_WRITERS_[geometry.getType()].call(this, feature, geometry);
} }
var map = this.getMap(); var map = this.getMap();
@@ -822,10 +823,10 @@ ol.interaction.Modify.prototype.insertVertex_ = function(segmentData, vertex) {
this.setGeometryCoordinates_(geometry, coordinates); this.setGeometryCoordinates_(geometry, coordinates);
var rTree = this.rBush_; var rTree = this.rBush_;
goog.asserts.assert(goog.isDef(segment), 'segment should be defined'); goog.asserts.assert(segment !== undefined, 'segment should be defined');
rTree.remove(segmentData); rTree.remove(segmentData);
goog.asserts.assert(goog.isDef(index), 'index should be defined'); goog.asserts.assert(index !== undefined, 'index should be defined');
this.updateSegmentIndices_(geometry, index, depth, 1); this.updateSegmentIndices_(geometry, /** @type {number} */ (index), depth, 1);
var newSegmentData = /** @type {ol.interaction.SegmentDataType} */ ({ var newSegmentData = /** @type {ol.interaction.SegmentDataType} */ ({
segment: [segment[0], vertex], segment: [segment[0], vertex],
feature: feature, feature: feature,
@@ -883,13 +884,13 @@ ol.interaction.Modify.prototype.removeVertex_ = function() {
segmentsByFeature[uid] = [left, right, index]; segmentsByFeature[uid] = [left, right, index];
} }
newSegment = segmentsByFeature[uid]; newSegment = segmentsByFeature[uid];
if (goog.isDef(left)) { if (left !== undefined) {
newSegment[0] = left; newSegment[0] = left;
} }
if (goog.isDef(right)) { if (right !== undefined) {
newSegment[1] = right; newSegment[1] = right;
} }
if (goog.isDef(newSegment[0]) && goog.isDef(newSegment[1])) { if (newSegment[0] !== undefined && newSegment[1] !== undefined) {
component = coordinates; component = coordinates;
deleted = false; deleted = false;
newIndex = index - 1; newIndex = index - 1;
@@ -974,8 +975,10 @@ ol.interaction.Modify.prototype.updateSegmentIndices_ = function(
geometry, index, depth, delta) { geometry, index, depth, delta) {
this.rBush_.forEachInExtent(geometry.getExtent(), function(segmentDataMatch) { this.rBush_.forEachInExtent(geometry.getExtent(), function(segmentDataMatch) {
if (segmentDataMatch.geometry === geometry && if (segmentDataMatch.geometry === geometry &&
(!goog.isDef(depth) || !goog.isDef(segmentDataMatch.depth) || (depth === undefined || segmentDataMatch.depth === undefined ||
goog.array.equals(segmentDataMatch.depth, depth)) && goog.array.equals(
/** @type {null|{length: number}} */ (segmentDataMatch.depth),
depth)) &&
segmentDataMatch.index > index) { segmentDataMatch.index > index) {
segmentDataMatch.index += delta; segmentDataMatch.index += delta;
} }
@@ -25,7 +25,7 @@ ol.interaction.MouseWheelZoom = function(opt_options) {
handleEvent: ol.interaction.MouseWheelZoom.handleEvent handleEvent: ol.interaction.MouseWheelZoom.handleEvent
}); });
var options = goog.isDef(opt_options) ? opt_options : {}; var options = opt_options || {};
/** /**
* @private * @private
@@ -37,14 +37,13 @@ ol.interaction.MouseWheelZoom = function(opt_options) {
* @private * @private
* @type {number} * @type {number}
*/ */
this.duration_ = goog.isDef(options.duration) ? options.duration : 250; this.duration_ = options.duration !== undefined ? options.duration : 250;
/** /**
* @private * @private
* @type {boolean} * @type {boolean}
*/ */
this.useAnchor_ = goog.isDef(options.useAnchor) ? this.useAnchor_ = options.useAnchor !== undefined ? options.useAnchor : true;
options.useAnchor : true;
/** /**
* @private * @private
@@ -91,7 +90,7 @@ ol.interaction.MouseWheelZoom.handleEvent = function(mapBrowserEvent) {
this.delta_ += mouseWheelEvent.deltaY; this.delta_ += mouseWheelEvent.deltaY;
if (!goog.isDef(this.startTime_)) { if (this.startTime_ === undefined) {
this.startTime_ = goog.now(); this.startTime_ = goog.now();
} }
+5 -4
View File
@@ -3,6 +3,7 @@ goog.provide('ol.interaction.PinchRotate');
goog.require('goog.asserts'); goog.require('goog.asserts');
goog.require('goog.functions'); goog.require('goog.functions');
goog.require('goog.style'); goog.require('goog.style');
goog.require('ol');
goog.require('ol.Coordinate'); goog.require('ol.Coordinate');
goog.require('ol.ViewHint'); goog.require('ol.ViewHint');
goog.require('ol.interaction.Interaction'); goog.require('ol.interaction.Interaction');
@@ -28,7 +29,7 @@ ol.interaction.PinchRotate = function(opt_options) {
handleUpEvent: ol.interaction.PinchRotate.handleUpEvent_ handleUpEvent: ol.interaction.PinchRotate.handleUpEvent_
}); });
var options = goog.isDef(opt_options) ? opt_options : {}; var options = opt_options || {};
/** /**
* @private * @private
@@ -58,13 +59,13 @@ ol.interaction.PinchRotate = function(opt_options) {
* @private * @private
* @type {number} * @type {number}
*/ */
this.threshold_ = goog.isDef(options.threshold) ? options.threshold : 0.3; this.threshold_ = options.threshold !== undefined ? options.threshold : 0.3;
/** /**
* @private * @private
* @type {number} * @type {number}
*/ */
this.duration_ = goog.isDef(options.duration) ? options.duration : 250; this.duration_ = options.duration !== undefined ? options.duration : 250;
}; };
goog.inherits(ol.interaction.PinchRotate, ol.interaction.Pointer); goog.inherits(ol.interaction.PinchRotate, ol.interaction.Pointer);
@@ -88,7 +89,7 @@ ol.interaction.PinchRotate.handleDragEvent_ = function(mapBrowserEvent) {
touch1.clientY - touch0.clientY, touch1.clientY - touch0.clientY,
touch1.clientX - touch0.clientX); touch1.clientX - touch0.clientX);
if (goog.isDef(this.lastAngle_)) { if (this.lastAngle_ !== undefined) {
var delta = angle - this.lastAngle_; var delta = angle - this.lastAngle_;
this.rotationDelta_ += delta; this.rotationDelta_ += delta;
if (!this.rotating_ && if (!this.rotating_ &&
+4 -3
View File
@@ -3,6 +3,7 @@ goog.provide('ol.interaction.PinchZoom');
goog.require('goog.asserts'); goog.require('goog.asserts');
goog.require('goog.functions'); goog.require('goog.functions');
goog.require('goog.style'); goog.require('goog.style');
goog.require('ol');
goog.require('ol.Coordinate'); goog.require('ol.Coordinate');
goog.require('ol.ViewHint'); goog.require('ol.ViewHint');
goog.require('ol.interaction.Interaction'); goog.require('ol.interaction.Interaction');
@@ -28,7 +29,7 @@ ol.interaction.PinchZoom = function(opt_options) {
handleUpEvent: ol.interaction.PinchZoom.handleUpEvent_ handleUpEvent: ol.interaction.PinchZoom.handleUpEvent_
}); });
var options = goog.isDef(opt_options) ? opt_options : {}; var options = opt_options ? opt_options : {};
/** /**
* @private * @private
@@ -40,7 +41,7 @@ ol.interaction.PinchZoom = function(opt_options) {
* @private * @private
* @type {number} * @type {number}
*/ */
this.duration_ = goog.isDef(options.duration) ? options.duration : 400; this.duration_ = options.duration !== undefined ? options.duration : 400;
/** /**
* @private * @private
@@ -76,7 +77,7 @@ ol.interaction.PinchZoom.handleDragEvent_ = function(mapBrowserEvent) {
// distance between touches // distance between touches
var distance = Math.sqrt(dx * dx + dy * dy); var distance = Math.sqrt(dx * dx + dy * dy);
if (goog.isDef(this.lastDistance_)) { if (this.lastDistance_ !== undefined) {
scaleDelta = this.lastDistance_ / distance; scaleDelta = this.lastDistance_ / distance;
} }
this.lastDistance_ = distance; this.lastDistance_ = distance;
+6 -6
View File
@@ -26,9 +26,9 @@ goog.require('ol.interaction.Interaction');
*/ */
ol.interaction.Pointer = function(opt_options) { ol.interaction.Pointer = function(opt_options) {
var options = goog.isDef(opt_options) ? opt_options : {}; var options = opt_options ? opt_options : {};
var handleEvent = goog.isDef(options.handleEvent) ? var handleEvent = options.handleEvent ?
options.handleEvent : ol.interaction.Pointer.handleEvent; options.handleEvent : ol.interaction.Pointer.handleEvent;
goog.base(this, { goog.base(this, {
@@ -39,28 +39,28 @@ ol.interaction.Pointer = function(opt_options) {
* @type {function(ol.MapBrowserPointerEvent):boolean} * @type {function(ol.MapBrowserPointerEvent):boolean}
* @private * @private
*/ */
this.handleDownEvent_ = goog.isDef(options.handleDownEvent) ? this.handleDownEvent_ = options.handleDownEvent ?
options.handleDownEvent : ol.interaction.Pointer.handleDownEvent; options.handleDownEvent : ol.interaction.Pointer.handleDownEvent;
/** /**
* @type {function(ol.MapBrowserPointerEvent)} * @type {function(ol.MapBrowserPointerEvent)}
* @private * @private
*/ */
this.handleDragEvent_ = goog.isDef(options.handleDragEvent) ? this.handleDragEvent_ = options.handleDragEvent ?
options.handleDragEvent : ol.interaction.Pointer.handleDragEvent; options.handleDragEvent : ol.interaction.Pointer.handleDragEvent;
/** /**
* @type {function(ol.MapBrowserPointerEvent)} * @type {function(ol.MapBrowserPointerEvent)}
* @private * @private
*/ */
this.handleMoveEvent_ = goog.isDef(options.handleMoveEvent) ? this.handleMoveEvent_ = options.handleMoveEvent ?
options.handleMoveEvent : ol.interaction.Pointer.handleMoveEvent; options.handleMoveEvent : ol.interaction.Pointer.handleMoveEvent;
/** /**
* @type {function(ol.MapBrowserPointerEvent):boolean} * @type {function(ol.MapBrowserPointerEvent):boolean}
* @private * @private
*/ */
this.handleUpEvent_ = goog.isDef(options.handleUpEvent) ? this.handleUpEvent_ = options.handleUpEvent ?
options.handleUpEvent : ol.interaction.Pointer.handleUpEvent; options.handleUpEvent : ol.interaction.Pointer.handleUpEvent;
/** /**
+9 -9
View File
@@ -105,51 +105,51 @@ ol.interaction.Select = function(opt_options) {
handleEvent: ol.interaction.Select.handleEvent handleEvent: ol.interaction.Select.handleEvent
}); });
var options = goog.isDef(opt_options) ? opt_options : {}; var options = opt_options ? opt_options : {};
/** /**
* @private * @private
* @type {ol.events.ConditionType} * @type {ol.events.ConditionType}
*/ */
this.condition_ = goog.isDef(options.condition) ? this.condition_ = options.condition ?
options.condition : ol.events.condition.singleClick; options.condition : ol.events.condition.singleClick;
/** /**
* @private * @private
* @type {ol.events.ConditionType} * @type {ol.events.ConditionType}
*/ */
this.addCondition_ = goog.isDef(options.addCondition) ? this.addCondition_ = options.addCondition ?
options.addCondition : ol.events.condition.never; options.addCondition : ol.events.condition.never;
/** /**
* @private * @private
* @type {ol.events.ConditionType} * @type {ol.events.ConditionType}
*/ */
this.removeCondition_ = goog.isDef(options.removeCondition) ? this.removeCondition_ = options.removeCondition ?
options.removeCondition : ol.events.condition.never; options.removeCondition : ol.events.condition.never;
/** /**
* @private * @private
* @type {ol.events.ConditionType} * @type {ol.events.ConditionType}
*/ */
this.toggleCondition_ = goog.isDef(options.toggleCondition) ? this.toggleCondition_ = options.toggleCondition ?
options.toggleCondition : ol.events.condition.shiftKeyOnly; options.toggleCondition : ol.events.condition.shiftKeyOnly;
/** /**
* @private * @private
* @type {boolean} * @type {boolean}
*/ */
this.multi_ = goog.isDef(options.multi) ? options.multi : false; this.multi_ = options.multi ? options.multi : false;
/** /**
* @private * @private
* @type {ol.interaction.SelectFilterFunction} * @type {ol.interaction.SelectFilterFunction}
*/ */
this.filter_ = goog.isDef(options.filter) ? options.filter : this.filter_ = options.filter ? options.filter :
goog.functions.TRUE; goog.functions.TRUE;
var layerFilter; var layerFilter;
if (goog.isDef(options.layers)) { if (options.layers) {
if (goog.isFunction(options.layers)) { if (goog.isFunction(options.layers)) {
layerFilter = options.layers; layerFilter = options.layers;
} else { } else {
@@ -183,7 +183,7 @@ ol.interaction.Select = function(opt_options) {
features: options.features, features: options.features,
wrapX: options.wrapX wrapX: options.wrapX
}), }),
style: goog.isDef(options.style) ? options.style : style: options.style ? options.style :
ol.interaction.Select.getDefaultStyleFunction(), ol.interaction.Select.getDefaultStyleFunction(),
updateWhileAnimating: true, updateWhileAnimating: true,
updateWhileInteracting: true updateWhileInteracting: true
+9 -8
View File
@@ -6,6 +6,7 @@ goog.require('goog.asserts');
goog.require('goog.events'); goog.require('goog.events');
goog.require('goog.events.EventType'); goog.require('goog.events.EventType');
goog.require('goog.object'); goog.require('goog.object');
goog.require('ol');
goog.require('ol.Collection'); goog.require('ol.Collection');
goog.require('ol.CollectionEvent'); goog.require('ol.CollectionEvent');
goog.require('ol.CollectionEventType'); goog.require('ol.CollectionEventType');
@@ -54,19 +55,19 @@ ol.interaction.Snap = function(opt_options) {
handleUpEvent: ol.interaction.Snap.handleUpEvent_ handleUpEvent: ol.interaction.Snap.handleUpEvent_
}); });
var options = goog.isDef(opt_options) ? opt_options : {}; var options = opt_options ? opt_options : {};
/** /**
* @type {ol.source.Vector} * @type {ol.source.Vector}
* @private * @private
*/ */
this.source_ = goog.isDef(options.source) ? options.source : null; this.source_ = options.source ? options.source : null;
/** /**
* @type {ol.Collection.<ol.Feature>} * @type {ol.Collection.<ol.Feature>}
* @private * @private
*/ */
this.features_ = goog.isDef(options.features) ? options.features : null; this.features_ = options.features ? options.features : null;
/** /**
* @type {Array.<goog.events.Key>} * @type {Array.<goog.events.Key>}
@@ -114,7 +115,7 @@ ol.interaction.Snap = function(opt_options) {
* @type {number} * @type {number}
* @private * @private
*/ */
this.pixelTolerance_ = goog.isDef(options.pixelTolerance) ? this.pixelTolerance_ = options.pixelTolerance !== undefined ?
options.pixelTolerance : 10; options.pixelTolerance : 10;
/** /**
@@ -159,10 +160,10 @@ goog.inherits(ol.interaction.Snap, ol.interaction.Pointer);
* @api * @api
*/ */
ol.interaction.Snap.prototype.addFeature = function(feature, opt_listen) { ol.interaction.Snap.prototype.addFeature = function(feature, opt_listen) {
var listen = goog.isDef(opt_listen) ? opt_listen : true; var listen = opt_listen !== undefined ? opt_listen : true;
var geometry = feature.getGeometry(); var geometry = feature.getGeometry();
var segmentWriter = this.SEGMENT_WRITERS_[geometry.getType()]; var segmentWriter = this.SEGMENT_WRITERS_[geometry.getType()];
if (goog.isDef(segmentWriter)) { if (segmentWriter) {
var feature_uid = goog.getUid(feature); var feature_uid = goog.getUid(feature);
this.indexedFeaturesExtents_[feature_uid] = geometry.getExtent( this.indexedFeaturesExtents_[feature_uid] = geometry.getExtent(
ol.extent.createEmpty()); ol.extent.createEmpty());
@@ -210,7 +211,7 @@ ol.interaction.Snap.prototype.getFeatures_ = function() {
} else if (!goog.isNull(this.source_)) { } else if (!goog.isNull(this.source_)) {
features = this.source_.getFeatures(); features = this.source_.getFeatures();
} }
goog.asserts.assert(goog.isDef(features), 'features should be defined'); goog.asserts.assert(features !== undefined, 'features should be defined');
return features; return features;
}; };
@@ -286,7 +287,7 @@ ol.interaction.Snap.prototype.handleGeometryModify_ = function(feature, evt) {
* @api * @api
*/ */
ol.interaction.Snap.prototype.removeFeature = function(feature, opt_unlisten) { ol.interaction.Snap.prototype.removeFeature = function(feature, opt_unlisten) {
var unlisten = goog.isDef(opt_unlisten) ? opt_unlisten : true; var unlisten = opt_unlisten !== undefined ? opt_unlisten : true;
var feature_uid = goog.getUid(feature); var feature_uid = goog.getUid(feature);
var extent = this.indexedFeaturesExtents_[feature_uid]; var extent = this.indexedFeaturesExtents_[feature_uid];
if (extent) { if (extent) {
+2 -2
View File
@@ -42,7 +42,7 @@ ol.interaction.Translate = function(options) {
* @type {ol.Collection.<ol.Feature>} * @type {ol.Collection.<ol.Feature>}
* @private * @private
*/ */
this.features_ = goog.isDef(options.features) ? options.features : null; this.features_ = options.features !== undefined ? options.features : null;
/** /**
* @type {ol.Feature} * @type {ol.Feature}
@@ -147,7 +147,7 @@ ol.interaction.Translate.handleMoveEvent_ = function(event)
'grabbing' : (isSelected ? 'grab' : 'pointer'); 'grabbing' : (isSelected ? 'grab' : 'pointer');
} else { } else {
elem.style.cursor = goog.isDef(this.previousCursor_) ? elem.style.cursor = this.previousCursor_ !== undefined ?
this.previousCursor_ : ''; this.previousCursor_ : '';
this.previousCursor_ = undefined; this.previousCursor_ = undefined;
} }
+14 -10
View File
@@ -4,6 +4,7 @@ goog.require('goog.asserts');
goog.require('goog.events'); goog.require('goog.events');
goog.require('goog.math'); goog.require('goog.math');
goog.require('goog.object'); goog.require('goog.object');
goog.require('ol');
goog.require('ol.Object'); goog.require('ol.Object');
goog.require('ol.dom'); goog.require('ol.dom');
goog.require('ol.layer.Vector'); goog.require('ol.layer.Vector');
@@ -37,7 +38,7 @@ ol.layer.HeatmapLayerProperty = {
* @api * @api
*/ */
ol.layer.Heatmap = function(opt_options) { ol.layer.Heatmap = function(opt_options) {
var options = goog.isDef(opt_options) ? opt_options : {}; var options = opt_options ? opt_options : {};
var baseOptions = goog.object.clone(options); var baseOptions = goog.object.clone(options);
@@ -58,7 +59,7 @@ ol.layer.Heatmap = function(opt_options) {
* @private * @private
* @type {number} * @type {number}
*/ */
this.shadow_ = goog.isDef(options.shadow) ? options.shadow : 250; this.shadow_ = options.shadow !== undefined ? options.shadow : 250;
/** /**
* @private * @private
@@ -76,12 +77,14 @@ ol.layer.Heatmap = function(opt_options) {
ol.Object.getChangeEventType(ol.layer.HeatmapLayerProperty.GRADIENT), ol.Object.getChangeEventType(ol.layer.HeatmapLayerProperty.GRADIENT),
this.handleGradientChanged_, false, this); this.handleGradientChanged_, false, this);
this.setGradient(goog.isDef(options.gradient) ? this.setGradient(options.gradient ?
options.gradient : ol.layer.Heatmap.DEFAULT_GRADIENT); options.gradient : ol.layer.Heatmap.DEFAULT_GRADIENT);
this.setBlur(goog.isDef(options.blur) ? options.blur : 15); this.setBlur(options.blur !== undefined ?
/** @type {number} */ (options.blur) : 15);
this.setRadius(goog.isDef(options.radius) ? options.radius : 8); this.setRadius(options.radius !== undefined ?
/** @type {number} */ (options.radius) : 8);
goog.events.listen(this, [ goog.events.listen(this, [
ol.Object.getChangeEventType(ol.layer.HeatmapLayerProperty.BLUR), ol.Object.getChangeEventType(ol.layer.HeatmapLayerProperty.BLUR),
@@ -90,7 +93,7 @@ ol.layer.Heatmap = function(opt_options) {
this.handleStyleChanged_(); this.handleStyleChanged_();
var weight = goog.isDef(options.weight) ? options.weight : 'weight'; var weight = options.weight ? options.weight : 'weight';
var weightFunction; var weightFunction;
if (goog.isString(weight)) { if (goog.isString(weight)) {
weightFunction = function(feature) { weightFunction = function(feature) {
@@ -105,14 +108,15 @@ ol.layer.Heatmap = function(opt_options) {
this.setStyle(goog.bind(function(feature, resolution) { this.setStyle(goog.bind(function(feature, resolution) {
goog.asserts.assert(!goog.isNull(this.styleCache_), goog.asserts.assert(!goog.isNull(this.styleCache_),
'this.styleCache_ should not be null'); 'this.styleCache_ should not be null');
goog.asserts.assert(goog.isDef(this.circleImage_), goog.asserts.assert(this.circleImage_ !== undefined,
'this.circleImage_ should be defined'); 'this.circleImage_ should be defined');
var weight = weightFunction(feature); var weight = weightFunction(feature);
var opacity = goog.isDef(weight) ? goog.math.clamp(weight, 0, 1) : 1; var opacity = weight !== undefined ?
goog.math.clamp(weight, 0, 1) : 1;
// cast to 8 bits // cast to 8 bits
var index = (255 * opacity) | 0; var index = (255 * opacity) | 0;
var style = this.styleCache_[index]; var style = this.styleCache_[index];
if (!goog.isDef(style)) { if (!style) {
style = [ style = [
new ol.style.Style({ new ol.style.Style({
image: new ol.style.Icon({ image: new ol.style.Icon({
@@ -174,7 +178,7 @@ ol.layer.Heatmap.createGradient_ = function(colors) {
ol.layer.Heatmap.prototype.createCircle_ = function() { ol.layer.Heatmap.prototype.createCircle_ = function() {
var radius = this.getRadius(); var radius = this.getRadius();
var blur = this.getBlur(); var blur = this.getBlur();
goog.asserts.assert(goog.isDef(radius) && goog.isDef(blur), goog.asserts.assert(radius !== undefined && blur !== undefined,
'radius and blur should be defined'); 'radius and blur should be defined');
var halfSize = radius + blur + 1; var halfSize = radius + blur + 1;
var size = 2 * halfSize; var size = 2 * halfSize;
+1 -1
View File
@@ -19,7 +19,7 @@ goog.require('ol.layer.Layer');
* @api stable * @api stable
*/ */
ol.layer.Image = function(opt_options) { ol.layer.Image = function(opt_options) {
var options = goog.isDef(opt_options) ? opt_options : {}; var options = opt_options ? opt_options : {};
goog.base(this, /** @type {olx.layer.LayerOptions} */ (options)); goog.base(this, /** @type {olx.layer.LayerOptions} */ (options));
}; };
goog.inherits(ol.layer.Image, ol.layer.Layer); goog.inherits(ol.layer.Image, ol.layer.Layer);
+6 -6
View File
@@ -3,6 +3,7 @@ goog.provide('ol.layer.Layer');
goog.require('goog.events'); goog.require('goog.events');
goog.require('goog.events.EventType'); goog.require('goog.events.EventType');
goog.require('goog.object'); goog.require('goog.object');
goog.require('ol');
goog.require('ol.Object'); goog.require('ol.Object');
goog.require('ol.layer.Base'); goog.require('ol.layer.Base');
goog.require('ol.layer.LayerProperty'); goog.require('ol.layer.LayerProperty');
@@ -52,7 +53,7 @@ ol.layer.Layer = function(options) {
*/ */
this.sourceChangeKey_ = null; this.sourceChangeKey_ = null;
if (goog.isDef(options.map)) { if (options.map) {
this.setMap(options.map); this.setMap(options.map);
} }
@@ -60,7 +61,7 @@ ol.layer.Layer = function(options) {
ol.Object.getChangeEventType(ol.layer.LayerProperty.SOURCE), ol.Object.getChangeEventType(ol.layer.LayerProperty.SOURCE),
this.handleSourcePropertyChange_, false, this); this.handleSourcePropertyChange_, false, this);
var source = goog.isDef(options.source) ? options.source : null; var source = options.source ? options.source : null;
this.setSource(source); this.setSource(source);
}; };
goog.inherits(ol.layer.Layer, ol.layer.Base); goog.inherits(ol.layer.Layer, ol.layer.Base);
@@ -84,7 +85,7 @@ ol.layer.Layer.visibleAtResolution = function(layerState, resolution) {
* @inheritDoc * @inheritDoc
*/ */
ol.layer.Layer.prototype.getLayersArray = function(opt_array) { ol.layer.Layer.prototype.getLayersArray = function(opt_array) {
var array = goog.isDef(opt_array) ? opt_array : []; var array = opt_array ? opt_array : [];
array.push(this); array.push(this);
return array; return array;
}; };
@@ -94,7 +95,7 @@ ol.layer.Layer.prototype.getLayersArray = function(opt_array) {
* @inheritDoc * @inheritDoc
*/ */
ol.layer.Layer.prototype.getLayerStatesArray = function(opt_states) { ol.layer.Layer.prototype.getLayerStatesArray = function(opt_states) {
var states = goog.isDef(opt_states) ? opt_states : []; var states = opt_states ? opt_states : [];
states.push(this.getLayerState()); states.push(this.getLayerState());
return states; return states;
}; };
@@ -108,8 +109,7 @@ ol.layer.Layer.prototype.getLayerStatesArray = function(opt_states) {
*/ */
ol.layer.Layer.prototype.getSource = function() { ol.layer.Layer.prototype.getSource = function() {
var source = this.get(ol.layer.LayerProperty.SOURCE); var source = this.get(ol.layer.LayerProperty.SOURCE);
return goog.isDef(source) ? return /** @type {ol.source.Source} */ (source) || null;
/** @type {ol.source.Source} */ (source) : null;
}; };
+10 -9
View File
@@ -4,6 +4,7 @@ goog.provide('ol.layer.LayerState');
goog.require('goog.math'); goog.require('goog.math');
goog.require('goog.object'); goog.require('goog.object');
goog.require('ol');
goog.require('ol.Object'); goog.require('ol.Object');
goog.require('ol.source.State'); goog.require('ol.source.State');
@@ -67,23 +68,23 @@ ol.layer.Base = function(options) {
*/ */
var properties = goog.object.clone(options); var properties = goog.object.clone(options);
properties[ol.layer.LayerProperty.BRIGHTNESS] = properties[ol.layer.LayerProperty.BRIGHTNESS] =
goog.isDef(options.brightness) ? options.brightness : 0; options.brightness !== undefined ? options.brightness : 0;
properties[ol.layer.LayerProperty.CONTRAST] = properties[ol.layer.LayerProperty.CONTRAST] =
goog.isDef(options.contrast) ? options.contrast : 1; options.contrast !== undefined ? options.contrast : 1;
properties[ol.layer.LayerProperty.HUE] = properties[ol.layer.LayerProperty.HUE] =
goog.isDef(options.hue) ? options.hue : 0; options.hue !== undefined ? options.hue : 0;
properties[ol.layer.LayerProperty.OPACITY] = properties[ol.layer.LayerProperty.OPACITY] =
goog.isDef(options.opacity) ? options.opacity : 1; options.opacity !== undefined ? options.opacity : 1;
properties[ol.layer.LayerProperty.SATURATION] = properties[ol.layer.LayerProperty.SATURATION] =
goog.isDef(options.saturation) ? options.saturation : 1; options.saturation !== undefined ? options.saturation : 1;
properties[ol.layer.LayerProperty.VISIBLE] = properties[ol.layer.LayerProperty.VISIBLE] =
goog.isDef(options.visible) ? options.visible : true; options.visible !== undefined ? options.visible : true;
properties[ol.layer.LayerProperty.Z_INDEX] = properties[ol.layer.LayerProperty.Z_INDEX] =
goog.isDef(options.zIndex) ? options.zIndex : 0; options.zIndex !== undefined ? options.zIndex : 0;
properties[ol.layer.LayerProperty.MAX_RESOLUTION] = properties[ol.layer.LayerProperty.MAX_RESOLUTION] =
goog.isDef(options.maxResolution) ? options.maxResolution : Infinity; options.maxResolution !== undefined ? options.maxResolution : Infinity;
properties[ol.layer.LayerProperty.MIN_RESOLUTION] = properties[ol.layer.LayerProperty.MIN_RESOLUTION] =
goog.isDef(options.minResolution) ? options.minResolution : 0; options.minResolution !== undefined ? options.minResolution : 0;
this.setProperties(properties); this.setProperties(properties);
}; };
+5 -5
View File
@@ -38,7 +38,7 @@ ol.layer.GroupProperty = {
*/ */
ol.layer.Group = function(opt_options) { ol.layer.Group = function(opt_options) {
var options = goog.isDef(opt_options) ? opt_options : {}; var options = opt_options || {};
var baseOptions = /** @type {olx.layer.GroupOptions} */ var baseOptions = /** @type {olx.layer.GroupOptions} */
(goog.object.clone(options)); (goog.object.clone(options));
delete baseOptions.layers; delete baseOptions.layers;
@@ -191,7 +191,7 @@ ol.layer.Group.prototype.setLayers = function(layers) {
* @inheritDoc * @inheritDoc
*/ */
ol.layer.Group.prototype.getLayersArray = function(opt_array) { ol.layer.Group.prototype.getLayersArray = function(opt_array) {
var array = goog.isDef(opt_array) ? opt_array : []; var array = opt_array !== undefined ? opt_array : [];
this.getLayers().forEach(function(layer) { this.getLayers().forEach(function(layer) {
layer.getLayersArray(array); layer.getLayersArray(array);
}); });
@@ -203,7 +203,7 @@ ol.layer.Group.prototype.getLayersArray = function(opt_array) {
* @inheritDoc * @inheritDoc
*/ */
ol.layer.Group.prototype.getLayerStatesArray = function(opt_states) { ol.layer.Group.prototype.getLayerStatesArray = function(opt_states) {
var states = goog.isDef(opt_states) ? opt_states : []; var states = opt_states !== undefined ? opt_states : [];
var pos = states.length; var pos = states.length;
@@ -226,8 +226,8 @@ ol.layer.Group.prototype.getLayerStatesArray = function(opt_states) {
layerState.maxResolution, ownLayerState.maxResolution); layerState.maxResolution, ownLayerState.maxResolution);
layerState.minResolution = Math.max( layerState.minResolution = Math.max(
layerState.minResolution, ownLayerState.minResolution); layerState.minResolution, ownLayerState.minResolution);
if (goog.isDef(ownLayerState.extent)) { if (ownLayerState.extent !== undefined) {
if (goog.isDef(layerState.extent)) { if (layerState.extent !== undefined) {
layerState.extent = ol.extent.getIntersection( layerState.extent = ol.extent.getIntersection(
layerState.extent, ownLayerState.extent); layerState.extent, ownLayerState.extent);
} else { } else {
+4 -3
View File
@@ -1,6 +1,7 @@
goog.provide('ol.layer.Tile'); goog.provide('ol.layer.Tile');
goog.require('goog.object'); goog.require('goog.object');
goog.require('ol');
goog.require('ol.layer.Layer'); goog.require('ol.layer.Layer');
@@ -29,7 +30,7 @@ ol.layer.TileProperty = {
* @api stable * @api stable
*/ */
ol.layer.Tile = function(opt_options) { ol.layer.Tile = function(opt_options) {
var options = goog.isDef(opt_options) ? opt_options : {}; var options = opt_options ? opt_options : {};
var baseOptions = goog.object.clone(options); var baseOptions = goog.object.clone(options);
@@ -37,8 +38,8 @@ ol.layer.Tile = function(opt_options) {
delete baseOptions.useInterimTilesOnError; delete baseOptions.useInterimTilesOnError;
goog.base(this, /** @type {olx.layer.LayerOptions} */ (baseOptions)); goog.base(this, /** @type {olx.layer.LayerOptions} */ (baseOptions));
this.setPreload(goog.isDef(options.preload) ? options.preload : 0); this.setPreload(options.preload !== undefined ? options.preload : 0);
this.setUseInterimTilesOnError(goog.isDef(options.useInterimTilesOnError) ? this.setUseInterimTilesOnError(options.useInterimTilesOnError !== undefined ?
options.useInterimTilesOnError : true); options.useInterimTilesOnError : true);
}; };
goog.inherits(ol.layer.Tile, ol.layer.Layer); goog.inherits(ol.layer.Tile, ol.layer.Layer);
+9 -8
View File
@@ -2,6 +2,7 @@ goog.provide('ol.layer.Vector');
goog.require('goog.asserts'); goog.require('goog.asserts');
goog.require('goog.object'); goog.require('goog.object');
goog.require('ol');
goog.require('ol.layer.Layer'); goog.require('ol.layer.Layer');
goog.require('ol.style.Style'); goog.require('ol.style.Style');
@@ -30,11 +31,11 @@ ol.layer.VectorProperty = {
*/ */
ol.layer.Vector = function(opt_options) { ol.layer.Vector = function(opt_options) {
var options = goog.isDef(opt_options) ? var options = opt_options ?
opt_options : /** @type {olx.layer.VectorOptions} */ ({}); opt_options : /** @type {olx.layer.VectorOptions} */ ({});
goog.asserts.assert( goog.asserts.assert(
!goog.isDef(options.renderOrder) || goog.isNull(options.renderOrder) || options.renderOrder === undefined || goog.isNull(options.renderOrder) ||
goog.isFunction(options.renderOrder), goog.isFunction(options.renderOrder),
'renderOrder must be a comparator function'); 'renderOrder must be a comparator function');
@@ -50,7 +51,7 @@ ol.layer.Vector = function(opt_options) {
* @type {number} * @type {number}
* @private * @private
*/ */
this.renderBuffer_ = goog.isDef(options.renderBuffer) ? this.renderBuffer_ = options.renderBuffer !== undefined ?
options.renderBuffer : 100; options.renderBuffer : 100;
/** /**
@@ -73,14 +74,14 @@ ol.layer.Vector = function(opt_options) {
* @type {boolean} * @type {boolean}
* @private * @private
*/ */
this.updateWhileAnimating_ = goog.isDef(options.updateWhileAnimating) ? this.updateWhileAnimating_ = options.updateWhileAnimating !== undefined ?
options.updateWhileAnimating : false; options.updateWhileAnimating : false;
/** /**
* @type {boolean} * @type {boolean}
* @private * @private
*/ */
this.updateWhileInteracting_ = goog.isDef(options.updateWhileInteracting) ? this.updateWhileInteracting_ = options.updateWhileInteracting !== undefined ?
options.updateWhileInteracting : false; options.updateWhileInteracting : false;
}; };
@@ -160,7 +161,7 @@ ol.layer.Vector.prototype.getUpdateWhileInteracting = function() {
*/ */
ol.layer.Vector.prototype.setRenderOrder = function(renderOrder) { ol.layer.Vector.prototype.setRenderOrder = function(renderOrder) {
goog.asserts.assert( goog.asserts.assert(
!goog.isDef(renderOrder) || goog.isNull(renderOrder) || renderOrder === undefined || goog.isNull(renderOrder) ||
goog.isFunction(renderOrder), goog.isFunction(renderOrder),
'renderOrder must be a comparator function'); 'renderOrder must be a comparator function');
this.set(ol.layer.VectorProperty.RENDER_ORDER, renderOrder); this.set(ol.layer.VectorProperty.RENDER_ORDER, renderOrder);
@@ -174,12 +175,12 @@ ol.layer.Vector.prototype.setRenderOrder = function(renderOrder) {
* it is `null` the layer has no style (a `null` style), so only features * it is `null` the layer has no style (a `null` style), so only features
* that have their own styles will be rendered in the layer. See * that have their own styles will be rendered in the layer. See
* {@link ol.style} for information on the default style. * {@link ol.style} for information on the default style.
* @param {ol.style.Style|Array.<ol.style.Style>|ol.style.StyleFunction|undefined} * @param {ol.style.Style|Array.<ol.style.Style>|ol.style.StyleFunction|null|undefined}
* style Layer style. * style Layer style.
* @api stable * @api stable
*/ */
ol.layer.Vector.prototype.setStyle = function(style) { ol.layer.Vector.prototype.setStyle = function(style) {
this.style_ = goog.isDef(style) ? style : ol.style.defaultStyleFunction; this.style_ = style !== undefined ? style : ol.style.defaultStyleFunction;
this.styleFunction_ = goog.isNull(style) ? this.styleFunction_ = goog.isNull(style) ?
undefined : ol.style.createStyleFunction(this.style_); undefined : ol.style.createStyleFunction(this.style_);
this.changed(); this.changed();
+32 -41
View File
@@ -181,22 +181,23 @@ ol.Map = function(options) {
* @type {boolean} * @type {boolean}
* @private * @private
*/ */
this.loadTilesWhileAnimating_ = goog.isDef(options.loadTilesWhileAnimating) ? this.loadTilesWhileAnimating_ =
options.loadTilesWhileAnimating : false; options.loadTilesWhileAnimating !== undefined ?
options.loadTilesWhileAnimating : false;
/** /**
* @type {boolean} * @type {boolean}
* @private * @private
*/ */
this.loadTilesWhileInteracting_ = this.loadTilesWhileInteracting_ =
goog.isDef(options.loadTilesWhileInteracting) ? options.loadTilesWhileInteracting !== undefined ?
options.loadTilesWhileInteracting : false; options.loadTilesWhileInteracting : false;
/** /**
* @private * @private
* @type {number} * @type {number}
*/ */
this.pixelRatio_ = goog.isDef(options.pixelRatio) ? this.pixelRatio_ = options.pixelRatio !== undefined ?
options.pixelRatio : ol.has.DEVICE_PIXEL_RATIO; options.pixelRatio : ol.has.DEVICE_PIXEL_RATIO;
/** /**
@@ -496,7 +497,7 @@ goog.inherits(ol.Map, ol.Object);
*/ */
ol.Map.prototype.addControl = function(control) { ol.Map.prototype.addControl = function(control) {
var controls = this.getControls(); var controls = this.getControls();
goog.asserts.assert(goog.isDef(controls), 'controls should be defined'); goog.asserts.assert(controls !== undefined, 'controls should be defined');
controls.push(control); controls.push(control);
}; };
@@ -508,7 +509,7 @@ ol.Map.prototype.addControl = function(control) {
*/ */
ol.Map.prototype.addInteraction = function(interaction) { ol.Map.prototype.addInteraction = function(interaction) {
var interactions = this.getInteractions(); var interactions = this.getInteractions();
goog.asserts.assert(goog.isDef(interactions), goog.asserts.assert(interactions !== undefined,
'interactions should be defined'); 'interactions should be defined');
interactions.push(interaction); interactions.push(interaction);
}; };
@@ -534,7 +535,7 @@ ol.Map.prototype.addLayer = function(layer) {
*/ */
ol.Map.prototype.addOverlay = function(overlay) { ol.Map.prototype.addOverlay = function(overlay) {
var overlays = this.getOverlays(); var overlays = this.getOverlays();
goog.asserts.assert(goog.isDef(overlays), 'overlays should be defined'); goog.asserts.assert(overlays !== undefined, 'overlays should be defined');
overlays.push(overlay); overlays.push(overlay);
}; };
@@ -600,10 +601,10 @@ ol.Map.prototype.forEachFeatureAtPixel =
return; return;
} }
var coordinate = this.getCoordinateFromPixel(pixel); var coordinate = this.getCoordinateFromPixel(pixel);
var thisArg = goog.isDef(opt_this) ? opt_this : null; var thisArg = opt_this !== undefined ? opt_this : null;
var layerFilter = goog.isDef(opt_layerFilter) ? var layerFilter = opt_layerFilter !== undefined ?
opt_layerFilter : goog.functions.TRUE; opt_layerFilter : goog.functions.TRUE;
var thisArg2 = goog.isDef(opt_this2) ? opt_this2 : null; var thisArg2 = opt_this2 !== undefined ? opt_this2 : null;
return this.renderer_.forEachFeatureAtCoordinate( return this.renderer_.forEachFeatureAtCoordinate(
coordinate, this.frameState_, callback, thisArg, coordinate, this.frameState_, callback, thisArg,
layerFilter, thisArg2); layerFilter, thisArg2);
@@ -637,10 +638,10 @@ ol.Map.prototype.forEachLayerAtPixel =
if (goog.isNull(this.frameState_)) { if (goog.isNull(this.frameState_)) {
return; return;
} }
var thisArg = goog.isDef(opt_this) ? opt_this : null; var thisArg = opt_this !== undefined ? opt_this : null;
var layerFilter = goog.isDef(opt_layerFilter) ? var layerFilter = opt_layerFilter !== undefined ?
opt_layerFilter : goog.functions.TRUE; opt_layerFilter : goog.functions.TRUE;
var thisArg2 = goog.isDef(opt_this2) ? opt_this2 : null; var thisArg2 = opt_this2 !== undefined ? opt_this2 : null;
return this.renderer_.forEachLayerAtPixel( return this.renderer_.forEachLayerAtPixel(
pixel, this.frameState_, callback, thisArg, pixel, this.frameState_, callback, thisArg,
layerFilter, thisArg2); layerFilter, thisArg2);
@@ -668,9 +669,9 @@ ol.Map.prototype.hasFeatureAtPixel =
return false; return false;
} }
var coordinate = this.getCoordinateFromPixel(pixel); var coordinate = this.getCoordinateFromPixel(pixel);
var layerFilter = goog.isDef(opt_layerFilter) ? var layerFilter = opt_layerFilter !== undefined ?
opt_layerFilter : goog.functions.TRUE; opt_layerFilter : goog.functions.TRUE;
var thisArg = goog.isDef(opt_this) ? opt_this : null; var thisArg = opt_this !== undefined ? opt_this : null;
return this.renderer_.hasFeatureAtCoordinate( return this.renderer_.hasFeatureAtCoordinate(
coordinate, this.frameState_, layerFilter, thisArg); coordinate, this.frameState_, layerFilter, thisArg);
}; };
@@ -723,7 +724,7 @@ ol.Map.prototype.getTarget = function() {
*/ */
ol.Map.prototype.getTargetElement = function() { ol.Map.prototype.getTargetElement = function() {
var target = this.getTarget(); var target = this.getTarget();
return goog.isDef(target) ? goog.dom.getElement(target) : null; return target !== undefined ? goog.dom.getElement(target) : null;
}; };
@@ -941,7 +942,7 @@ ol.Map.prototype.handleMapBrowserEvent = function(mapBrowserEvent) {
this.focus_ = mapBrowserEvent.coordinate; this.focus_ = mapBrowserEvent.coordinate;
mapBrowserEvent.frameState = this.frameState_; mapBrowserEvent.frameState = this.frameState_;
var interactions = this.getInteractions(); var interactions = this.getInteractions();
goog.asserts.assert(goog.isDef(interactions), goog.asserts.assert(interactions !== undefined,
'interactions should be defined'); 'interactions should be defined');
var interactionsArray = interactions.getArray(); var interactionsArray = interactions.getArray();
var i; var i;
@@ -1199,11 +1200,8 @@ ol.Map.prototype.render = function() {
*/ */
ol.Map.prototype.removeControl = function(control) { ol.Map.prototype.removeControl = function(control) {
var controls = this.getControls(); var controls = this.getControls();
goog.asserts.assert(goog.isDef(controls), 'controls should be defined'); goog.asserts.assert(controls !== undefined, 'controls should be defined');
if (goog.isDef(controls.remove(control))) { return controls.remove(control);
return control;
}
return undefined;
}; };
@@ -1215,14 +1213,10 @@ ol.Map.prototype.removeControl = function(control) {
* @api stable * @api stable
*/ */
ol.Map.prototype.removeInteraction = function(interaction) { ol.Map.prototype.removeInteraction = function(interaction) {
var removed;
var interactions = this.getInteractions(); var interactions = this.getInteractions();
goog.asserts.assert(goog.isDef(interactions), goog.asserts.assert(interactions !== undefined,
'interactions should be defined'); 'interactions should be defined');
if (goog.isDef(interactions.remove(interaction))) { return interactions.remove(interaction);
removed = interaction;
}
return removed;
}; };
@@ -1248,11 +1242,8 @@ ol.Map.prototype.removeLayer = function(layer) {
*/ */
ol.Map.prototype.removeOverlay = function(overlay) { ol.Map.prototype.removeOverlay = function(overlay) {
var overlays = this.getOverlays(); var overlays = this.getOverlays();
goog.asserts.assert(goog.isDef(overlays), 'overlays should be defined'); goog.asserts.assert(overlays !== undefined, 'overlays should be defined');
if (goog.isDef(overlays.remove(overlay))) { return overlays.remove(overlay);
return overlay;
}
return undefined;
}; };
@@ -1268,7 +1259,7 @@ ol.Map.prototype.renderFrame_ = function(time) {
var view = this.getView(); var view = this.getView();
/** @type {?olx.FrameState} */ /** @type {?olx.FrameState} */
var frameState = null; var frameState = null;
if (goog.isDef(size) && ol.size.hasArea(size) && if (size !== undefined && ol.size.hasArea(size) &&
!goog.isNull(view) && view.isDef()) { !goog.isNull(view) && view.isDef()) {
var viewHints = view.getHints(); var viewHints = view.getHints();
var layerStatesArray = this.getLayerGroup().getLayerStatesArray(); var layerStatesArray = this.getLayerGroup().getLayerStatesArray();
@@ -1452,7 +1443,7 @@ ol.Map.createOptionsInternal = function(options) {
* @type {Element|Document} * @type {Element|Document}
*/ */
var keyboardEventTarget = null; var keyboardEventTarget = null;
if (goog.isDef(options.keyboardEventTarget)) { if (options.keyboardEventTarget !== undefined) {
// cannot use goog.dom.getElement because its argument cannot be // cannot use goog.dom.getElement because its argument cannot be
// of type Document // of type Document
keyboardEventTarget = goog.isString(options.keyboardEventTarget) ? keyboardEventTarget = goog.isString(options.keyboardEventTarget) ?
@@ -1466,7 +1457,7 @@ ol.Map.createOptionsInternal = function(options) {
var values = {}; var values = {};
var logos = {}; var logos = {};
if (!goog.isDef(options.logo) || if (options.logo === undefined ||
(goog.isBoolean(options.logo) && options.logo)) { (goog.isBoolean(options.logo) && options.logo)) {
logos[ol.OL3_LOGO_URL] = ol.OL3_URL; logos[ol.OL3_LOGO_URL] = ol.OL3_URL;
} else { } else {
@@ -1486,7 +1477,7 @@ ol.Map.createOptionsInternal = function(options) {
values[ol.MapProperty.TARGET] = options.target; values[ol.MapProperty.TARGET] = options.target;
values[ol.MapProperty.VIEW] = goog.isDef(options.view) ? values[ol.MapProperty.VIEW] = options.view !== undefined ?
options.view : new ol.View(); options.view : new ol.View();
/** /**
@@ -1498,7 +1489,7 @@ ol.Map.createOptionsInternal = function(options) {
* @type {Array.<ol.RendererType>} * @type {Array.<ol.RendererType>}
*/ */
var rendererTypes; var rendererTypes;
if (goog.isDef(options.renderer)) { if (options.renderer !== undefined) {
if (goog.isArray(options.renderer)) { if (goog.isArray(options.renderer)) {
rendererTypes = options.renderer; rendererTypes = options.renderer;
} else if (goog.isString(options.renderer)) { } else if (goog.isString(options.renderer)) {
@@ -1533,7 +1524,7 @@ ol.Map.createOptionsInternal = function(options) {
} }
var controls; var controls;
if (goog.isDef(options.controls)) { if (options.controls !== undefined) {
if (goog.isArray(options.controls)) { if (goog.isArray(options.controls)) {
controls = new ol.Collection(options.controls.slice()); controls = new ol.Collection(options.controls.slice());
} else { } else {
@@ -1546,7 +1537,7 @@ ol.Map.createOptionsInternal = function(options) {
} }
var interactions; var interactions;
if (goog.isDef(options.interactions)) { if (options.interactions !== undefined) {
if (goog.isArray(options.interactions)) { if (goog.isArray(options.interactions)) {
interactions = new ol.Collection(options.interactions.slice()); interactions = new ol.Collection(options.interactions.slice());
} else { } else {
@@ -1559,7 +1550,7 @@ ol.Map.createOptionsInternal = function(options) {
} }
var overlays; var overlays;
if (goog.isDef(options.overlays)) { if (options.overlays !== undefined) {
if (goog.isArray(options.overlays)) { if (goog.isArray(options.overlays)) {
overlays = new ol.Collection(options.overlays.slice()); overlays = new ol.Collection(options.overlays.slice());
} else { } else {
+1 -1
View File
@@ -73,7 +73,7 @@ ol.MapBrowserEvent = function(type, map, browserEvent, opt_dragging,
* @type {boolean} * @type {boolean}
* @api stable * @api stable
*/ */
this.dragging = goog.isDef(opt_dragging) ? opt_dragging : false; this.dragging = opt_dragging !== undefined ? opt_dragging : false;
}; };
goog.inherits(ol.MapBrowserEvent, ol.MapEvent); goog.inherits(ol.MapBrowserEvent, ol.MapEvent);
+1 -1
View File
@@ -55,7 +55,7 @@ ol.MapEvent = function(type, map, opt_frameState) {
* @type {?olx.FrameState} * @type {?olx.FrameState}
* @api * @api
*/ */
this.frameState = goog.isDef(opt_frameState) ? opt_frameState : null; this.frameState = opt_frameState !== undefined ? opt_frameState : null;
}; };
goog.inherits(ol.MapEvent, goog.events.Event); goog.inherits(ol.MapEvent, goog.events.Event);
+1 -1
View File
@@ -116,7 +116,7 @@ ol.Object = function(opt_values) {
*/ */
this.values_ = {}; this.values_ = {};
if (goog.isDef(opt_values)) { if (opt_values !== undefined) {
this.setProperties(opt_values); this.setProperties(opt_values);
} }
}; };
+16 -16
View File
@@ -78,14 +78,14 @@ ol.Overlay = function(options) {
* @private * @private
* @type {boolean} * @type {boolean}
*/ */
this.insertFirst_ = goog.isDef(options.insertFirst) ? this.insertFirst_ = options.insertFirst !== undefined ?
options.insertFirst : true; options.insertFirst : true;
/** /**
* @private * @private
* @type {boolean} * @type {boolean}
*/ */
this.stopEvent_ = goog.isDef(options.stopEvent) ? options.stopEvent : true; this.stopEvent_ = options.stopEvent !== undefined ? options.stopEvent : true;
/** /**
* @private * @private
@@ -100,20 +100,20 @@ ol.Overlay = function(options) {
* @protected * @protected
* @type {boolean} * @type {boolean}
*/ */
this.autoPan = goog.isDef(options.autoPan) ? options.autoPan : false; this.autoPan = options.autoPan !== undefined ? options.autoPan : false;
/** /**
* @private * @private
* @type {olx.animation.PanOptions} * @type {olx.animation.PanOptions}
*/ */
this.autoPanAnimation_ = goog.isDef(options.autoPanAnimation) ? this.autoPanAnimation_ = options.autoPanAnimation !== undefined ?
options.autoPanAnimation : /** @type {olx.animation.PanOptions} */ ({}); options.autoPanAnimation : /** @type {olx.animation.PanOptions} */ ({});
/** /**
* @private * @private
* @type {number} * @type {number}
*/ */
this.autoPanMargin_ = goog.isDef(options.autoPanMargin) ? this.autoPanMargin_ = options.autoPanMargin !== undefined ?
options.autoPanMargin : 20; options.autoPanMargin : 20;
/** /**
@@ -158,17 +158,17 @@ ol.Overlay = function(options) {
this, ol.Object.getChangeEventType(ol.OverlayProperty.POSITIONING), this, ol.Object.getChangeEventType(ol.OverlayProperty.POSITIONING),
this.handlePositioningChanged, false, this); this.handlePositioningChanged, false, this);
if (goog.isDef(options.element)) { if (options.element !== undefined) {
this.setElement(options.element); this.setElement(options.element);
} }
this.setOffset(goog.isDef(options.offset) ? options.offset : [0, 0]); this.setOffset(options.offset !== undefined ? options.offset : [0, 0]);
this.setPositioning(goog.isDef(options.positioning) ? this.setPositioning(options.positioning !== undefined ?
/** @type {ol.OverlayPositioning} */ (options.positioning) : /** @type {ol.OverlayPositioning} */ (options.positioning) :
ol.OverlayPositioning.TOP_LEFT); ol.OverlayPositioning.TOP_LEFT);
if (goog.isDef(options.position)) { if (options.position !== undefined) {
this.setPosition(options.position); this.setPosition(options.position);
} }
@@ -297,7 +297,7 @@ ol.Overlay.prototype.handleOffsetChanged = function() {
*/ */
ol.Overlay.prototype.handlePositionChanged = function() { ol.Overlay.prototype.handlePositionChanged = function() {
this.updatePixelPosition(); this.updatePixelPosition();
if (goog.isDef(this.get(ol.OverlayProperty.POSITION)) && this.autoPan) { if (this.get(ol.OverlayProperty.POSITION) !== undefined && this.autoPan) {
this.panIntoView_(); this.panIntoView_();
} }
}; };
@@ -366,7 +366,7 @@ ol.Overlay.prototype.panIntoView_ = function() {
goog.asserts.assert(this.autoPan, 'this.autoPan should be true'); goog.asserts.assert(this.autoPan, 'this.autoPan should be true');
var map = this.getMap(); var map = this.getMap();
if (!goog.isDef(map) || goog.isNull(map.getTargetElement())) { if (map === undefined || goog.isNull(map.getTargetElement())) {
return; return;
} }
@@ -403,7 +403,7 @@ ol.Overlay.prototype.panIntoView_ = function() {
if (delta[0] !== 0 || delta[1] !== 0) { if (delta[0] !== 0 || delta[1] !== 0) {
var center = map.getView().getCenter(); var center = map.getView().getCenter();
goog.asserts.assert(goog.isDef(center), 'center should be defined'); goog.asserts.assert(center !== undefined, 'center should be defined');
var centerPx = map.getPixelFromCoordinate(center); var centerPx = map.getPixelFromCoordinate(center);
var newCenterPx = [ var newCenterPx = [
centerPx[0] + delta[0], centerPx[0] + delta[0],
@@ -430,7 +430,7 @@ ol.Overlay.prototype.panIntoView_ = function() {
ol.Overlay.prototype.getRect_ = function(element, size) { ol.Overlay.prototype.getRect_ = function(element, size) {
goog.asserts.assert(goog.isDefAndNotNull(element), goog.asserts.assert(goog.isDefAndNotNull(element),
'element should be defined'); 'element should be defined');
goog.asserts.assert(goog.isDef(size), 'size should be defined'); goog.asserts.assert(size !== undefined, 'size should be defined');
var offset = goog.style.getPageOffset(element); var offset = goog.style.getPageOffset(element);
return [ return [
@@ -474,7 +474,7 @@ ol.Overlay.prototype.setVisible = function(visible) {
ol.Overlay.prototype.updatePixelPosition = function() { ol.Overlay.prototype.updatePixelPosition = function() {
var map = this.getMap(); var map = this.getMap();
var position = this.getPosition(); var position = this.getPosition();
if (!goog.isDef(map) || !map.isRendered() || !goog.isDef(position)) { if (map === undefined || !map.isRendered() || position === undefined) {
this.setVisible(false); this.setVisible(false);
return; return;
} }
@@ -492,13 +492,13 @@ ol.Overlay.prototype.updatePixelPosition = function() {
*/ */
ol.Overlay.prototype.updateRenderedPosition = function(pixel, mapSize) { ol.Overlay.prototype.updateRenderedPosition = function(pixel, mapSize) {
goog.asserts.assert(!goog.isNull(pixel), 'pixel should not be null'); goog.asserts.assert(!goog.isNull(pixel), 'pixel should not be null');
goog.asserts.assert(goog.isDef(mapSize), 'mapSize should be defined'); goog.asserts.assert(mapSize !== undefined, 'mapSize should be defined');
var style = this.element_.style; var style = this.element_.style;
var offset = this.getOffset(); var offset = this.getOffset();
goog.asserts.assert(goog.isArray(offset), 'offset should be an array'); goog.asserts.assert(goog.isArray(offset), 'offset should be an array');
var positioning = this.getPositioning(); var positioning = this.getPositioning();
goog.asserts.assert(goog.isDef(positioning), goog.asserts.assert(positioning !== undefined,
'positioning should be defined'); 'positioning should be defined');
var offsetX = offset[0]; var offsetX = offset[0];
+1 -1
View File
@@ -59,7 +59,7 @@ ol.pointer.PointerEvent = function(type, browserEvent, opt_eventDict) {
*/ */
this.browserEvent = browserEvent; this.browserEvent = browserEvent;
var eventDict = goog.isDef(opt_eventDict) ? opt_eventDict : {}; var eventDict = opt_eventDict ? opt_eventDict : {};
/** /**
* @type {number} * @type {number}
+2 -1
View File
@@ -32,6 +32,7 @@ goog.provide('ol.pointer.TouchSource');
goog.require('goog.array'); goog.require('goog.array');
goog.require('goog.object'); goog.require('goog.object');
goog.require('ol');
goog.require('ol.pointer.EventSource'); goog.require('ol.pointer.EventSource');
goog.require('ol.pointer.MouseSource'); goog.require('ol.pointer.MouseSource');
@@ -168,7 +169,7 @@ ol.pointer.TouchSource.prototype.resetClickCountHandler_ = function() {
* @private * @private
*/ */
ol.pointer.TouchSource.prototype.cancelResetClickCount_ = function() { ol.pointer.TouchSource.prototype.cancelResetClickCount_ = function() {
if (goog.isDef(this.resetId_)) { if (this.resetId_ !== undefined) {
goog.global.clearTimeout(this.resetId_); goog.global.clearTimeout(this.resetId_);
} }
}; };

Some files were not shown because too many files have changed in this diff Show More