Merge pull request #4192 from marcjansen/simpler-no-is-null

Remove use of goog.isNull in favor of simple truthy checks
This commit is contained in:
Marc Jansen
2015-10-01 09:30:34 +02:00
117 changed files with 585 additions and 617 deletions
+1 -1
View File
@@ -115,7 +115,7 @@ ol.animation.rotate = function(options) {
(sourceRotation - frameState.viewState.rotation) * delta; (sourceRotation - frameState.viewState.rotation) * delta;
frameState.animate = true; frameState.animate = true;
frameState.viewState.rotation += deltaRotation; frameState.viewState.rotation += deltaRotation;
if (!goog.isNull(anchor)) { if (anchor) {
var center = frameState.viewState.center; var center = frameState.viewState.center;
ol.coordinate.sub(center, anchor); ol.coordinate.sub(center, anchor);
ol.coordinate.rotate(center, deltaRotation); ol.coordinate.rotate(center, deltaRotation);
+1 -1
View File
@@ -61,7 +61,7 @@ ol.Attribution.prototype.getHTML = function() {
*/ */
ol.Attribution.prototype.intersectsAnyTileRange = ol.Attribution.prototype.intersectsAnyTileRange =
function(tileRanges, tileGrid, projection) { function(tileRanges, tileGrid, projection) {
if (goog.isNull(this.tileRanges_)) { if (!this.tileRanges_) {
return true; return true;
} }
var i, ii, tileRange, zKey; var i, ii, tileRange, zKey;
+5 -5
View File
@@ -164,15 +164,15 @@ ol.control.Attribution.prototype.getSourceAttributions = function(frameState) {
/** @type {Object.<string, ol.Attribution>} */ /** @type {Object.<string, ol.Attribution>} */
var hiddenAttributions = {}; var hiddenAttributions = {};
var projection = frameState.viewState.projection; var projection = frameState.viewState.projection;
goog.asserts.assert(!goog.isNull(projection), 'projection cannot be null'); goog.asserts.assert(projection, 'projection of viewState required');
for (i = 0, ii = layerStatesArray.length; i < ii; i++) { for (i = 0, ii = layerStatesArray.length; i < ii; i++) {
source = layerStatesArray[i].layer.getSource(); source = layerStatesArray[i].layer.getSource();
if (goog.isNull(source)) { if (!source) {
continue; continue;
} }
sourceKey = goog.getUid(source).toString(); sourceKey = goog.getUid(source).toString();
sourceAttributions = source.getAttributions(); sourceAttributions = source.getAttributions();
if (goog.isNull(sourceAttributions)) { if (!sourceAttributions) {
continue; continue;
} }
for (j = 0, jj = sourceAttributions.length; j < jj; j++) { for (j = 0, jj = sourceAttributions.length; j < jj; j++) {
@@ -186,7 +186,7 @@ ol.control.Attribution.prototype.getSourceAttributions = function(frameState) {
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);
goog.asserts.assert(!goog.isNull(tileGrid), 'tileGrid cannot be null'); goog.asserts.assert(tileGrid, 'tileGrid required for projection');
intersectsTileRange = sourceAttribution.intersectsAnyTileRange( intersectsTileRange = sourceAttribution.intersectsAnyTileRange(
tileRanges, tileGrid, projection); tileRanges, tileGrid, projection);
} else { } else {
@@ -223,7 +223,7 @@ ol.control.Attribution.render = function(mapEvent) {
*/ */
ol.control.Attribution.prototype.updateElement_ = function(frameState) { ol.control.Attribution.prototype.updateElement_ = function(frameState) {
if (goog.isNull(frameState)) { if (!frameState) {
if (this.renderedVisible_) { if (this.renderedVisible_) {
goog.style.setElementShown(this.element, false); goog.style.setElementShown(this.element, false);
this.renderedVisible_ = false; this.renderedVisible_ = false;
+3 -3
View File
@@ -105,7 +105,7 @@ ol.control.Control.prototype.getMap = function() {
* @api stable * @api stable
*/ */
ol.control.Control.prototype.setMap = function(map) { ol.control.Control.prototype.setMap = function(map) {
if (!goog.isNull(this.map_)) { if (this.map_) {
goog.dom.removeNode(this.element); goog.dom.removeNode(this.element);
} }
if (this.listenerKeys.length > 0) { if (this.listenerKeys.length > 0) {
@@ -113,8 +113,8 @@ ol.control.Control.prototype.setMap = function(map) {
this.listenerKeys.length = 0; this.listenerKeys.length = 0;
} }
this.map_ = map; this.map_ = map;
if (!goog.isNull(this.map_)) { if (this.map_) {
var target = !goog.isNull(this.target_) ? var target = this.target_ ?
this.target_ : map.getOverlayContainerStopEvent(); this.target_ : map.getOverlayContainerStopEvent();
goog.dom.appendChild(target, this.element); goog.dom.appendChild(target, this.element);
if (this.render !== ol.nullFunction) { if (this.render !== ol.nullFunction) {
+2 -2
View File
@@ -107,7 +107,7 @@ ol.control.FullScreen.prototype.handleFullScreen_ = function() {
return; return;
} }
var map = this.getMap(); var map = this.getMap();
if (goog.isNull(map)) { if (!map) {
return; return;
} }
if (goog.dom.fullscreen.isFullScreen()) { if (goog.dom.fullscreen.isFullScreen()) {
@@ -141,7 +141,7 @@ ol.control.FullScreen.prototype.handleFullScreenChange_ = function() {
goog.dom.classlist.swap(button, opened, closed); goog.dom.classlist.swap(button, opened, closed);
goog.dom.replaceNode(this.labelNode_, this.labelActiveNode_); goog.dom.replaceNode(this.labelNode_, this.labelActiveNode_);
} }
if (!goog.isNull(map)) { if (map) {
map.updateSize(); map.updateSize();
} }
}; };
+5 -5
View File
@@ -108,7 +108,7 @@ goog.inherits(ol.control.MousePosition, ol.control.Control);
*/ */
ol.control.MousePosition.render = function(mapEvent) { ol.control.MousePosition.render = function(mapEvent) {
var frameState = mapEvent.frameState; var frameState = mapEvent.frameState;
if (goog.isNull(frameState)) { if (!frameState) {
this.mapProjection_ = null; this.mapProjection_ = null;
} else { } else {
if (this.mapProjection_ != frameState.viewState.projection) { if (this.mapProjection_ != frameState.viewState.projection) {
@@ -182,7 +182,7 @@ ol.control.MousePosition.prototype.handleMouseOut = function(browserEvent) {
*/ */
ol.control.MousePosition.prototype.setMap = function(map) { ol.control.MousePosition.prototype.setMap = function(map) {
goog.base(this, 'setMap', map); goog.base(this, 'setMap', map);
if (!goog.isNull(map)) { if (map) {
var viewport = map.getViewport(); var viewport = map.getViewport();
this.listenerKeys.push( this.listenerKeys.push(
goog.events.listen(viewport, goog.events.EventType.MOUSEMOVE, goog.events.listen(viewport, goog.events.EventType.MOUSEMOVE,
@@ -224,8 +224,8 @@ ol.control.MousePosition.prototype.setProjection = function(projection) {
*/ */
ol.control.MousePosition.prototype.updateHTML_ = function(pixel) { ol.control.MousePosition.prototype.updateHTML_ = function(pixel) {
var html = this.undefinedHTML_; var html = this.undefinedHTML_;
if (!goog.isNull(pixel) && !goog.isNull(this.mapProjection_)) { if (pixel && this.mapProjection_) {
if (goog.isNull(this.transform_)) { if (!this.transform_) {
var projection = this.getProjection(); var projection = this.getProjection();
if (projection) { if (projection) {
this.transform_ = ol.proj.getTransformFromProjections( this.transform_ = ol.proj.getTransformFromProjections(
@@ -236,7 +236,7 @@ ol.control.MousePosition.prototype.updateHTML_ = function(pixel) {
} }
var map = this.getMap(); var map = this.getMap();
var coordinate = map.getCoordinateFromPixel(pixel); var coordinate = map.getCoordinateFromPixel(pixel);
if (!goog.isNull(coordinate)) { if (coordinate) {
this.transform_(coordinate, coordinate); this.transform_(coordinate, coordinate);
var coordinateFormat = this.getCoordinateFormat(); var coordinateFormat = this.getCoordinateFormat();
if (coordinateFormat) { if (coordinateFormat) {
+2 -2
View File
@@ -113,7 +113,7 @@ ol.control.Rotate.prototype.handleClick_ = function(event) {
ol.control.Rotate.prototype.resetNorth_ = function() { ol.control.Rotate.prototype.resetNorth_ = function() {
var map = this.getMap(); var map = this.getMap();
var view = map.getView(); var view = map.getView();
if (goog.isNull(view)) { if (!view) {
// the map does not have a view, so we can't act // the map does not have a view, so we can't act
// upon it // upon it
return; return;
@@ -147,7 +147,7 @@ ol.control.Rotate.prototype.resetNorth_ = function() {
*/ */
ol.control.Rotate.render = function(mapEvent) { ol.control.Rotate.render = function(mapEvent) {
var frameState = mapEvent.frameState; var frameState = mapEvent.frameState;
if (goog.isNull(frameState)) { if (!frameState) {
return; return;
} }
var rotation = frameState.viewState.rotation; var rotation = frameState.viewState.rotation;
+3 -3
View File
@@ -160,7 +160,7 @@ ol.control.ScaleLine.prototype.getUnits = function() {
*/ */
ol.control.ScaleLine.render = function(mapEvent) { ol.control.ScaleLine.render = function(mapEvent) {
var frameState = mapEvent.frameState; var frameState = mapEvent.frameState;
if (goog.isNull(frameState)) { if (!frameState) {
this.viewState_ = null; this.viewState_ = null;
} else { } else {
this.viewState_ = frameState.viewState; this.viewState_ = frameState.viewState;
@@ -194,7 +194,7 @@ ol.control.ScaleLine.prototype.setUnits = function(units) {
ol.control.ScaleLine.prototype.updateElement_ = function() { ol.control.ScaleLine.prototype.updateElement_ = function() {
var viewState = this.viewState_; var viewState = this.viewState_;
if (goog.isNull(viewState)) { if (!viewState) {
if (this.renderedVisible_) { if (this.renderedVisible_) {
goog.style.setElementShown(this.element_, false); goog.style.setElementShown(this.element_, false);
this.renderedVisible_ = false; this.renderedVisible_ = false;
@@ -226,7 +226,7 @@ ol.control.ScaleLine.prototype.updateElement_ = function() {
units == ol.control.ScaleLineUnits.DEGREES) { units == ol.control.ScaleLineUnits.DEGREES) {
// Convert pointResolution from other units to degrees // Convert pointResolution from other units to degrees
if (goog.isNull(this.toEPSG4326_)) { if (!this.toEPSG4326_) {
this.toEPSG4326_ = ol.proj.getTransformFromProjections( this.toEPSG4326_ = ol.proj.getTransformFromProjections(
projection, ol.proj.get('EPSG:4326')); projection, ol.proj.get('EPSG:4326'));
} }
+1 -1
View File
@@ -96,7 +96,7 @@ ol.control.Zoom.prototype.handleClick_ = function(delta, event) {
ol.control.Zoom.prototype.zoomByDelta_ = function(delta) { ol.control.Zoom.prototype.zoomByDelta_ = function(delta) {
var map = this.getMap(); var map = this.getMap();
var view = map.getView(); var view = map.getView();
if (goog.isNull(view)) { if (!view) {
// the map does not have a view, so we can't act // the map does not have a view, so we can't act
// upon it // upon it
return; return;
+2 -2
View File
@@ -130,7 +130,7 @@ ol.control.ZoomSlider.direction = {
*/ */
ol.control.ZoomSlider.prototype.setMap = function(map) { ol.control.ZoomSlider.prototype.setMap = function(map) {
goog.base(this, 'setMap', map); goog.base(this, 'setMap', map);
if (!goog.isNull(map)) { if (map) {
map.render(); map.render();
} }
}; };
@@ -179,7 +179,7 @@ ol.control.ZoomSlider.prototype.initSlider_ = function() {
* @api * @api
*/ */
ol.control.ZoomSlider.render = function(mapEvent) { ol.control.ZoomSlider.render = function(mapEvent) {
if (goog.isNull(mapEvent.frameState)) { if (!mapEvent.frameState) {
return; return;
} }
goog.asserts.assert(mapEvent.frameState.viewState, goog.asserts.assert(mapEvent.frameState.viewState,
+1 -1
View File
@@ -71,7 +71,7 @@ ol.control.ZoomToExtent.prototype.handleClick_ = function(event) {
ol.control.ZoomToExtent.prototype.handleZoomToExtent_ = function() { ol.control.ZoomToExtent.prototype.handleZoomToExtent_ = function() {
var map = this.getMap(); var map = this.getMap();
var view = map.getView(); var view = map.getView();
var extent = goog.isNull(this.extent_) ? var extent = !this.extent_ ?
view.getProjection().getExtent() : this.extent_; view.getProjection().getExtent() : this.extent_;
var size = map.getSize(); var size = map.getSize();
goog.asserts.assert(size, 'size should be defined'); goog.asserts.assert(size, 'size should be defined');
+2 -2
View File
@@ -208,10 +208,10 @@ ol.DeviceOrientation.prototype.getTracking = function() {
ol.DeviceOrientation.prototype.handleTrackingChanged_ = function() { ol.DeviceOrientation.prototype.handleTrackingChanged_ = function() {
if (ol.has.DEVICE_ORIENTATION) { if (ol.has.DEVICE_ORIENTATION) {
var tracking = this.getTracking(); var tracking = this.getTracking();
if (tracking && goog.isNull(this.listenerKey_)) { if (tracking && !this.listenerKey_) {
this.listenerKey_ = goog.events.listen(goog.global, 'deviceorientation', this.listenerKey_ = goog.events.listen(goog.global, 'deviceorientation',
this.orientationChange_, false, this); this.orientationChange_, false, this);
} else if (!tracking && !goog.isNull(this.listenerKey_)) { } else if (!tracking && this.listenerKey_) {
goog.events.unlistenByKey(this.listenerKey_); goog.events.unlistenByKey(this.listenerKey_);
this.listenerKey_ = null; this.listenerKey_ = null;
} }
+2 -2
View File
@@ -39,7 +39,7 @@ ol.dom.canUseCssTransform = (function() {
var canUseCssTransform; var canUseCssTransform;
return function() { return function() {
if (canUseCssTransform === undefined) { if (canUseCssTransform === undefined) {
goog.asserts.assert(!goog.isNull(document.body), goog.asserts.assert(document.body,
'document.body should not be null'); 'document.body should not be null');
if (!goog.global.getComputedStyle) { if (!goog.global.getComputedStyle) {
// this browser is ancient // this browser is ancient
@@ -82,7 +82,7 @@ ol.dom.canUseCssTransform3D = (function() {
var canUseCssTransform3D; var canUseCssTransform3D;
return function() { return function() {
if (canUseCssTransform3D === undefined) { if (canUseCssTransform3D === undefined) {
goog.asserts.assert(!goog.isNull(document.body), goog.asserts.assert(document.body,
'document.body should not be null'); 'document.body should not be null');
if (!goog.global.getComputedStyle) { if (!goog.global.getComputedStyle) {
// this browser is ancient // this browser is ancient
+4 -4
View File
@@ -98,7 +98,7 @@ ol.Feature = function(opt_geometryOrProperties) {
if (opt_geometryOrProperties !== undefined) { if (opt_geometryOrProperties !== undefined) {
if (opt_geometryOrProperties instanceof ol.geom.Geometry || if (opt_geometryOrProperties instanceof ol.geom.Geometry ||
goog.isNull(opt_geometryOrProperties)) { !opt_geometryOrProperties) {
var geometry = /** @type {ol.geom.Geometry} */ (opt_geometryOrProperties); var geometry = /** @type {ol.geom.Geometry} */ (opt_geometryOrProperties);
this.setGeometry(geometry); this.setGeometry(geometry);
} else { } else {
@@ -127,7 +127,7 @@ ol.Feature.prototype.clone = function() {
clone.setGeometry(geometry.clone()); clone.setGeometry(geometry.clone());
} }
var style = this.getStyle(); var style = this.getStyle();
if (!goog.isNull(style)) { if (style) {
clone.setStyle(style); clone.setStyle(style);
} }
return clone; return clone;
@@ -209,7 +209,7 @@ ol.Feature.prototype.handleGeometryChange_ = function() {
* @private * @private
*/ */
ol.Feature.prototype.handleGeometryChanged_ = function() { ol.Feature.prototype.handleGeometryChanged_ = function() {
if (!goog.isNull(this.geometryChangeKey_)) { if (this.geometryChangeKey_) {
goog.events.unlistenByKey(this.geometryChangeKey_); goog.events.unlistenByKey(this.geometryChangeKey_);
this.geometryChangeKey_ = null; this.geometryChangeKey_ = null;
} }
@@ -245,7 +245,7 @@ ol.Feature.prototype.setGeometry = function(geometry) {
*/ */
ol.Feature.prototype.setStyle = function(style) { ol.Feature.prototype.setStyle = function(style) {
this.style_ = style; this.style_ = style;
this.styleFunction_ = goog.isNull(style) ? this.styleFunction_ = !style ?
undefined : ol.Feature.createStyleFunction(style); undefined : ol.Feature.createStyleFunction(style);
this.changed(); this.changed();
}; };
+1 -1
View File
@@ -54,7 +54,7 @@ goog.inherits(ol.format.EsriJSON, ol.format.JSONFeature);
* @return {ol.geom.Geometry} Geometry. * @return {ol.geom.Geometry} Geometry.
*/ */
ol.format.EsriJSON.readGeometry_ = function(object, opt_options) { ol.format.EsriJSON.readGeometry_ = function(object, opt_options) {
if (goog.isNull(object)) { if (!object) {
return null; return null;
} }
var type; var type;
+1 -1
View File
@@ -165,7 +165,7 @@ ol.format.Feature.transformWithOptions = function(
ol.proj.get(opt_options.featureProjection) : null; ol.proj.get(opt_options.featureProjection) : null;
var dataProjection = 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 (featureProjection && dataProjection &&
!ol.proj.equivalent(featureProjection, dataProjection)) { !ol.proj.equivalent(featureProjection, dataProjection)) {
if (geometry instanceof ol.geom.Geometry) { if (geometry instanceof ol.geom.Geometry) {
return (write ? geometry.clone() : geometry).transform( return (write ? geometry.clone() : geometry).transform(
+1 -1
View File
@@ -68,7 +68,7 @@ ol.format.GeoJSON.EXTENSIONS_ = ['.geojson'];
* @return {ol.geom.Geometry} Geometry. * @return {ol.geom.Geometry} Geometry.
*/ */
ol.format.GeoJSON.readGeometry_ = function(object, opt_options) { ol.format.GeoJSON.readGeometry_ = function(object, opt_options) {
if (goog.isNull(object)) { if (!object) {
return null; return null;
} }
var geometryReader = ol.format.GeoJSON.GEOMETRY_READERS_[object.type]; var geometryReader = ol.format.GeoJSON.GEOMETRY_READERS_[object.type];
+4 -4
View File
@@ -62,20 +62,20 @@ ol.format.GML2.prototype.readFlatCoordinates_ = function(node, objectStack) {
var containerSrs = context['srsName']; var containerSrs = context['srsName'];
var containerDimension = node.parentNode.getAttribute('srsDimension'); var containerDimension = node.parentNode.getAttribute('srsDimension');
var axisOrientation = 'enu'; var axisOrientation = 'enu';
if (!goog.isNull(containerSrs)) { if (containerSrs) {
var proj = ol.proj.get(containerSrs); var proj = ol.proj.get(containerSrs);
axisOrientation = proj.getAxisOrientation(); axisOrientation = proj.getAxisOrientation();
} }
var coords = s.split(/[\s,]+/); var coords = s.split(/[\s,]+/);
// The "dimension" attribute is from the GML 3.0.1 spec. // The "dimension" attribute is from the GML 3.0.1 spec.
var dim = 2; var dim = 2;
if (!goog.isNull(node.getAttribute('srsDimension'))) { if (node.getAttribute('srsDimension')) {
dim = ol.format.XSD.readNonNegativeIntegerString( dim = ol.format.XSD.readNonNegativeIntegerString(
node.getAttribute('srsDimension')); node.getAttribute('srsDimension'));
} else if (!goog.isNull(node.getAttribute('dimension'))) { } else if (node.getAttribute('dimension')) {
dim = ol.format.XSD.readNonNegativeIntegerString( dim = ol.format.XSD.readNonNegativeIntegerString(
node.getAttribute('dimension')); node.getAttribute('dimension'));
} else if (!goog.isNull(containerDimension)) { } else if (containerDimension) {
dim = ol.format.XSD.readNonNegativeIntegerString(containerDimension); dim = ol.format.XSD.readNonNegativeIntegerString(containerDimension);
} }
var x, y, z; var x, y, z;
+7 -7
View File
@@ -301,7 +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 (flatLinearRings && !goog.isNull(flatLinearRings[0])) { if (flatLinearRings && 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];
@@ -385,7 +385,7 @@ ol.format.GML3.prototype.readFlatPos_ = function(node, objectStack) {
goog.asserts.assert(goog.isObject(context), 'context should be an Object'); goog.asserts.assert(goog.isObject(context), 'context should be an Object');
var containerSrs = context['srsName']; var containerSrs = context['srsName'];
var axisOrientation = 'enu'; var axisOrientation = 'enu';
if (!goog.isNull(containerSrs)) { if (containerSrs) {
var proj = ol.proj.get(containerSrs); var proj = ol.proj.get(containerSrs);
axisOrientation = proj.getAxisOrientation(); axisOrientation = proj.getAxisOrientation();
} }
@@ -422,20 +422,20 @@ ol.format.GML3.prototype.readFlatPosList_ = function(node, objectStack) {
var containerSrs = context['srsName']; var containerSrs = context['srsName'];
var containerDimension = node.parentNode.getAttribute('srsDimension'); var containerDimension = node.parentNode.getAttribute('srsDimension');
var axisOrientation = 'enu'; var axisOrientation = 'enu';
if (!goog.isNull(containerSrs)) { if (containerSrs) {
var proj = ol.proj.get(containerSrs); var proj = ol.proj.get(containerSrs);
axisOrientation = proj.getAxisOrientation(); axisOrientation = proj.getAxisOrientation();
} }
var coords = s.split(/\s+/); var coords = s.split(/\s+/);
// The "dimension" attribute is from the GML 3.0.1 spec. // The "dimension" attribute is from the GML 3.0.1 spec.
var dim = 2; var dim = 2;
if (!goog.isNull(node.getAttribute('srsDimension'))) { if (node.getAttribute('srsDimension')) {
dim = ol.format.XSD.readNonNegativeIntegerString( dim = ol.format.XSD.readNonNegativeIntegerString(
node.getAttribute('srsDimension')); node.getAttribute('srsDimension'));
} else if (!goog.isNull(node.getAttribute('dimension'))) { } else if (node.getAttribute('dimension')) {
dim = ol.format.XSD.readNonNegativeIntegerString( dim = ol.format.XSD.readNonNegativeIntegerString(
node.getAttribute('dimension')); node.getAttribute('dimension'));
} else if (!goog.isNull(containerDimension)) { } else if (containerDimension) {
dim = ol.format.XSD.readNonNegativeIntegerString(containerDimension); dim = ol.format.XSD.readNonNegativeIntegerString(containerDimension);
} }
var x, y, z; var x, y, z;
@@ -1067,7 +1067,7 @@ ol.format.GML3.prototype.writeFeatureElement =
var keys = [], values = []; var keys = [], values = [];
for (var key in properties) { for (var key in properties) {
var value = properties[key]; var value = properties[key];
if (!goog.isNull(value)) { if (value !== null) {
keys.push(key); keys.push(key);
values.push(value); values.push(value);
if (key == geometryName) { if (key == geometryName) {
+2 -4
View File
@@ -199,8 +199,7 @@ ol.format.GMLBase.prototype.readFeatureElement = function(node, objectStack) {
var fid = node.getAttribute('fid') || var fid = node.getAttribute('fid') ||
ol.xml.getAttributeNS(node, ol.format.GMLBase.GMLNS, 'id'); ol.xml.getAttributeNS(node, ol.format.GMLBase.GMLNS, 'id');
var values = {}, geometryName; var values = {}, geometryName;
for (n = node.firstElementChild; !goog.isNull(n); for (n = node.firstElementChild; n; n = n.nextElementSibling) {
n = n.nextElementSibling) {
var localName = ol.xml.getLocalName(n); var localName = ol.xml.getLocalName(n);
// Assume attribute elements have one child node and that the child // Assume attribute elements have one child node and that the child
// is a text or CDATA node (to be treated as text). // is a text or CDATA node (to be treated as text).
@@ -449,8 +448,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 (flatLinearRings && if (flatLinearRings && 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];
+2 -2
View File
@@ -97,7 +97,7 @@ ol.format.GPX.parseLink_ = function(node, objectStack) {
goog.asserts.assert(node.localName == 'link', 'localName should be link'); goog.asserts.assert(node.localName == 'link', 'localName should be link');
var values = /** @type {Object} */ (objectStack[objectStack.length - 1]); var values = /** @type {Object} */ (objectStack[objectStack.length - 1]);
var href = node.getAttribute('href'); var href = node.getAttribute('href');
if (!goog.isNull(href)) { if (href !== null) {
values['link'] = href; values['link'] = href;
} }
ol.xml.parseNode(ol.format.GPX.LINK_PARSERS_, node, objectStack); ol.xml.parseNode(ol.format.GPX.LINK_PARSERS_, node, objectStack);
@@ -417,7 +417,7 @@ ol.format.GPX.WPT_PARSERS_ = ol.xml.makeStructureNS(
* @private * @private
*/ */
ol.format.GPX.prototype.handleReadExtensions_ = function(features) { ol.format.GPX.prototype.handleReadExtensions_ = function(features) {
if (goog.isNull(features)) { if (!features) {
features = []; features = [];
} }
for (var i = 0, ii = features.length; i < ii; ++i) { for (var i = 0, ii = features.length; i < ii; ++i) {
+1 -1
View File
@@ -202,7 +202,7 @@ ol.format.IGC.prototype.readFeatures;
*/ */
ol.format.IGC.prototype.readFeaturesFromText = function(text, opt_options) { ol.format.IGC.prototype.readFeaturesFromText = function(text, opt_options) {
var feature = this.readFeatureFromText(text, opt_options); var feature = this.readFeatureFromText(text, opt_options);
if (!goog.isNull(feature)) { if (feature) {
return [feature]; return [feature];
} else { } else {
return []; return [];
+23 -26
View File
@@ -979,7 +979,7 @@ ol.format.KML.readPolygon_ = function(node, objectStack) {
var flatLinearRings = ol.xml.pushParseAndPop( var flatLinearRings = ol.xml.pushParseAndPop(
/** @type {Array.<Array.<number>>} */ ([null]), /** @type {Array.<Array.<number>>} */ ([null]),
ol.format.KML.FLAT_LINEAR_RINGS_PARSERS_, node, objectStack); ol.format.KML.FLAT_LINEAR_RINGS_PARSERS_, node, objectStack);
if (flatLinearRings && !goog.isNull(flatLinearRings[0])) { if (flatLinearRings && 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];
@@ -1085,7 +1085,7 @@ ol.format.KML.DataParser_ = function(node, objectStack) {
'node.nodeType should be ELEMENT'); 'node.nodeType should be ELEMENT');
goog.asserts.assert(node.localName == 'Data', 'localName should be Data'); goog.asserts.assert(node.localName == 'Data', 'localName should be Data');
var name = node.getAttribute('name'); var name = node.getAttribute('name');
if (!goog.isNull(name)) { if (name !== null) {
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 (data) { if (data) {
@@ -1196,7 +1196,7 @@ ol.format.KML.SimpleDataParser_ = function(node, objectStack) {
goog.asserts.assert(node.localName == 'SimpleData', goog.asserts.assert(node.localName == 'SimpleData',
'localName should be SimpleData'); 'localName should be SimpleData');
var name = node.getAttribute('name'); var name = node.getAttribute('name');
if (!goog.isNull(name)) { if (name !== null) {
var data = ol.format.XSD.readString(node); var data = ol.format.XSD.readString(node);
var featureObject = var featureObject =
/** @type {Object} */ (objectStack[objectStack.length - 1]); /** @type {Object} */ (objectStack[objectStack.length - 1]);
@@ -1679,7 +1679,7 @@ ol.format.KML.prototype.readPlacemark_ = function(node, objectStack) {
} }
var feature = new ol.Feature(); var feature = new ol.Feature();
var id = node.getAttribute('id'); var id = node.getAttribute('id');
if (!goog.isNull(id)) { if (id !== null) {
feature.setId(id); feature.setId(id);
} }
var options = /** @type {olx.format.ReadOptions} */ (objectStack[0]); var options = /** @type {olx.format.ReadOptions} */ (objectStack[0]);
@@ -1718,7 +1718,7 @@ ol.format.KML.prototype.readSharedStyle_ = function(node, objectStack) {
'node.nodeType should be ELEMENT'); 'node.nodeType should be ELEMENT');
goog.asserts.assert(node.localName == 'Style', 'localName should be Style'); goog.asserts.assert(node.localName == 'Style', 'localName should be Style');
var id = node.getAttribute('id'); var id = node.getAttribute('id');
if (!goog.isNull(id)) { if (id !== null) {
var style = ol.format.KML.readStyle_(node, objectStack); var style = ol.format.KML.readStyle_(node, objectStack);
if (style) { if (style) {
var styleUri; var styleUri;
@@ -1744,7 +1744,7 @@ ol.format.KML.prototype.readSharedStyleMap_ = function(node, objectStack) {
goog.asserts.assert(node.localName == 'StyleMap', goog.asserts.assert(node.localName == 'StyleMap',
'localName should be StyleMap'); 'localName should be StyleMap');
var id = node.getAttribute('id'); var id = node.getAttribute('id');
if (goog.isNull(id)) { if (id === null) {
return; return;
} }
var styleMapValue = ol.format.KML.readStyleMapValue_(node, objectStack); var styleMapValue = ol.format.KML.readStyleMapValue_(node, objectStack);
@@ -1836,8 +1836,7 @@ ol.format.KML.prototype.readFeaturesFromNode = function(node, opt_options) {
} else if (localName == 'kml') { } else if (localName == 'kml') {
features = []; features = [];
var n; var n;
for (n = node.firstElementChild; !goog.isNull(n); for (n = node.firstElementChild; n; n = n.nextElementSibling) {
n = n.nextElementSibling) {
var fs = this.readFeaturesFromNode(n, opt_options); var fs = this.readFeaturesFromNode(n, opt_options);
if (fs) { if (fs) {
goog.array.extend(features, fs); goog.array.extend(features, fs);
@@ -1878,7 +1877,7 @@ ol.format.KML.prototype.readName = function(source) {
*/ */
ol.format.KML.prototype.readNameFromDocument = function(doc) { ol.format.KML.prototype.readNameFromDocument = function(doc) {
var n; var n;
for (n = doc.firstChild; !goog.isNull(n); n = n.nextSibling) { for (n = doc.firstChild; 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 (name) { if (name) {
@@ -1896,13 +1895,13 @@ ol.format.KML.prototype.readNameFromDocument = function(doc) {
*/ */
ol.format.KML.prototype.readNameFromNode = function(node) { ol.format.KML.prototype.readNameFromNode = function(node) {
var n; var n;
for (n = node.firstElementChild; !goog.isNull(n); n = n.nextElementSibling) { for (n = node.firstElementChild; n; n = n.nextElementSibling) {
if (ol.array.includes(ol.format.KML.NAMESPACE_URIS_, n.namespaceURI) && if (ol.array.includes(ol.format.KML.NAMESPACE_URIS_, n.namespaceURI) &&
n.localName == 'name') { n.localName == 'name') {
return ol.format.XSD.readString(n); return ol.format.XSD.readString(n);
} }
} }
for (n = node.firstElementChild; !goog.isNull(n); n = n.nextElementSibling) { for (n = node.firstElementChild; n; n = n.nextElementSibling) {
var localName = ol.xml.getLocalName(n); var localName = ol.xml.getLocalName(n);
if (ol.array.includes(ol.format.KML.NAMESPACE_URIS_, n.namespaceURI) && if (ol.array.includes(ol.format.KML.NAMESPACE_URIS_, n.namespaceURI) &&
(localName == 'Document' || (localName == 'Document' ||
@@ -1950,7 +1949,7 @@ ol.format.KML.prototype.readNetworkLinks = function(source) {
*/ */
ol.format.KML.prototype.readNetworkLinksFromDocument = function(doc) { ol.format.KML.prototype.readNetworkLinksFromDocument = function(doc) {
var n, networkLinks = []; var n, networkLinks = [];
for (n = doc.firstChild; !goog.isNull(n); n = n.nextSibling) { for (n = doc.firstChild; n; n = n.nextSibling) {
if (n.nodeType == goog.dom.NodeType.ELEMENT) { if (n.nodeType == goog.dom.NodeType.ELEMENT) {
goog.array.extend(networkLinks, this.readNetworkLinksFromNode(n)); goog.array.extend(networkLinks, this.readNetworkLinksFromNode(n));
} }
@@ -1965,7 +1964,7 @@ ol.format.KML.prototype.readNetworkLinksFromDocument = function(doc) {
*/ */
ol.format.KML.prototype.readNetworkLinksFromNode = function(node) { ol.format.KML.prototype.readNetworkLinksFromNode = function(node) {
var n, networkLinks = []; var n, networkLinks = [];
for (n = node.firstElementChild; !goog.isNull(n); n = n.nextElementSibling) { for (n = node.firstElementChild; n; n = n.nextElementSibling) {
if (ol.array.includes(ol.format.KML.NAMESPACE_URIS_, n.namespaceURI) && if (ol.array.includes(ol.format.KML.NAMESPACE_URIS_, n.namespaceURI) &&
n.localName == 'NetworkLink') { n.localName == 'NetworkLink') {
var obj = ol.xml.pushParseAndPop({}, ol.format.KML.NETWORK_LINK_PARSERS_, var obj = ol.xml.pushParseAndPop({}, ol.format.KML.NETWORK_LINK_PARSERS_,
@@ -1973,7 +1972,7 @@ ol.format.KML.prototype.readNetworkLinksFromNode = function(node) {
networkLinks.push(obj); networkLinks.push(obj);
} }
} }
for (n = node.firstElementChild; !goog.isNull(n); n = n.nextElementSibling) { for (n = node.firstElementChild; n; n = n.nextElementSibling) {
var localName = ol.xml.getLocalName(n); var localName = ol.xml.getLocalName(n);
if (ol.array.includes(ol.format.KML.NAMESPACE_URIS_, n.namespaceURI) && if (ol.array.includes(ol.format.KML.NAMESPACE_URIS_, n.namespaceURI) &&
(localName == 'Document' || (localName == 'Document' ||
@@ -2110,20 +2109,18 @@ ol.format.KML.writeIconStyle_ = function(node, style, objectStack) {
'href': src 'href': src
}; };
if (!goog.isNull(size)) { if (size) {
iconProperties['w'] = size[0]; iconProperties['w'] = size[0];
iconProperties['h'] = size[1]; iconProperties['h'] = size[1];
var anchor = style.getAnchor(); // top-left var anchor = style.getAnchor(); // top-left
var origin = style.getOrigin(); // top-left var origin = style.getOrigin(); // top-left
if (!goog.isNull(origin) && !goog.isNull(iconImageSize) && if (origin && iconImageSize && origin[0] !== 0 && origin[1] !== size[1]) {
origin[0] !== 0 && origin[1] !== size[1]) {
iconProperties['x'] = origin[0]; iconProperties['x'] = origin[0];
iconProperties['y'] = iconImageSize[1] - (origin[1] + size[1]); iconProperties['y'] = iconImageSize[1] - (origin[1] + size[1]);
} }
if (!goog.isNull(anchor) && if (anchor && anchor[0] !== 0 && anchor[1] !== size[1]) {
anchor[0] !== 0 && anchor[1] !== size[1]) {
var /** @type {ol.format.KMLVec2_} */ hotSpot = { var /** @type {ol.format.KMLVec2_} */ hotSpot = {
x: anchor[0], x: anchor[0],
xunits: ol.style.IconAnchorUnits.PIXELS, xunits: ol.style.IconAnchorUnits.PIXELS,
@@ -2164,7 +2161,7 @@ ol.format.KML.writeLabelStyle_ = function(node, style, objectStack) {
var /** @type {ol.xml.NodeStackItem} */ context = {node: node}; var /** @type {ol.xml.NodeStackItem} */ context = {node: node};
var properties = {}; var properties = {};
var fill = style.getFill(); var fill = style.getFill();
if (!goog.isNull(fill)) { if (fill) {
properties['color'] = fill.getColor(); properties['color'] = fill.getColor();
} }
var scale = style.getScale(); var scale = style.getScale();
@@ -2279,10 +2276,10 @@ ol.format.KML.writePlacemark_ = function(node, feature, objectStack) {
// 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);
if (!goog.isNull(styles) && styles.length > 0) { if (styles && styles.length > 0) {
properties['Style'] = styles[0]; properties['Style'] = styles[0];
var textStyle = styles[0].getText(); var textStyle = styles[0].getText();
if (!goog.isNull(textStyle)) { if (textStyle) {
properties['name'] = textStyle.getText(); properties['name'] = textStyle.getText();
} }
} }
@@ -2392,16 +2389,16 @@ ol.format.KML.writeStyle_ = function(node, style, objectStack) {
var strokeStyle = style.getStroke(); var strokeStyle = style.getStroke();
var imageStyle = style.getImage(); var imageStyle = style.getImage();
var textStyle = style.getText(); var textStyle = style.getText();
if (!goog.isNull(imageStyle)) { if (imageStyle) {
properties['IconStyle'] = imageStyle; properties['IconStyle'] = imageStyle;
} }
if (!goog.isNull(textStyle)) { if (textStyle) {
properties['LabelStyle'] = textStyle; properties['LabelStyle'] = textStyle;
} }
if (!goog.isNull(strokeStyle)) { if (strokeStyle) {
properties['LineStyle'] = strokeStyle; properties['LineStyle'] = strokeStyle;
} }
if (!goog.isNull(fillStyle)) { if (fillStyle) {
properties['PolyStyle'] = fillStyle; properties['PolyStyle'] = fillStyle;
} }
var parentNode = objectStack[objectStack.length - 1].node; var parentNode = objectStack[objectStack.length - 1].node;
+1 -1
View File
@@ -26,7 +26,7 @@ goog.inherits(ol.format.OWS, ol.format.XML);
ol.format.OWS.prototype.readFromDocument = function(doc) { ol.format.OWS.prototype.readFromDocument = function(doc) {
goog.asserts.assert(doc.nodeType == goog.dom.NodeType.DOCUMENT, goog.asserts.assert(doc.nodeType == goog.dom.NodeType.DOCUMENT,
'doc.nodeType should be DOCUMENT'); 'doc.nodeType should be DOCUMENT');
for (var n = doc.firstChild; !goog.isNull(n); n = n.nextSibling) { for (var n = doc.firstChild; n; n = n.nextSibling) {
if (n.nodeType == goog.dom.NodeType.ELEMENT) { if (n.nodeType == goog.dom.NodeType.ELEMENT) {
return this.readFromNode(n); return this.readFromNode(n);
} }
+2 -2
View File
@@ -97,7 +97,7 @@ ol.format.TopoJSON.concatenateArcs_ = function(indices, arcs) {
*/ */
ol.format.TopoJSON.readPointGeometry_ = function(object, scale, translate) { ol.format.TopoJSON.readPointGeometry_ = function(object, scale, translate) {
var coordinates = object.coordinates; var coordinates = object.coordinates;
if (!goog.isNull(scale) && !goog.isNull(translate)) { if (scale && translate) {
ol.format.TopoJSON.transformVertex_(coordinates, scale, translate); ol.format.TopoJSON.transformVertex_(coordinates, scale, translate);
} }
return new ol.geom.Point(coordinates); return new ol.geom.Point(coordinates);
@@ -117,7 +117,7 @@ ol.format.TopoJSON.readMultiPointGeometry_ = function(object, scale,
translate) { translate) {
var coordinates = object.coordinates; var coordinates = object.coordinates;
var i, ii; var i, ii;
if (!goog.isNull(scale) && !goog.isNull(translate)) { if (scale && translate) {
for (i = 0, ii = coordinates.length; i < ii; ++i) { for (i = 0, ii = coordinates.length; i < ii; ++i) {
ol.format.TopoJSON.transformVertex_(coordinates[i], scale, translate); ol.format.TopoJSON.transformVertex_(coordinates[i], scale, translate);
} }
+4 -5
View File
@@ -196,7 +196,7 @@ ol.format.WFS.prototype.readFeatureCollectionMetadataFromDocument =
function(doc) { function(doc) {
goog.asserts.assert(doc.nodeType == goog.dom.NodeType.DOCUMENT, goog.asserts.assert(doc.nodeType == goog.dom.NodeType.DOCUMENT,
'doc.nodeType should be DOCUMENT'); 'doc.nodeType should be DOCUMENT');
for (var n = doc.firstChild; !goog.isNull(n); n = n.nextSibling) { for (var n = doc.firstChild; n; n = n.nextSibling) {
if (n.nodeType == goog.dom.NodeType.ELEMENT) { if (n.nodeType == goog.dom.NodeType.ELEMENT) {
return this.readFeatureCollectionMetadataFromNode(n); return this.readFeatureCollectionMetadataFromNode(n);
} }
@@ -337,7 +337,7 @@ ol.format.WFS.TRANSACTION_RESPONSE_PARSERS_ = {
ol.format.WFS.prototype.readTransactionResponseFromDocument = function(doc) { ol.format.WFS.prototype.readTransactionResponseFromDocument = function(doc) {
goog.asserts.assert(doc.nodeType == goog.dom.NodeType.DOCUMENT, goog.asserts.assert(doc.nodeType == goog.dom.NodeType.DOCUMENT,
'doc.nodeType should be DOCUMENT'); 'doc.nodeType should be DOCUMENT');
for (var n = doc.firstChild; !goog.isNull(n); n = n.nextSibling) { for (var n = doc.firstChild; n; n = n.nextSibling) {
if (n.nodeType == goog.dom.NodeType.ELEMENT) { if (n.nodeType == goog.dom.NodeType.ELEMENT) {
return this.readTransactionResponseFromNode(n); return this.readTransactionResponseFromNode(n);
} }
@@ -750,7 +750,7 @@ ol.format.WFS.prototype.readProjection;
ol.format.WFS.prototype.readProjectionFromDocument = function(doc) { ol.format.WFS.prototype.readProjectionFromDocument = function(doc) {
goog.asserts.assert(doc.nodeType == goog.dom.NodeType.DOCUMENT, goog.asserts.assert(doc.nodeType == goog.dom.NodeType.DOCUMENT,
'doc.nodeType should be a DOCUMENT'); 'doc.nodeType should be a DOCUMENT');
for (var n = doc.firstChild; !goog.isNull(n); n = n.nextSibling) { for (var n = doc.firstChild; n; n = n.nextSibling) {
if (n.nodeType == goog.dom.NodeType.ELEMENT) { if (n.nodeType == goog.dom.NodeType.ELEMENT) {
return this.readProjectionFromNode(n); return this.readProjectionFromNode(n);
} }
@@ -771,8 +771,7 @@ ol.format.WFS.prototype.readProjectionFromNode = function(node) {
if (node.firstElementChild && if (node.firstElementChild &&
node.firstElementChild.firstElementChild) { node.firstElementChild.firstElementChild) {
node = node.firstElementChild.firstElementChild; node = node.firstElementChild.firstElementChild;
for (var n = node.firstElementChild; !goog.isNull(n); for (var n = node.firstElementChild; n; n = n.nextElementSibling) {
n = n.nextElementSibling) {
if (!(n.childNodes.length === 0 || if (!(n.childNodes.length === 0 ||
(n.childNodes.length === 1 && (n.childNodes.length === 1 &&
n.firstChild.nodeType === 3))) { n.firstChild.nodeType === 3))) {
+1 -1
View File
@@ -50,7 +50,7 @@ ol.format.WMSCapabilities.prototype.read;
ol.format.WMSCapabilities.prototype.readFromDocument = function(doc) { ol.format.WMSCapabilities.prototype.readFromDocument = function(doc) {
goog.asserts.assert(doc.nodeType == goog.dom.NodeType.DOCUMENT, goog.asserts.assert(doc.nodeType == goog.dom.NodeType.DOCUMENT,
'doc.nodeType should be DOCUMENT'); 'doc.nodeType should be DOCUMENT');
for (var n = doc.firstChild; !goog.isNull(n); n = n.nextSibling) { for (var n = doc.firstChild; n; n = n.nextSibling) {
if (n.nodeType == goog.dom.NodeType.ELEMENT) { if (n.nodeType == goog.dom.NodeType.ELEMENT) {
return this.readFromNode(n); return this.readFromNode(n);
} }
+1 -1
View File
@@ -50,7 +50,7 @@ ol.format.WMTSCapabilities.prototype.read;
ol.format.WMTSCapabilities.prototype.readFromDocument = function(doc) { ol.format.WMTSCapabilities.prototype.readFromDocument = function(doc) {
goog.asserts.assert(doc.nodeType == goog.dom.NodeType.DOCUMENT, goog.asserts.assert(doc.nodeType == goog.dom.NodeType.DOCUMENT,
'doc.nodeType should be DOCUMENT'); 'doc.nodeType should be DOCUMENT');
for (var n = doc.firstChild; !goog.isNull(n); n = n.nextSibling) { for (var n = doc.firstChild; n; n = n.nextSibling) {
if (n.nodeType == goog.dom.NodeType.ELEMENT) { if (n.nodeType == goog.dom.NodeType.ELEMENT) {
return this.readFromNode(n); return this.readFromNode(n);
} }
+1 -1
View File
@@ -107,7 +107,7 @@ ol.format.XMLFeature.prototype.readFeaturesFromDocument = function(
/** @type {Array.<ol.Feature>} */ /** @type {Array.<ol.Feature>} */
var features = []; var features = [];
var n; var n;
for (n = doc.firstChild; !goog.isNull(n); n = n.nextSibling) { for (n = doc.firstChild; n; n = n.nextSibling) {
if (n.nodeType == goog.dom.NodeType.ELEMENT) { if (n.nodeType == goog.dom.NodeType.ELEMENT) {
goog.array.extend(features, this.readFeaturesFromNode(n, opt_options)); goog.array.extend(features, this.readFeaturesFromNode(n, opt_options));
} }
+6 -6
View File
@@ -120,7 +120,7 @@ ol.Geolocation.prototype.handleProjectionChanged_ = function() {
if (projection) { if (projection) {
this.transform_ = ol.proj.getTransformFromProjections( this.transform_ = ol.proj.getTransformFromProjections(
ol.proj.get('EPSG:4326'), projection); ol.proj.get('EPSG:4326'), projection);
if (!goog.isNull(this.position_)) { if (this.position_) {
this.set( this.set(
ol.GeolocationProperty.POSITION, this.transform_(this.position_)); ol.GeolocationProperty.POSITION, this.transform_(this.position_));
} }
@@ -155,13 +155,13 @@ ol.Geolocation.prototype.positionChange_ = function(position) {
var coords = position.coords; var coords = position.coords;
this.set(ol.GeolocationProperty.ACCURACY, coords.accuracy); this.set(ol.GeolocationProperty.ACCURACY, coords.accuracy);
this.set(ol.GeolocationProperty.ALTITUDE, this.set(ol.GeolocationProperty.ALTITUDE,
goog.isNull(coords.altitude) ? undefined : coords.altitude); coords.altitude === null ? undefined : coords.altitude);
this.set(ol.GeolocationProperty.ALTITUDE_ACCURACY, this.set(ol.GeolocationProperty.ALTITUDE_ACCURACY,
goog.isNull(coords.altitudeAccuracy) ? coords.altitudeAccuracy === null ?
undefined : coords.altitudeAccuracy); undefined : coords.altitudeAccuracy);
this.set(ol.GeolocationProperty.HEADING, goog.isNull(coords.heading) ? this.set(ol.GeolocationProperty.HEADING, coords.heading === null ?
undefined : goog.math.toRadians(coords.heading)); undefined : goog.math.toRadians(coords.heading));
if (goog.isNull(this.position_)) { if (!this.position_) {
this.position_ = [coords.longitude, coords.latitude]; this.position_ = [coords.longitude, coords.latitude];
} else { } else {
this.position_[0] = coords.longitude; this.position_[0] = coords.longitude;
@@ -170,7 +170,7 @@ ol.Geolocation.prototype.positionChange_ = function(position) {
var projectedPosition = this.transform_(this.position_); var projectedPosition = this.transform_(this.position_);
this.set(ol.GeolocationProperty.POSITION, projectedPosition); this.set(ol.GeolocationProperty.POSITION, projectedPosition);
this.set(ol.GeolocationProperty.SPEED, this.set(ol.GeolocationProperty.SPEED,
goog.isNull(coords.speed) ? undefined : coords.speed); coords.speed === null ? undefined : coords.speed);
var geometry = ol.geom.Polygon.circular( var geometry = ol.geom.Polygon.circular(
ol.sphere.WGS84, this.position_, coords.accuracy); ol.sphere.WGS84, this.position_, coords.accuracy);
geometry.applyTransform(this.transform_); geometry.applyTransform(this.transform_);
+4 -4
View File
@@ -189,11 +189,11 @@ ol.geom.Circle.prototype.setCenter = function(center) {
*/ */
ol.geom.Circle.prototype.setCenterAndRadius = ol.geom.Circle.prototype.setCenterAndRadius =
function(center, radius, opt_layout) { function(center, radius, opt_layout) {
if (goog.isNull(center)) { if (!center) {
this.setFlatCoordinates(ol.geom.GeometryLayout.XY, null); this.setFlatCoordinates(ol.geom.GeometryLayout.XY, null);
} else { } else {
this.setLayout(opt_layout, center, 0); this.setLayout(opt_layout, center, 0);
if (goog.isNull(this.flatCoordinates)) { if (!this.flatCoordinates) {
this.flatCoordinates = []; this.flatCoordinates = [];
} }
/** @type {Array.<number>} */ /** @type {Array.<number>} */
@@ -228,8 +228,8 @@ ol.geom.Circle.prototype.setFlatCoordinates =
* @api * @api
*/ */
ol.geom.Circle.prototype.setRadius = function(radius) { ol.geom.Circle.prototype.setRadius = function(radius) {
goog.asserts.assert(!goog.isNull(this.flatCoordinates), goog.asserts.assert(this.flatCoordinates,
'this.flatCoordinates cannot be null'); 'truthy this.flatCoordinates expected');
this.flatCoordinates[this.stride] = this.flatCoordinates[0] + radius; this.flatCoordinates[this.stride] = this.flatCoordinates[0] + radius;
this.changed(); this.changed();
}; };
+2 -2
View File
@@ -53,7 +53,7 @@ ol.geom.GeometryCollection.cloneGeometries_ = function(geometries) {
*/ */
ol.geom.GeometryCollection.prototype.unlistenGeometriesChange_ = function() { ol.geom.GeometryCollection.prototype.unlistenGeometriesChange_ = function() {
var i, ii; var i, ii;
if (goog.isNull(this.geometries_)) { if (!this.geometries_) {
return; return;
} }
for (i = 0, ii = this.geometries_.length; i < ii; ++i) { for (i = 0, ii = this.geometries_.length; i < ii; ++i) {
@@ -69,7 +69,7 @@ ol.geom.GeometryCollection.prototype.unlistenGeometriesChange_ = function() {
*/ */
ol.geom.GeometryCollection.prototype.listenGeometriesChange_ = function() { ol.geom.GeometryCollection.prototype.listenGeometriesChange_ = function() {
var i, ii; var i, ii;
if (goog.isNull(this.geometries_)) { if (!this.geometries_) {
return; return;
} }
for (i = 0, ii = this.geometries_.length; i < ii; ++i) { for (i = 0, ii = this.geometries_.length; i < ii; ++i) {
+2 -2
View File
@@ -132,11 +132,11 @@ ol.geom.LinearRing.prototype.getType = function() {
*/ */
ol.geom.LinearRing.prototype.setCoordinates = ol.geom.LinearRing.prototype.setCoordinates =
function(coordinates, opt_layout) { function(coordinates, opt_layout) {
if (goog.isNull(coordinates)) { if (!coordinates) {
this.setFlatCoordinates(ol.geom.GeometryLayout.XY, null); this.setFlatCoordinates(ol.geom.GeometryLayout.XY, null);
} else { } else {
this.setLayout(opt_layout, coordinates, 1); this.setLayout(opt_layout, coordinates, 1);
if (goog.isNull(this.flatCoordinates)) { if (!this.flatCoordinates) {
this.flatCoordinates = []; this.flatCoordinates = [];
} }
this.flatCoordinates.length = ol.geom.flat.deflate.coordinates( this.flatCoordinates.length = ol.geom.flat.deflate.coordinates(
+3 -3
View File
@@ -70,7 +70,7 @@ goog.inherits(ol.geom.LineString, ol.geom.SimpleGeometry);
ol.geom.LineString.prototype.appendCoordinate = function(coordinate) { ol.geom.LineString.prototype.appendCoordinate = function(coordinate) {
goog.asserts.assert(coordinate.length == this.stride, goog.asserts.assert(coordinate.length == this.stride,
'length of coordinate array should match stride'); 'length of coordinate array should match stride');
if (goog.isNull(this.flatCoordinates)) { if (!this.flatCoordinates) {
this.flatCoordinates = coordinate.slice(); this.flatCoordinates = coordinate.slice();
} else { } else {
goog.array.extend(this.flatCoordinates, coordinate); goog.array.extend(this.flatCoordinates, coordinate);
@@ -235,11 +235,11 @@ ol.geom.LineString.prototype.intersectsExtent = function(extent) {
*/ */
ol.geom.LineString.prototype.setCoordinates = ol.geom.LineString.prototype.setCoordinates =
function(coordinates, opt_layout) { function(coordinates, opt_layout) {
if (goog.isNull(coordinates)) { if (!coordinates) {
this.setFlatCoordinates(ol.geom.GeometryLayout.XY, null); this.setFlatCoordinates(ol.geom.GeometryLayout.XY, null);
} else { } else {
this.setLayout(opt_layout, coordinates, 1); this.setLayout(opt_layout, coordinates, 1);
if (goog.isNull(this.flatCoordinates)) { if (!this.flatCoordinates) {
this.flatCoordinates = []; this.flatCoordinates = [];
} }
this.flatCoordinates.length = ol.geom.flat.deflate.coordinates( this.flatCoordinates.length = ol.geom.flat.deflate.coordinates(
+6 -6
View File
@@ -63,7 +63,7 @@ goog.inherits(ol.geom.MultiLineString, ol.geom.SimpleGeometry);
ol.geom.MultiLineString.prototype.appendLineString = function(lineString) { ol.geom.MultiLineString.prototype.appendLineString = function(lineString) {
goog.asserts.assert(lineString.getLayout() == this.layout, goog.asserts.assert(lineString.getLayout() == this.layout,
'layout of lineString should match the layout'); 'layout of lineString should match the layout');
if (goog.isNull(this.flatCoordinates)) { if (!this.flatCoordinates) {
this.flatCoordinates = lineString.getFlatCoordinates().slice(); this.flatCoordinates = lineString.getFlatCoordinates().slice();
} else { } else {
goog.array.extend( goog.array.extend(
@@ -270,11 +270,11 @@ ol.geom.MultiLineString.prototype.intersectsExtent = function(extent) {
*/ */
ol.geom.MultiLineString.prototype.setCoordinates = ol.geom.MultiLineString.prototype.setCoordinates =
function(coordinates, opt_layout) { function(coordinates, opt_layout) {
if (goog.isNull(coordinates)) { if (!coordinates) {
this.setFlatCoordinates(ol.geom.GeometryLayout.XY, null, this.ends_); this.setFlatCoordinates(ol.geom.GeometryLayout.XY, null, this.ends_);
} else { } else {
this.setLayout(opt_layout, coordinates, 2); this.setLayout(opt_layout, coordinates, 2);
if (goog.isNull(this.flatCoordinates)) { if (!this.flatCoordinates) {
this.flatCoordinates = []; this.flatCoordinates = [];
} }
var ends = ol.geom.flat.deflate.coordinatess( var ends = ol.geom.flat.deflate.coordinatess(
@@ -292,9 +292,9 @@ ol.geom.MultiLineString.prototype.setCoordinates =
*/ */
ol.geom.MultiLineString.prototype.setFlatCoordinates = ol.geom.MultiLineString.prototype.setFlatCoordinates =
function(layout, flatCoordinates, ends) { function(layout, flatCoordinates, ends) {
if (goog.isNull(flatCoordinates)) { if (!flatCoordinates) {
goog.asserts.assert(!goog.isNull(ends) && ends.length === 0, goog.asserts.assert(ends && ends.length === 0,
'ends cannot be null and ends.length should be 0'); 'ends must be truthy and ends.length should be 0');
} else if (ends.length === 0) { } else if (ends.length === 0) {
goog.asserts.assert(flatCoordinates.length === 0, goog.asserts.assert(flatCoordinates.length === 0,
'flatCoordinates should be an empty array'); 'flatCoordinates should be an empty array');
+4 -4
View File
@@ -38,7 +38,7 @@ goog.inherits(ol.geom.MultiPoint, ol.geom.SimpleGeometry);
ol.geom.MultiPoint.prototype.appendPoint = function(point) { ol.geom.MultiPoint.prototype.appendPoint = function(point) {
goog.asserts.assert(point.getLayout() == this.layout, goog.asserts.assert(point.getLayout() == this.layout,
'the layout of point should match layout'); 'the layout of point should match layout');
if (goog.isNull(this.flatCoordinates)) { if (!this.flatCoordinates) {
this.flatCoordinates = point.getFlatCoordinates().slice(); this.flatCoordinates = point.getFlatCoordinates().slice();
} else { } else {
goog.array.extend(this.flatCoordinates, point.getFlatCoordinates()); goog.array.extend(this.flatCoordinates, point.getFlatCoordinates());
@@ -104,7 +104,7 @@ ol.geom.MultiPoint.prototype.getCoordinates = function() {
* @api stable * @api stable
*/ */
ol.geom.MultiPoint.prototype.getPoint = function(index) { ol.geom.MultiPoint.prototype.getPoint = function(index) {
var n = goog.isNull(this.flatCoordinates) ? var n = !this.flatCoordinates ?
0 : this.flatCoordinates.length / this.stride; 0 : this.flatCoordinates.length / this.stride;
goog.asserts.assert(0 <= index && index < n, goog.asserts.assert(0 <= index && index < n,
'index should be in between 0 and n'); 'index should be in between 0 and n');
@@ -175,11 +175,11 @@ ol.geom.MultiPoint.prototype.intersectsExtent = function(extent) {
*/ */
ol.geom.MultiPoint.prototype.setCoordinates = ol.geom.MultiPoint.prototype.setCoordinates =
function(coordinates, opt_layout) { function(coordinates, opt_layout) {
if (goog.isNull(coordinates)) { if (!coordinates) {
this.setFlatCoordinates(ol.geom.GeometryLayout.XY, null); this.setFlatCoordinates(ol.geom.GeometryLayout.XY, null);
} else { } else {
this.setLayout(opt_layout, coordinates, 1); this.setLayout(opt_layout, coordinates, 1);
if (goog.isNull(this.flatCoordinates)) { if (!this.flatCoordinates) {
this.flatCoordinates = []; this.flatCoordinates = [];
} }
this.flatCoordinates.length = ol.geom.flat.deflate.coordinates( this.flatCoordinates.length = ol.geom.flat.deflate.coordinates(
+5 -5
View File
@@ -95,7 +95,7 @@ ol.geom.MultiPolygon.prototype.appendPolygon = function(polygon) {
'layout of polygon should match layout'); 'layout of polygon should match layout');
/** @type {Array.<number>} */ /** @type {Array.<number>} */
var ends; var ends;
if (goog.isNull(this.flatCoordinates)) { if (!this.flatCoordinates) {
this.flatCoordinates = polygon.getFlatCoordinates().slice(); this.flatCoordinates = polygon.getFlatCoordinates().slice();
ends = polygon.getEnds().slice(); ends = polygon.getEnds().slice();
this.endss_.push(); this.endss_.push();
@@ -363,11 +363,11 @@ ol.geom.MultiPolygon.prototype.intersectsExtent = function(extent) {
*/ */
ol.geom.MultiPolygon.prototype.setCoordinates = ol.geom.MultiPolygon.prototype.setCoordinates =
function(coordinates, opt_layout) { function(coordinates, opt_layout) {
if (goog.isNull(coordinates)) { if (!coordinates) {
this.setFlatCoordinates(ol.geom.GeometryLayout.XY, null, this.endss_); this.setFlatCoordinates(ol.geom.GeometryLayout.XY, null, this.endss_);
} else { } else {
this.setLayout(opt_layout, coordinates, 3); this.setLayout(opt_layout, coordinates, 3);
if (goog.isNull(this.flatCoordinates)) { if (!this.flatCoordinates) {
this.flatCoordinates = []; this.flatCoordinates = [];
} }
var endss = ol.geom.flat.deflate.coordinatesss( var endss = ol.geom.flat.deflate.coordinatesss(
@@ -391,8 +391,8 @@ ol.geom.MultiPolygon.prototype.setCoordinates =
*/ */
ol.geom.MultiPolygon.prototype.setFlatCoordinates = ol.geom.MultiPolygon.prototype.setFlatCoordinates =
function(layout, flatCoordinates, endss) { function(layout, flatCoordinates, endss) {
goog.asserts.assert(!goog.isNull(endss), 'endss cannot be null'); goog.asserts.assert(endss, 'endss must be truthy');
if (goog.isNull(flatCoordinates) || flatCoordinates.length === 0) { if (!flatCoordinates || flatCoordinates.length === 0) {
goog.asserts.assert(endss.length === 0, 'the length of endss should be 0'); goog.asserts.assert(endss.length === 0, 'the length of endss should be 0');
} else { } else {
goog.asserts.assert(endss.length > 0, 'endss cannot be an empty array'); goog.asserts.assert(endss.length > 0, 'endss cannot be an empty array');
+3 -3
View File
@@ -66,7 +66,7 @@ ol.geom.Point.prototype.closestPointXY =
* @api stable * @api stable
*/ */
ol.geom.Point.prototype.getCoordinates = function() { ol.geom.Point.prototype.getCoordinates = function() {
return goog.isNull(this.flatCoordinates) ? [] : this.flatCoordinates.slice(); return !this.flatCoordinates ? [] : this.flatCoordinates.slice();
}; };
@@ -104,11 +104,11 @@ ol.geom.Point.prototype.intersectsExtent = function(extent) {
* @api stable * @api stable
*/ */
ol.geom.Point.prototype.setCoordinates = function(coordinates, opt_layout) { ol.geom.Point.prototype.setCoordinates = function(coordinates, opt_layout) {
if (goog.isNull(coordinates)) { if (!coordinates) {
this.setFlatCoordinates(ol.geom.GeometryLayout.XY, null); this.setFlatCoordinates(ol.geom.GeometryLayout.XY, null);
} else { } else {
this.setLayout(opt_layout, coordinates, 0); this.setLayout(opt_layout, coordinates, 0);
if (goog.isNull(this.flatCoordinates)) { if (!this.flatCoordinates) {
this.flatCoordinates = []; this.flatCoordinates = [];
} }
this.flatCoordinates.length = ol.geom.flat.deflate.coordinate( this.flatCoordinates.length = ol.geom.flat.deflate.coordinate(
+6 -6
View File
@@ -92,7 +92,7 @@ goog.inherits(ol.geom.Polygon, ol.geom.SimpleGeometry);
ol.geom.Polygon.prototype.appendLinearRing = function(linearRing) { ol.geom.Polygon.prototype.appendLinearRing = function(linearRing) {
goog.asserts.assert(linearRing.getLayout() == this.layout, goog.asserts.assert(linearRing.getLayout() == this.layout,
'layout of linearRing should match layout'); 'layout of linearRing should match layout');
if (goog.isNull(this.flatCoordinates)) { if (!this.flatCoordinates) {
this.flatCoordinates = linearRing.getFlatCoordinates().slice(); this.flatCoordinates = linearRing.getFlatCoordinates().slice();
} else { } else {
goog.array.extend(this.flatCoordinates, linearRing.getFlatCoordinates()); goog.array.extend(this.flatCoordinates, linearRing.getFlatCoordinates());
@@ -339,11 +339,11 @@ ol.geom.Polygon.prototype.intersectsExtent = function(extent) {
* @api stable * @api stable
*/ */
ol.geom.Polygon.prototype.setCoordinates = function(coordinates, opt_layout) { ol.geom.Polygon.prototype.setCoordinates = function(coordinates, opt_layout) {
if (goog.isNull(coordinates)) { if (!coordinates) {
this.setFlatCoordinates(ol.geom.GeometryLayout.XY, null, this.ends_); this.setFlatCoordinates(ol.geom.GeometryLayout.XY, null, this.ends_);
} else { } else {
this.setLayout(opt_layout, coordinates, 2); this.setLayout(opt_layout, coordinates, 2);
if (goog.isNull(this.flatCoordinates)) { if (!this.flatCoordinates) {
this.flatCoordinates = []; this.flatCoordinates = [];
} }
var ends = ol.geom.flat.deflate.coordinatess( var ends = ol.geom.flat.deflate.coordinatess(
@@ -361,9 +361,9 @@ ol.geom.Polygon.prototype.setCoordinates = function(coordinates, opt_layout) {
*/ */
ol.geom.Polygon.prototype.setFlatCoordinates = ol.geom.Polygon.prototype.setFlatCoordinates =
function(layout, flatCoordinates, ends) { function(layout, flatCoordinates, ends) {
if (goog.isNull(flatCoordinates)) { if (!flatCoordinates) {
goog.asserts.assert(!goog.isNull(ends) && ends.length === 0, goog.asserts.assert(ends && ends.length === 0,
'ends cannot be null and should be an empty array'); 'ends must be an empty array');
} else if (ends.length === 0) { } else if (ends.length === 0) {
goog.asserts.assert(flatCoordinates.length === 0, goog.asserts.assert(flatCoordinates.length === 0,
'flatCoordinates should be an empty array'); 'flatCoordinates should be an empty array');
+3 -3
View File
@@ -258,7 +258,7 @@ ol.geom.SimpleGeometry.prototype.setLayout =
* @api stable * @api stable
*/ */
ol.geom.SimpleGeometry.prototype.applyTransform = function(transformFn) { ol.geom.SimpleGeometry.prototype.applyTransform = function(transformFn) {
if (!goog.isNull(this.flatCoordinates)) { if (this.flatCoordinates) {
transformFn(this.flatCoordinates, this.flatCoordinates, this.stride); transformFn(this.flatCoordinates, this.flatCoordinates, this.stride);
this.changed(); this.changed();
} }
@@ -271,7 +271,7 @@ ol.geom.SimpleGeometry.prototype.applyTransform = function(transformFn) {
*/ */
ol.geom.SimpleGeometry.prototype.translate = function(deltaX, deltaY) { ol.geom.SimpleGeometry.prototype.translate = function(deltaX, deltaY) {
var flatCoordinates = this.getFlatCoordinates(); var flatCoordinates = this.getFlatCoordinates();
if (!goog.isNull(flatCoordinates)) { if (flatCoordinates) {
var stride = this.getStride(); var stride = this.getStride();
ol.geom.flat.transform.translate( ol.geom.flat.transform.translate(
flatCoordinates, 0, flatCoordinates.length, stride, flatCoordinates, 0, flatCoordinates.length, stride,
@@ -290,7 +290,7 @@ ol.geom.SimpleGeometry.prototype.translate = function(deltaX, deltaY) {
ol.geom.transformSimpleGeometry2D = ol.geom.transformSimpleGeometry2D =
function(simpleGeometry, transform, opt_dest) { function(simpleGeometry, transform, opt_dest) {
var flatCoordinates = simpleGeometry.getFlatCoordinates(); var flatCoordinates = simpleGeometry.getFlatCoordinates();
if (goog.isNull(flatCoordinates)) { if (!flatCoordinates) {
return null; return null;
} else { } else {
var stride = simpleGeometry.getStride(); var stride = simpleGeometry.getStride();
+5 -5
View File
@@ -415,7 +415,7 @@ ol.Graticule.prototype.handlePostCompose_ = function(e) {
var squaredTolerance = var squaredTolerance =
resolution * resolution / (4 * pixelRatio * pixelRatio); resolution * resolution / (4 * pixelRatio * pixelRatio);
var updateProjectionInfo = goog.isNull(this.projection_) || var updateProjectionInfo = !this.projection_ ||
!ol.proj.equivalent(this.projection_, projection); !ol.proj.equivalent(this.projection_, projection);
if (updateProjectionInfo) { if (updateProjectionInfo) {
@@ -443,7 +443,7 @@ ol.Graticule.prototype.handlePostCompose_ = function(e) {
* @private * @private
*/ */
ol.Graticule.prototype.updateProjectionInfo_ = function(projection) { ol.Graticule.prototype.updateProjectionInfo_ = function(projection) {
goog.asserts.assert(!goog.isNull(projection), 'projection cannot be null'); goog.asserts.assert(projection, 'projection cannot be null');
var epsg4326Projection = ol.proj.get('EPSG:4326'); var epsg4326Projection = ol.proj.get('EPSG:4326');
@@ -462,7 +462,7 @@ ol.Graticule.prototype.updateProjectionInfo_ = function(projection) {
var minLatP = worldExtentP[1]; var minLatP = worldExtentP[1];
var minLonP = worldExtentP[0]; var minLonP = worldExtentP[0];
goog.asserts.assert(!goog.isNull(extent), 'extent cannot be null'); goog.asserts.assert(extent, 'extent cannot be null');
goog.asserts.assert(maxLat !== undefined, 'maxLat should be defined'); goog.asserts.assert(maxLat !== undefined, 'maxLat should be defined');
goog.asserts.assert(maxLon !== undefined, 'maxLon should be defined'); goog.asserts.assert(maxLon !== undefined, 'maxLon should be defined');
goog.asserts.assert(minLat !== undefined, 'minLat should be defined'); goog.asserts.assert(minLat !== undefined, 'minLat should be defined');
@@ -508,12 +508,12 @@ ol.Graticule.prototype.updateProjectionInfo_ = function(projection) {
* @api * @api
*/ */
ol.Graticule.prototype.setMap = function(map) { ol.Graticule.prototype.setMap = function(map) {
if (!goog.isNull(this.map_)) { if (this.map_) {
this.map_.un(ol.render.EventType.POSTCOMPOSE, this.map_.un(ol.render.EventType.POSTCOMPOSE,
this.handlePostCompose_, this); this.handlePostCompose_, this);
this.map_.render(); this.map_.render();
} }
if (!goog.isNull(map)) { if (map) {
map.on(ol.render.EventType.POSTCOMPOSE, map.on(ol.render.EventType.POSTCOMPOSE,
this.handlePostCompose_, this); this.handlePostCompose_, this);
map.render(); map.render();
+2 -2
View File
@@ -41,7 +41,7 @@ ol.has.CANVAS = ol.ENABLE_CANVAS && (
} }
try { try {
var context = ol.dom.createCanvasContext2D(); var context = ol.dom.createCanvasContext2D();
if (goog.isNull(context)) { if (!context) {
return false; return false;
} else { } else {
if (context.setLineDash !== undefined) { if (context.setLineDash !== undefined) {
@@ -129,7 +129,7 @@ ol.has.WEBGL;
var gl = ol.webgl.getContext(canvas, { var gl = ol.webgl.getContext(canvas, {
failIfMajorPerformanceCaveat: true failIfMajorPerformanceCaveat: true
}); });
if (!goog.isNull(gl)) { if (gl) {
hasWebGL = true; hasWebGL = true;
textureSize = /** @type {number} */ textureSize = /** @type {number} */
(gl.getParameter(gl.MAX_TEXTURE_SIZE)); (gl.getParameter(gl.MAX_TEXTURE_SIZE));
+3 -3
View File
@@ -38,7 +38,7 @@ ol.Image = function(extent, resolution, pixelRatio, attributions, src,
* @type {Image} * @type {Image}
*/ */
this.image_ = new Image(); this.image_ = new Image();
if (!goog.isNull(crossOrigin)) { if (crossOrigin) {
this.image_.crossOrigin = crossOrigin; this.image_.crossOrigin = crossOrigin;
} }
@@ -129,7 +129,7 @@ ol.Image.prototype.load = function() {
if (this.state == ol.ImageState.IDLE) { if (this.state == ol.ImageState.IDLE) {
this.state = ol.ImageState.LOADING; this.state = ol.ImageState.LOADING;
this.changed(); this.changed();
goog.asserts.assert(goog.isNull(this.imageListenerKeys_), goog.asserts.assert(!this.imageListenerKeys_,
'this.imageListenerKeys_ should be null'); 'this.imageListenerKeys_ should be null');
this.imageListenerKeys_ = [ this.imageListenerKeys_ = [
goog.events.listenOnce(this.image_, goog.events.EventType.ERROR, goog.events.listenOnce(this.image_, goog.events.EventType.ERROR,
@@ -148,7 +148,7 @@ ol.Image.prototype.load = function() {
* @private * @private
*/ */
ol.Image.prototype.unlistenImage_ = function() { ol.Image.prototype.unlistenImage_ = function() {
goog.asserts.assert(!goog.isNull(this.imageListenerKeys_), goog.asserts.assert(this.imageListenerKeys_,
'this.imageListenerKeys_ should not be null'); 'this.imageListenerKeys_ should not be null');
this.imageListenerKeys_.forEach(goog.events.unlistenByKey); this.imageListenerKeys_.forEach(goog.events.unlistenByKey);
this.imageListenerKeys_ = null; this.imageListenerKeys_ = null;
+1 -1
View File
@@ -78,7 +78,7 @@ ol.ImageCanvas.prototype.handleLoad_ = function(err) {
*/ */
ol.ImageCanvas.prototype.load = function() { ol.ImageCanvas.prototype.load = function() {
if (this.state == ol.ImageState.IDLE) { if (this.state == ol.ImageState.IDLE) {
goog.asserts.assert(!goog.isNull(this.loader_)); goog.asserts.assert(this.loader_, 'this.loader_ must be set');
this.state = ol.ImageState.LOADING; this.state = ol.ImageState.LOADING;
this.changed(); this.changed();
this.loader_(goog.bind(this.handleLoad_, this)); this.loader_(goog.bind(this.handleLoad_, this));
+3 -3
View File
@@ -37,7 +37,7 @@ ol.ImageTile = function(tileCoord, state, src, crossOrigin, tileLoadFunction) {
* @type {Image} * @type {Image}
*/ */
this.image_ = new Image(); this.image_ = new Image();
if (!goog.isNull(crossOrigin)) { if (crossOrigin) {
this.image_.crossOrigin = crossOrigin; this.image_.crossOrigin = crossOrigin;
} }
@@ -141,7 +141,7 @@ ol.ImageTile.prototype.load = function() {
if (this.state == ol.TileState.IDLE) { if (this.state == ol.TileState.IDLE) {
this.state = ol.TileState.LOADING; this.state = ol.TileState.LOADING;
this.changed(); this.changed();
goog.asserts.assert(goog.isNull(this.imageListenerKeys_), goog.asserts.assert(!this.imageListenerKeys_,
'this.imageListenerKeys_ should be null'); 'this.imageListenerKeys_ should be null');
this.imageListenerKeys_ = [ this.imageListenerKeys_ = [
goog.events.listenOnce(this.image_, goog.events.EventType.ERROR, goog.events.listenOnce(this.image_, goog.events.EventType.ERROR,
@@ -160,7 +160,7 @@ ol.ImageTile.prototype.load = function() {
* @private * @private
*/ */
ol.ImageTile.prototype.unlistenImage_ = function() { ol.ImageTile.prototype.unlistenImage_ = function() {
goog.asserts.assert(!goog.isNull(this.imageListenerKeys_), goog.asserts.assert(this.imageListenerKeys_,
'this.imageListenerKeys_ should not be null'); 'this.imageListenerKeys_ should not be null');
this.imageListenerKeys_.forEach(goog.events.unlistenByKey); this.imageListenerKeys_.forEach(goog.events.unlistenByKey);
this.imageListenerKeys_ = null; this.imageListenerKeys_ = null;
@@ -56,7 +56,7 @@ ol.interaction.DoubleClickZoom.handleEvent = function(mapBrowserEvent) {
var anchor = mapBrowserEvent.coordinate; var anchor = mapBrowserEvent.coordinate;
var delta = browserEvent.shiftKey ? -this.delta_ : this.delta_; var delta = browserEvent.shiftKey ? -this.delta_ : this.delta_;
var view = map.getView(); var view = map.getView();
goog.asserts.assert(!goog.isNull(view), 'view should not be null'); goog.asserts.assert(view, 'map must have a view');
ol.interaction.Interaction.zoomByDelta( ol.interaction.Interaction.zoomByDelta(
map, view, delta, anchor, this.duration_); map, view, delta, anchor, this.duration_);
mapBrowserEvent.preventDefault(); mapBrowserEvent.preventDefault();
+6 -6
View File
@@ -98,11 +98,11 @@ ol.interaction.DragAndDrop.prototype.handleDrop_ = function(event) {
*/ */
ol.interaction.DragAndDrop.prototype.handleResult_ = function(file, result) { ol.interaction.DragAndDrop.prototype.handleResult_ = function(file, result) {
var map = this.getMap(); var map = this.getMap();
goog.asserts.assert(!goog.isNull(map), 'map should not be null'); goog.asserts.assert(map, 'map must be set');
var projection = this.projection_; var projection = this.projection_;
if (goog.isNull(projection)) { if (!projection) {
var view = map.getView(); var view = map.getView();
goog.asserts.assert(!goog.isNull(view), 'view should not be null'); goog.asserts.assert(view, 'map must have view');
projection = view.getProjection(); projection = view.getProjection();
goog.asserts.assert(projection !== undefined, goog.asserts.assert(projection !== undefined,
'projection should be defined'); 'projection should be defined');
@@ -114,7 +114,7 @@ ol.interaction.DragAndDrop.prototype.handleResult_ = function(file, result) {
var formatConstructor = formatConstructors[i]; var formatConstructor = formatConstructors[i];
var format = new formatConstructor(); var format = new formatConstructor();
var readFeatures = this.tryReadFeatures_(format, result); var readFeatures = this.tryReadFeatures_(format, result);
if (!goog.isNull(readFeatures)) { if (readFeatures) {
var featureProjection = format.readProjection(result); var featureProjection = format.readProjection(result);
var transform = ol.proj.getTransform(featureProjection, projection); var transform = ol.proj.getTransform(featureProjection, projection);
var j, jj; var j, jj;
@@ -154,14 +154,14 @@ ol.interaction.DragAndDrop.prototype.setMap = function(map) {
goog.events.unlistenByKey(this.dropListenKey_); goog.events.unlistenByKey(this.dropListenKey_);
this.dropListenKey_ = undefined; this.dropListenKey_ = undefined;
} }
if (!goog.isNull(this.fileDropHandler_)) { if (this.fileDropHandler_) {
goog.dispose(this.fileDropHandler_); goog.dispose(this.fileDropHandler_);
this.fileDropHandler_ = null; this.fileDropHandler_ = null;
} }
goog.asserts.assert(this.dropListenKey_ === undefined, 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 (map) {
this.fileDropHandler_ = new goog.events.FileDropHandler(map.getViewport()); this.fileDropHandler_ = new goog.events.FileDropHandler(map.getViewport());
this.dropListenKey_ = goog.events.listen( this.dropListenKey_ = goog.events.listen(
this.fileDropHandler_, goog.events.FileDropHandler.EventType.DROP, this.fileDropHandler_, goog.events.FileDropHandler.EventType.DROP,
+2 -2
View File
@@ -77,7 +77,7 @@ ol.interaction.DragPan.handleDragEvent_ = function(mapBrowserEvent) {
if (this.kinetic_) { if (this.kinetic_) {
this.kinetic_.update(centroid[0], centroid[1]); this.kinetic_.update(centroid[0], centroid[1]);
} }
if (!goog.isNull(this.lastCentroid)) { if (this.lastCentroid) {
var deltaX = this.lastCentroid[0] - centroid[0]; var deltaX = this.lastCentroid[0] - centroid[0];
var deltaY = centroid[1] - this.lastCentroid[1]; var deltaY = centroid[1] - this.lastCentroid[1];
var map = mapBrowserEvent.map; var map = mapBrowserEvent.map;
@@ -145,7 +145,7 @@ ol.interaction.DragPan.handleDownEvent_ = function(mapBrowserEvent) {
view.setHint(ol.ViewHint.INTERACTING, 1); view.setHint(ol.ViewHint.INTERACTING, 1);
} }
map.render(); map.render();
if (!goog.isNull(this.kineticPreRenderFn_) && if (this.kineticPreRenderFn_ &&
map.removePreRenderFunction(this.kineticPreRenderFn_)) { map.removePreRenderFunction(this.kineticPreRenderFn_)) {
view.setCenter(mapBrowserEvent.frameState.viewState.center); view.setCenter(mapBrowserEvent.frameState.viewState.center);
this.kineticPreRenderFn_ = null; this.kineticPreRenderFn_ = null;
+1 -1
View File
@@ -61,7 +61,7 @@ ol.interaction.DragZoom.prototype.onBoxEnd = function() {
var map = this.getMap(); var map = this.getMap();
var view = map.getView(); var view = map.getView();
goog.asserts.assert(!goog.isNull(view), 'view should not be null'); goog.asserts.assert(view, 'map must have view');
var size = map.getSize(); var size = map.getSize();
goog.asserts.assert(size !== undefined, 'size should be defined'); goog.asserts.assert(size !== undefined, 'size should be defined');
+18 -20
View File
@@ -367,7 +367,7 @@ ol.interaction.Draw.handleDownEvent_ = function(event) {
this.freehandCondition_(event)) { this.freehandCondition_(event)) {
this.downPx_ = event.pixel; this.downPx_ = event.pixel;
this.freehand_ = true; this.freehand_ = true;
if (goog.isNull(this.finishCoordinate_)) { if (!this.finishCoordinate_) {
this.startDrawing_(event); this.startDrawing_(event);
} }
return true; return true;
@@ -393,7 +393,7 @@ ol.interaction.Draw.handleUpEvent_ = function(event) {
var pass = true; var pass = true;
if (squaredDistance <= this.squaredClickTolerance_) { if (squaredDistance <= this.squaredClickTolerance_) {
this.handlePointerMove_(event); this.handlePointerMove_(event);
if (goog.isNull(this.finishCoordinate_)) { if (!this.finishCoordinate_) {
this.startDrawing_(event); this.startDrawing_(event);
if (this.mode_ === ol.interaction.DrawMode.POINT) { if (this.mode_ === ol.interaction.DrawMode.POINT) {
this.finishDrawing(); this.finishDrawing();
@@ -418,7 +418,7 @@ ol.interaction.Draw.handleUpEvent_ = function(event) {
* @private * @private
*/ */
ol.interaction.Draw.prototype.handlePointerMove_ = function(event) { ol.interaction.Draw.prototype.handlePointerMove_ = function(event) {
if (!goog.isNull(this.finishCoordinate_)) { if (this.finishCoordinate_) {
this.modifyDrawing_(event); this.modifyDrawing_(event);
} else { } else {
this.createOrUpdateSketchPoint_(event); this.createOrUpdateSketchPoint_(event);
@@ -435,7 +435,7 @@ ol.interaction.Draw.prototype.handlePointerMove_ = function(event) {
*/ */
ol.interaction.Draw.prototype.atFinish_ = function(event) { ol.interaction.Draw.prototype.atFinish_ = function(event) {
var at = false; var at = false;
if (!goog.isNull(this.sketchFeature_)) { if (this.sketchFeature_) {
var potentiallyDone = false; var potentiallyDone = false;
var potentiallyFinishCoordinates = [this.finishCoordinate_]; var potentiallyFinishCoordinates = [this.finishCoordinate_];
if (this.mode_ === ol.interaction.DrawMode.LINE_STRING) { if (this.mode_ === ol.interaction.DrawMode.LINE_STRING) {
@@ -474,7 +474,7 @@ ol.interaction.Draw.prototype.atFinish_ = function(event) {
*/ */
ol.interaction.Draw.prototype.createOrUpdateSketchPoint_ = function(event) { ol.interaction.Draw.prototype.createOrUpdateSketchPoint_ = function(event) {
var coordinates = event.coordinate.slice(); var coordinates = event.coordinate.slice();
if (goog.isNull(this.sketchPoint_)) { if (!this.sketchPoint_) {
this.sketchPoint_ = new ol.Feature(new ol.geom.Point(coordinates)); this.sketchPoint_ = new ol.Feature(new ol.geom.Point(coordinates));
this.updateSketchFeatures_(); this.updateSketchFeatures_();
} else { } else {
@@ -505,7 +505,7 @@ ol.interaction.Draw.prototype.startDrawing_ = function(event) {
this.sketchLineCoords_ = this.sketchCoords_; this.sketchLineCoords_ = this.sketchCoords_;
} }
} }
if (!goog.isNull(this.sketchLineCoords_)) { if (this.sketchLineCoords_) {
this.sketchLine_ = new ol.Feature( this.sketchLine_ = new ol.Feature(
new ol.geom.LineString(this.sketchLineCoords_)); new ol.geom.LineString(this.sketchLineCoords_));
} }
@@ -548,10 +548,9 @@ ol.interaction.Draw.prototype.modifyDrawing_ = function(event) {
} }
last[0] = coordinate[0]; last[0] = coordinate[0];
last[1] = coordinate[1]; last[1] = coordinate[1];
goog.asserts.assert(!goog.isNull(this.sketchCoords_), goog.asserts.assert(this.sketchCoords_, 'sketchCoords_ expected');
'sketchCoords_ must not be null');
this.geometryFunction_(this.sketchCoords_, geometry); this.geometryFunction_(this.sketchCoords_, geometry);
if (!goog.isNull(this.sketchPoint_)) { if (this.sketchPoint_) {
var sketchPointGeom = this.sketchPoint_.getGeometry(); var sketchPointGeom = this.sketchPoint_.getGeometry();
goog.asserts.assertInstanceof(sketchPointGeom, ol.geom.Point, goog.asserts.assertInstanceof(sketchPointGeom, ol.geom.Point,
'sketchPointGeom should be an ol.geom.Point'); 'sketchPointGeom should be an ol.geom.Point');
@@ -560,7 +559,7 @@ ol.interaction.Draw.prototype.modifyDrawing_ = function(event) {
var sketchLineGeom; var sketchLineGeom;
if (geometry instanceof ol.geom.Polygon && if (geometry instanceof ol.geom.Polygon &&
this.mode_ !== ol.interaction.DrawMode.POLYGON) { this.mode_ !== ol.interaction.DrawMode.POLYGON) {
if (goog.isNull(this.sketchLine_)) { if (!this.sketchLine_) {
this.sketchLine_ = new ol.Feature(new ol.geom.LineString(null)); this.sketchLine_ = new ol.Feature(new ol.geom.LineString(null));
} }
var ring = geometry.getLinearRing(0); var ring = geometry.getLinearRing(0);
@@ -569,7 +568,7 @@ ol.interaction.Draw.prototype.modifyDrawing_ = function(event) {
'sketchLineGeom must be an ol.geom.LineString'); 'sketchLineGeom must be an ol.geom.LineString');
sketchLineGeom.setFlatCoordinates( sketchLineGeom.setFlatCoordinates(
ring.getLayout(), ring.getFlatCoordinates()); ring.getLayout(), ring.getFlatCoordinates());
} else if (!goog.isNull(this.sketchLineCoords_)) { } else if (this.sketchLineCoords_) {
sketchLineGeom = this.sketchLine_.getGeometry(); sketchLineGeom = this.sketchLine_.getGeometry();
goog.asserts.assertInstanceof(sketchLineGeom, ol.geom.LineString, goog.asserts.assertInstanceof(sketchLineGeom, ol.geom.LineString,
'sketchLineGeom must be an ol.geom.LineString'); 'sketchLineGeom must be an ol.geom.LineString');
@@ -652,8 +651,7 @@ ol.interaction.Draw.prototype.removeLastPoint = function() {
*/ */
ol.interaction.Draw.prototype.finishDrawing = function() { ol.interaction.Draw.prototype.finishDrawing = function() {
var sketchFeature = this.abortDrawing_(); var sketchFeature = this.abortDrawing_();
goog.asserts.assert(!goog.isNull(sketchFeature), goog.asserts.assert(sketchFeature, 'sketchFeature expected to be truthy');
'sketchFeature should not be null');
var coordinates = this.sketchCoords_; var coordinates = this.sketchCoords_;
var geometry = sketchFeature.getGeometry(); var geometry = sketchFeature.getGeometry();
goog.asserts.assertInstanceof(geometry, ol.geom.SimpleGeometry, goog.asserts.assertInstanceof(geometry, ol.geom.SimpleGeometry,
@@ -685,10 +683,10 @@ ol.interaction.Draw.prototype.finishDrawing = function() {
ol.interaction.DrawEventType.DRAWEND, sketchFeature)); ol.interaction.DrawEventType.DRAWEND, sketchFeature));
// Then insert feature // Then insert feature
if (!goog.isNull(this.features_)) { if (this.features_) {
this.features_.push(sketchFeature); this.features_.push(sketchFeature);
} }
if (!goog.isNull(this.source_)) { if (this.source_) {
this.source_.addFeature(sketchFeature); this.source_.addFeature(sketchFeature);
} }
}; };
@@ -702,7 +700,7 @@ ol.interaction.Draw.prototype.finishDrawing = function() {
ol.interaction.Draw.prototype.abortDrawing_ = function() { ol.interaction.Draw.prototype.abortDrawing_ = function() {
this.finishCoordinate_ = null; this.finishCoordinate_ = null;
var sketchFeature = this.sketchFeature_; var sketchFeature = this.sketchFeature_;
if (!goog.isNull(sketchFeature)) { if (sketchFeature) {
this.sketchFeature_ = null; this.sketchFeature_ = null;
this.sketchPoint_ = null; this.sketchPoint_ = null;
this.sketchLine_ = null; this.sketchLine_ = null;
@@ -750,13 +748,13 @@ ol.interaction.Draw.prototype.shouldStopEvent = goog.functions.FALSE;
*/ */
ol.interaction.Draw.prototype.updateSketchFeatures_ = function() { ol.interaction.Draw.prototype.updateSketchFeatures_ = function() {
var sketchFeatures = []; var sketchFeatures = [];
if (!goog.isNull(this.sketchFeature_)) { if (this.sketchFeature_) {
sketchFeatures.push(this.sketchFeature_); sketchFeatures.push(this.sketchFeature_);
} }
if (!goog.isNull(this.sketchLine_)) { if (this.sketchLine_) {
sketchFeatures.push(this.sketchLine_); sketchFeatures.push(this.sketchLine_);
} }
if (!goog.isNull(this.sketchPoint_)) { if (this.sketchPoint_) {
sketchFeatures.push(this.sketchPoint_); sketchFeatures.push(this.sketchPoint_);
} }
var overlaySource = this.overlay_.getSource(); var overlaySource = this.overlay_.getSource();
@@ -771,7 +769,7 @@ ol.interaction.Draw.prototype.updateSketchFeatures_ = function() {
ol.interaction.Draw.prototype.updateState_ = function() { ol.interaction.Draw.prototype.updateState_ = function() {
var map = this.getMap(); var map = this.getMap();
var active = this.getActive(); var active = this.getActive();
if (goog.isNull(map) || !active) { if (!map || !active) {
this.abortDrawing_(); this.abortDrawing_();
} }
this.overlay_.setMap(active ? map : null); this.overlay_.setMap(active ? map : null);
+1 -1
View File
@@ -85,7 +85,7 @@ ol.interaction.KeyboardPan.handleEvent = function(mapBrowserEvent) {
keyCode == goog.events.KeyCodes.UP)) { keyCode == goog.events.KeyCodes.UP)) {
var map = mapBrowserEvent.map; var map = mapBrowserEvent.map;
var view = map.getView(); var view = map.getView();
goog.asserts.assert(!goog.isNull(view), 'view should not be null'); goog.asserts.assert(view, 'map must have view');
var mapUnitsDelta = view.getResolution() * this.pixelDelta_; var mapUnitsDelta = view.getResolution() * this.pixelDelta_;
var deltaX = 0, deltaY = 0; var deltaX = 0, deltaY = 0;
if (keyCode == goog.events.KeyCodes.DOWN) { if (keyCode == goog.events.KeyCodes.DOWN) {
@@ -77,7 +77,7 @@ ol.interaction.KeyboardZoom.handleEvent = function(mapBrowserEvent) {
var delta = (charCode == '+'.charCodeAt(0)) ? this.delta_ : -this.delta_; var delta = (charCode == '+'.charCodeAt(0)) ? this.delta_ : -this.delta_;
map.render(); map.render();
var view = map.getView(); var view = map.getView();
goog.asserts.assert(!goog.isNull(view), 'view should not be null'); goog.asserts.assert(view, 'map must have view');
ol.interaction.Interaction.zoomByDelta( ol.interaction.Interaction.zoomByDelta(
map, view, delta, undefined, this.duration_); map, view, delta, undefined, this.duration_);
mapBrowserEvent.preventDefault(); mapBrowserEvent.preventDefault();
+8 -10
View File
@@ -243,7 +243,7 @@ ol.interaction.Modify.prototype.addFeature_ = function(feature) {
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();
if (!goog.isNull(map)) { if (map) {
this.handlePointerAtPixel_(this.lastPixel_, map); this.handlePointerAtPixel_(this.lastPixel_, map);
} }
goog.events.listen(feature, goog.events.EventType.CHANGE, goog.events.listen(feature, goog.events.EventType.CHANGE,
@@ -259,8 +259,7 @@ ol.interaction.Modify.prototype.removeFeature_ = function(feature) {
this.removeFeatureSegmentData_(feature); this.removeFeatureSegmentData_(feature);
// Remove the vertex feature if the collection of canditate features // Remove the vertex feature if the collection of canditate features
// is empty. // is empty.
if (!goog.isNull(this.vertexFeature_) && if (this.vertexFeature_ && this.features_.getLength() === 0) {
this.features_.getLength() === 0) {
this.overlay_.getSource().removeFeature(this.vertexFeature_); this.overlay_.getSource().removeFeature(this.vertexFeature_);
this.vertexFeature_ = null; this.vertexFeature_ = null;
} }
@@ -501,7 +500,7 @@ ol.interaction.Modify.prototype.writeGeometryCollectionGeometry_ =
ol.interaction.Modify.prototype.createOrUpdateVertexFeature_ = ol.interaction.Modify.prototype.createOrUpdateVertexFeature_ =
function(coordinates) { function(coordinates) {
var vertexFeature = this.vertexFeature_; var vertexFeature = this.vertexFeature_;
if (goog.isNull(vertexFeature)) { if (!vertexFeature) {
vertexFeature = new ol.Feature(new ol.geom.Point(coordinates)); vertexFeature = new ol.Feature(new ol.geom.Point(coordinates));
this.vertexFeature_ = vertexFeature; this.vertexFeature_ = vertexFeature;
this.overlay_.getSource().addFeature(vertexFeature); this.overlay_.getSource().addFeature(vertexFeature);
@@ -534,7 +533,7 @@ ol.interaction.Modify.handleDownEvent_ = function(evt) {
this.handlePointerAtPixel_(evt.pixel, evt.map); this.handlePointerAtPixel_(evt.pixel, evt.map);
this.dragSegments_ = []; this.dragSegments_ = [];
var vertexFeature = this.vertexFeature_; var vertexFeature = this.vertexFeature_;
if (!goog.isNull(vertexFeature)) { if (vertexFeature) {
var insertVertices = []; var insertVertices = [];
var geometry = /** @type {ol.geom.Point} */ (vertexFeature.getGeometry()); var geometry = /** @type {ol.geom.Point} */ (vertexFeature.getGeometry());
var vertex = geometry.getCoordinates(); var vertex = geometry.getCoordinates();
@@ -584,7 +583,7 @@ ol.interaction.Modify.handleDownEvent_ = function(evt) {
new ol.interaction.ModifyEvent(ol.ModifyEventType.MODIFYSTART, new ol.interaction.ModifyEvent(ol.ModifyEventType.MODIFYSTART,
this.features_, evt)); this.features_, evt));
} }
return !goog.isNull(this.vertexFeature_); return !!this.vertexFeature_;
}; };
@@ -678,8 +677,7 @@ ol.interaction.Modify.handleEvent = function(mapBrowserEvent) {
!this.handlingDownUpSequence) { !this.handlingDownUpSequence) {
this.handlePointerMove_(mapBrowserEvent); this.handlePointerMove_(mapBrowserEvent);
} }
if (!goog.isNull(this.vertexFeature_) && if (this.vertexFeature_ && this.deleteCondition_(mapBrowserEvent)) {
this.deleteCondition_(mapBrowserEvent)) {
if (mapBrowserEvent.type != ol.MapBrowserEvent.EventType.SINGLECLICK || if (mapBrowserEvent.type != ol.MapBrowserEvent.EventType.SINGLECLICK ||
!this.ignoreNextSingleClick_) { !this.ignoreNextSingleClick_) {
var geometry = this.vertexFeature_.getGeometry(); var geometry = this.vertexFeature_.getGeometry();
@@ -768,7 +766,7 @@ ol.interaction.Modify.prototype.handlePointerAtPixel_ = function(pixel, map) {
return; return;
} }
} }
if (!goog.isNull(this.vertexFeature_)) { if (this.vertexFeature_) {
this.overlay_.getSource().removeFeature(this.vertexFeature_); this.overlay_.getSource().removeFeature(this.vertexFeature_);
this.vertexFeature_ = null; this.vertexFeature_ = null;
} }
@@ -940,7 +938,7 @@ ol.interaction.Modify.prototype.removeVertex_ = function() {
newSegmentData); newSegmentData);
this.updateSegmentIndices_(geometry, index, segmentData.depth, -1); this.updateSegmentIndices_(geometry, index, segmentData.depth, -1);
if (!goog.isNull(this.vertexFeature_)) { if (this.vertexFeature_) {
this.overlay_.getSource().removeFeature(this.vertexFeature_); this.overlay_.getSource().removeFeature(this.vertexFeature_);
this.vertexFeature_ = null; this.vertexFeature_ = null;
} }
@@ -117,7 +117,7 @@ ol.interaction.MouseWheelZoom.prototype.doZoom_ = function(map) {
var delta = ol.math.clamp(this.delta_, -maxDelta, maxDelta); var delta = ol.math.clamp(this.delta_, -maxDelta, maxDelta);
var view = map.getView(); var view = map.getView();
goog.asserts.assert(!goog.isNull(view), 'view should not be null'); goog.asserts.assert(view, 'map must have view');
map.render(); map.render();
ol.interaction.Interaction.zoomByDelta(map, view, -delta, this.lastAnchor_, ol.interaction.Interaction.zoomByDelta(map, view, -delta, this.lastAnchor_,
+4 -4
View File
@@ -205,9 +205,9 @@ ol.interaction.Snap.prototype.forEachFeatureRemove_ = function(feature) {
*/ */
ol.interaction.Snap.prototype.getFeatures_ = function() { ol.interaction.Snap.prototype.getFeatures_ = function() {
var features; var features;
if (!goog.isNull(this.features_)) { if (this.features_) {
features = this.features_; features = this.features_;
} else if (!goog.isNull(this.source_)) { } else if (this.source_) {
features = this.source_.getFeatures(); features = this.source_.getFeatures();
} }
goog.asserts.assert(features !== undefined, 'features should be defined'); goog.asserts.assert(features !== undefined, 'features should be defined');
@@ -328,12 +328,12 @@ ol.interaction.Snap.prototype.setMap = function(map) {
goog.base(this, 'setMap', map); goog.base(this, 'setMap', map);
if (map) { if (map) {
if (!goog.isNull(this.features_)) { if (this.features_) {
keys.push(this.features_.on(ol.CollectionEventType.ADD, keys.push(this.features_.on(ol.CollectionEventType.ADD,
this.handleFeatureAdd_, this)); this.handleFeatureAdd_, this));
keys.push(this.features_.on(ol.CollectionEventType.REMOVE, keys.push(this.features_.on(ol.CollectionEventType.REMOVE,
this.handleFeatureRemove_, this)); this.handleFeatureRemove_, this));
} else if (!goog.isNull(this.source_)) { } else if (this.source_) {
keys.push(this.source_.on(ol.source.VectorEventType.ADDFEATURE, keys.push(this.source_.on(ol.source.VectorEventType.ADDFEATURE,
this.handleFeatureAdd_, this)); this.handleFeatureAdd_, this));
keys.push(this.source_.on(ol.source.VectorEventType.REMOVEFEATURE, keys.push(this.source_.on(ol.source.VectorEventType.REMOVEFEATURE,
+9 -9
View File
@@ -61,7 +61,7 @@ goog.inherits(ol.interaction.Translate, ol.interaction.Pointer);
*/ */
ol.interaction.Translate.handleDownEvent_ = function(event) { ol.interaction.Translate.handleDownEvent_ = function(event) {
this.lastFeature_ = this.featuresAtPixel_(event.pixel, event.map); this.lastFeature_ = this.featuresAtPixel_(event.pixel, event.map);
if (goog.isNull(this.lastCoordinate_) && !goog.isNull(this.lastFeature_)) { if (!this.lastCoordinate_ && this.lastFeature_) {
this.lastCoordinate_ = event.coordinate; this.lastCoordinate_ = event.coordinate;
ol.interaction.Translate.handleMoveEvent_.call(this, event); ol.interaction.Translate.handleMoveEvent_.call(this, event);
return true; return true;
@@ -77,7 +77,7 @@ ol.interaction.Translate.handleDownEvent_ = function(event) {
* @private * @private
*/ */
ol.interaction.Translate.handleUpEvent_ = function(event) { ol.interaction.Translate.handleUpEvent_ = function(event) {
if (!goog.isNull(this.lastCoordinate_)) { if (this.lastCoordinate_) {
this.lastCoordinate_ = null; this.lastCoordinate_ = null;
ol.interaction.Translate.handleMoveEvent_.call(this, event); ol.interaction.Translate.handleMoveEvent_.call(this, event);
return true; return true;
@@ -92,18 +92,18 @@ ol.interaction.Translate.handleUpEvent_ = function(event) {
* @private * @private
*/ */
ol.interaction.Translate.handleDragEvent_ = function(event) { ol.interaction.Translate.handleDragEvent_ = function(event) {
if (!goog.isNull(this.lastCoordinate_)) { if (this.lastCoordinate_) {
var newCoordinate = event.coordinate; var newCoordinate = event.coordinate;
var deltaX = newCoordinate[0] - this.lastCoordinate_[0]; var deltaX = newCoordinate[0] - this.lastCoordinate_[0];
var deltaY = newCoordinate[1] - this.lastCoordinate_[1]; var deltaY = newCoordinate[1] - this.lastCoordinate_[1];
if (!goog.isNull(this.features_)) { if (this.features_) {
this.features_.forEach(function(feature) { this.features_.forEach(function(feature) {
var geom = feature.getGeometry(); var geom = feature.getGeometry();
geom.translate(deltaX, deltaY); geom.translate(deltaX, deltaY);
feature.setGeometry(geom); feature.setGeometry(geom);
}); });
} else if (goog.isNull(this.lastFeature_)) { } else if (this.lastFeature_) {
var geom = this.lastFeature_.getGeometry(); var geom = this.lastFeature_.getGeometry();
geom.translate(deltaX, deltaY); geom.translate(deltaX, deltaY);
this.lastFeature_.setGeometry(geom); this.lastFeature_.setGeometry(geom);
@@ -130,7 +130,7 @@ ol.interaction.Translate.handleMoveEvent_ = function(event)
if (intersectingFeature) { if (intersectingFeature) {
var isSelected = false; var isSelected = false;
if (!goog.isNull(this.features_) && if (this.features_ &&
ol.array.includes(this.features_.getArray(), intersectingFeature)) { ol.array.includes(this.features_.getArray(), intersectingFeature)) {
isSelected = true; isSelected = true;
} }
@@ -138,12 +138,12 @@ ol.interaction.Translate.handleMoveEvent_ = function(event)
this.previousCursor_ = elem.style.cursor; this.previousCursor_ = elem.style.cursor;
// WebKit browsers don't support the grab icons without a prefix // WebKit browsers don't support the grab icons without a prefix
elem.style.cursor = !goog.isNull(this.lastCoordinate_) ? elem.style.cursor = this.lastCoordinate_ ?
'-webkit-grabbing' : (isSelected ? '-webkit-grab' : 'pointer'); '-webkit-grabbing' : (isSelected ? '-webkit-grab' : 'pointer');
// Thankfully, attempting to set the standard ones will silently fail, // Thankfully, attempting to set the standard ones will silently fail,
// keeping the prefixed icons // keeping the prefixed icons
elem.style.cursor = goog.isNull(this.lastCoordinate_) ? elem.style.cursor = !this.lastCoordinate_ ?
'grabbing' : (isSelected ? 'grab' : 'pointer'); 'grabbing' : (isSelected ? 'grab' : 'pointer');
} else { } else {
@@ -171,7 +171,7 @@ ol.interaction.Translate.prototype.featuresAtPixel_ = function(pixel, map) {
return feature; return feature;
}); });
if (!goog.isNull(this.features_) && if (this.features_ &&
ol.array.includes(this.features_.getArray(), intersectingFeature)) { ol.array.includes(this.features_.getArray(), intersectingFeature)) {
found = intersectingFeature; found = intersectingFeature;
} }
+2 -4
View File
@@ -106,8 +106,7 @@ ol.layer.Heatmap = function(opt_options) {
'weightFunction should be a function'); 'weightFunction should be a function');
this.setStyle(goog.bind(function(feature, resolution) { this.setStyle(goog.bind(function(feature, resolution) {
goog.asserts.assert(!goog.isNull(this.styleCache_), goog.asserts.assert(this.styleCache_, 'this.styleCache_ expected');
'this.styleCache_ should not be null');
goog.asserts.assert(this.circleImage_ !== undefined, goog.asserts.assert(this.circleImage_ !== undefined,
'this.circleImage_ should be defined'); 'this.circleImage_ should be defined');
var weight = weightFunction(feature); var weight = weightFunction(feature);
@@ -252,8 +251,7 @@ ol.layer.Heatmap.prototype.handleStyleChanged_ = function() {
ol.layer.Heatmap.prototype.handleRender_ = function(event) { ol.layer.Heatmap.prototype.handleRender_ = function(event) {
goog.asserts.assert(event.type == ol.render.EventType.RENDER, goog.asserts.assert(event.type == ol.render.EventType.RENDER,
'event.type should be RENDER'); 'event.type should be RENDER');
goog.asserts.assert(!goog.isNull(this.gradient_), goog.asserts.assert(this.gradient_, 'this.gradient_ expected');
'this.gradient_ should not be null');
var context = event.context; var context = event.context;
var canvas = context.canvas; var canvas = context.canvas;
var image = context.getImageData(0, 0, canvas.width, canvas.height); var image = context.getImageData(0, 0, canvas.width, canvas.height);
+5 -5
View File
@@ -118,7 +118,7 @@ ol.layer.Layer.prototype.getSource = function() {
*/ */
ol.layer.Layer.prototype.getSourceState = function() { ol.layer.Layer.prototype.getSourceState = function() {
var source = this.getSource(); var source = this.getSource();
return goog.isNull(source) ? ol.source.State.UNDEFINED : source.getState(); return !source ? ol.source.State.UNDEFINED : source.getState();
}; };
@@ -134,12 +134,12 @@ ol.layer.Layer.prototype.handleSourceChange_ = function() {
* @private * @private
*/ */
ol.layer.Layer.prototype.handleSourcePropertyChange_ = function() { ol.layer.Layer.prototype.handleSourcePropertyChange_ = function() {
if (!goog.isNull(this.sourceChangeKey_)) { if (this.sourceChangeKey_) {
goog.events.unlistenByKey(this.sourceChangeKey_); goog.events.unlistenByKey(this.sourceChangeKey_);
this.sourceChangeKey_ = null; this.sourceChangeKey_ = null;
} }
var source = this.getSource(); var source = this.getSource();
if (!goog.isNull(source)) { if (source) {
this.sourceChangeKey_ = goog.events.listen(source, this.sourceChangeKey_ = goog.events.listen(source,
goog.events.EventType.CHANGE, this.handleSourceChange_, false, this); goog.events.EventType.CHANGE, this.handleSourceChange_, false, this);
} }
@@ -162,12 +162,12 @@ ol.layer.Layer.prototype.handleSourcePropertyChange_ = function() {
ol.layer.Layer.prototype.setMap = function(map) { ol.layer.Layer.prototype.setMap = function(map) {
goog.events.unlistenByKey(this.mapPrecomposeKey_); goog.events.unlistenByKey(this.mapPrecomposeKey_);
this.mapPrecomposeKey_ = null; this.mapPrecomposeKey_ = null;
if (goog.isNull(map)) { if (!map) {
this.changed(); this.changed();
} }
goog.events.unlistenByKey(this.mapRenderKey_); goog.events.unlistenByKey(this.mapRenderKey_);
this.mapRenderKey_ = null; this.mapRenderKey_ = null;
if (!goog.isNull(map)) { if (map) {
this.mapPrecomposeKey_ = goog.events.listen( this.mapPrecomposeKey_ = goog.events.listen(
map, ol.render.EventType.PRECOMPOSE, function(evt) { map, ol.render.EventType.PRECOMPOSE, function(evt) {
var layerState = this.getLayerState(); var layerState = this.getLayerState();
+3 -3
View File
@@ -35,7 +35,7 @@ ol.layer.Vector = function(opt_options) {
opt_options : /** @type {olx.layer.VectorOptions} */ ({}); opt_options : /** @type {olx.layer.VectorOptions} */ ({});
goog.asserts.assert( goog.asserts.assert(
options.renderOrder === undefined || goog.isNull(options.renderOrder) || options.renderOrder === undefined || !options.renderOrder ||
goog.isFunction(options.renderOrder), goog.isFunction(options.renderOrder),
'renderOrder must be a comparator function'); 'renderOrder must be a comparator function');
@@ -161,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(
renderOrder === undefined || goog.isNull(renderOrder) || renderOrder === undefined || !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);
@@ -181,7 +181,7 @@ ol.layer.Vector.prototype.setRenderOrder = function(renderOrder) {
*/ */
ol.layer.Vector.prototype.setStyle = function(style) { ol.layer.Vector.prototype.setStyle = function(style) {
this.style_ = style !== undefined ? style : ol.style.defaultStyleFunction; this.style_ = style !== undefined ? style : ol.style.defaultStyleFunction;
this.styleFunction_ = goog.isNull(style) ? this.styleFunction_ = style === null ?
undefined : ol.style.createStyleFunction(this.style_); undefined : ol.style.createStyleFunction(this.style_);
this.changed(); this.changed();
}; };
+22 -22
View File
@@ -597,7 +597,7 @@ ol.Map.prototype.disposeInternal = function() {
*/ */
ol.Map.prototype.forEachFeatureAtPixel = ol.Map.prototype.forEachFeatureAtPixel =
function(pixel, callback, opt_this, opt_layerFilter, opt_this2) { function(pixel, callback, opt_this, opt_layerFilter, opt_this2) {
if (goog.isNull(this.frameState_)) { if (!this.frameState_) {
return; return;
} }
var coordinate = this.getCoordinateFromPixel(pixel); var coordinate = this.getCoordinateFromPixel(pixel);
@@ -635,7 +635,7 @@ ol.Map.prototype.forEachFeatureAtPixel =
*/ */
ol.Map.prototype.forEachLayerAtPixel = ol.Map.prototype.forEachLayerAtPixel =
function(pixel, callback, opt_this, opt_layerFilter, opt_this2) { function(pixel, callback, opt_this, opt_layerFilter, opt_this2) {
if (goog.isNull(this.frameState_)) { if (!this.frameState_) {
return; return;
} }
var thisArg = opt_this !== undefined ? opt_this : null; var thisArg = opt_this !== undefined ? opt_this : null;
@@ -665,7 +665,7 @@ ol.Map.prototype.forEachLayerAtPixel =
*/ */
ol.Map.prototype.hasFeatureAtPixel = ol.Map.prototype.hasFeatureAtPixel =
function(pixel, opt_layerFilter, opt_this) { function(pixel, opt_layerFilter, opt_this) {
if (goog.isNull(this.frameState_)) { if (!this.frameState_) {
return false; return false;
} }
var coordinate = this.getCoordinateFromPixel(pixel); var coordinate = this.getCoordinateFromPixel(pixel);
@@ -737,7 +737,7 @@ ol.Map.prototype.getTargetElement = function() {
*/ */
ol.Map.prototype.getCoordinateFromPixel = function(pixel) { ol.Map.prototype.getCoordinateFromPixel = function(pixel) {
var frameState = this.frameState_; var frameState = this.frameState_;
if (goog.isNull(frameState)) { if (!frameState) {
return null; return null;
} else { } else {
var vec2 = pixel.slice(); var vec2 = pixel.slice();
@@ -812,7 +812,7 @@ ol.Map.prototype.getLayers = function() {
*/ */
ol.Map.prototype.getPixelFromCoordinate = function(coordinate) { ol.Map.prototype.getPixelFromCoordinate = function(coordinate) {
var frameState = this.frameState_; var frameState = this.frameState_;
if (goog.isNull(frameState)) { if (!frameState) {
return null; return null;
} else { } else {
var vec2 = coordinate.slice(0, 2); var vec2 = coordinate.slice(0, 2);
@@ -899,7 +899,7 @@ ol.Map.prototype.getTilePriority =
// Filter out tiles at higher zoom levels than the current zoom level, or that // Filter out tiles at higher zoom levels than the current zoom level, or that
// are outside the visible extent. // are outside the visible extent.
var frameState = this.frameState_; var frameState = this.frameState_;
if (goog.isNull(frameState) || !(tileSourceKey in frameState.wantedTiles)) { if (!frameState || !(tileSourceKey in frameState.wantedTiles)) {
return ol.structs.PriorityQueue.DROP; return ol.structs.PriorityQueue.DROP;
} }
var coordKey = ol.tilecoord.toString(tile.tileCoord); var coordKey = ol.tilecoord.toString(tile.tileCoord);
@@ -934,7 +934,7 @@ ol.Map.prototype.handleBrowserEvent = function(browserEvent, opt_type) {
* @param {ol.MapBrowserEvent} mapBrowserEvent The event to handle. * @param {ol.MapBrowserEvent} mapBrowserEvent The event to handle.
*/ */
ol.Map.prototype.handleMapBrowserEvent = function(mapBrowserEvent) { ol.Map.prototype.handleMapBrowserEvent = function(mapBrowserEvent) {
if (goog.isNull(this.frameState_)) { if (!this.frameState_) {
// With no view defined, we cannot translate pixels into geographical // With no view defined, we cannot translate pixels into geographical
// coordinates so interactions cannot be used. // coordinates so interactions cannot be used.
return; return;
@@ -982,7 +982,7 @@ ol.Map.prototype.handlePostRender = function() {
var maxTotalLoading = 16; var maxTotalLoading = 16;
var maxNewLoads = maxTotalLoading; var maxNewLoads = maxTotalLoading;
var tileSourceCount = 0; var tileSourceCount = 0;
if (!goog.isNull(frameState)) { if (frameState) {
var hints = frameState.viewHints; var hints = frameState.viewHints;
if (hints[ol.ViewHint.ANIMATING]) { if (hints[ol.ViewHint.ANIMATING]) {
maxTotalLoading = this.loadTilesWhileAnimating_ ? 8 : 0; maxTotalLoading = this.loadTilesWhileAnimating_ ? 8 : 0;
@@ -1032,20 +1032,20 @@ ol.Map.prototype.handleTargetChanged_ = function() {
this.keyHandler_.detach(); this.keyHandler_.detach();
if (goog.isNull(targetElement)) { if (!targetElement) {
goog.dom.removeNode(this.viewport_); goog.dom.removeNode(this.viewport_);
if (!goog.isNull(this.viewportResizeListenerKey_)) { if (this.viewportResizeListenerKey_) {
goog.events.unlistenByKey(this.viewportResizeListenerKey_); goog.events.unlistenByKey(this.viewportResizeListenerKey_);
this.viewportResizeListenerKey_ = null; this.viewportResizeListenerKey_ = null;
} }
} else { } else {
goog.dom.appendChild(targetElement, this.viewport_); goog.dom.appendChild(targetElement, this.viewport_);
var keyboardEventTarget = goog.isNull(this.keyboardEventTarget_) ? var keyboardEventTarget = !this.keyboardEventTarget_ ?
targetElement : this.keyboardEventTarget_; targetElement : this.keyboardEventTarget_;
this.keyHandler_.attach(keyboardEventTarget); this.keyHandler_.attach(keyboardEventTarget);
if (goog.isNull(this.viewportResizeListenerKey_)) { if (!this.viewportResizeListenerKey_) {
this.viewportResizeListenerKey_ = goog.events.listen( this.viewportResizeListenerKey_ = goog.events.listen(
this.viewportSizeMonitor_, goog.events.EventType.RESIZE, this.viewportSizeMonitor_, goog.events.EventType.RESIZE,
this.updateSize, false, this); this.updateSize, false, this);
@@ -1078,12 +1078,12 @@ ol.Map.prototype.handleViewPropertyChanged_ = function() {
* @private * @private
*/ */
ol.Map.prototype.handleViewChanged_ = function() { ol.Map.prototype.handleViewChanged_ = function() {
if (!goog.isNull(this.viewPropertyListenerKey_)) { if (this.viewPropertyListenerKey_) {
goog.events.unlistenByKey(this.viewPropertyListenerKey_); goog.events.unlistenByKey(this.viewPropertyListenerKey_);
this.viewPropertyListenerKey_ = null; this.viewPropertyListenerKey_ = null;
} }
var view = this.getView(); var view = this.getView();
if (!goog.isNull(view)) { if (view) {
this.viewPropertyListenerKey_ = goog.events.listen( this.viewPropertyListenerKey_ = goog.events.listen(
view, ol.ObjectEventType.PROPERTYCHANGE, view, ol.ObjectEventType.PROPERTYCHANGE,
this.handleViewPropertyChanged_, false, this); this.handleViewPropertyChanged_, false, this);
@@ -1118,7 +1118,7 @@ ol.Map.prototype.handleLayerGroupPropertyChanged_ = function(event) {
* @private * @private
*/ */
ol.Map.prototype.handleLayerGroupChanged_ = function() { ol.Map.prototype.handleLayerGroupChanged_ = function() {
if (!goog.isNull(this.layerGroupPropertyListenerKeys_)) { if (this.layerGroupPropertyListenerKeys_) {
this.layerGroupPropertyListenerKeys_.forEach(goog.events.unlistenByKey); this.layerGroupPropertyListenerKeys_.forEach(goog.events.unlistenByKey);
this.layerGroupPropertyListenerKeys_ = null; this.layerGroupPropertyListenerKeys_ = null;
} }
@@ -1155,7 +1155,7 @@ ol.Map.prototype.isDef = function() {
return false; return false;
} }
var view = this.getView(); var view = this.getView();
if (goog.isNull(view) || !view.isDef()) { if (!view || !view.isDef()) {
return false; return false;
} }
return true; return true;
@@ -1166,7 +1166,7 @@ ol.Map.prototype.isDef = function() {
* @return {boolean} Is rendered. * @return {boolean} Is rendered.
*/ */
ol.Map.prototype.isRendered = function() { ol.Map.prototype.isRendered = function() {
return !goog.isNull(this.frameState_); return !!this.frameState_;
}; };
@@ -1259,7 +1259,7 @@ ol.Map.prototype.renderFrame_ = function(time) {
/** @type {?olx.FrameState} */ /** @type {?olx.FrameState} */
var frameState = null; var frameState = null;
if (size !== undefined && ol.size.hasArea(size) && if (size !== undefined && ol.size.hasArea(size) &&
!goog.isNull(view) && view.isDef()) { view && view.isDef()) {
var viewHints = view.getHints(); var viewHints = view.getHints();
var layerStatesArray = this.getLayerGroup().getLayerStatesArray(); var layerStatesArray = this.getLayerGroup().getLayerStatesArray();
var layerStates = {}; var layerStates = {};
@@ -1272,7 +1272,7 @@ ol.Map.prototype.renderFrame_ = function(time) {
attributions: {}, attributions: {},
coordinateToPixelMatrix: this.coordinateToPixelMatrix_, coordinateToPixelMatrix: this.coordinateToPixelMatrix_,
extent: null, extent: null,
focus: goog.isNull(this.focus_) ? viewState.center : this.focus_, focus: !this.focus_ ? viewState.center : this.focus_,
index: this.frameIndex_++, index: this.frameIndex_++,
layerStates: layerStates, layerStates: layerStates,
layerStatesArray: layerStatesArray, layerStatesArray: layerStatesArray,
@@ -1291,7 +1291,7 @@ ol.Map.prototype.renderFrame_ = function(time) {
}); });
} }
if (!goog.isNull(frameState)) { if (frameState) {
var preRenderFunctions = this.preRenderFunctions_; var preRenderFunctions = this.preRenderFunctions_;
var n = 0, preRenderFunction; var n = 0, preRenderFunction;
for (i = 0, ii = preRenderFunctions.length; i < ii; ++i) { for (i = 0, ii = preRenderFunctions.length; i < ii; ++i) {
@@ -1309,7 +1309,7 @@ ol.Map.prototype.renderFrame_ = function(time) {
this.frameState_ = frameState; this.frameState_ = frameState;
this.renderer_.renderFrame(frameState); this.renderer_.renderFrame(frameState);
if (!goog.isNull(frameState)) { if (frameState) {
if (frameState.animate) { if (frameState.animate) {
this.render(); this.render();
} }
@@ -1400,7 +1400,7 @@ ol.Map.prototype.skipFeature = function(feature) {
ol.Map.prototype.updateSize = function() { ol.Map.prototype.updateSize = function() {
var targetElement = this.getTargetElement(); var targetElement = this.getTargetElement();
if (goog.isNull(targetElement)) { if (!targetElement) {
this.setSize(undefined); this.setSize(undefined);
} else { } else {
var size = goog.style.getContentBoxSize(targetElement); var size = goog.style.getContentBoxSize(targetElement);
+8 -9
View File
@@ -284,8 +284,7 @@ ol.MapBrowserEventHandler.prototype.handlePointerUp_ = function(pointerEvent) {
// to 0). // to 0).
// See http://www.w3.org/TR/pointerevents/#button-states // See http://www.w3.org/TR/pointerevents/#button-states
if (!this.dragging_ && this.isMouseActionButton_(pointerEvent)) { if (!this.dragging_ && this.isMouseActionButton_(pointerEvent)) {
goog.asserts.assert(!goog.isNull(this.down_), goog.asserts.assert(this.down_, 'this.down_ must be truthy');
'this.down_ should not be null');
this.emulateClick_(this.down_); this.emulateClick_(this.down_);
} }
@@ -326,7 +325,7 @@ ol.MapBrowserEventHandler.prototype.handlePointerDown_ =
this.down_ = pointerEvent; this.down_ = pointerEvent;
if (goog.isNull(this.dragListenerKeys_)) { if (!this.dragListenerKeys_) {
/* Set up a pointer event handler on the `document`, /* Set up a pointer event handler on the `document`,
* which is required when the pointer is moved outside * which is required when the pointer is moved outside
* the viewport when dragging. * the viewport when dragging.
@@ -396,7 +395,7 @@ ol.MapBrowserEventHandler.prototype.handlePointerMove_ =
* @private * @private
*/ */
ol.MapBrowserEventHandler.prototype.relayEvent_ = function(pointerEvent) { ol.MapBrowserEventHandler.prototype.relayEvent_ = function(pointerEvent) {
var dragging = !goog.isNull(this.down_) && this.isMoving_(pointerEvent); var dragging = !!(this.down_ && this.isMoving_(pointerEvent));
this.dispatchEvent(new ol.MapBrowserPointerEvent( this.dispatchEvent(new ol.MapBrowserPointerEvent(
pointerEvent.type, this.map_, pointerEvent, dragging)); pointerEvent.type, this.map_, pointerEvent, dragging));
}; };
@@ -417,23 +416,23 @@ ol.MapBrowserEventHandler.prototype.isMoving_ = function(pointerEvent) {
* @inheritDoc * @inheritDoc
*/ */
ol.MapBrowserEventHandler.prototype.disposeInternal = function() { ol.MapBrowserEventHandler.prototype.disposeInternal = function() {
if (!goog.isNull(this.relayedListenerKey_)) { if (this.relayedListenerKey_) {
goog.events.unlistenByKey(this.relayedListenerKey_); goog.events.unlistenByKey(this.relayedListenerKey_);
this.relayedListenerKey_ = null; this.relayedListenerKey_ = null;
} }
if (!goog.isNull(this.pointerdownListenerKey_)) { if (this.pointerdownListenerKey_) {
goog.events.unlistenByKey(this.pointerdownListenerKey_); goog.events.unlistenByKey(this.pointerdownListenerKey_);
this.pointerdownListenerKey_ = null; this.pointerdownListenerKey_ = null;
} }
if (!goog.isNull(this.dragListenerKeys_)) { if (this.dragListenerKeys_) {
this.dragListenerKeys_.forEach(goog.events.unlistenByKey); this.dragListenerKeys_.forEach(goog.events.unlistenByKey);
this.dragListenerKeys_ = null; this.dragListenerKeys_ = null;
} }
if (!goog.isNull(this.documentPointerEventHandler_)) { if (this.documentPointerEventHandler_) {
goog.dispose(this.documentPointerEventHandler_); goog.dispose(this.documentPointerEventHandler_);
this.documentPointerEventHandler_ = null; this.documentPointerEventHandler_ = null;
} }
if (!goog.isNull(this.pointerEventHandler_)) { if (this.pointerEventHandler_) {
goog.dispose(this.pointerEventHandler_); goog.dispose(this.pointerEventHandler_);
this.pointerEventHandler_ = null; this.pointerEventHandler_ = null;
} }
+4 -4
View File
@@ -254,7 +254,7 @@ ol.Overlay.prototype.handleElementChanged = function() {
* @protected * @protected
*/ */
ol.Overlay.prototype.handleMapChanged = function() { ol.Overlay.prototype.handleMapChanged = function() {
if (!goog.isNull(this.mapPostrenderListenerKey_)) { if (this.mapPostrenderListenerKey_) {
goog.dom.removeNode(this.element_); goog.dom.removeNode(this.element_);
goog.events.unlistenByKey(this.mapPostrenderListenerKey_); goog.events.unlistenByKey(this.mapPostrenderListenerKey_);
this.mapPostrenderListenerKey_ = null; this.mapPostrenderListenerKey_ = null;
@@ -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 (map === undefined || goog.isNull(map.getTargetElement())) { if (map === undefined || !map.getTargetElement()) {
return; return;
} }
@@ -409,7 +409,7 @@ ol.Overlay.prototype.panIntoView_ = function() {
centerPx[1] + delta[1] centerPx[1] + delta[1]
]; ];
if (!goog.isNull(this.autoPanAnimation_)) { if (this.autoPanAnimation_) {
this.autoPanAnimation_.source = center; this.autoPanAnimation_.source = center;
map.beforeRender(ol.animation.pan(this.autoPanAnimation_)); map.beforeRender(ol.animation.pan(this.autoPanAnimation_));
} }
@@ -489,7 +489,7 @@ ol.Overlay.prototype.updatePixelPosition = function() {
* @protected * @protected
*/ */
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(pixel, 'pixel should not be null');
goog.asserts.assert(mapSize !== undefined, '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();
+1 -1
View File
@@ -366,7 +366,7 @@ ol.pointer.PointerEventHandler.prototype.enterOver =
*/ */
ol.pointer.PointerEventHandler.prototype.contains_ = ol.pointer.PointerEventHandler.prototype.contains_ =
function(container, contained) { function(container, contained) {
if (goog.isNull(contained)) { if (!contained) {
return false; return false;
} }
return goog.dom.contains(container, contained); return goog.dom.contains(container, contained);
+3 -3
View File
@@ -125,7 +125,7 @@ ol.proj.Projection = function(options) {
* @private * @private
* @type {boolean} * @type {boolean}
*/ */
this.canWrapX_ = this.global_ && !goog.isNull(this.extent_); this.canWrapX_ = !!(this.global_ && this.extent_);
/** /**
* @private * @private
@@ -272,7 +272,7 @@ ol.proj.Projection.prototype.isGlobal = function() {
*/ */
ol.proj.Projection.prototype.setGlobal = function(global) { ol.proj.Projection.prototype.setGlobal = function(global) {
this.global_ = global; this.global_ = global;
this.canWrapX_ = global && !goog.isNull(this.extent_); this.canWrapX_ = !!(global && this.extent_);
}; };
@@ -299,7 +299,7 @@ ol.proj.Projection.prototype.setDefaultTileGrid = function(tileGrid) {
*/ */
ol.proj.Projection.prototype.setExtent = function(extent) { ol.proj.Projection.prototype.setExtent = function(extent) {
this.extent_ = extent; this.extent_ = extent;
this.canWrapX_ = this.global_ && !goog.isNull(extent); this.canWrapX_ = !!(this.global_ && extent);
}; };
+9 -11
View File
@@ -62,11 +62,11 @@ goog.inherits(ol.render.Box, goog.Disposable);
* @return {ol.geom.Polygon} Geometry. * @return {ol.geom.Polygon} Geometry.
*/ */
ol.render.Box.prototype.createGeometry_ = function() { ol.render.Box.prototype.createGeometry_ = function() {
goog.asserts.assert(!goog.isNull(this.startPixel_), goog.asserts.assert(this.startPixel_,
'this.startPixel_ should not be null'); 'this.startPixel_ must be truthy');
goog.asserts.assert(!goog.isNull(this.endPixel_), goog.asserts.assert(this.endPixel_,
'this.endPixel_ should not be null'); 'this.endPixel_ must be truthy');
goog.asserts.assert(!goog.isNull(this.map_), 'this.map_ should not be null'); goog.asserts.assert(this.map_, 'this.map_ must be truthy');
var startPixel = this.startPixel_; var startPixel = this.startPixel_;
var endPixel = this.endPixel_; var endPixel = this.endPixel_;
var pixels = [ var pixels = [
@@ -98,7 +98,7 @@ ol.render.Box.prototype.handleMapPostCompose_ = function(event) {
var geometry = this.geometry_; var geometry = this.geometry_;
goog.asserts.assert(geometry, 'geometry should be defined'); goog.asserts.assert(geometry, 'geometry should be defined');
var style = this.style_; var style = this.style_;
goog.asserts.assert(!goog.isNull(style), 'style should not be null'); goog.asserts.assert(style, 'style must be truthy');
// use drawAsync(Infinity) to draw above everything // use drawAsync(Infinity) to draw above everything
event.vectorContext.drawAsync(Infinity, function(render) { event.vectorContext.drawAsync(Infinity, function(render) {
render.setFillStrokeStyle(style.getFill(), style.getStroke()); render.setFillStrokeStyle(style.getFill(), style.getStroke());
@@ -120,9 +120,7 @@ ol.render.Box.prototype.getGeometry = function() {
* @private * @private
*/ */
ol.render.Box.prototype.requestMapRenderFrame_ = function() { ol.render.Box.prototype.requestMapRenderFrame_ = function() {
if (!goog.isNull(this.map_) && if (this.map_ && this.startPixel_ && this.endPixel_) {
!goog.isNull(this.startPixel_) &&
!goog.isNull(this.endPixel_)) {
this.map_.render(); this.map_.render();
} }
}; };
@@ -132,14 +130,14 @@ ol.render.Box.prototype.requestMapRenderFrame_ = function() {
* @param {ol.Map} map Map. * @param {ol.Map} map Map.
*/ */
ol.render.Box.prototype.setMap = function(map) { ol.render.Box.prototype.setMap = function(map) {
if (!goog.isNull(this.postComposeListenerKey_)) { if (this.postComposeListenerKey_) {
goog.events.unlistenByKey(this.postComposeListenerKey_); goog.events.unlistenByKey(this.postComposeListenerKey_);
this.postComposeListenerKey_ = null; this.postComposeListenerKey_ = null;
this.map_.render(); this.map_.render();
this.map_ = null; this.map_ = null;
} }
this.map_ = map; this.map_ = map;
if (!goog.isNull(this.map_)) { if (this.map_) {
this.postComposeListenerKey_ = goog.events.listen( this.postComposeListenerKey_ = goog.events.listen(
map, ol.render.EventType.POSTCOMPOSE, this.handleMapPostCompose_, false, map, ol.render.EventType.POSTCOMPOSE, this.handleMapPostCompose_, false,
this); this);
+42 -46
View File
@@ -249,7 +249,7 @@ ol.render.canvas.Immediate =
*/ */
ol.render.canvas.Immediate.prototype.drawImages_ = ol.render.canvas.Immediate.prototype.drawImages_ =
function(flatCoordinates, offset, end, stride) { function(flatCoordinates, offset, end, stride) {
if (goog.isNull(this.image_)) { if (!this.image_) {
return; return;
} }
goog.asserts.assert(offset === 0, 'offset should be 0'); goog.asserts.assert(offset === 0, 'offset should be 0');
@@ -312,13 +312,13 @@ ol.render.canvas.Immediate.prototype.drawImages_ =
*/ */
ol.render.canvas.Immediate.prototype.drawText_ = ol.render.canvas.Immediate.prototype.drawText_ =
function(flatCoordinates, offset, end, stride) { function(flatCoordinates, offset, end, stride) {
if (goog.isNull(this.textState_) || this.text_ === '') { if (!this.textState_ || this.text_ === '') {
return; return;
} }
if (!goog.isNull(this.textFillState_)) { if (this.textFillState_) {
this.setContextFillState_(this.textFillState_); this.setContextFillState_(this.textFillState_);
} }
if (!goog.isNull(this.textStrokeState_)) { if (this.textStrokeState_) {
this.setContextStrokeState_(this.textStrokeState_); this.setContextStrokeState_(this.textStrokeState_);
} }
this.setContextTextState_(this.textState_); this.setContextTextState_(this.textState_);
@@ -343,10 +343,10 @@ ol.render.canvas.Immediate.prototype.drawText_ =
goog.vec.Mat4.getElement(localTransform, 0, 3), goog.vec.Mat4.getElement(localTransform, 0, 3),
goog.vec.Mat4.getElement(localTransform, 1, 3)); goog.vec.Mat4.getElement(localTransform, 1, 3));
} }
if (!goog.isNull(this.textStrokeState_)) { if (this.textStrokeState_) {
context.strokeText(this.text_, x, y); context.strokeText(this.text_, x, y);
} }
if (!goog.isNull(this.textFillState_)) { if (this.textFillState_) {
context.fillText(this.text_, x, y); context.fillText(this.text_, x, y);
} }
} }
@@ -437,11 +437,11 @@ ol.render.canvas.Immediate.prototype.drawCircleGeometry =
if (!ol.extent.intersects(this.extent_, circleGeometry.getExtent())) { if (!ol.extent.intersects(this.extent_, circleGeometry.getExtent())) {
return; return;
} }
if (!goog.isNull(this.fillState_) || !goog.isNull(this.strokeState_)) { if (this.fillState_ || this.strokeState_) {
if (!goog.isNull(this.fillState_)) { if (this.fillState_) {
this.setContextFillState_(this.fillState_); this.setContextFillState_(this.fillState_);
} }
if (!goog.isNull(this.strokeState_)) { if (this.strokeState_) {
this.setContextStrokeState_(this.strokeState_); this.setContextStrokeState_(this.strokeState_);
} }
var pixelCoordinates = ol.geom.transformSimpleGeometry2D( var pixelCoordinates = ol.geom.transformSimpleGeometry2D(
@@ -453,10 +453,10 @@ ol.render.canvas.Immediate.prototype.drawCircleGeometry =
context.beginPath(); context.beginPath();
context.arc( context.arc(
pixelCoordinates[0], pixelCoordinates[1], radius, 0, 2 * Math.PI); pixelCoordinates[0], pixelCoordinates[1], radius, 0, 2 * Math.PI);
if (!goog.isNull(this.fillState_)) { if (this.fillState_) {
context.fill(); context.fill();
} }
if (!goog.isNull(this.strokeState_)) { if (this.strokeState_) {
context.stroke(); context.stroke();
} }
} }
@@ -535,7 +535,7 @@ ol.render.canvas.Immediate.prototype.drawPointGeometry =
function(pointGeometry, feature) { function(pointGeometry, feature) {
var flatCoordinates = pointGeometry.getFlatCoordinates(); var flatCoordinates = pointGeometry.getFlatCoordinates();
var stride = pointGeometry.getStride(); var stride = pointGeometry.getStride();
if (!goog.isNull(this.image_)) { if (this.image_) {
this.drawImages_(flatCoordinates, 0, flatCoordinates.length, stride); this.drawImages_(flatCoordinates, 0, flatCoordinates.length, stride);
} }
if (this.text_ !== '') { if (this.text_ !== '') {
@@ -556,7 +556,7 @@ ol.render.canvas.Immediate.prototype.drawMultiPointGeometry =
function(multiPointGeometry, feature) { function(multiPointGeometry, feature) {
var flatCoordinates = multiPointGeometry.getFlatCoordinates(); var flatCoordinates = multiPointGeometry.getFlatCoordinates();
var stride = multiPointGeometry.getStride(); var stride = multiPointGeometry.getStride();
if (!goog.isNull(this.image_)) { if (this.image_) {
this.drawImages_(flatCoordinates, 0, flatCoordinates.length, stride); this.drawImages_(flatCoordinates, 0, flatCoordinates.length, stride);
} }
if (this.text_ !== '') { if (this.text_ !== '') {
@@ -578,7 +578,7 @@ ol.render.canvas.Immediate.prototype.drawLineStringGeometry =
if (!ol.extent.intersects(this.extent_, lineStringGeometry.getExtent())) { if (!ol.extent.intersects(this.extent_, lineStringGeometry.getExtent())) {
return; return;
} }
if (!goog.isNull(this.strokeState_)) { if (this.strokeState_) {
this.setContextStrokeState_(this.strokeState_); this.setContextStrokeState_(this.strokeState_);
var context = this.context_; var context = this.context_;
var flatCoordinates = lineStringGeometry.getFlatCoordinates(); var flatCoordinates = lineStringGeometry.getFlatCoordinates();
@@ -609,7 +609,7 @@ ol.render.canvas.Immediate.prototype.drawMultiLineStringGeometry =
if (!ol.extent.intersects(this.extent_, geometryExtent)) { if (!ol.extent.intersects(this.extent_, geometryExtent)) {
return; return;
} }
if (!goog.isNull(this.strokeState_)) { if (this.strokeState_) {
this.setContextStrokeState_(this.strokeState_); this.setContextStrokeState_(this.strokeState_);
var context = this.context_; var context = this.context_;
var flatCoordinates = multiLineStringGeometry.getFlatCoordinates(); var flatCoordinates = multiLineStringGeometry.getFlatCoordinates();
@@ -644,21 +644,21 @@ ol.render.canvas.Immediate.prototype.drawPolygonGeometry =
if (!ol.extent.intersects(this.extent_, polygonGeometry.getExtent())) { if (!ol.extent.intersects(this.extent_, polygonGeometry.getExtent())) {
return; return;
} }
if (!goog.isNull(this.strokeState_) || !goog.isNull(this.fillState_)) { if (this.strokeState_ || this.fillState_) {
if (!goog.isNull(this.fillState_)) { if (this.fillState_) {
this.setContextFillState_(this.fillState_); this.setContextFillState_(this.fillState_);
} }
if (!goog.isNull(this.strokeState_)) { if (this.strokeState_) {
this.setContextStrokeState_(this.strokeState_); this.setContextStrokeState_(this.strokeState_);
} }
var context = this.context_; var context = this.context_;
context.beginPath(); context.beginPath();
this.drawRings_(polygonGeometry.getOrientedFlatCoordinates(), this.drawRings_(polygonGeometry.getOrientedFlatCoordinates(),
0, polygonGeometry.getEnds(), polygonGeometry.getStride()); 0, polygonGeometry.getEnds(), polygonGeometry.getStride());
if (!goog.isNull(this.fillState_)) { if (this.fillState_) {
context.fill(); context.fill();
} }
if (!goog.isNull(this.strokeState_)) { if (this.strokeState_) {
context.stroke(); context.stroke();
} }
} }
@@ -681,11 +681,11 @@ ol.render.canvas.Immediate.prototype.drawMultiPolygonGeometry =
if (!ol.extent.intersects(this.extent_, multiPolygonGeometry.getExtent())) { if (!ol.extent.intersects(this.extent_, multiPolygonGeometry.getExtent())) {
return; return;
} }
if (!goog.isNull(this.strokeState_) || !goog.isNull(this.fillState_)) { if (this.strokeState_ || this.fillState_) {
if (!goog.isNull(this.fillState_)) { if (this.fillState_) {
this.setContextFillState_(this.fillState_); this.setContextFillState_(this.fillState_);
} }
if (!goog.isNull(this.strokeState_)) { if (this.strokeState_) {
this.setContextStrokeState_(this.strokeState_); this.setContextStrokeState_(this.strokeState_);
} }
var context = this.context_; var context = this.context_;
@@ -698,10 +698,10 @@ ol.render.canvas.Immediate.prototype.drawMultiPolygonGeometry =
var ends = endss[i]; var ends = endss[i];
context.beginPath(); context.beginPath();
offset = this.drawRings_(flatCoordinates, offset, ends, stride); offset = this.drawRings_(flatCoordinates, offset, ends, stride);
if (!goog.isNull(this.fillState_)) { if (this.fillState_) {
context.fill(); context.fill();
} }
if (!goog.isNull(this.strokeState_)) { if (this.strokeState_) {
context.stroke(); context.stroke();
} }
} }
@@ -744,7 +744,7 @@ ol.render.canvas.Immediate.prototype.setContextFillState_ =
function(fillState) { function(fillState) {
var context = this.context_; var context = this.context_;
var contextFillState = this.contextFillState_; var contextFillState = this.contextFillState_;
if (goog.isNull(contextFillState)) { if (!contextFillState) {
context.fillStyle = fillState.fillStyle; context.fillStyle = fillState.fillStyle;
this.contextFillState_ = { this.contextFillState_ = {
fillStyle: fillState.fillStyle fillStyle: fillState.fillStyle
@@ -765,7 +765,7 @@ ol.render.canvas.Immediate.prototype.setContextStrokeState_ =
function(strokeState) { function(strokeState) {
var context = this.context_; var context = this.context_;
var contextStrokeState = this.contextStrokeState_; var contextStrokeState = this.contextStrokeState_;
if (goog.isNull(contextStrokeState)) { if (!contextStrokeState) {
context.lineCap = strokeState.lineCap; context.lineCap = strokeState.lineCap;
if (ol.has.CANVAS_LINE_DASH) { if (ol.has.CANVAS_LINE_DASH) {
context.setLineDash(strokeState.lineDash); context.setLineDash(strokeState.lineDash);
@@ -818,7 +818,7 @@ ol.render.canvas.Immediate.prototype.setContextTextState_ =
function(textState) { function(textState) {
var context = this.context_; var context = this.context_;
var contextTextState = this.contextTextState_; var contextTextState = this.contextTextState_;
if (goog.isNull(contextTextState)) { if (!contextTextState) {
context.font = textState.font; context.font = textState.font;
context.textAlign = textState.textAlign; context.textAlign = textState.textAlign;
context.textBaseline = textState.textBaseline; context.textBaseline = textState.textBaseline;
@@ -852,16 +852,16 @@ ol.render.canvas.Immediate.prototype.setContextTextState_ =
*/ */
ol.render.canvas.Immediate.prototype.setFillStrokeStyle = ol.render.canvas.Immediate.prototype.setFillStrokeStyle =
function(fillStyle, strokeStyle) { function(fillStyle, strokeStyle) {
if (goog.isNull(fillStyle)) { if (!fillStyle) {
this.fillState_ = null; this.fillState_ = null;
} else { } else {
var fillStyleColor = fillStyle.getColor(); var fillStyleColor = fillStyle.getColor();
this.fillState_ = { this.fillState_ = {
fillStyle: ol.color.asString(!goog.isNull(fillStyleColor) ? fillStyle: ol.color.asString(fillStyleColor ?
fillStyleColor : ol.render.canvas.defaultFillStyle) fillStyleColor : ol.render.canvas.defaultFillStyle)
}; };
} }
if (goog.isNull(strokeStyle)) { if (!strokeStyle) {
this.strokeState_ = null; this.strokeState_ = null;
} else { } else {
var strokeStyleColor = strokeStyle.getColor(); var strokeStyleColor = strokeStyle.getColor();
@@ -881,7 +881,7 @@ ol.render.canvas.Immediate.prototype.setFillStrokeStyle =
strokeStyleWidth : ol.render.canvas.defaultLineWidth), strokeStyleWidth : ol.render.canvas.defaultLineWidth),
miterLimit: strokeStyleMiterLimit !== undefined ? miterLimit: strokeStyleMiterLimit !== undefined ?
strokeStyleMiterLimit : ol.render.canvas.defaultMiterLimit, strokeStyleMiterLimit : ol.render.canvas.defaultMiterLimit,
strokeStyle: ol.color.asString(!goog.isNull(strokeStyleColor) ? strokeStyle: ol.color.asString(strokeStyleColor ?
strokeStyleColor : ol.render.canvas.defaultStrokeStyle) strokeStyleColor : ol.render.canvas.defaultStrokeStyle)
}; };
} }
@@ -896,7 +896,7 @@ ol.render.canvas.Immediate.prototype.setFillStrokeStyle =
* @api * @api
*/ */
ol.render.canvas.Immediate.prototype.setImageStyle = function(imageStyle) { ol.render.canvas.Immediate.prototype.setImageStyle = function(imageStyle) {
if (goog.isNull(imageStyle)) { if (!imageStyle) {
this.image_ = null; this.image_ = null;
} else { } else {
var imageAnchor = imageStyle.getAnchor(); var imageAnchor = imageStyle.getAnchor();
@@ -904,14 +904,10 @@ ol.render.canvas.Immediate.prototype.setImageStyle = function(imageStyle) {
var imageImage = imageStyle.getImage(1); var imageImage = imageStyle.getImage(1);
var imageOrigin = imageStyle.getOrigin(); var imageOrigin = imageStyle.getOrigin();
var imageSize = imageStyle.getSize(); var imageSize = imageStyle.getSize();
goog.asserts.assert(!goog.isNull(imageAnchor), goog.asserts.assert(imageAnchor, 'imageAnchor must be truthy');
'imageAnchor should not be null'); goog.asserts.assert(imageImage, 'imageImage must be truthy');
goog.asserts.assert(!goog.isNull(imageImage), goog.asserts.assert(imageOrigin, 'imageOrigin must be truthy');
'imageImage should not be null'); goog.asserts.assert(imageSize, 'imageSize must be truthy');
goog.asserts.assert(!goog.isNull(imageOrigin),
'imageOrigin should not be null');
goog.asserts.assert(!goog.isNull(imageSize),
'imageSize should not be null');
this.imageAnchorX_ = imageAnchor[0]; this.imageAnchorX_ = imageAnchor[0];
this.imageAnchorY_ = imageAnchor[1]; this.imageAnchorY_ = imageAnchor[1];
this.imageHeight_ = imageSize[1]; this.imageHeight_ = imageSize[1];
@@ -936,21 +932,21 @@ ol.render.canvas.Immediate.prototype.setImageStyle = function(imageStyle) {
* @api * @api
*/ */
ol.render.canvas.Immediate.prototype.setTextStyle = function(textStyle) { ol.render.canvas.Immediate.prototype.setTextStyle = function(textStyle) {
if (goog.isNull(textStyle)) { if (!textStyle) {
this.text_ = ''; this.text_ = '';
} else { } else {
var textFillStyle = textStyle.getFill(); var textFillStyle = textStyle.getFill();
if (goog.isNull(textFillStyle)) { if (!textFillStyle) {
this.textFillState_ = null; this.textFillState_ = null;
} else { } else {
var textFillStyleColor = textFillStyle.getColor(); var textFillStyleColor = textFillStyle.getColor();
this.textFillState_ = { this.textFillState_ = {
fillStyle: ol.color.asString(!goog.isNull(textFillStyleColor) ? fillStyle: ol.color.asString(textFillStyleColor ?
textFillStyleColor : ol.render.canvas.defaultFillStyle) textFillStyleColor : ol.render.canvas.defaultFillStyle)
}; };
} }
var textStrokeStyle = textStyle.getStroke(); var textStrokeStyle = textStyle.getStroke();
if (goog.isNull(textStrokeStyle)) { if (!textStrokeStyle) {
this.textStrokeState_ = null; this.textStrokeState_ = null;
} else { } else {
var textStrokeStyleColor = textStrokeStyle.getColor(); var textStrokeStyleColor = textStrokeStyle.getColor();
@@ -970,7 +966,7 @@ ol.render.canvas.Immediate.prototype.setTextStyle = function(textStyle) {
textStrokeStyleWidth : ol.render.canvas.defaultLineWidth, textStrokeStyleWidth : ol.render.canvas.defaultLineWidth,
miterLimit: textStrokeStyleMiterLimit !== undefined ? miterLimit: textStrokeStyleMiterLimit !== undefined ?
textStrokeStyleMiterLimit : ol.render.canvas.defaultMiterLimit, textStrokeStyleMiterLimit : ol.render.canvas.defaultMiterLimit,
strokeStyle: ol.color.asString(!goog.isNull(textStrokeStyleColor) ? strokeStyle: ol.color.asString(textStrokeStyleColor ?
textStrokeStyleColor : ol.render.canvas.defaultStrokeStyle) textStrokeStyleColor : ol.render.canvas.defaultStrokeStyle)
}; };
} }
+55 -60
View File
@@ -451,7 +451,7 @@ ol.render.canvas.Replay.prototype.replay_ = function(
'5th instruction should be a string'); '5th instruction should be a string');
goog.asserts.assert(goog.isNumber(instruction[5]), goog.asserts.assert(goog.isNumber(instruction[5]),
'6th instruction should be a number'); '6th instruction should be a number');
goog.asserts.assert(!goog.isNull(instruction[6]), goog.asserts.assert(instruction[6],
'7th instruction should not be null'); '7th instruction should not be null');
var usePixelRatio = instruction[7] !== undefined ? var usePixelRatio = instruction[7] !== undefined ?
instruction[7] : true; instruction[7] : true;
@@ -568,11 +568,11 @@ ol.render.canvas.Replay.prototype.reverseHitDetectionInstructions_ =
* @param {ol.Feature} feature Feature. * @param {ol.Feature} feature Feature.
*/ */
ol.render.canvas.Replay.prototype.endGeometry = function(geometry, feature) { ol.render.canvas.Replay.prototype.endGeometry = function(geometry, feature) {
goog.asserts.assert(!goog.isNull(this.beginGeometryInstruction1_), goog.asserts.assert(this.beginGeometryInstruction1_,
'this.beginGeometryInstruction1_ should not be null'); 'this.beginGeometryInstruction1_ should not be null');
this.beginGeometryInstruction1_[2] = this.instructions.length; this.beginGeometryInstruction1_[2] = this.instructions.length;
this.beginGeometryInstruction1_ = null; this.beginGeometryInstruction1_ = null;
goog.asserts.assert(!goog.isNull(this.beginGeometryInstruction2_), goog.asserts.assert(this.beginGeometryInstruction2_,
'this.beginGeometryInstruction2_ should not be null'); 'this.beginGeometryInstruction2_ should not be null');
this.beginGeometryInstruction2_[2] = this.hitDetectionInstructions.length; this.beginGeometryInstruction2_[2] = this.hitDetectionInstructions.length;
this.beginGeometryInstruction2_ = null; this.beginGeometryInstruction2_ = null;
@@ -716,7 +716,7 @@ ol.render.canvas.ImageReplay.prototype.drawCoordinates_ =
*/ */
ol.render.canvas.ImageReplay.prototype.drawPointGeometry = ol.render.canvas.ImageReplay.prototype.drawPointGeometry =
function(pointGeometry, feature) { function(pointGeometry, feature) {
if (goog.isNull(this.image_)) { if (!this.image_) {
return; return;
} }
goog.asserts.assert(this.anchorX_ !== undefined, goog.asserts.assert(this.anchorX_ !== undefined,
@@ -769,7 +769,7 @@ ol.render.canvas.ImageReplay.prototype.drawPointGeometry =
*/ */
ol.render.canvas.ImageReplay.prototype.drawMultiPointGeometry = ol.render.canvas.ImageReplay.prototype.drawMultiPointGeometry =
function(multiPointGeometry, feature) { function(multiPointGeometry, feature) {
if (goog.isNull(this.image_)) { if (!this.image_) {
return; return;
} }
goog.asserts.assert(this.anchorX_ !== undefined, goog.asserts.assert(this.anchorX_ !== undefined,
@@ -843,19 +843,18 @@ ol.render.canvas.ImageReplay.prototype.finish = function() {
* @inheritDoc * @inheritDoc
*/ */
ol.render.canvas.ImageReplay.prototype.setImageStyle = function(imageStyle) { ol.render.canvas.ImageReplay.prototype.setImageStyle = function(imageStyle) {
goog.asserts.assert(!goog.isNull(imageStyle), goog.asserts.assert(imageStyle, 'imageStyle should not be null');
'imageStyle should not be null');
var anchor = imageStyle.getAnchor(); var anchor = imageStyle.getAnchor();
goog.asserts.assert(!goog.isNull(anchor), 'anchor should not be null'); goog.asserts.assert(anchor, 'anchor should not be null');
var size = imageStyle.getSize(); var size = imageStyle.getSize();
goog.asserts.assert(!goog.isNull(size), 'size should not be null'); goog.asserts.assert(size, 'size should not be null');
var hitDetectionImage = imageStyle.getHitDetectionImage(1); var hitDetectionImage = imageStyle.getHitDetectionImage(1);
goog.asserts.assert(!goog.isNull(hitDetectionImage), goog.asserts.assert(hitDetectionImage,
'hitDetectionImage should not be null'); 'hitDetectionImage should not be null');
var image = imageStyle.getImage(1); var image = imageStyle.getImage(1);
goog.asserts.assert(!goog.isNull(image), 'image should not be null'); goog.asserts.assert(image, 'image should not be null');
var origin = imageStyle.getOrigin(); var origin = imageStyle.getOrigin();
goog.asserts.assert(!goog.isNull(origin), 'origin should not be null'); goog.asserts.assert(origin, 'origin should not be null');
this.anchorX_ = anchor[0]; this.anchorX_ = anchor[0];
this.anchorY_ = anchor[1]; this.anchorY_ = anchor[1];
this.hitDetectionImage_ = hitDetectionImage; this.hitDetectionImage_ = hitDetectionImage;
@@ -947,7 +946,7 @@ ol.render.canvas.LineStringReplay.prototype.drawFlatCoordinates_ =
* @inheritDoc * @inheritDoc
*/ */
ol.render.canvas.LineStringReplay.prototype.getBufferedMaxExtent = function() { ol.render.canvas.LineStringReplay.prototype.getBufferedMaxExtent = function() {
if (goog.isNull(this.bufferedMaxExtent_)) { if (!this.bufferedMaxExtent_) {
this.bufferedMaxExtent_ = ol.extent.clone(this.maxExtent); this.bufferedMaxExtent_ = ol.extent.clone(this.maxExtent);
if (this.maxLineWidth > 0) { if (this.maxLineWidth > 0) {
var width = this.resolution * (this.maxLineWidth + 1) / 2; var width = this.resolution * (this.maxLineWidth + 1) / 2;
@@ -972,7 +971,7 @@ ol.render.canvas.LineStringReplay.prototype.setStrokeStyle_ = function() {
goog.asserts.assert(strokeStyle !== undefined, goog.asserts.assert(strokeStyle !== undefined,
'strokeStyle should be defined'); 'strokeStyle should be defined');
goog.asserts.assert(lineCap !== undefined, 'lineCap should be defined'); goog.asserts.assert(lineCap !== undefined, 'lineCap should be defined');
goog.asserts.assert(!goog.isNull(lineDash), 'lineDash should not be null'); goog.asserts.assert(lineDash, 'lineDash should not be null');
goog.asserts.assert(lineJoin !== undefined, 'lineJoin should be defined'); goog.asserts.assert(lineJoin !== undefined, 'lineJoin should be defined');
goog.asserts.assert(lineWidth !== undefined, 'lineWidth should be defined'); goog.asserts.assert(lineWidth !== undefined, 'lineWidth should be defined');
goog.asserts.assert(miterLimit !== undefined, 'miterLimit should be defined'); goog.asserts.assert(miterLimit !== undefined, 'miterLimit should be defined');
@@ -1007,7 +1006,7 @@ ol.render.canvas.LineStringReplay.prototype.setStrokeStyle_ = function() {
ol.render.canvas.LineStringReplay.prototype.drawLineStringGeometry = ol.render.canvas.LineStringReplay.prototype.drawLineStringGeometry =
function(lineStringGeometry, feature) { function(lineStringGeometry, feature) {
var state = this.state_; var state = this.state_;
goog.asserts.assert(!goog.isNull(state), 'state should not be null'); goog.asserts.assert(state, 'state should not be null');
var strokeStyle = state.strokeStyle; var strokeStyle = state.strokeStyle;
var lineWidth = state.lineWidth; var lineWidth = state.lineWidth;
if (strokeStyle === undefined || lineWidth === undefined) { if (strokeStyle === undefined || lineWidth === undefined) {
@@ -1035,7 +1034,7 @@ ol.render.canvas.LineStringReplay.prototype.drawLineStringGeometry =
ol.render.canvas.LineStringReplay.prototype.drawMultiLineStringGeometry = ol.render.canvas.LineStringReplay.prototype.drawMultiLineStringGeometry =
function(multiLineStringGeometry, feature) { function(multiLineStringGeometry, feature) {
var state = this.state_; var state = this.state_;
goog.asserts.assert(!goog.isNull(state), 'state should not be null'); goog.asserts.assert(state, 'state should not be null');
var strokeStyle = state.strokeStyle; var strokeStyle = state.strokeStyle;
var lineWidth = state.lineWidth; var lineWidth = state.lineWidth;
if (strokeStyle === undefined || lineWidth === undefined) { if (strokeStyle === undefined || lineWidth === undefined) {
@@ -1067,7 +1066,7 @@ ol.render.canvas.LineStringReplay.prototype.drawMultiLineStringGeometry =
*/ */
ol.render.canvas.LineStringReplay.prototype.finish = function() { ol.render.canvas.LineStringReplay.prototype.finish = function() {
var state = this.state_; var state = this.state_;
goog.asserts.assert(!goog.isNull(state), 'state should not be null'); goog.asserts.assert(state, 'state should not be null');
if (state.lastStroke != this.coordinates.length) { if (state.lastStroke != this.coordinates.length) {
this.instructions.push([ol.render.canvas.Instruction.STROKE]); this.instructions.push([ol.render.canvas.Instruction.STROKE]);
} }
@@ -1081,19 +1080,17 @@ ol.render.canvas.LineStringReplay.prototype.finish = function() {
*/ */
ol.render.canvas.LineStringReplay.prototype.setFillStrokeStyle = ol.render.canvas.LineStringReplay.prototype.setFillStrokeStyle =
function(fillStyle, strokeStyle) { function(fillStyle, strokeStyle) {
goog.asserts.assert(!goog.isNull(this.state_), goog.asserts.assert(this.state_, 'this.state_ should not be null');
'this.state_ should not be null'); goog.asserts.assert(!fillStyle, 'fillStyle should be null');
goog.asserts.assert(goog.isNull(fillStyle), 'fillStyle should be null'); goog.asserts.assert(strokeStyle, 'strokeStyle should not be null');
goog.asserts.assert(!goog.isNull(strokeStyle),
'strokeStyle should not be null');
var strokeStyleColor = strokeStyle.getColor(); var strokeStyleColor = strokeStyle.getColor();
this.state_.strokeStyle = ol.color.asString(!goog.isNull(strokeStyleColor) ? this.state_.strokeStyle = ol.color.asString(strokeStyleColor ?
strokeStyleColor : ol.render.canvas.defaultStrokeStyle); strokeStyleColor : ol.render.canvas.defaultStrokeStyle);
var strokeStyleLineCap = strokeStyle.getLineCap(); var strokeStyleLineCap = strokeStyle.getLineCap();
this.state_.lineCap = strokeStyleLineCap !== undefined ? this.state_.lineCap = strokeStyleLineCap !== undefined ?
strokeStyleLineCap : ol.render.canvas.defaultLineCap; strokeStyleLineCap : ol.render.canvas.defaultLineCap;
var strokeStyleLineDash = strokeStyle.getLineDash(); var strokeStyleLineDash = strokeStyle.getLineDash();
this.state_.lineDash = !goog.isNull(strokeStyleLineDash) ? this.state_.lineDash = strokeStyleLineDash ?
strokeStyleLineDash : ol.render.canvas.defaultLineDash; strokeStyleLineDash : ol.render.canvas.defaultLineDash;
var strokeStyleLineJoin = strokeStyle.getLineJoin(); var strokeStyleLineJoin = strokeStyle.getLineJoin();
this.state_.lineJoin = strokeStyleLineJoin !== undefined ? this.state_.lineJoin = strokeStyleLineJoin !== undefined ?
@@ -1217,7 +1214,7 @@ ol.render.canvas.PolygonReplay.prototype.drawFlatCoordinatess_ =
ol.render.canvas.PolygonReplay.prototype.drawCircleGeometry = ol.render.canvas.PolygonReplay.prototype.drawCircleGeometry =
function(circleGeometry, feature) { function(circleGeometry, feature) {
var state = this.state_; var state = this.state_;
goog.asserts.assert(!goog.isNull(state), 'state should not be null'); goog.asserts.assert(state, 'state should not be null');
var fillStyle = state.fillStyle; var fillStyle = state.fillStyle;
var strokeStyle = state.strokeStyle; var strokeStyle = state.strokeStyle;
if (fillStyle === undefined && strokeStyle === undefined) { if (fillStyle === undefined && strokeStyle === undefined) {
@@ -1270,7 +1267,7 @@ ol.render.canvas.PolygonReplay.prototype.drawCircleGeometry =
ol.render.canvas.PolygonReplay.prototype.drawPolygonGeometry = ol.render.canvas.PolygonReplay.prototype.drawPolygonGeometry =
function(polygonGeometry, feature) { function(polygonGeometry, feature) {
var state = this.state_; var state = this.state_;
goog.asserts.assert(!goog.isNull(state), 'state should not be null'); goog.asserts.assert(state, 'state should not be null');
var fillStyle = state.fillStyle; var fillStyle = state.fillStyle;
var strokeStyle = state.strokeStyle; var strokeStyle = state.strokeStyle;
if (fillStyle === undefined && strokeStyle === undefined) { if (fillStyle === undefined && strokeStyle === undefined) {
@@ -1306,7 +1303,7 @@ ol.render.canvas.PolygonReplay.prototype.drawPolygonGeometry =
ol.render.canvas.PolygonReplay.prototype.drawMultiPolygonGeometry = ol.render.canvas.PolygonReplay.prototype.drawMultiPolygonGeometry =
function(multiPolygonGeometry, feature) { function(multiPolygonGeometry, feature) {
var state = this.state_; var state = this.state_;
goog.asserts.assert(!goog.isNull(state), 'state should not be null'); goog.asserts.assert(state, 'state should not be null');
var fillStyle = state.fillStyle; var fillStyle = state.fillStyle;
var strokeStyle = state.strokeStyle; var strokeStyle = state.strokeStyle;
if (fillStyle === undefined && strokeStyle === undefined) { if (fillStyle === undefined && strokeStyle === undefined) {
@@ -1345,8 +1342,7 @@ ol.render.canvas.PolygonReplay.prototype.drawMultiPolygonGeometry =
* @inheritDoc * @inheritDoc
*/ */
ol.render.canvas.PolygonReplay.prototype.finish = function() { ol.render.canvas.PolygonReplay.prototype.finish = function() {
goog.asserts.assert(!goog.isNull(this.state_), goog.asserts.assert(this.state_, 'this.state_ should not be null');
'this.state_ should not be null');
this.reverseHitDetectionInstructions_(); this.reverseHitDetectionInstructions_();
this.state_ = null; this.state_ = null;
// We want to preserve topology when drawing polygons. Polygons are // We want to preserve topology when drawing polygons. Polygons are
@@ -1368,7 +1364,7 @@ ol.render.canvas.PolygonReplay.prototype.finish = function() {
* @inheritDoc * @inheritDoc
*/ */
ol.render.canvas.PolygonReplay.prototype.getBufferedMaxExtent = function() { ol.render.canvas.PolygonReplay.prototype.getBufferedMaxExtent = function() {
if (goog.isNull(this.bufferedMaxExtent_)) { if (!this.bufferedMaxExtent_) {
this.bufferedMaxExtent_ = ol.extent.clone(this.maxExtent); this.bufferedMaxExtent_ = ol.extent.clone(this.maxExtent);
if (this.maxLineWidth > 0) { if (this.maxLineWidth > 0) {
var width = this.resolution * (this.maxLineWidth + 1) / 2; var width = this.resolution * (this.maxLineWidth + 1) / 2;
@@ -1384,27 +1380,26 @@ ol.render.canvas.PolygonReplay.prototype.getBufferedMaxExtent = function() {
*/ */
ol.render.canvas.PolygonReplay.prototype.setFillStrokeStyle = ol.render.canvas.PolygonReplay.prototype.setFillStrokeStyle =
function(fillStyle, strokeStyle) { function(fillStyle, strokeStyle) {
goog.asserts.assert(!goog.isNull(this.state_), goog.asserts.assert(this.state_, 'this.state_ should not be null');
'this.state_ should not be null'); goog.asserts.assert(fillStyle || strokeStyle,
goog.asserts.assert(!goog.isNull(fillStyle) || !goog.isNull(strokeStyle),
'fillStyle or strokeStyle should not be null'); 'fillStyle or strokeStyle should not be null');
var state = this.state_; var state = this.state_;
if (!goog.isNull(fillStyle)) { if (fillStyle) {
var fillStyleColor = fillStyle.getColor(); var fillStyleColor = fillStyle.getColor();
state.fillStyle = ol.color.asString(!goog.isNull(fillStyleColor) ? state.fillStyle = ol.color.asString(fillStyleColor ?
fillStyleColor : ol.render.canvas.defaultFillStyle); fillStyleColor : ol.render.canvas.defaultFillStyle);
} else { } else {
state.fillStyle = undefined; state.fillStyle = undefined;
} }
if (!goog.isNull(strokeStyle)) { if (strokeStyle) {
var strokeStyleColor = strokeStyle.getColor(); var strokeStyleColor = strokeStyle.getColor();
state.strokeStyle = ol.color.asString(!goog.isNull(strokeStyleColor) ? state.strokeStyle = ol.color.asString(strokeStyleColor ?
strokeStyleColor : ol.render.canvas.defaultStrokeStyle); strokeStyleColor : ol.render.canvas.defaultStrokeStyle);
var strokeStyleLineCap = strokeStyle.getLineCap(); var strokeStyleLineCap = strokeStyle.getLineCap();
state.lineCap = strokeStyleLineCap !== undefined ? state.lineCap = strokeStyleLineCap !== undefined ?
strokeStyleLineCap : ol.render.canvas.defaultLineCap; strokeStyleLineCap : ol.render.canvas.defaultLineCap;
var strokeStyleLineDash = strokeStyle.getLineDash(); var strokeStyleLineDash = strokeStyle.getLineDash();
state.lineDash = !goog.isNull(strokeStyleLineDash) ? state.lineDash = strokeStyleLineDash ?
strokeStyleLineDash.slice() : ol.render.canvas.defaultLineDash; strokeStyleLineDash.slice() : ol.render.canvas.defaultLineDash;
var strokeStyleLineJoin = strokeStyle.getLineJoin(); var strokeStyleLineJoin = strokeStyle.getLineJoin();
state.lineJoin = strokeStyleLineJoin !== undefined ? state.lineJoin = strokeStyleLineJoin !== undefined ?
@@ -1451,7 +1446,7 @@ ol.render.canvas.PolygonReplay.prototype.setFillStrokeStyles_ = function() {
} }
if (strokeStyle !== undefined) { if (strokeStyle !== undefined) {
goog.asserts.assert(lineCap !== undefined, 'lineCap should be defined'); goog.asserts.assert(lineCap !== undefined, 'lineCap should be defined');
goog.asserts.assert(!goog.isNull(lineDash), 'lineDash should not be null'); goog.asserts.assert(lineDash, 'lineDash should not be null');
goog.asserts.assert(lineJoin !== undefined, 'lineJoin should be defined'); goog.asserts.assert(lineJoin !== undefined, 'lineJoin should be defined');
goog.asserts.assert(lineWidth !== undefined, 'lineWidth should be defined'); goog.asserts.assert(lineWidth !== undefined, 'lineWidth should be defined');
goog.asserts.assert(miterLimit !== undefined, goog.asserts.assert(miterLimit !== undefined,
@@ -1566,15 +1561,15 @@ goog.inherits(ol.render.canvas.TextReplay, ol.render.canvas.Replay);
ol.render.canvas.TextReplay.prototype.drawText = ol.render.canvas.TextReplay.prototype.drawText =
function(flatCoordinates, offset, end, stride, geometry, feature) { function(flatCoordinates, offset, end, stride, geometry, feature) {
if (this.text_ === '' || if (this.text_ === '' ||
goog.isNull(this.textState_) || !this.textState_ ||
(goog.isNull(this.textFillState_) && (this.textFillState_ &&
goog.isNull(this.textStrokeState_))) { !this.textStrokeState_)) {
return; return;
} }
if (!goog.isNull(this.textFillState_)) { if (this.textFillState_) {
this.setReplayFillState_(this.textFillState_); this.setReplayFillState_(this.textFillState_);
} }
if (!goog.isNull(this.textStrokeState_)) { if (this.textStrokeState_) {
this.setReplayStrokeState_(this.textStrokeState_); this.setReplayStrokeState_(this.textStrokeState_);
} }
this.setReplayTextState_(this.textState_); this.setReplayTextState_(this.textState_);
@@ -1582,8 +1577,8 @@ ol.render.canvas.TextReplay.prototype.drawText =
var myBegin = this.coordinates.length; var myBegin = this.coordinates.length;
var myEnd = var myEnd =
this.appendFlatCoordinates(flatCoordinates, offset, end, stride, false); this.appendFlatCoordinates(flatCoordinates, offset, end, stride, false);
var fill = !goog.isNull(this.textFillState_); var fill = this.textFillState_;
var stroke = !goog.isNull(this.textStrokeState_); var stroke = this.textStrokeState_;
var drawTextInstruction = [ var drawTextInstruction = [
ol.render.canvas.Instruction.DRAW_TEXT, myBegin, myEnd, this.text_, ol.render.canvas.Instruction.DRAW_TEXT, myBegin, myEnd, this.text_,
this.textOffsetX_, this.textOffsetY_, this.textRotation_, this.textScale_, this.textOffsetX_, this.textOffsetY_, this.textRotation_, this.textScale_,
@@ -1601,7 +1596,7 @@ ol.render.canvas.TextReplay.prototype.drawText =
ol.render.canvas.TextReplay.prototype.setReplayFillState_ = ol.render.canvas.TextReplay.prototype.setReplayFillState_ =
function(fillState) { function(fillState) {
var replayFillState = this.replayFillState_; var replayFillState = this.replayFillState_;
if (!goog.isNull(replayFillState) && if (replayFillState &&
replayFillState.fillStyle == fillState.fillStyle) { replayFillState.fillStyle == fillState.fillStyle) {
return; return;
} }
@@ -1609,7 +1604,7 @@ ol.render.canvas.TextReplay.prototype.setReplayFillState_ =
[ol.render.canvas.Instruction.SET_FILL_STYLE, fillState.fillStyle]; [ol.render.canvas.Instruction.SET_FILL_STYLE, fillState.fillStyle];
this.instructions.push(setFillStyleInstruction); this.instructions.push(setFillStyleInstruction);
this.hitDetectionInstructions.push(setFillStyleInstruction); this.hitDetectionInstructions.push(setFillStyleInstruction);
if (goog.isNull(replayFillState)) { if (!replayFillState) {
this.replayFillState_ = { this.replayFillState_ = {
fillStyle: fillState.fillStyle fillStyle: fillState.fillStyle
}; };
@@ -1626,7 +1621,7 @@ ol.render.canvas.TextReplay.prototype.setReplayFillState_ =
ol.render.canvas.TextReplay.prototype.setReplayStrokeState_ = ol.render.canvas.TextReplay.prototype.setReplayStrokeState_ =
function(strokeState) { function(strokeState) {
var replayStrokeState = this.replayStrokeState_; var replayStrokeState = this.replayStrokeState_;
if (!goog.isNull(replayStrokeState) && if (replayStrokeState &&
replayStrokeState.lineCap == strokeState.lineCap && replayStrokeState.lineCap == strokeState.lineCap &&
replayStrokeState.lineDash == strokeState.lineDash && replayStrokeState.lineDash == strokeState.lineDash &&
replayStrokeState.lineJoin == strokeState.lineJoin && replayStrokeState.lineJoin == strokeState.lineJoin &&
@@ -1642,7 +1637,7 @@ ol.render.canvas.TextReplay.prototype.setReplayStrokeState_ =
]; ];
this.instructions.push(setStrokeStyleInstruction); this.instructions.push(setStrokeStyleInstruction);
this.hitDetectionInstructions.push(setStrokeStyleInstruction); this.hitDetectionInstructions.push(setStrokeStyleInstruction);
if (goog.isNull(replayStrokeState)) { if (!replayStrokeState) {
this.replayStrokeState_ = { this.replayStrokeState_ = {
lineCap: strokeState.lineCap, lineCap: strokeState.lineCap,
lineDash: strokeState.lineDash, lineDash: strokeState.lineDash,
@@ -1669,7 +1664,7 @@ ol.render.canvas.TextReplay.prototype.setReplayStrokeState_ =
ol.render.canvas.TextReplay.prototype.setReplayTextState_ = ol.render.canvas.TextReplay.prototype.setReplayTextState_ =
function(textState) { function(textState) {
var replayTextState = this.replayTextState_; var replayTextState = this.replayTextState_;
if (!goog.isNull(replayTextState) && if (replayTextState &&
replayTextState.font == textState.font && replayTextState.font == textState.font &&
replayTextState.textAlign == textState.textAlign && replayTextState.textAlign == textState.textAlign &&
replayTextState.textBaseline == textState.textBaseline) { replayTextState.textBaseline == textState.textBaseline) {
@@ -1679,7 +1674,7 @@ ol.render.canvas.TextReplay.prototype.setReplayTextState_ =
textState.font, textState.textAlign, textState.textBaseline]; textState.font, textState.textAlign, textState.textBaseline];
this.instructions.push(setTextStyleInstruction); this.instructions.push(setTextStyleInstruction);
this.hitDetectionInstructions.push(setTextStyleInstruction); this.hitDetectionInstructions.push(setTextStyleInstruction);
if (goog.isNull(replayTextState)) { if (!replayTextState) {
this.replayTextState_ = { this.replayTextState_ = {
font: textState.font, font: textState.font,
textAlign: textState.textAlign, textAlign: textState.textAlign,
@@ -1697,17 +1692,17 @@ ol.render.canvas.TextReplay.prototype.setReplayTextState_ =
* @inheritDoc * @inheritDoc
*/ */
ol.render.canvas.TextReplay.prototype.setTextStyle = function(textStyle) { ol.render.canvas.TextReplay.prototype.setTextStyle = function(textStyle) {
if (goog.isNull(textStyle)) { if (!textStyle) {
this.text_ = ''; this.text_ = '';
} else { } else {
var textFillStyle = textStyle.getFill(); var textFillStyle = textStyle.getFill();
if (goog.isNull(textFillStyle)) { if (!textFillStyle) {
this.textFillState_ = null; this.textFillState_ = null;
} else { } else {
var textFillStyleColor = textFillStyle.getColor(); var textFillStyleColor = textFillStyle.getColor();
var fillStyle = ol.color.asString(!goog.isNull(textFillStyleColor) ? var fillStyle = ol.color.asString(textFillStyleColor ?
textFillStyleColor : ol.render.canvas.defaultFillStyle); textFillStyleColor : ol.render.canvas.defaultFillStyle);
if (goog.isNull(this.textFillState_)) { if (!this.textFillState_) {
this.textFillState_ = { this.textFillState_ = {
fillStyle: fillStyle fillStyle: fillStyle
}; };
@@ -1717,7 +1712,7 @@ ol.render.canvas.TextReplay.prototype.setTextStyle = function(textStyle) {
} }
} }
var textStrokeStyle = textStyle.getStroke(); var textStrokeStyle = textStyle.getStroke();
if (goog.isNull(textStrokeStyle)) { if (!textStrokeStyle) {
this.textStrokeState_ = null; this.textStrokeState_ = null;
} else { } else {
var textStrokeStyleColor = textStrokeStyle.getColor(); var textStrokeStyleColor = textStrokeStyle.getColor();
@@ -1736,9 +1731,9 @@ ol.render.canvas.TextReplay.prototype.setTextStyle = function(textStyle) {
textStrokeStyleWidth : ol.render.canvas.defaultLineWidth; textStrokeStyleWidth : ol.render.canvas.defaultLineWidth;
var miterLimit = textStrokeStyleMiterLimit !== undefined ? var miterLimit = textStrokeStyleMiterLimit !== undefined ?
textStrokeStyleMiterLimit : ol.render.canvas.defaultMiterLimit; textStrokeStyleMiterLimit : ol.render.canvas.defaultMiterLimit;
var strokeStyle = ol.color.asString(!goog.isNull(textStrokeStyleColor) ? var strokeStyle = ol.color.asString(textStrokeStyleColor ?
textStrokeStyleColor : ol.render.canvas.defaultStrokeStyle); textStrokeStyleColor : ol.render.canvas.defaultStrokeStyle);
if (goog.isNull(this.textStrokeState_)) { if (!this.textStrokeState_) {
this.textStrokeState_ = { this.textStrokeState_ = {
lineCap: lineCap, lineCap: lineCap,
lineDash: lineDash, lineDash: lineDash,
@@ -1771,7 +1766,7 @@ ol.render.canvas.TextReplay.prototype.setTextStyle = function(textStyle) {
textTextAlign : ol.render.canvas.defaultTextAlign; textTextAlign : ol.render.canvas.defaultTextAlign;
var textBaseline = textTextBaseline !== undefined ? var textBaseline = textTextBaseline !== undefined ?
textTextBaseline : ol.render.canvas.defaultTextBaseline; textTextBaseline : ol.render.canvas.defaultTextBaseline;
if (goog.isNull(this.textState_)) { if (!this.textState_) {
this.textState_ = { this.textState_ = {
font: font, font: font,
textAlign: textAlign, textAlign: textAlign,
+15 -15
View File
@@ -58,14 +58,14 @@ ol.renderer.vector.renderCircleGeometry_ =
'geometry should be an ol.geom.Circle'); 'geometry should be an ol.geom.Circle');
var fillStyle = style.getFill(); var fillStyle = style.getFill();
var strokeStyle = style.getStroke(); var strokeStyle = style.getStroke();
if (!goog.isNull(fillStyle) || !goog.isNull(strokeStyle)) { if (fillStyle || strokeStyle) {
var polygonReplay = replayGroup.getReplay( var polygonReplay = replayGroup.getReplay(
style.getZIndex(), ol.render.ReplayType.POLYGON); style.getZIndex(), ol.render.ReplayType.POLYGON);
polygonReplay.setFillStrokeStyle(fillStyle, strokeStyle); polygonReplay.setFillStrokeStyle(fillStyle, strokeStyle);
polygonReplay.drawCircleGeometry(geometry, feature); polygonReplay.drawCircleGeometry(geometry, feature);
} }
var textStyle = style.getText(); var textStyle = style.getText();
if (!goog.isNull(textStyle)) { if (textStyle) {
var textReplay = replayGroup.getReplay( var textReplay = replayGroup.getReplay(
style.getZIndex(), ol.render.ReplayType.TEXT); style.getZIndex(), ol.render.ReplayType.TEXT);
textReplay.setTextStyle(textStyle); textReplay.setTextStyle(textStyle);
@@ -89,7 +89,7 @@ ol.renderer.vector.renderFeature = function(
var loading = false; var loading = false;
var imageStyle, imageState; var imageStyle, imageState;
imageStyle = style.getImage(); imageStyle = style.getImage();
if (!goog.isNull(imageStyle)) { if (imageStyle) {
imageState = imageStyle.getImageState(); imageState = imageStyle.getImageState();
if (imageState == ol.style.ImageState.LOADED || if (imageState == ol.style.ImageState.LOADED ||
imageState == ol.style.ImageState.ERROR) { imageState == ol.style.ImageState.ERROR) {
@@ -168,14 +168,14 @@ ol.renderer.vector.renderLineStringGeometry_ =
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');
var strokeStyle = style.getStroke(); var strokeStyle = style.getStroke();
if (!goog.isNull(strokeStyle)) { if (strokeStyle) {
var lineStringReplay = replayGroup.getReplay( var lineStringReplay = replayGroup.getReplay(
style.getZIndex(), ol.render.ReplayType.LINE_STRING); style.getZIndex(), ol.render.ReplayType.LINE_STRING);
lineStringReplay.setFillStrokeStyle(null, strokeStyle); lineStringReplay.setFillStrokeStyle(null, strokeStyle);
lineStringReplay.drawLineStringGeometry(geometry, feature); lineStringReplay.drawLineStringGeometry(geometry, feature);
} }
var textStyle = style.getText(); var textStyle = style.getText();
if (!goog.isNull(textStyle)) { if (textStyle) {
var textReplay = replayGroup.getReplay( var textReplay = replayGroup.getReplay(
style.getZIndex(), ol.render.ReplayType.TEXT); style.getZIndex(), ol.render.ReplayType.TEXT);
textReplay.setTextStyle(textStyle); textReplay.setTextStyle(textStyle);
@@ -196,14 +196,14 @@ ol.renderer.vector.renderMultiLineStringGeometry_ =
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');
var strokeStyle = style.getStroke(); var strokeStyle = style.getStroke();
if (!goog.isNull(strokeStyle)) { if (strokeStyle) {
var lineStringReplay = replayGroup.getReplay( var lineStringReplay = replayGroup.getReplay(
style.getZIndex(), ol.render.ReplayType.LINE_STRING); style.getZIndex(), ol.render.ReplayType.LINE_STRING);
lineStringReplay.setFillStrokeStyle(null, strokeStyle); lineStringReplay.setFillStrokeStyle(null, strokeStyle);
lineStringReplay.drawMultiLineStringGeometry(geometry, feature); lineStringReplay.drawMultiLineStringGeometry(geometry, feature);
} }
var textStyle = style.getText(); var textStyle = style.getText();
if (!goog.isNull(textStyle)) { if (textStyle) {
var textReplay = replayGroup.getReplay( var textReplay = replayGroup.getReplay(
style.getZIndex(), ol.render.ReplayType.TEXT); style.getZIndex(), ol.render.ReplayType.TEXT);
textReplay.setTextStyle(textStyle); textReplay.setTextStyle(textStyle);
@@ -227,14 +227,14 @@ ol.renderer.vector.renderMultiPolygonGeometry_ =
'geometry should be an ol.geom.MultiPolygon'); 'geometry should be an ol.geom.MultiPolygon');
var fillStyle = style.getFill(); var fillStyle = style.getFill();
var strokeStyle = style.getStroke(); var strokeStyle = style.getStroke();
if (!goog.isNull(strokeStyle) || !goog.isNull(fillStyle)) { if (strokeStyle || fillStyle) {
var polygonReplay = replayGroup.getReplay( var polygonReplay = replayGroup.getReplay(
style.getZIndex(), ol.render.ReplayType.POLYGON); style.getZIndex(), ol.render.ReplayType.POLYGON);
polygonReplay.setFillStrokeStyle(fillStyle, strokeStyle); polygonReplay.setFillStrokeStyle(fillStyle, strokeStyle);
polygonReplay.drawMultiPolygonGeometry(geometry, feature); polygonReplay.drawMultiPolygonGeometry(geometry, feature);
} }
var textStyle = style.getText(); var textStyle = style.getText();
if (!goog.isNull(textStyle)) { if (textStyle) {
var textReplay = replayGroup.getReplay( var textReplay = replayGroup.getReplay(
style.getZIndex(), ol.render.ReplayType.TEXT); style.getZIndex(), ol.render.ReplayType.TEXT);
textReplay.setTextStyle(textStyle); textReplay.setTextStyle(textStyle);
@@ -257,7 +257,7 @@ ol.renderer.vector.renderPointGeometry_ =
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');
var imageStyle = style.getImage(); var imageStyle = style.getImage();
if (!goog.isNull(imageStyle)) { if (imageStyle) {
if (imageStyle.getImageState() != ol.style.ImageState.LOADED) { if (imageStyle.getImageState() != ol.style.ImageState.LOADED) {
return; return;
} }
@@ -267,7 +267,7 @@ ol.renderer.vector.renderPointGeometry_ =
imageReplay.drawPointGeometry(geometry, feature); imageReplay.drawPointGeometry(geometry, feature);
} }
var textStyle = style.getText(); var textStyle = style.getText();
if (!goog.isNull(textStyle)) { if (textStyle) {
var textReplay = replayGroup.getReplay( var textReplay = replayGroup.getReplay(
style.getZIndex(), ol.render.ReplayType.TEXT); style.getZIndex(), ol.render.ReplayType.TEXT);
textReplay.setTextStyle(textStyle); textReplay.setTextStyle(textStyle);
@@ -288,7 +288,7 @@ ol.renderer.vector.renderMultiPointGeometry_ =
goog.asserts.assertInstanceof(geometry, ol.geom.MultiPoint, goog.asserts.assertInstanceof(geometry, ol.geom.MultiPoint,
'geometry should be an ol.goem.MultiPoint'); 'geometry should be an ol.goem.MultiPoint');
var imageStyle = style.getImage(); var imageStyle = style.getImage();
if (!goog.isNull(imageStyle)) { if (imageStyle) {
if (imageStyle.getImageState() != ol.style.ImageState.LOADED) { if (imageStyle.getImageState() != ol.style.ImageState.LOADED) {
return; return;
} }
@@ -298,7 +298,7 @@ ol.renderer.vector.renderMultiPointGeometry_ =
imageReplay.drawMultiPointGeometry(geometry, feature); imageReplay.drawMultiPointGeometry(geometry, feature);
} }
var textStyle = style.getText(); var textStyle = style.getText();
if (!goog.isNull(textStyle)) { if (textStyle) {
var textReplay = replayGroup.getReplay( var textReplay = replayGroup.getReplay(
style.getZIndex(), ol.render.ReplayType.TEXT); style.getZIndex(), ol.render.ReplayType.TEXT);
textReplay.setTextStyle(textStyle); textReplay.setTextStyle(textStyle);
@@ -322,14 +322,14 @@ ol.renderer.vector.renderPolygonGeometry_ =
'geometry should be an ol.geom.Polygon'); 'geometry should be an ol.geom.Polygon');
var fillStyle = style.getFill(); var fillStyle = style.getFill();
var strokeStyle = style.getStroke(); var strokeStyle = style.getStroke();
if (!goog.isNull(fillStyle) || !goog.isNull(strokeStyle)) { if (fillStyle || strokeStyle) {
var polygonReplay = replayGroup.getReplay( var polygonReplay = replayGroup.getReplay(
style.getZIndex(), ol.render.ReplayType.POLYGON); style.getZIndex(), ol.render.ReplayType.POLYGON);
polygonReplay.setFillStrokeStyle(fillStyle, strokeStyle); polygonReplay.setFillStrokeStyle(fillStyle, strokeStyle);
polygonReplay.drawPolygonGeometry(geometry, feature); polygonReplay.drawPolygonGeometry(geometry, feature);
} }
var textStyle = style.getText(); var textStyle = style.getText();
if (!goog.isNull(textStyle)) { if (textStyle) {
var textReplay = replayGroup.getReplay( var textReplay = replayGroup.getReplay(
style.getZIndex(), ol.render.ReplayType.TEXT); style.getZIndex(), ol.render.ReplayType.TEXT);
textReplay.setTextStyle(textStyle); textReplay.setTextStyle(textStyle);
+12 -12
View File
@@ -222,9 +222,9 @@ ol.render.webgl.ImageReplay.prototype.getDeleteResourcesFunction =
// be used by other ImageReplay instances (for other layers). And // be used by other ImageReplay instances (for other layers). And
// they will be deleted when disposing of the ol.webgl.Context // they will be deleted when disposing of the ol.webgl.Context
// object. // object.
goog.asserts.assert(!goog.isNull(this.verticesBuffer_), goog.asserts.assert(this.verticesBuffer_,
'verticesBuffer must not be null'); 'verticesBuffer must not be null');
goog.asserts.assert(!goog.isNull(this.indicesBuffer_), goog.asserts.assert(this.indicesBuffer_,
'indicesBuffer must not be null'); 'indicesBuffer must not be null');
var verticesBuffer = this.verticesBuffer_; var verticesBuffer = this.verticesBuffer_;
var indicesBuffer = this.indicesBuffer_; var indicesBuffer = this.indicesBuffer_;
@@ -514,12 +514,12 @@ ol.render.webgl.ImageReplay.prototype.replay = function(context,
var gl = context.getGL(); var gl = context.getGL();
// bind the vertices buffer // bind the vertices buffer
goog.asserts.assert(!goog.isNull(this.verticesBuffer_), goog.asserts.assert(this.verticesBuffer_,
'verticesBuffer must not be null'); 'verticesBuffer must not be null');
context.bindBuffer(goog.webgl.ARRAY_BUFFER, this.verticesBuffer_); context.bindBuffer(goog.webgl.ARRAY_BUFFER, this.verticesBuffer_);
// bind the indices buffer // bind the indices buffer
goog.asserts.assert(!goog.isNull(this.indicesBuffer_), goog.asserts.assert(this.indicesBuffer_,
'indecesBuffer must not be null'); 'indecesBuffer must not be null');
context.bindBuffer(goog.webgl.ELEMENT_ARRAY_BUFFER, this.indicesBuffer_); context.bindBuffer(goog.webgl.ELEMENT_ARRAY_BUFFER, this.indicesBuffer_);
@@ -532,7 +532,7 @@ ol.render.webgl.ImageReplay.prototype.replay = function(context,
// get the locations // get the locations
var locations; var locations;
if (goog.isNull(this.defaultLocations_)) { if (!this.defaultLocations_) {
locations = locations =
new ol.render.webgl.imagereplay.shader.Default.Locations(gl, program); new ol.render.webgl.imagereplay.shader.Default.Locations(gl, program);
this.defaultLocations_ = locations; this.defaultLocations_ = locations;
@@ -863,20 +863,20 @@ ol.render.webgl.ImageReplay.prototype.setImageStyle = function(imageStyle) {
var rotation = imageStyle.getRotation(); var rotation = imageStyle.getRotation();
var size = imageStyle.getSize(); var size = imageStyle.getSize();
var scale = imageStyle.getScale(); var scale = imageStyle.getScale();
goog.asserts.assert(!goog.isNull(anchor), 'imageStyle anchor is not null'); goog.asserts.assert(anchor, 'imageStyle anchor is not null');
goog.asserts.assert(!goog.isNull(image), 'imageStyle image is not null'); goog.asserts.assert(image, 'imageStyle image is not null');
goog.asserts.assert(!goog.isNull(imageSize), goog.asserts.assert(imageSize,
'imageStyle imageSize is not null'); 'imageStyle imageSize is not null');
goog.asserts.assert(!goog.isNull(hitDetectionImage), goog.asserts.assert(hitDetectionImage,
'imageStyle hitDetectionImage is not null'); 'imageStyle hitDetectionImage is not null');
goog.asserts.assert(!goog.isNull(hitDetectionImageSize), goog.asserts.assert(hitDetectionImageSize,
'imageStyle hitDetectionImageSize is not null'); 'imageStyle hitDetectionImageSize is not null');
goog.asserts.assert(opacity !== undefined, 'imageStyle opacity is defined'); goog.asserts.assert(opacity !== undefined, 'imageStyle opacity is defined');
goog.asserts.assert(!goog.isNull(origin), 'imageStyle origin is not null'); goog.asserts.assert(origin, 'imageStyle origin is not null');
goog.asserts.assert(rotateWithView !== undefined, goog.asserts.assert(rotateWithView !== undefined,
'imageStyle rotateWithView is defined'); 'imageStyle rotateWithView is defined');
goog.asserts.assert(rotation !== undefined, 'imageStyle rotation is defined'); goog.asserts.assert(rotation !== undefined, 'imageStyle rotation is defined');
goog.asserts.assert(!goog.isNull(size), 'imageStyle size is not null'); goog.asserts.assert(size, 'imageStyle size is not null');
goog.asserts.assert(scale !== undefined, 'imageStyle scale is defined'); goog.asserts.assert(scale !== undefined, 'imageStyle scale is defined');
var currentImage; var currentImage;
@@ -79,7 +79,7 @@ ol.renderer.canvas.ImageLayer.prototype.forEachFeatureAtCoordinate =
*/ */
ol.renderer.canvas.ImageLayer.prototype.forEachLayerAtPixel = ol.renderer.canvas.ImageLayer.prototype.forEachLayerAtPixel =
function(pixel, frameState, callback, thisArg) { function(pixel, frameState, callback, thisArg) {
if (goog.isNull(this.getImage())) { if (!this.getImage()) {
return undefined; return undefined;
} }
@@ -99,7 +99,7 @@ ol.renderer.canvas.ImageLayer.prototype.forEachLayerAtPixel =
} }
} else { } else {
// for all other image sources directly check the image // for all other image sources directly check the image
if (goog.isNull(this.imageTransformInv_)) { if (!this.imageTransformInv_) {
this.imageTransformInv_ = goog.vec.Mat4.createNumber(); this.imageTransformInv_ = goog.vec.Mat4.createNumber();
goog.vec.Mat4.invert(this.imageTransform_, this.imageTransformInv_); goog.vec.Mat4.invert(this.imageTransform_, this.imageTransformInv_);
} }
@@ -107,7 +107,7 @@ ol.renderer.canvas.ImageLayer.prototype.forEachLayerAtPixel =
var pixelOnCanvas = var pixelOnCanvas =
this.getPixelOnCanvas(pixel, this.imageTransformInv_); this.getPixelOnCanvas(pixel, this.imageTransformInv_);
if (goog.isNull(this.hitCanvasContext_)) { if (!this.hitCanvasContext_) {
this.hitCanvasContext_ = ol.dom.createCanvasContext2D(1, 1); this.hitCanvasContext_ = ol.dom.createCanvasContext2D(1, 1);
} }
@@ -129,8 +129,7 @@ ol.renderer.canvas.ImageLayer.prototype.forEachLayerAtPixel =
* @inheritDoc * @inheritDoc
*/ */
ol.renderer.canvas.ImageLayer.prototype.getImage = function() { ol.renderer.canvas.ImageLayer.prototype.getImage = function() {
return goog.isNull(this.image_) ? return !this.image_ ? null : this.image_.getImage();
null : this.image_.getImage();
}; };
@@ -172,14 +171,14 @@ ol.renderer.canvas.ImageLayer.prototype.prepareFrame =
!ol.extent.isEmpty(renderedExtent)) { !ol.extent.isEmpty(renderedExtent)) {
var projection = viewState.projection; var projection = viewState.projection;
var sourceProjection = imageSource.getProjection(); var sourceProjection = imageSource.getProjection();
if (!goog.isNull(sourceProjection)) { if (sourceProjection) {
goog.asserts.assert(ol.proj.equivalent(projection, sourceProjection), goog.asserts.assert(ol.proj.equivalent(projection, sourceProjection),
'projection and sourceProjection are equivalent'); 'projection and sourceProjection are equivalent');
projection = sourceProjection; projection = sourceProjection;
} }
image = imageSource.getImage( image = imageSource.getImage(
renderedExtent, viewResolution, pixelRatio, projection); renderedExtent, viewResolution, pixelRatio, projection);
if (!goog.isNull(image)) { if (image) {
var loaded = this.loadImage(image); var loaded = this.loadImage(image);
if (loaded) { if (loaded) {
this.image_ = image; this.image_ = image;
@@ -187,7 +186,7 @@ ol.renderer.canvas.ImageLayer.prototype.prepareFrame =
} }
} }
if (!goog.isNull(this.image_)) { if (this.image_) {
image = this.image_; image = this.image_;
var imageExtent = image.getExtent(); var imageExtent = image.getExtent();
var imageResolution = image.getResolution(); var imageResolution = image.getResolution();
@@ -44,7 +44,7 @@ ol.renderer.canvas.Layer.prototype.composeFrame =
this.dispatchPreComposeEvent(context, frameState); this.dispatchPreComposeEvent(context, frameState);
var image = this.getImage(); var image = this.getImage();
if (!goog.isNull(image)) { if (image) {
// clipped rendering if layer extent is set // clipped rendering if layer extent is set
var extent = layerState.extent; var extent = layerState.extent;
@@ -252,7 +252,7 @@ ol.renderer.canvas.Layer.testCanvasSize = (function() {
var imageData = null; var imageData = null;
return function(size) { return function(size) {
if (goog.isNull(context)) { if (!context) {
context = ol.dom.createCanvasContext2D(1, 1); context = ol.dom.createCanvasContext2D(1, 1);
imageData = context.createImageData(1, 1); imageData = context.createImageData(1, 1);
var data = imageData.data; var data = imageData.data;
+1 -1
View File
@@ -146,7 +146,7 @@ ol.renderer.canvas.Map.prototype.getType = function() {
*/ */
ol.renderer.canvas.Map.prototype.renderFrame = function(frameState) { ol.renderer.canvas.Map.prototype.renderFrame = function(frameState) {
if (goog.isNull(frameState)) { if (!frameState) {
if (this.renderedVisible_) { if (this.renderedVisible_) {
goog.style.setElementShown(this.canvas_, false); goog.style.setElementShown(this.canvas_, false);
this.renderedVisible_ = false; this.renderedVisible_ = false;
@@ -231,12 +231,12 @@ ol.renderer.canvas.TileLayer.prototype.prepareFrame =
var canvasHeight = tilePixelSize[1] * tileRange.getHeight(); var canvasHeight = tilePixelSize[1] * tileRange.getHeight();
var canvas, context; var canvas, context;
if (goog.isNull(this.canvas_)) { if (!this.canvas_) {
goog.asserts.assert(goog.isNull(this.canvasSize_), goog.asserts.assert(!this.canvasSize_,
'canvasSize is null (because canvas is null)'); 'canvasSize is null (because canvas is null)');
goog.asserts.assert(goog.isNull(this.context_), goog.asserts.assert(!this.context_,
'context is null (because canvas is null)'); 'context is null (because canvas is null)');
goog.asserts.assert(goog.isNull(this.renderedCanvasTileRange_), goog.asserts.assert(!this.renderedCanvasTileRange_,
'renderedCanvasTileRange is null (because canvas is null)'); 'renderedCanvasTileRange is null (because canvas is null)');
context = ol.dom.createCanvasContext2D(canvasWidth, canvasHeight); context = ol.dom.createCanvasContext2D(canvasWidth, canvasHeight);
this.canvas_ = context.canvas; this.canvas_ = context.canvas;
@@ -245,9 +245,9 @@ ol.renderer.canvas.TileLayer.prototype.prepareFrame =
this.canvasTooBig_ = this.canvasTooBig_ =
!ol.renderer.canvas.Layer.testCanvasSize(this.canvasSize_); !ol.renderer.canvas.Layer.testCanvasSize(this.canvasSize_);
} else { } else {
goog.asserts.assert(!goog.isNull(this.canvasSize_), goog.asserts.assert(this.canvasSize_,
'non-null canvasSize (because canvas is not null)'); 'non-null canvasSize (because canvas is not null)');
goog.asserts.assert(!goog.isNull(this.context_), goog.asserts.assert(this.context_,
'non-null context (because canvas is not null)'); 'non-null context (because canvas is not null)');
canvas = this.canvas_; canvas = this.canvas_;
context = this.context_; context = this.context_;
@@ -277,7 +277,7 @@ ol.renderer.canvas.TileLayer.prototype.prepareFrame =
} }
var canvasTileRange, canvasTileRangeWidth, minX, minY; var canvasTileRange, canvasTileRangeWidth, minX, minY;
if (goog.isNull(this.renderedCanvasTileRange_)) { if (!this.renderedCanvasTileRange_) {
canvasTileRangeWidth = canvasWidth / tilePixelSize[0]; canvasTileRangeWidth = canvasWidth / tilePixelSize[0];
var canvasTileRangeHeight = canvasHeight / tilePixelSize[1]; var canvasTileRangeHeight = canvasHeight / tilePixelSize[1];
minX = tileRange.minX - minX = tileRange.minX -
@@ -336,7 +336,7 @@ ol.renderer.canvas.TileLayer.prototype.prepareFrame =
tilesToClear.push(tile); tilesToClear.push(tile);
childTileRange = tileGrid.getTileCoordChildTileRange( childTileRange = tileGrid.getTileCoordChildTileRange(
tile.tileCoord, tmpTileRange, tmpExtent); tile.tileCoord, tmpTileRange, tmpExtent);
if (!goog.isNull(childTileRange)) { if (childTileRange) {
findLoadedTiles(z + 1, childTileRange); findLoadedTiles(z + 1, childTileRange);
} }
} }
@@ -450,11 +450,11 @@ ol.renderer.canvas.TileLayer.prototype.prepareFrame =
*/ */
ol.renderer.canvas.TileLayer.prototype.forEachLayerAtPixel = ol.renderer.canvas.TileLayer.prototype.forEachLayerAtPixel =
function(pixel, frameState, callback, thisArg) { function(pixel, frameState, callback, thisArg) {
if (goog.isNull(this.context_)) { if (!this.context_) {
return undefined; return undefined;
} }
if (goog.isNull(this.imageTransformInv_)) { if (!this.imageTransformInv_) {
this.imageTransformInv_ = goog.vec.Mat4.createNumber(); this.imageTransformInv_ = goog.vec.Mat4.createNumber();
goog.vec.Mat4.invert(this.imageTransform_, this.imageTransformInv_); goog.vec.Mat4.invert(this.imageTransform_, this.imageTransformInv_);
} }
@@ -92,7 +92,7 @@ ol.renderer.canvas.VectorLayer.prototype.composeFrame =
this.dispatchPreComposeEvent(context, frameState, transform); this.dispatchPreComposeEvent(context, frameState, transform);
var replayGroup = this.replayGroup_; var replayGroup = this.replayGroup_;
if (!goog.isNull(replayGroup) && !replayGroup.isEmpty()) { if (replayGroup && !replayGroup.isEmpty()) {
var layer = this.getLayer(); var layer = this.getLayer();
var replayContext; var replayContext;
if (layer.hasListener(ol.render.EventType.RENDER)) { if (layer.hasListener(ol.render.EventType.RENDER)) {
@@ -156,7 +156,7 @@ ol.renderer.canvas.VectorLayer.prototype.composeFrame =
*/ */
ol.renderer.canvas.VectorLayer.prototype.forEachFeatureAtCoordinate = ol.renderer.canvas.VectorLayer.prototype.forEachFeatureAtCoordinate =
function(coordinate, frameState, callback, thisArg) { function(coordinate, frameState, callback, thisArg) {
if (goog.isNull(this.replayGroup_)) { if (!this.replayGroup_) {
return undefined; return undefined;
} else { } else {
var resolution = frameState.viewState.resolution; var resolution = frameState.viewState.resolution;
@@ -290,7 +290,7 @@ ol.renderer.canvas.VectorLayer.prototype.prepareFrame =
this.dirty_ = this.dirty_ || dirty; this.dirty_ = this.dirty_ || dirty;
} }
}; };
if (!goog.isNull(vectorLayerRenderOrder)) { if (vectorLayerRenderOrder) {
/** @type {Array.<ol.Feature>} */ /** @type {Array.<ol.Feature>} */
var features = []; var features = [];
vectorSource.forEachFeatureInExtentAtResolution(extent, resolution, vectorSource.forEachFeatureInExtentAtResolution(extent, resolution,
+3 -3
View File
@@ -103,14 +103,14 @@ ol.renderer.dom.ImageLayer.prototype.prepareFrame =
!ol.extent.isEmpty(renderedExtent)) { !ol.extent.isEmpty(renderedExtent)) {
var projection = viewState.projection; var projection = viewState.projection;
var sourceProjection = imageSource.getProjection(); var sourceProjection = imageSource.getProjection();
if (!goog.isNull(sourceProjection)) { if (sourceProjection) {
goog.asserts.assert(ol.proj.equivalent(projection, sourceProjection), goog.asserts.assert(ol.proj.equivalent(projection, sourceProjection),
'projection and sourceProjection are equivalent'); 'projection and sourceProjection are equivalent');
projection = sourceProjection; projection = sourceProjection;
} }
var image_ = imageSource.getImage(renderedExtent, viewResolution, var image_ = imageSource.getImage(renderedExtent, viewResolution,
frameState.pixelRatio, projection); frameState.pixelRatio, projection);
if (!goog.isNull(image_)) { if (image_) {
var loaded = this.loadImage(image_); var loaded = this.loadImage(image_);
if (loaded) { if (loaded) {
image = image_; image = image_;
@@ -118,7 +118,7 @@ ol.renderer.dom.ImageLayer.prototype.prepareFrame =
} }
} }
if (!goog.isNull(image)) { if (image) {
var imageExtent = image.getExtent(); var imageExtent = image.getExtent();
var imageResolution = image.getResolution(); var imageResolution = image.getResolution();
var transform = goog.vec.Mat4.createNumber(); var transform = goog.vec.Mat4.createNumber();
+1 -1
View File
@@ -159,7 +159,7 @@ ol.renderer.dom.Map.prototype.getType = function() {
*/ */
ol.renderer.dom.Map.prototype.renderFrame = function(frameState) { ol.renderer.dom.Map.prototype.renderFrame = function(frameState) {
if (goog.isNull(frameState)) { if (!frameState) {
if (this.renderedVisible_) { if (this.renderedVisible_) {
goog.style.setElementShown(this.layersPane_, false); goog.style.setElementShown(this.layersPane_, false);
this.renderedVisible_ = false; this.renderedVisible_ = false;
+3 -3
View File
@@ -148,7 +148,7 @@ ol.renderer.dom.TileLayer.prototype.prepareFrame =
if (!fullyLoaded) { if (!fullyLoaded) {
childTileRange = tileGrid.getTileCoordChildTileRange( childTileRange = tileGrid.getTileCoordChildTileRange(
tile.tileCoord, tmpTileRange, tmpExtent); tile.tileCoord, tmpTileRange, tmpExtent);
if (!goog.isNull(childTileRange)) { if (childTileRange) {
findLoadedTiles(z + 1, childTileRange); findLoadedTiles(z + 1, childTileRange);
} }
} }
@@ -376,7 +376,7 @@ ol.renderer.dom.TileLayerZ_.prototype.addTile = function(tile, tileGutter) {
((tileCoordX - this.tileCoordOrigin_[1]) * tileSize[0]) + 'px'; ((tileCoordX - this.tileCoordOrigin_[1]) * tileSize[0]) + 'px';
tileElementStyle.top = tileElementStyle.top =
((this.tileCoordOrigin_[2] - tileCoordY) * tileSize[1]) + 'px'; ((this.tileCoordOrigin_[2] - tileCoordY) * tileSize[1]) + 'px';
if (goog.isNull(this.documentFragment_)) { if (!this.documentFragment_) {
this.documentFragment_ = document.createDocumentFragment(); this.documentFragment_ = document.createDocumentFragment();
} }
goog.dom.appendChild(this.documentFragment_, tileElement); goog.dom.appendChild(this.documentFragment_, tileElement);
@@ -388,7 +388,7 @@ ol.renderer.dom.TileLayerZ_.prototype.addTile = function(tile, tileGutter) {
* FIXME empty description for jsdoc * FIXME empty description for jsdoc
*/ */
ol.renderer.dom.TileLayerZ_.prototype.finalizeAddTiles = function() { ol.renderer.dom.TileLayerZ_.prototype.finalizeAddTiles = function() {
if (!goog.isNull(this.documentFragment_)) { if (this.documentFragment_) {
goog.dom.appendChild(this.target, this.documentFragment_); goog.dom.appendChild(this.target, this.documentFragment_);
this.documentFragment_ = null; this.documentFragment_ = null;
} }
@@ -138,7 +138,7 @@ ol.renderer.dom.VectorLayer.prototype.composeFrame =
var replayGroup = this.replayGroup_; var replayGroup = this.replayGroup_;
if (!goog.isNull(replayGroup) && !replayGroup.isEmpty()) { if (replayGroup && !replayGroup.isEmpty()) {
context.globalAlpha = layerState.opacity; context.globalAlpha = layerState.opacity;
replayGroup.replay(context, pixelRatio, transform, viewRotation, replayGroup.replay(context, pixelRatio, transform, viewRotation,
@@ -178,7 +178,7 @@ ol.renderer.dom.VectorLayer.prototype.dispatchEvent_ =
*/ */
ol.renderer.dom.VectorLayer.prototype.forEachFeatureAtCoordinate = ol.renderer.dom.VectorLayer.prototype.forEachFeatureAtCoordinate =
function(coordinate, frameState, callback, thisArg) { function(coordinate, frameState, callback, thisArg) {
if (goog.isNull(this.replayGroup_)) { if (!this.replayGroup_) {
return undefined; return undefined;
} else { } else {
var resolution = frameState.viewState.resolution; var resolution = frameState.viewState.resolution;
@@ -298,7 +298,7 @@ ol.renderer.dom.VectorLayer.prototype.prepareFrame =
this.dirty_ = this.dirty_ || dirty; this.dirty_ = this.dirty_ || dirty;
} }
}; };
if (!goog.isNull(vectorLayerRenderOrder)) { if (vectorLayerRenderOrder) {
/** @type {Array.<ol.Feature>} */ /** @type {Array.<ol.Feature>} */
var features = []; var features = [];
vectorSource.forEachFeatureInExtentAtResolution(extent, resolution, vectorSource.forEachFeatureInExtentAtResolution(extent, resolution,
+4 -4
View File
@@ -71,8 +71,8 @@ goog.inherits(ol.renderer.Map, goog.Disposable);
ol.renderer.Map.prototype.calculateMatrices2D = function(frameState) { ol.renderer.Map.prototype.calculateMatrices2D = function(frameState) {
var viewState = frameState.viewState; var viewState = frameState.viewState;
var coordinateToPixelMatrix = frameState.coordinateToPixelMatrix; var coordinateToPixelMatrix = frameState.coordinateToPixelMatrix;
goog.asserts.assert(!goog.isNull(coordinateToPixelMatrix), goog.asserts.assert(coordinateToPixelMatrix,
'frameState has non-null coordinateToPixelMatrix'); 'frameState has a coordinateToPixelMatrix');
ol.vec.Mat4.makeTransform2D(coordinateToPixelMatrix, ol.vec.Mat4.makeTransform2D(coordinateToPixelMatrix,
frameState.size[0] / 2, frameState.size[1] / 2, frameState.size[0] / 2, frameState.size[1] / 2,
1 / viewState.resolution, -1 / viewState.resolution, 1 / viewState.resolution, -1 / viewState.resolution,
@@ -171,7 +171,7 @@ ol.renderer.Map.prototype.forEachFeatureAtCoordinate =
(ol.layer.Layer.visibleAtResolution(layerState, viewResolution) && (ol.layer.Layer.visibleAtResolution(layerState, viewResolution) &&
layerFilter.call(thisArg2, layer))) { layerFilter.call(thisArg2, layer))) {
var layerRenderer = this.getLayerRenderer(layer); var layerRenderer = this.getLayerRenderer(layer);
if (!goog.isNull(layer.getSource())) { if (layer.getSource()) {
result = layerRenderer.forEachFeatureAtCoordinate( result = layerRenderer.forEachFeatureAtCoordinate(
layer.getSource().getWrapX() ? translatedCoordinate : coordinate, layer.getSource().getWrapX() ? translatedCoordinate : coordinate,
frameState, callback, thisArg); frameState, callback, thisArg);
@@ -347,7 +347,7 @@ ol.renderer.Map.prototype.removeUnusedLayerRenderers_ =
function(map, frameState) { function(map, frameState) {
var layerKey; var layerKey;
for (layerKey in this.layerRenderers_) { for (layerKey in this.layerRenderers_) {
if (goog.isNull(frameState) || !(layerKey in frameState.layerStates)) { if (!frameState || !(layerKey in frameState.layerStates)) {
goog.dispose(this.removeLayerRendererByKey_(layerKey)); goog.dispose(this.removeLayerRendererByKey_(layerKey));
} }
} }
@@ -126,19 +126,19 @@ ol.renderer.webgl.ImageLayer.prototype.prepareFrame =
!ol.extent.isEmpty(renderedExtent)) { !ol.extent.isEmpty(renderedExtent)) {
var projection = viewState.projection; var projection = viewState.projection;
var sourceProjection = imageSource.getProjection(); var sourceProjection = imageSource.getProjection();
if (!goog.isNull(sourceProjection)) { if (sourceProjection) {
goog.asserts.assert(ol.proj.equivalent(projection, sourceProjection), goog.asserts.assert(ol.proj.equivalent(projection, sourceProjection),
'projection and sourceProjection are equivalent'); 'projection and sourceProjection are equivalent');
projection = sourceProjection; projection = sourceProjection;
} }
var image_ = imageSource.getImage(renderedExtent, viewResolution, var image_ = imageSource.getImage(renderedExtent, viewResolution,
pixelRatio, projection); pixelRatio, projection);
if (!goog.isNull(image_)) { if (image_) {
var loaded = this.loadImage(image_); var loaded = this.loadImage(image_);
if (loaded) { if (loaded) {
image = image_; image = image_;
texture = this.createTexture_(image_); texture = this.createTexture_(image_);
if (!goog.isNull(this.texture)) { if (this.texture) {
frameState.postRenderFunctions.push( frameState.postRenderFunctions.push(
goog.partial( goog.partial(
/** /**
@@ -155,8 +155,8 @@ ol.renderer.webgl.ImageLayer.prototype.prepareFrame =
} }
} }
if (!goog.isNull(image)) { if (image) {
goog.asserts.assert(!goog.isNull(texture), 'texture is not null'); goog.asserts.assert(texture, 'texture is truthy');
var canvas = this.mapRenderer.getContext().getCanvas(); var canvas = this.mapRenderer.getContext().getCanvas();
@@ -234,7 +234,7 @@ ol.renderer.webgl.ImageLayer.prototype.hasFeatureAtCoordinate =
*/ */
ol.renderer.webgl.ImageLayer.prototype.forEachLayerAtPixel = ol.renderer.webgl.ImageLayer.prototype.forEachLayerAtPixel =
function(pixel, frameState, callback, thisArg) { function(pixel, frameState, callback, thisArg) {
if (goog.isNull(this.image_) || goog.isNull(this.image_.getImage())) { if (!this.image_ || !this.image_.getImage()) {
return undefined; return undefined;
} }
@@ -256,7 +256,7 @@ ol.renderer.webgl.ImageLayer.prototype.forEachLayerAtPixel =
var imageSize = var imageSize =
[this.image_.getImage().width, this.image_.getImage().height]; [this.image_.getImage().width, this.image_.getImage().height];
if (goog.isNull(this.hitTransformationMatrix_)) { if (!this.hitTransformationMatrix_) {
this.hitTransformationMatrix_ = this.getHitTransformationMatrix_( this.hitTransformationMatrix_ = this.getHitTransformationMatrix_(
frameState.size, imageSize); frameState.size, imageSize);
} }
@@ -271,7 +271,7 @@ ol.renderer.webgl.ImageLayer.prototype.forEachLayerAtPixel =
return undefined; return undefined;
} }
if (goog.isNull(this.hitCanvasContext_)) { if (!this.hitCanvasContext_) {
this.hitCanvasContext_ = ol.dom.createCanvasContext2D(1, 1); this.hitCanvasContext_ = ol.dom.createCanvasContext2D(1, 1);
} }
+1 -1
View File
@@ -151,7 +151,7 @@ ol.renderer.webgl.Layer.prototype.composeFrame =
var program = context.getProgram(fragmentShader, vertexShader); var program = context.getProgram(fragmentShader, vertexShader);
var locations; var locations;
if (goog.isNull(this.defaultLocations_)) { if (!this.defaultLocations_) {
locations = locations =
new ol.renderer.webgl.map.shader.Default.Locations(gl, program); new ol.renderer.webgl.map.shader.Default.Locations(gl, program);
this.defaultLocations_ = locations; this.defaultLocations_ = locations;
+5 -5
View File
@@ -100,7 +100,7 @@ ol.renderer.webgl.Map = function(container, map) {
preserveDrawingBuffer: false, preserveDrawingBuffer: false,
stencil: true stencil: true
}); });
goog.asserts.assert(!goog.isNull(this.gl_), 'got a WebGLRenderingContext'); goog.asserts.assert(this.gl_, 'got a WebGLRenderingContext');
/** /**
* @private * @private
@@ -194,7 +194,7 @@ ol.renderer.webgl.Map.prototype.bindTileTexture =
var tileKey = tile.getKey(); var tileKey = tile.getKey();
if (this.textureCache_.containsKey(tileKey)) { if (this.textureCache_.containsKey(tileKey)) {
var textureCacheEntry = this.textureCache_.get(tileKey); var textureCacheEntry = this.textureCache_.get(tileKey);
goog.asserts.assert(!goog.isNull(textureCacheEntry), goog.asserts.assert(textureCacheEntry,
'a texture cache entry exists for key %s', tileKey); 'a texture cache entry exists for key %s', tileKey);
gl.bindTexture(goog.webgl.TEXTURE_2D, textureCacheEntry.texture); gl.bindTexture(goog.webgl.TEXTURE_2D, textureCacheEntry.texture);
if (textureCacheEntry.magFilter != magFilter) { if (textureCacheEntry.magFilter != magFilter) {
@@ -309,7 +309,7 @@ ol.renderer.webgl.Map.prototype.disposeInternal = function() {
* Texture cache entry. * Texture cache entry.
*/ */
function(textureCacheEntry) { function(textureCacheEntry) {
if (!goog.isNull(textureCacheEntry)) { if (textureCacheEntry) {
gl.deleteTexture(textureCacheEntry.texture); gl.deleteTexture(textureCacheEntry.texture);
} }
}); });
@@ -330,7 +330,7 @@ ol.renderer.webgl.Map.prototype.expireCache_ = function(map, frameState) {
while (this.textureCache_.getCount() - this.textureCacheFrameMarkerCount_ > while (this.textureCache_.getCount() - this.textureCacheFrameMarkerCount_ >
ol.WEBGL_TEXTURE_CACHE_HIGH_WATER_MARK) { ol.WEBGL_TEXTURE_CACHE_HIGH_WATER_MARK) {
textureCacheEntry = this.textureCache_.peekLast(); textureCacheEntry = this.textureCache_.peekLast();
if (goog.isNull(textureCacheEntry)) { if (!textureCacheEntry) {
if (+this.textureCache_.peekLastKey() == frameState.index) { if (+this.textureCache_.peekLastKey() == frameState.index) {
break; break;
} else { } else {
@@ -452,7 +452,7 @@ ol.renderer.webgl.Map.prototype.renderFrame = function(frameState) {
return false; return false;
} }
if (goog.isNull(frameState)) { if (!frameState) {
if (this.renderedVisible_) { if (this.renderedVisible_) {
goog.style.setElementShown(this.canvas_, false); goog.style.setElementShown(this.canvas_, false);
this.renderedVisible_ = false; this.renderedVisible_ = false;
@@ -186,7 +186,7 @@ ol.renderer.webgl.TileLayer.prototype.prepareFrame =
extent, tileResolution); extent, tileResolution);
var framebufferExtent; var framebufferExtent;
if (!goog.isNull(this.renderedTileRange_) && if (this.renderedTileRange_ &&
this.renderedTileRange_.equals(tileRange) && this.renderedTileRange_.equals(tileRange) &&
this.renderedRevision_ == tileSource.getRevision()) { this.renderedRevision_ == tileSource.getRevision()) {
framebufferExtent = this.renderedFramebufferExtent_; framebufferExtent = this.renderedFramebufferExtent_;
@@ -218,7 +218,7 @@ ol.renderer.webgl.TileLayer.prototype.prepareFrame =
var program = context.getProgram(this.fragmentShader_, this.vertexShader_); var program = context.getProgram(this.fragmentShader_, this.vertexShader_);
context.useProgram(program); context.useProgram(program);
if (goog.isNull(this.locations_)) { if (!this.locations_) {
this.locations_ = this.locations_ =
new ol.renderer.webgl.tilelayer.shader.Locations(gl, program); new ol.renderer.webgl.tilelayer.shader.Locations(gl, program);
} }
@@ -275,7 +275,7 @@ ol.renderer.webgl.TileLayer.prototype.prepareFrame =
if (!fullyLoaded) { if (!fullyLoaded) {
childTileRange = tileGrid.getTileCoordChildTileRange( childTileRange = tileGrid.getTileCoordChildTileRange(
tile.tileCoord, tmpTileRange, tmpExtent); tile.tileCoord, tmpTileRange, tmpExtent);
if (!goog.isNull(childTileRange)) { if (childTileRange) {
findLoadedTiles(z + 1, childTileRange); findLoadedTiles(z + 1, childTileRange);
} }
} }
@@ -377,7 +377,7 @@ ol.renderer.webgl.TileLayer.prototype.prepareFrame =
*/ */
ol.renderer.webgl.TileLayer.prototype.forEachLayerAtPixel = ol.renderer.webgl.TileLayer.prototype.forEachLayerAtPixel =
function(pixel, frameState, callback, thisArg) { function(pixel, frameState, callback, thisArg) {
if (goog.isNull(this.framebuffer)) { if (!this.framebuffer) {
return undefined; return undefined;
} }
@@ -78,7 +78,7 @@ ol.renderer.webgl.VectorLayer.prototype.composeFrame =
this.layerState_ = layerState; this.layerState_ = layerState;
var viewState = frameState.viewState; var viewState = frameState.viewState;
var replayGroup = this.replayGroup_; var replayGroup = this.replayGroup_;
if (!goog.isNull(replayGroup) && !replayGroup.isEmpty()) { if (replayGroup && !replayGroup.isEmpty()) {
replayGroup.replay(context, replayGroup.replay(context,
viewState.center, viewState.resolution, viewState.rotation, viewState.center, viewState.resolution, viewState.rotation,
frameState.size, frameState.pixelRatio, layerState.opacity, frameState.size, frameState.pixelRatio, layerState.opacity,
@@ -93,7 +93,7 @@ ol.renderer.webgl.VectorLayer.prototype.composeFrame =
*/ */
ol.renderer.webgl.VectorLayer.prototype.disposeInternal = function() { ol.renderer.webgl.VectorLayer.prototype.disposeInternal = function() {
var replayGroup = this.replayGroup_; var replayGroup = this.replayGroup_;
if (!goog.isNull(replayGroup)) { if (replayGroup) {
var context = this.mapRenderer.getContext(); var context = this.mapRenderer.getContext();
replayGroup.getDeleteResourcesFunction(context)(); replayGroup.getDeleteResourcesFunction(context)();
this.replayGroup_ = null; this.replayGroup_ = null;
@@ -107,7 +107,7 @@ ol.renderer.webgl.VectorLayer.prototype.disposeInternal = function() {
*/ */
ol.renderer.webgl.VectorLayer.prototype.forEachFeatureAtCoordinate = ol.renderer.webgl.VectorLayer.prototype.forEachFeatureAtCoordinate =
function(coordinate, frameState, callback, thisArg) { function(coordinate, frameState, callback, thisArg) {
if (goog.isNull(this.replayGroup_) || goog.isNull(this.layerState_)) { if (!this.replayGroup_ || !this.layerState_) {
return undefined; return undefined;
} else { } else {
var context = this.mapRenderer.getContext(); var context = this.mapRenderer.getContext();
@@ -141,7 +141,7 @@ ol.renderer.webgl.VectorLayer.prototype.forEachFeatureAtCoordinate =
*/ */
ol.renderer.webgl.VectorLayer.prototype.hasFeatureAtCoordinate = ol.renderer.webgl.VectorLayer.prototype.hasFeatureAtCoordinate =
function(coordinate, frameState) { function(coordinate, frameState) {
if (goog.isNull(this.replayGroup_) || goog.isNull(this.layerState_)) { if (!this.replayGroup_ || !this.layerState_) {
return false; return false;
} else { } else {
var context = this.mapRenderer.getContext(); var context = this.mapRenderer.getContext();
@@ -233,7 +233,7 @@ ol.renderer.webgl.VectorLayer.prototype.prepareFrame =
return true; return true;
} }
if (!goog.isNull(this.replayGroup_)) { if (this.replayGroup_) {
frameState.postRenderFunctions.push( frameState.postRenderFunctions.push(
this.replayGroup_.getDeleteResourcesFunction(context)); this.replayGroup_.getDeleteResourcesFunction(context));
} }
@@ -266,7 +266,7 @@ ol.renderer.webgl.VectorLayer.prototype.prepareFrame =
this.dirty_ = this.dirty_ || dirty; this.dirty_ = this.dirty_ || dirty;
} }
}; };
if (!goog.isNull(vectorLayerRenderOrder)) { if (vectorLayerRenderOrder) {
/** @type {Array.<ol.Feature>} */ /** @type {Array.<ol.Feature>} */
var features = []; var features = [];
vectorSource.forEachFeatureInExtentAtResolution(extent, resolution, vectorSource.forEachFeatureInExtentAtResolution(extent, resolution,
+1 -1
View File
@@ -130,7 +130,7 @@ ol.source.BingMaps.prototype.handleImageryMetadataResponse =
goog.asserts.assert(ol.proj.equivalent( goog.asserts.assert(ol.proj.equivalent(
projection, sourceProjection), projection, sourceProjection),
'projections are equivalent'); 'projections are equivalent');
if (goog.isNull(tileCoord)) { if (!tileCoord) {
return undefined; return undefined;
} else { } else {
ol.tilecoord.createOrUpdate(tileCoord[0], tileCoord[1], ol.tilecoord.createOrUpdate(tileCoord[0], tileCoord[1],
+2 -2
View File
@@ -64,7 +64,7 @@ ol.source.ImageCanvas.prototype.getImage =
resolution = this.findNearestResolution(resolution); resolution = this.findNearestResolution(resolution);
var canvas = this.canvas_; var canvas = this.canvas_;
if (!goog.isNull(canvas) && if (canvas &&
this.renderedRevision_ == this.getRevision() && this.renderedRevision_ == this.getRevision() &&
canvas.getResolution() == resolution && canvas.getResolution() == resolution &&
canvas.getPixelRatio() == pixelRatio && canvas.getPixelRatio() == pixelRatio &&
@@ -80,7 +80,7 @@ ol.source.ImageCanvas.prototype.getImage =
var canvasElement = this.canvasFunction_( var canvasElement = this.canvasFunction_(
extent, resolution, pixelRatio, size, projection); extent, resolution, pixelRatio, size, projection);
if (!goog.isNull(canvasElement)) { if (canvasElement) {
canvas = new ol.ImageCanvas(extent, resolution, pixelRatio, canvas = new ol.ImageCanvas(extent, resolution, pixelRatio,
this.getAttributions(), canvasElement); this.getAttributions(), canvasElement);
} }
+1 -1
View File
@@ -132,7 +132,7 @@ ol.source.ImageMapGuide.prototype.getImage =
pixelRatio = this.hidpi_ ? pixelRatio : 1; pixelRatio = this.hidpi_ ? pixelRatio : 1;
var image = this.image_; var image = this.image_;
if (!goog.isNull(image) && if (image &&
this.renderedRevision_ == this.getRevision() && this.renderedRevision_ == this.getRevision() &&
image.getResolution() == resolution && image.getResolution() == resolution &&
image.getPixelRatio() == pixelRatio && image.getPixelRatio() == pixelRatio &&
+2 -2
View File
@@ -50,7 +50,7 @@ ol.source.Image = function(options) {
*/ */
this.resolutions_ = options.resolutions !== undefined ? this.resolutions_ = options.resolutions !== undefined ?
options.resolutions : null; options.resolutions : null;
goog.asserts.assert(goog.isNull(this.resolutions_) || goog.asserts.assert(!this.resolutions_ ||
goog.array.isSorted(this.resolutions_, goog.array.isSorted(this.resolutions_,
function(a, b) { function(a, b) {
return b - a; return b - a;
@@ -75,7 +75,7 @@ ol.source.Image.prototype.getResolutions = function() {
*/ */
ol.source.Image.prototype.findNearestResolution = ol.source.Image.prototype.findNearestResolution =
function(resolution) { function(resolution) {
if (!goog.isNull(this.resolutions_)) { if (this.resolutions_) {
var idx = ol.array.linearFindNearest(this.resolutions_, resolution, 0); var idx = ol.array.linearFindNearest(this.resolutions_, resolution, 0);
resolution = this.resolutions_[idx]; resolution = this.resolutions_[idx];
} }
+2 -2
View File
@@ -154,7 +154,7 @@ ol.source.ImageVector.prototype.canvasFunctionInternal_ =
*/ */
ol.source.ImageVector.prototype.forEachFeatureAtCoordinate = function( ol.source.ImageVector.prototype.forEachFeatureAtCoordinate = function(
coordinate, resolution, rotation, skippedFeatureUids, callback) { coordinate, resolution, rotation, skippedFeatureUids, callback) {
if (goog.isNull(this.replayGroup_)) { if (!this.replayGroup_) {
return undefined; return undefined;
} else { } else {
/** @type {Object.<string, boolean>} */ /** @type {Object.<string, boolean>} */
@@ -292,7 +292,7 @@ ol.source.ImageVector.prototype.renderFeature_ =
*/ */
ol.source.ImageVector.prototype.setStyle = function(style) { ol.source.ImageVector.prototype.setStyle = function(style) {
this.style_ = style !== undefined ? style : ol.style.defaultStyleFunction; this.style_ = style !== undefined ? style : ol.style.defaultStyleFunction;
this.styleFunction_ = goog.isNull(style) ? this.styleFunction_ = !style ?
undefined : ol.style.createStyleFunction(this.style_); undefined : ol.style.createStyleFunction(this.style_);
this.changed(); this.changed();
}; };
+1 -1
View File
@@ -223,7 +223,7 @@ ol.source.ImageWMS.prototype.getImage =
extent[3] = centerY + imageResolution * height / 2; extent[3] = centerY + imageResolution * height / 2;
var image = this.image_; var image = this.image_;
if (!goog.isNull(image) && if (image &&
this.renderedRevision_ == this.getRevision() && this.renderedRevision_ == this.getRevision() &&
image.getResolution() == resolution && image.getResolution() == resolution &&
image.getPixelRatio() == pixelRatio && image.getPixelRatio() == pixelRatio &&
+1 -1
View File
@@ -319,7 +319,7 @@ ol.source.Raster.prototype.onWorkerComplete_ =
callback(err); callback(err);
return; return;
} }
if (goog.isNull(output)) { if (!output) {
// job aborted // job aborted
return; return;
} }
+1 -1
View File
@@ -200,7 +200,7 @@ ol.source.TileArcGISRest.prototype.tileUrlFunction_ =
function(tileCoord, pixelRatio, projection) { function(tileCoord, pixelRatio, projection) {
var tileGrid = this.getTileGrid(); var tileGrid = this.getTileGrid();
if (goog.isNull(tileGrid)) { if (!tileGrid) {
tileGrid = this.getTileGridForProjection(projection); tileGrid = this.getTileGridForProjection(projection);
} }
+1 -1
View File
@@ -110,7 +110,7 @@ ol.source.TileDebug.prototype.getTile = function(z, x, y) {
var tileSize = ol.size.toSize(this.tileGrid.getTileSize(z)); var tileSize = ol.size.toSize(this.tileGrid.getTileSize(z));
var tileCoord = [z, x, y]; var tileCoord = [z, x, y];
var textTileCoord = this.getTileCoordForTileUrlFunction(tileCoord); var textTileCoord = this.getTileCoordForTileUrlFunction(tileCoord);
var text = goog.isNull(textTileCoord) ? '' : ol.tilecoord.toString( var text = !textTileCoord ? '' : ol.tilecoord.toString(
this.getTileCoordForTileUrlFunction(textTileCoord)); this.getTileCoordForTileUrlFunction(textTileCoord));
var tile = new ol.DebugTile_(tileCoord, tileSize, text); var tile = new ol.DebugTile_(tileCoord, tileSize, text);
this.tileCache.set(tileCoordKey, tile); this.tileCache.set(tileCoordKey, tile);
+1 -1
View File
@@ -95,7 +95,7 @@ ol.source.TileImage.prototype.getTile =
var tileCoord = [z, x, y]; var tileCoord = [z, x, y];
var urlTileCoord = this.getTileCoordForTileUrlFunction( var urlTileCoord = this.getTileCoordForTileUrlFunction(
tileCoord, projection); tileCoord, projection);
var tileUrl = goog.isNull(urlTileCoord) ? undefined : var tileUrl = !urlTileCoord ? undefined :
this.tileUrlFunction(urlTileCoord, pixelRatio, projection); this.tileUrlFunction(urlTileCoord, pixelRatio, projection);
var tile = new this.tileClass( var tile = new this.tileClass(
tileCoord, tileCoord,
+1 -2
View File
@@ -78,8 +78,7 @@ ol.source.TileJSON.prototype.handleTileJSONResponse = function(tileJSON) {
this.tileUrlFunction = this.tileUrlFunction =
ol.TileUrlFunction.createFromTemplates(tileJSON.tiles, tileGrid); ol.TileUrlFunction.createFromTemplates(tileJSON.tiles, tileGrid);
if (tileJSON.attribution !== undefined && if (tileJSON.attribution !== undefined && !this.getAttributions()) {
goog.isNull(this.getAttributions())) {
var attributionExtent = extent !== undefined ? var attributionExtent = extent !== undefined ?
extent : epsg4326Projection.getExtent(); extent : epsg4326Projection.getExtent();
/** @type {Object.<string, Array.<ol.TileRange>>} */ /** @type {Object.<string, Array.<ol.TileRange>>} */
+2 -2
View File
@@ -195,7 +195,7 @@ ol.source.Tile.prototype.getTileGrid = function() {
* @return {ol.tilegrid.TileGrid} Tile grid. * @return {ol.tilegrid.TileGrid} Tile grid.
*/ */
ol.source.Tile.prototype.getTileGridForProjection = function(projection) { ol.source.Tile.prototype.getTileGridForProjection = function(projection) {
if (goog.isNull(this.tileGrid)) { if (!this.tileGrid) {
return ol.tilegrid.getForProjection(projection); return ol.tilegrid.getForProjection(projection);
} else { } else {
return this.tileGrid; return this.tileGrid;
@@ -231,7 +231,7 @@ ol.source.Tile.prototype.getTileCoordForTileUrlFunction =
var projection = opt_projection !== undefined ? var projection = opt_projection !== undefined ?
opt_projection : this.getProjection(); opt_projection : this.getProjection();
var tileGrid = this.getTileGridForProjection(projection); var tileGrid = this.getTileGridForProjection(projection);
goog.asserts.assert(!goog.isNull(tileGrid), 'tile grid needed'); goog.asserts.assert(tileGrid, 'tile grid needed');
if (this.getWrapX() && projection.isGlobal()) { if (this.getWrapX() && projection.isGlobal()) {
tileCoord = ol.tilecoord.wrapX(tileCoord, tileGrid, projection); tileCoord = ol.tilecoord.wrapX(tileCoord, tileGrid, projection);
} }
+2 -2
View File
@@ -81,7 +81,7 @@ ol.source.TileUTFGrid.prototype.getTemplate = function() {
*/ */
ol.source.TileUTFGrid.prototype.forDataAtCoordinateAndResolution = function( ol.source.TileUTFGrid.prototype.forDataAtCoordinateAndResolution = function(
coordinate, resolution, callback, opt_this, opt_request) { coordinate, resolution, callback, opt_this, opt_request) {
if (!goog.isNull(this.tileGrid)) { if (this.tileGrid) {
var tileCoord = this.tileGrid.getTileCoordForCoordAndResolution( var tileCoord = this.tileGrid.getTileCoordForCoordAndResolution(
coordinate, resolution); coordinate, resolution);
var tile = /** @type {!ol.source.TileUTFGridTile_} */(this.getTile( var tile = /** @type {!ol.source.TileUTFGridTile_} */(this.getTile(
@@ -269,7 +269,7 @@ ol.source.TileUTFGridTile_.prototype.getImage = function(opt_context) {
* @return {Object} * @return {Object}
*/ */
ol.source.TileUTFGridTile_.prototype.getData = function(coordinate) { ol.source.TileUTFGridTile_.prototype.getData = function(coordinate) {
if (goog.isNull(this.grid_) || goog.isNull(this.keys_) || !this.data_) { if (!this.grid_ || !this.keys_ || !this.data_) {
return null; return null;
} }
var xRelative = (coordinate[0] - this.extent_[0]) / var xRelative = (coordinate[0] - this.extent_[0]) /
+4 -5
View File
@@ -57,8 +57,7 @@ ol.source.TileVector = function(options) {
this.tileLoadFunction_ = options.tileLoadFunction !== undefined ? this.tileLoadFunction_ = options.tileLoadFunction !== undefined ?
options.tileLoadFunction : null; options.tileLoadFunction : null;
goog.asserts.assert(!goog.isNull(this.format_) || goog.asserts.assert(this.format_ || this.tileLoadFunction_,
!goog.isNull(this.tileLoadFunction_),
'Either format or tileLoadFunction are required'); 'Either format or tileLoadFunction are required');
/** /**
@@ -252,7 +251,7 @@ ol.source.TileVector.prototype.getFeaturesInExtent = goog.abstractMethod;
ol.source.TileVector.prototype.getTileCoordForTileUrlFunction = ol.source.TileVector.prototype.getTileCoordForTileUrlFunction =
function(tileCoord, projection) { function(tileCoord, projection) {
var tileGrid = this.tileGrid_; var tileGrid = this.tileGrid_;
goog.asserts.assert(!goog.isNull(tileGrid), 'tile grid needed'); goog.asserts.assert(tileGrid, 'tile grid needed');
if (this.getWrapX() && projection.isGlobal()) { if (this.getWrapX() && projection.isGlobal()) {
tileCoord = ol.tilecoord.wrapX(tileCoord, tileGrid, projection); tileCoord = ol.tilecoord.wrapX(tileCoord, tileGrid, projection);
} }
@@ -302,12 +301,12 @@ ol.source.TileVector.prototype.loadFeatures =
tileCoord[2] = y; tileCoord[2] = y;
var urlTileCoord = this.getTileCoordForTileUrlFunction( var urlTileCoord = this.getTileCoordForTileUrlFunction(
tileCoord, projection); tileCoord, projection);
var url = goog.isNull(urlTileCoord) ? undefined : var url = !urlTileCoord ? undefined :
tileUrlFunction(urlTileCoord, 1, projection); tileUrlFunction(urlTileCoord, 1, projection);
if (url !== undefined) { if (url !== undefined) {
tiles[tileKey] = []; tiles[tileKey] = [];
var tileSuccess = goog.partial(success, tileKey); var tileSuccess = goog.partial(success, tileKey);
if (!goog.isNull(this.tileLoadFunction_)) { if (this.tileLoadFunction_) {
this.tileLoadFunction_(url, goog.bind(tileSuccess, this)); this.tileLoadFunction_(url, goog.bind(tileSuccess, this));
} else { } else {
var loader = ol.featureloader.loadFeaturesXhr(url, var loader = ol.featureloader.loadFeaturesXhr(url,
+2 -2
View File
@@ -135,7 +135,7 @@ ol.source.TileWMS.prototype.getGetFeatureInfoUrl =
var projectionObj = ol.proj.get(projection); var projectionObj = ol.proj.get(projection);
var tileGrid = this.getTileGrid(); var tileGrid = this.getTileGrid();
if (goog.isNull(tileGrid)) { if (!tileGrid) {
tileGrid = this.getTileGridForProjection(projectionObj); tileGrid = this.getTileGridForProjection(projectionObj);
} }
@@ -365,7 +365,7 @@ ol.source.TileWMS.prototype.tileUrlFunction_ =
function(tileCoord, pixelRatio, projection) { function(tileCoord, pixelRatio, projection) {
var tileGrid = this.getTileGrid(); var tileGrid = this.getTileGrid();
if (goog.isNull(tileGrid)) { if (!tileGrid) {
tileGrid = this.getTileGridForProjection(projection); tileGrid = this.getTileGridForProjection(projection);
} }
+20 -20
View File
@@ -206,7 +206,7 @@ ol.source.Vector.prototype.addFeatureInternal = function(feature) {
var geometry = feature.getGeometry(); var geometry = feature.getGeometry();
if (geometry) { if (geometry) {
var extent = geometry.getExtent(); var extent = geometry.getExtent();
if (!goog.isNull(this.featuresRtree_)) { if (this.featuresRtree_) {
this.featuresRtree_.insert(extent, feature); this.featuresRtree_.insert(extent, feature);
} }
} else { } else {
@@ -307,7 +307,7 @@ ol.source.Vector.prototype.addFeaturesInternal = function(features) {
this.nullGeometryFeatures_[featureKey] = feature; this.nullGeometryFeatures_[featureKey] = feature;
} }
} }
if (!goog.isNull(this.featuresRtree_)) { if (this.featuresRtree_) {
this.featuresRtree_.load(extents, geometryFeatures); this.featuresRtree_.load(extents, geometryFeatures);
} }
@@ -323,7 +323,7 @@ ol.source.Vector.prototype.addFeaturesInternal = function(features) {
* @private * @private
*/ */
ol.source.Vector.prototype.bindFeaturesCollection_ = function(collection) { ol.source.Vector.prototype.bindFeaturesCollection_ = function(collection) {
goog.asserts.assert(goog.isNull(this.featuresCollection_), goog.asserts.assert(!this.featuresCollection_,
'bindFeaturesCollection can only be called once'); 'bindFeaturesCollection can only be called once');
var modifyingCollection = false; var modifyingCollection = false;
goog.events.listen(this, ol.source.VectorEventType.ADDFEATURE, goog.events.listen(this, ol.source.VectorEventType.ADDFEATURE,
@@ -377,19 +377,19 @@ ol.source.Vector.prototype.clear = function(opt_fast) {
var keys = this.featureChangeKeys_[featureId]; var keys = this.featureChangeKeys_[featureId];
keys.forEach(goog.events.unlistenByKey); keys.forEach(goog.events.unlistenByKey);
} }
if (goog.isNull(this.featuresCollection_)) { if (!this.featuresCollection_) {
this.featureChangeKeys_ = {}; this.featureChangeKeys_ = {};
this.idIndex_ = {}; this.idIndex_ = {};
this.undefIdIndex_ = {}; this.undefIdIndex_ = {};
} }
} else { } else {
var rmFeatureInternal = this.removeFeatureInternal; var rmFeatureInternal = this.removeFeatureInternal;
if (!goog.isNull(this.featuresRtree_)) { if (this.featuresRtree_) {
this.featuresRtree_.forEach(rmFeatureInternal, this); this.featuresRtree_.forEach(rmFeatureInternal, this);
goog.object.forEach(this.nullGeometryFeatures_, rmFeatureInternal, this); goog.object.forEach(this.nullGeometryFeatures_, rmFeatureInternal, this);
} }
} }
if (!goog.isNull(this.featuresCollection_)) { if (this.featuresCollection_) {
this.featuresCollection_.clear(); this.featuresCollection_.clear();
} }
goog.asserts.assert(goog.object.isEmpty(this.featureChangeKeys_), goog.asserts.assert(goog.object.isEmpty(this.featureChangeKeys_),
@@ -399,7 +399,7 @@ ol.source.Vector.prototype.clear = function(opt_fast) {
goog.asserts.assert(goog.object.isEmpty(this.undefIdIndex_), goog.asserts.assert(goog.object.isEmpty(this.undefIdIndex_),
'undefIdIndex is an empty object now'); 'undefIdIndex is an empty object now');
if (!goog.isNull(this.featuresRtree_)) { if (this.featuresRtree_) {
this.featuresRtree_.clear(); this.featuresRtree_.clear();
} }
this.loadedExtentsRtree_.clear(); this.loadedExtentsRtree_.clear();
@@ -424,9 +424,9 @@ ol.source.Vector.prototype.clear = function(opt_fast) {
* @api stable * @api stable
*/ */
ol.source.Vector.prototype.forEachFeature = function(callback, opt_this) { ol.source.Vector.prototype.forEachFeature = function(callback, opt_this) {
if (!goog.isNull(this.featuresRtree_)) { if (this.featuresRtree_) {
return this.featuresRtree_.forEach(callback, opt_this); return this.featuresRtree_.forEach(callback, opt_this);
} else if (!goog.isNull(this.featuresCollection_)) { } else if (this.featuresCollection_) {
return this.featuresCollection_.forEach(callback, opt_this); return this.featuresCollection_.forEach(callback, opt_this);
} }
}; };
@@ -483,9 +483,9 @@ ol.source.Vector.prototype.forEachFeatureAtCoordinateDirect =
*/ */
ol.source.Vector.prototype.forEachFeatureInExtent = ol.source.Vector.prototype.forEachFeatureInExtent =
function(extent, callback, opt_this) { function(extent, callback, opt_this) {
if (!goog.isNull(this.featuresRtree_)) { if (this.featuresRtree_) {
return this.featuresRtree_.forEachInExtent(extent, callback, opt_this); return this.featuresRtree_.forEachInExtent(extent, callback, opt_this);
} else if (!goog.isNull(this.featuresCollection_)) { } else if (this.featuresCollection_) {
return this.featuresCollection_.forEach(callback, opt_this); return this.featuresCollection_.forEach(callback, opt_this);
} }
}; };
@@ -563,9 +563,9 @@ ol.source.Vector.prototype.getFeaturesCollection = function() {
*/ */
ol.source.Vector.prototype.getFeatures = function() { ol.source.Vector.prototype.getFeatures = function() {
var features; var features;
if (!goog.isNull(this.featuresCollection_)) { if (this.featuresCollection_) {
features = this.featuresCollection_.getArray(); features = this.featuresCollection_.getArray();
} else if (!goog.isNull(this.featuresRtree_)) { } else if (this.featuresRtree_) {
features = this.featuresRtree_.getAll(); features = this.featuresRtree_.getAll();
if (!goog.object.isEmpty(this.nullGeometryFeatures_)) { if (!goog.object.isEmpty(this.nullGeometryFeatures_)) {
goog.array.extend( goog.array.extend(
@@ -605,7 +605,7 @@ ol.source.Vector.prototype.getFeaturesAtCoordinate = function(coordinate) {
* @api * @api
*/ */
ol.source.Vector.prototype.getFeaturesInExtent = function(extent) { ol.source.Vector.prototype.getFeaturesInExtent = function(extent) {
goog.asserts.assert(!goog.isNull(this.featuresRtree_), goog.asserts.assert(this.featuresRtree_,
'getFeaturesInExtent does not work when useSpatialIndex is set to false'); 'getFeaturesInExtent does not work when useSpatialIndex is set to false');
return this.featuresRtree_.getInExtent(extent); return this.featuresRtree_.getInExtent(extent);
}; };
@@ -635,7 +635,7 @@ ol.source.Vector.prototype.getClosestFeatureToCoordinate =
var closestPoint = [NaN, NaN]; var closestPoint = [NaN, NaN];
var minSquaredDistance = Infinity; var minSquaredDistance = Infinity;
var extent = [-Infinity, -Infinity, Infinity, Infinity]; var extent = [-Infinity, -Infinity, Infinity, Infinity];
goog.asserts.assert(!goog.isNull(this.featuresRtree_), goog.asserts.assert(this.featuresRtree_,
'getClosestFeatureToCoordinate does not work with useSpatialIndex set ' + 'getClosestFeatureToCoordinate does not work with useSpatialIndex set ' +
'to false'); 'to false');
this.featuresRtree_.forEachInExtent(extent, this.featuresRtree_.forEachInExtent(extent,
@@ -675,7 +675,7 @@ ol.source.Vector.prototype.getClosestFeatureToCoordinate =
* @api stable * @api stable
*/ */
ol.source.Vector.prototype.getExtent = function() { ol.source.Vector.prototype.getExtent = function() {
goog.asserts.assert(!goog.isNull(this.featuresRtree_), goog.asserts.assert(this.featuresRtree_,
'getExtent does not work when useSpatialIndex is set to false'); 'getExtent does not work when useSpatialIndex is set to false');
return this.featuresRtree_.getExtent(); return this.featuresRtree_.getExtent();
}; };
@@ -706,7 +706,7 @@ ol.source.Vector.prototype.handleFeatureChange_ = function(event) {
var geometry = feature.getGeometry(); var geometry = feature.getGeometry();
if (!geometry) { if (!geometry) {
if (!(featureKey in this.nullGeometryFeatures_)) { if (!(featureKey in this.nullGeometryFeatures_)) {
if (!goog.isNull(this.featuresRtree_)) { if (this.featuresRtree_) {
this.featuresRtree_.remove(feature); this.featuresRtree_.remove(feature);
} }
this.nullGeometryFeatures_[featureKey] = feature; this.nullGeometryFeatures_[featureKey] = feature;
@@ -715,11 +715,11 @@ ol.source.Vector.prototype.handleFeatureChange_ = function(event) {
var extent = geometry.getExtent(); var extent = geometry.getExtent();
if (featureKey in this.nullGeometryFeatures_) { if (featureKey in this.nullGeometryFeatures_) {
delete this.nullGeometryFeatures_[featureKey]; delete this.nullGeometryFeatures_[featureKey];
if (!goog.isNull(this.featuresRtree_)) { if (this.featuresRtree_) {
this.featuresRtree_.insert(extent, feature); this.featuresRtree_.insert(extent, feature);
} }
} else { } else {
if (!goog.isNull(this.featuresRtree_)) { if (this.featuresRtree_) {
this.featuresRtree_.update(extent, feature); this.featuresRtree_.update(extent, feature);
} }
} }
@@ -805,7 +805,7 @@ ol.source.Vector.prototype.removeFeature = function(feature) {
if (featureKey in this.nullGeometryFeatures_) { if (featureKey in this.nullGeometryFeatures_) {
delete this.nullGeometryFeatures_[featureKey]; delete this.nullGeometryFeatures_[featureKey];
} else { } else {
if (!goog.isNull(this.featuresRtree_)) { if (this.featuresRtree_) {
this.featuresRtree_.remove(feature); this.featuresRtree_.remove(feature);
} }
} }

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