Merge branch 'master' of github.com:openlayers/ol3 into vector

This commit is contained in:
Tim Schaub
2013-03-07 23:10:06 -07:00
120 changed files with 16315 additions and 1555 deletions

View File

@@ -1,11 +1,11 @@
@exportSymbol ol.Collection
@exportProperty ol.Collection.prototype.clear
@exportProperty ol.Collection.prototype.forEach
@exportProperty ol.Collection.prototype.getArray
@exportProperty ol.Collection.prototype.getAt
@exportProperty ol.Collection.prototype.getLength
@exportProperty ol.Collection.prototype.insertAt
@exportProperty ol.Collection.prototype.pop
@exportProperty ol.Collection.prototype.push
@exportProperty ol.Collection.prototype.remove
@exportProperty ol.Collection.prototype.removeAt
@exportProperty ol.Collection.prototype.setAt

View File

@@ -18,10 +18,7 @@ goog.require('ol.Object');
*/
ol.CollectionEventType = {
ADD: 'add',
INSERT_AT: 'insert_at',
REMOVE: 'remove',
REMOVE_AT: 'remove_at',
SET_AT: 'set_at'
REMOVE: 'remove'
};
@@ -31,12 +28,9 @@ ol.CollectionEventType = {
* @extends {goog.events.Event}
* @param {ol.CollectionEventType} type Type.
* @param {*=} opt_elem Element.
* @param {number=} opt_index Index.
* @param {*=} opt_prev Value.
* @param {Object=} opt_target Target.
*/
ol.CollectionEvent =
function(type, opt_elem, opt_index, opt_prev, opt_target) {
ol.CollectionEvent = function(type, opt_elem, opt_target) {
goog.base(this, type, opt_target);
@@ -45,16 +39,6 @@ ol.CollectionEvent =
*/
this.elem = opt_elem;
/**
* @type {number|undefined}
*/
this.index = opt_index;
/**
* @type {*}
*/
this.prev = opt_prev;
};
goog.inherits(ol.CollectionEvent, goog.events.Event);
@@ -99,6 +83,17 @@ ol.Collection.prototype.clear = function() {
};
/**
* @param {Array} arr Array.
*/
ol.Collection.prototype.extend = function(arr) {
var i;
for (i = 0; i < arr.length; ++i) {
this.push(arr[i]);
}
};
/**
* @param {Function} f Function.
* @param {Object=} opt_obj Object.
@@ -140,10 +135,8 @@ ol.Collection.prototype.getLength = function() {
ol.Collection.prototype.insertAt = function(index, elem) {
goog.array.insertAt(this.array_, elem, index);
this.updateLength_();
this.dispatchEvent(new ol.CollectionEvent(
ol.CollectionEventType.ADD, elem, undefined, undefined, this));
this.dispatchEvent(new ol.CollectionEvent(
ol.CollectionEventType.INSERT_AT, elem, index, undefined, this));
this.dispatchEvent(
new ol.CollectionEvent(ol.CollectionEventType.ADD, elem, this));
};
@@ -166,6 +159,22 @@ ol.Collection.prototype.push = function(elem) {
};
/**
* Removes the first occurence of elem from the collection.
* @param {*} elem Element.
* @return {*} The removed element or undefined if elem was not found.
*/
ol.Collection.prototype.remove = function(elem) {
var i;
for (i = 0; i < this.array_.length; ++i) {
if (this.array_[i] === elem) {
return this.removeAt(i);
}
}
return undefined;
};
/**
* @param {number} index Index.
* @return {*} Value.
@@ -174,10 +183,8 @@ ol.Collection.prototype.removeAt = function(index) {
var prev = this.array_[index];
goog.array.removeAt(this.array_, index);
this.updateLength_();
this.dispatchEvent(new ol.CollectionEvent(
ol.CollectionEventType.REMOVE, prev, undefined, undefined, this));
this.dispatchEvent(new ol.CollectionEvent(ol.CollectionEventType.REMOVE_AT,
undefined, index, prev, this));
this.dispatchEvent(
new ol.CollectionEvent(ol.CollectionEventType.REMOVE, prev, this));
return prev;
};
@@ -191,12 +198,10 @@ ol.Collection.prototype.setAt = function(index, elem) {
if (index < n) {
var prev = this.array_[index];
this.array_[index] = elem;
this.dispatchEvent(new ol.CollectionEvent(ol.CollectionEventType.SET_AT,
elem, index, prev, this));
this.dispatchEvent(new ol.CollectionEvent(ol.CollectionEventType.REMOVE,
prev, undefined, undefined, this));
this.dispatchEvent(new ol.CollectionEvent(ol.CollectionEventType.ADD,
elem, undefined, undefined, this));
this.dispatchEvent(
new ol.CollectionEvent(ol.CollectionEventType.REMOVE, prev, this));
this.dispatchEvent(
new ol.CollectionEvent(ol.CollectionEventType.ADD, elem, this));
} else {
var j;
for (j = n; j < index; ++j) {

View File

@@ -21,10 +21,11 @@ goog.require('ol.source.Source');
/**
* @constructor
* @extends {ol.control.Control}
* @param {ol.control.AttributionOptions} attributionOptions Attribution
* options.
* @param {ol.control.AttributionOptions=} opt_options Options.
*/
ol.control.Attribution = function(attributionOptions) {
ol.control.Attribution = function(opt_options) {
var options = goog.isDef(opt_options) ? opt_options : {};
this.ulElement_ = goog.dom.createElement(goog.dom.TagName.UL);
@@ -34,8 +35,8 @@ ol.control.Attribution = function(attributionOptions) {
goog.base(this, {
element: element,
map: attributionOptions.map,
target: attributionOptions.target
map: options.map,
target: options.target
});
/**

View File

@@ -0,0 +1 @@
@exportSymbol ol.control.defaults ol.control.defaults

View File

@@ -0,0 +1,42 @@
goog.provide('ol.control.defaults');
goog.require('goog.array');
goog.require('ol.control.Attribution');
goog.require('ol.control.Zoom');
/**
* @param {ol.control.DefaultsOptions=} opt_options Options.
* @param {Array.<ol.control.Control>=} opt_controls Additional controls.
* @return {Array.<ol.control.Control>} Controls.
*/
ol.control.defaults = function(opt_options, opt_controls) {
var options = goog.isDef(opt_options) ? opt_options : {};
/** @type {Array.<ol.control.Control>} */
var controls = [];
var attributionControl = goog.isDef(options.attribution) ?
options.attribution : true;
if (attributionControl) {
var attributionControlOptions = goog.isDef(options.attributionOptions) ?
options.attributionOptions : undefined;
controls.push(new ol.control.Attribution(attributionControlOptions));
}
var zoomControl = goog.isDef(options.zoom) ?
options.zoom : true;
if (zoomControl) {
var zoomControlOptions = goog.isDef(options.zoomControlOptions) ?
options.zoomControlOptions : undefined;
controls.push(new ol.control.Zoom(zoomControlOptions));
}
if (goog.isDef(opt_controls)) {
goog.array.extend(controls, opt_controls);
}
return controls;
};

View File

@@ -23,10 +23,11 @@ goog.require('ol.projection');
/**
* @constructor
* @extends {ol.control.Control}
* @param {ol.control.MousePositionOptions} mousePositionOptions Mouse position
* options.
* @param {ol.control.MousePositionOptions=} opt_options Options.
*/
ol.control.MousePosition = function(mousePositionOptions) {
ol.control.MousePosition = function(opt_options) {
var options = goog.isDef(opt_options) ? opt_options : {};
var element = goog.dom.createDom(goog.dom.TagName.DIV, {
'class': 'ol-mouse-position'
@@ -34,28 +35,28 @@ ol.control.MousePosition = function(mousePositionOptions) {
goog.base(this, {
element: element,
map: mousePositionOptions.map,
target: mousePositionOptions.target
map: options.map,
target: options.target
});
/**
* @private
* @type {ol.Projection|undefined}
* @type {ol.Projection}
*/
this.projection_ = mousePositionOptions.projection;
this.projection_ = ol.projection.get(options.projection);
/**
* @private
* @type {ol.CoordinateFormatType|undefined}
*/
this.coordinateFormat_ = mousePositionOptions.coordinateFormat;
this.coordinateFormat_ = options.coordinateFormat;
/**
* @private
* @type {string}
*/
this.undefinedHTML_ = goog.isDef(mousePositionOptions.undefinedHTML) ?
mousePositionOptions.undefinedHTML : '';
this.undefinedHTML_ = goog.isDef(options.undefinedHTML) ?
options.undefinedHTML : '';
/**
* @private
@@ -167,8 +168,8 @@ ol.control.MousePosition.prototype.updateHTML_ = function(pixel) {
var html = this.undefinedHTML_;
if (!goog.isNull(pixel)) {
if (this.renderedProjection_ != this.mapProjection_) {
if (goog.isDef(this.projection_)) {
this.transform_ = ol.projection.getTransform(
if (!goog.isNull(this.projection_)) {
this.transform_ = ol.projection.getTransformFromProjections(
this.mapProjection_, this.projection_);
} else {
this.transform_ = ol.projection.identityTransform;

View File

@@ -176,8 +176,8 @@ ol.control.ScaleLine.prototype.updateElement_ = function(frameState) {
// Convert pointResolution from meters or feet to degrees
if (goog.isNull(this.toEPSG4326_)) {
this.toEPSG4326_ = ol.projection.getTransform(
projection, ol.projection.getFromCode('EPSG:4326'));
this.toEPSG4326_ = ol.projection.getTransformFromProjections(
projection, ol.projection.get('EPSG:4326'));
}
var vertex = [center.x, center.y];
vertex = this.toEPSG4326_(vertex, vertex, 2);

View File

@@ -19,9 +19,11 @@ ol.control.ZOOM_DURATION = 250;
/**
* @constructor
* @extends {ol.control.Control}
* @param {ol.control.ZoomOptions} zoomOptions Zoom options.
* @param {ol.control.ZoomOptions=} opt_options Options.
*/
ol.control.Zoom = function(zoomOptions) {
ol.control.Zoom = function(opt_options) {
var options = goog.isDef(opt_options) ? opt_options : {};
var inElement = goog.dom.createDom(goog.dom.TagName.A, {
'href': '#zoomIn',
@@ -46,15 +48,15 @@ ol.control.Zoom = function(zoomOptions) {
goog.base(this, {
element: element,
map: zoomOptions.map,
target: zoomOptions.target
map: options.map,
target: options.target
});
/**
* @type {number}
* @private
*/
this.delta_ = goog.isDef(zoomOptions.delta) ? zoomOptions.delta : 1;
this.delta_ = goog.isDef(options.delta) ? options.delta : 1;
};
goog.inherits(ol.control.Zoom, ol.control.Control);

View File

@@ -76,8 +76,8 @@ ol.Geolocation.prototype.disposeInternal = function() {
ol.Geolocation.prototype.handleProjectionChanged_ = function() {
var projection = this.getProjection();
if (goog.isDefAndNotNull(projection)) {
this.transformFn_ = ol.projection.getTransform(
ol.projection.getFromCode('EPSG:4326'), projection);
this.transformFn_ = ol.projection.getTransformFromProjections(
ol.projection.get('EPSG:4326'), projection);
if (!goog.isNull(this.position_)) {
var vertex = [this.position_.x, this.position_.y];
vertex = this.transformFn_(vertex, vertex, 2);

View File

@@ -0,0 +1 @@
@exportSymbol ol.interaction.defaults ol.interaction.defaults

View File

@@ -0,0 +1,101 @@
goog.provide('ol.interaction.defaults');
goog.require('ol.Collection');
goog.require('ol.Kinetic');
goog.require('ol.interaction.DblClickZoom');
goog.require('ol.interaction.DragPan');
goog.require('ol.interaction.DragRotate');
goog.require('ol.interaction.DragZoom');
goog.require('ol.interaction.Interaction');
goog.require('ol.interaction.KeyboardPan');
goog.require('ol.interaction.KeyboardZoom');
goog.require('ol.interaction.MouseWheelZoom');
goog.require('ol.interaction.TouchPan');
goog.require('ol.interaction.TouchRotate');
goog.require('ol.interaction.TouchZoom');
goog.require('ol.interaction.condition');
/**
* @param {ol.interaction.DefaultOptions=} opt_options Options.
* @param {Array.<ol.interaction.Interaction>=} opt_interactions Additional
* interactions.
* @return {ol.Collection} Interactions.
*/
ol.interaction.defaults = function(opt_options, opt_interactions) {
var options = goog.isDef(opt_options) ? opt_options : {};
var interactions = new ol.Collection();
var rotate = goog.isDef(options.rotate) ?
options.rotate : true;
if (rotate) {
interactions.push(new ol.interaction.DragRotate(
ol.interaction.condition.altShiftKeysOnly));
}
var doubleClickZoom = goog.isDef(options.doubleClickZoom) ?
options.doubleClickZoom : true;
if (doubleClickZoom) {
var zoomDelta = goog.isDef(options.zoomDelta) ?
options.zoomDelta : 1;
interactions.push(new ol.interaction.DblClickZoom(zoomDelta));
}
var touchPan = goog.isDef(options.touchPan) ?
options.touchPan : true;
if (touchPan) {
interactions.push(new ol.interaction.TouchPan(
new ol.Kinetic(-0.005, 0.05, 100)));
}
var touchRotate = goog.isDef(options.touchRotate) ?
options.touchRotate : true;
if (touchRotate) {
interactions.push(new ol.interaction.TouchRotate());
}
var touchZoom = goog.isDef(options.touchZoom) ?
options.touchZoom : true;
if (touchZoom) {
interactions.push(new ol.interaction.TouchZoom());
}
var dragPan = goog.isDef(options.dragPan) ?
options.dragPan : true;
if (dragPan) {
interactions.push(
new ol.interaction.DragPan(ol.interaction.condition.noModifierKeys,
new ol.Kinetic(-0.005, 0.05, 100)));
}
var keyboard = goog.isDef(options.keyboard) ?
options.keyboard : true;
var keyboardPanOffset = goog.isDef(options.keyboardPanOffset) ?
options.keyboardPanOffset : 80;
if (keyboard) {
interactions.push(new ol.interaction.KeyboardPan(keyboardPanOffset));
interactions.push(new ol.interaction.KeyboardZoom());
}
var mouseWheelZoom = goog.isDef(options.mouseWheelZoom) ?
options.mouseWheelZoom : true;
if (mouseWheelZoom) {
interactions.push(new ol.interaction.MouseWheelZoom());
}
var shiftDragZoom = goog.isDef(options.shiftDragZoom) ?
options.shiftDragZoom : true;
if (shiftDragZoom) {
interactions.push(
new ol.interaction.DragZoom(ol.interaction.condition.shiftKeyOnly));
}
if (goog.isDef(opt_interactions)) {
interactions.extend(opt_interactions);
}
return interactions;
};

View File

@@ -1,8 +1,10 @@
@exportClass ol.Map ol.MapOptions
@exportProperty ol.Map.prototype.addLayer
@exportProperty ol.Map.prototype.addPreRenderFunction
@exportProperty ol.Map.prototype.addPreRenderFunctions
@exportProperty ol.Map.prototype.getInteractions
@exportProperty ol.Map.prototype.getRenderer
@exportProperty ol.Map.prototype.removeLayer
@exportSymbol ol.RendererHint
@exportProperty ol.RendererHint.CANVAS

View File

@@ -20,6 +20,7 @@ goog.require('goog.events.KeyHandler');
goog.require('goog.events.KeyHandler.EventType');
goog.require('goog.events.MouseWheelHandler');
goog.require('goog.events.MouseWheelHandler.EventType');
goog.require('goog.style');
goog.require('ol.BrowserFeature');
goog.require('ol.Collection');
goog.require('ol.Color');
@@ -27,7 +28,6 @@ goog.require('ol.Coordinate');
goog.require('ol.Extent');
goog.require('ol.FrameState');
goog.require('ol.IView');
goog.require('ol.Kinetic');
goog.require('ol.MapBrowserEvent');
goog.require('ol.MapBrowserEvent.EventType');
goog.require('ol.MapBrowserEventHandler');
@@ -43,22 +43,8 @@ goog.require('ol.Tile');
goog.require('ol.TileQueue');
goog.require('ol.View');
goog.require('ol.View2D');
goog.require('ol.control.Attribution');
goog.require('ol.control.Control');
goog.require('ol.control.ScaleLine');
goog.require('ol.control.Zoom');
goog.require('ol.interaction.DblClickZoom');
goog.require('ol.interaction.DragPan');
goog.require('ol.interaction.DragRotate');
goog.require('ol.interaction.DragZoom');
goog.require('ol.interaction.Interaction');
goog.require('ol.interaction.KeyboardPan');
goog.require('ol.interaction.KeyboardZoom');
goog.require('ol.interaction.MouseWheelZoom');
goog.require('ol.interaction.TouchPan');
goog.require('ol.interaction.TouchRotate');
goog.require('ol.interaction.TouchZoom');
goog.require('ol.interaction.condition');
goog.require('ol.control.defaults');
goog.require('ol.interaction.defaults');
goog.require('ol.layer.Layer');
goog.require('ol.projection');
goog.require('ol.projection.addCommonProjections');
@@ -292,20 +278,30 @@ ol.Map = function(mapOptions) {
// this gives the map an initial size
this.handleBrowserWindowResize();
/** @type {Array.<ol.control.Control>} */
var controls = mapOptionsInternal.controls;
goog.array.forEach(controls,
/**
* @param {ol.control.Control} control Control.
*/
function(control) {
control.setMap(this);
}, this);
if (goog.isDef(mapOptionsInternal.controls)) {
goog.array.forEach(mapOptionsInternal.controls,
/**
* @param {ol.control.Control} control Control.
*/
function(control) {
control.setMap(this);
}, this);
}
};
goog.inherits(ol.Map, ol.Object);
/**
* @param {ol.layer.Layer} layer Layer.
*/
ol.Map.prototype.addLayer = function(layer) {
var layers = this.getLayers();
goog.asserts.assert(goog.isDef(layers));
layers.push(layer);
};
/**
* @param {ol.PreRenderFunction} preRenderFunction Pre-render function.
*/
@@ -534,7 +530,14 @@ ol.Map.prototype.handleMapBrowserEvent = function(mapBrowserEvent) {
*/
ol.Map.prototype.handlePostRender = function() {
this.tileQueue_.reprioritize(); // FIXME only call if needed
this.tileQueue_.loadMoreTiles();
var moreLoadingTiles = this.tileQueue_.loadMoreTiles();
if (moreLoadingTiles) {
// The tile layer renderers need to know when tiles change
// to the LOADING state (to register the change listener
// on the tile).
this.requestRenderFrame();
}
var postRenderFunctions = this.postRenderFunctions_;
var i;
for (i = 0; i < postRenderFunctions.length; ++i) {
@@ -556,8 +559,8 @@ ol.Map.prototype.handleBackgroundColorChanged_ = function() {
* @protected
*/
ol.Map.prototype.handleBrowserWindowResize = function() {
var size = new ol.Size(this.target_.clientWidth, this.target_.clientHeight);
this.setSize(size);
var size = goog.style.getSize(this.target_);
this.setSize(new ol.Size(size.width, size.height));
};
@@ -633,6 +636,18 @@ ol.Map.prototype.requestRenderFrame = function() {
};
/**
* @param {ol.layer.Layer} layer Layer.
* @return {ol.layer.Layer|undefined} The removed layer or undefined if the
* layer was not found.
*/
ol.Map.prototype.removeLayer = function(layer) {
var layers = this.getLayers();
goog.asserts.assert(goog.isDef(layers));
return /** @type {ol.layer.Layer|undefined} */ (layers.remove(layer));
};
/**
* @param {number} time Time.
* @private
@@ -837,8 +852,18 @@ ol.Map.createOptionsInternal = function(mapOptions) {
*/
var values = {};
values[ol.MapProperty.LAYERS] = goog.isDef(mapOptions.layers) ?
mapOptions.layers : new ol.Collection();
var layers;
if (goog.isDef(mapOptions.layers)) {
if (goog.isArray(mapOptions.layers)) {
layers = new ol.Collection(goog.array.clone(mapOptions.layers));
} else {
goog.asserts.assert(mapOptions.layers instanceof ol.Collection);
layers = mapOptions.layers;
}
} else {
layers = new ol.Collection();
}
values[ol.MapProperty.LAYERS] = layers;
values[ol.MapProperty.VIEW] = goog.isDef(mapOptions.view) ?
mapOptions.view : new ol.View2D();
@@ -881,20 +906,11 @@ ol.Map.createOptionsInternal = function(mapOptions) {
}
}
/**
* @type {Array.<ol.control.Control>}
*/
var controls = ol.Map.createControls_(mapOptions);
var controls = goog.isDef(mapOptions.controls) ?
mapOptions.controls : ol.control.defaults();
/**
* @type {ol.Collection}
*/
var interactions;
if (goog.isDef(mapOptions.interactions)) {
interactions = mapOptions.interactions;
} else {
interactions = ol.Map.createInteractions_(mapOptions);
}
var interactions = goog.isDef(mapOptions.interactions) ?
mapOptions.interactions : ol.interaction.defaults();
/**
* @type {Element}
@@ -912,123 +928,6 @@ ol.Map.createOptionsInternal = function(mapOptions) {
};
/**
* @private
* @param {ol.MapOptions} mapOptions Map options.
* @return {Array.<ol.control.Control>} Controls.
*/
ol.Map.createControls_ = function(mapOptions) {
/** @type {Array.<ol.control.Control>} */
var controls = [];
var attributionControl = goog.isDef(mapOptions.attributionControl) ?
mapOptions.attributionControl : true;
if (attributionControl) {
controls.push(new ol.control.Attribution({}));
}
var scaleLineControl = goog.isDef(mapOptions.scaleLineControl) ?
mapOptions.scaleLineControl : false;
if (scaleLineControl) {
var scaleLineUnits = goog.isDef(mapOptions.scaleLineUnits) ?
mapOptions.scaleLineUnits : undefined;
controls.push(new ol.control.ScaleLine({
units: scaleLineUnits
}));
}
var zoomControl = goog.isDef(mapOptions.zoomControl) ?
mapOptions.zoomControl : true;
if (zoomControl) {
var zoomDelta = goog.isDef(mapOptions.zoomDelta) ?
mapOptions.zoomDelta : 1;
controls.push(new ol.control.Zoom({
delta: zoomDelta
}));
}
return controls;
};
/**
* @private
* @param {ol.MapOptions} mapOptions Map options.
* @return {ol.Collection} Interactions.
*/
ol.Map.createInteractions_ = function(mapOptions) {
var interactions = new ol.Collection();
var rotate = goog.isDef(mapOptions.rotate) ?
mapOptions.rotate : true;
if (rotate) {
interactions.push(new ol.interaction.DragRotate(
ol.interaction.condition.altShiftKeysOnly));
}
var doubleClickZoom = goog.isDef(mapOptions.doubleClickZoom) ?
mapOptions.doubleClickZoom : true;
if (doubleClickZoom) {
var zoomDelta = goog.isDef(mapOptions.zoomDelta) ?
mapOptions.zoomDelta : 1;
interactions.push(new ol.interaction.DblClickZoom(zoomDelta));
}
var touchPan = goog.isDef(mapOptions.touchPan) ?
mapOptions.touchPan : true;
if (touchPan) {
interactions.push(new ol.interaction.TouchPan(
new ol.Kinetic(-0.005, 0.05, 100)));
}
var touchRotate = goog.isDef(mapOptions.touchRotate) ?
mapOptions.touchRotate : true;
if (touchRotate) {
interactions.push(new ol.interaction.TouchRotate());
}
var touchZoom = goog.isDef(mapOptions.touchZoom) ?
mapOptions.touchZoom : true;
if (touchZoom) {
interactions.push(new ol.interaction.TouchZoom());
}
var dragPan = goog.isDef(mapOptions.dragPan) ?
mapOptions.dragPan : true;
if (dragPan) {
interactions.push(
new ol.interaction.DragPan(ol.interaction.condition.noModifierKeys,
new ol.Kinetic(-0.005, 0.05, 100)));
}
var keyboard = goog.isDef(mapOptions.keyboard) ?
mapOptions.keyboard : true;
var keyboardPanOffset = goog.isDef(mapOptions.keyboardPanOffset) ?
mapOptions.keyboardPanOffset : 80;
if (keyboard) {
interactions.push(new ol.interaction.KeyboardPan(keyboardPanOffset));
interactions.push(new ol.interaction.KeyboardZoom());
}
var mouseWheelZoom = goog.isDef(mapOptions.mouseWheelZoom) ?
mapOptions.mouseWheelZoom : true;
if (mouseWheelZoom) {
interactions.push(new ol.interaction.MouseWheelZoom());
}
var shiftDragZoom = goog.isDef(mapOptions.shiftDragZoom) ?
mapOptions.shiftDragZoom : true;
if (shiftDragZoom) {
interactions.push(
new ol.interaction.DragZoom(ol.interaction.condition.shiftKeyOnly));
}
return interactions;
};
/**
* @param {goog.Uri.QueryData=} opt_queryData Query data.
* @return {Array.<ol.RendererHint>} Renderer hints.

View File

@@ -1,11 +1,18 @@
goog.provide('ol.parser.ogc.WMSCapabilities');
goog.require('ol.parser.ogc.Versioned');
goog.require('ol.parser.ogc.WMSCapabilities_v1_0_0');
goog.require('ol.parser.ogc.WMSCapabilities_v1_1_0');
goog.require('ol.parser.ogc.WMSCapabilities_v1_1_1');
goog.require('ol.parser.ogc.WMSCapabilities_v1_1_1_WMSC');
goog.require('ol.parser.ogc.WMSCapabilities_v1_3_0');
/**
* @define {boolean} Whether to enable WMS Capabilities version 1.0.0.
*/
ol.ENABLE_WMSCAPS_1_0_0 = false;
/**
* @define {boolean} Whether to enable WMS Capabilities version 1.1.0.
*/
@@ -41,6 +48,9 @@ ol.parser.ogc.WMSCapabilities = function(opt_options) {
opt_options = opt_options || {};
opt_options['defaultVersion'] = '1.1.1';
this.parsers = {};
if (ol.ENABLE_WMSCAPS_1_0_0) {
this.parsers['v1_0_0'] = ol.parser.ogc.WMSCapabilities_v1_0_0;
}
if (ol.ENABLE_WMSCAPS_1_1_0) {
this.parsers['v1_1_0'] = ol.parser.ogc.WMSCapabilities_v1_1_0;
}

View File

@@ -0,0 +1,62 @@
goog.provide('ol.parser.ogc.WMSCapabilities_v1_0_0');
goog.require('goog.string');
goog.require('ol.parser.ogc.WMSCapabilities_v1_1_0');
/**
* @constructor
* @extends {ol.parser.ogc.WMSCapabilities_v1_1_0}
*/
ol.parser.ogc.WMSCapabilities_v1_0_0 = function() {
goog.base(this);
this.version = '1.0.0';
goog.object.extend(this.readers['http://www.opengis.net/wms'], {
'Format': function(node, obj) {
for (var i = 0, ii = node.childNodes.length; i < ii; i++) {
var child = node.childNodes[i];
var local = child.localName || child.nodeName.split(':').pop();
if (goog.isArray(obj['formats'])) {
obj['formats'].push(local);
} else {
obj['format'] = local;
}
}
},
'Keywords': function(node, obj) {
if (!goog.isDef(obj['keywords'])) {
obj['keywords'] = [];
}
var keywords = this.getChildValue(node).split(/ +/);
for (var i = 0, ii = keywords.length; i < ii; ++i) {
if (!goog.string.isEmpty(keywords[i])) {
obj['keywords'].push({'value': keywords[i]});
}
}
},
'OnlineResource': function(node, obj) {
obj['href'] = this.getChildValue(node);
},
'Get': function(node, obj) {
obj['get'] = {'href': node.getAttribute('onlineResource')};
},
'Post': function(node, obj) {
obj['post'] = {'href': node.getAttribute('onlineResource')};
},
'Map': function(node, obj) {
var reader = this.readers[this.defaultNamespaceURI]['GetMap'];
reader.apply(this, arguments);
},
'Capabilities': function(node, obj) {
var reader = this.readers[this.defaultNamespaceURI]['GetCapabilities'];
reader.apply(this, arguments);
},
'FeatureInfo': function(node, obj) {
var reader = this.readers[this.defaultNamespaceURI]['GetFeatureInfo'];
reader.apply(this, arguments);
}
});
};
goog.inherits(ol.parser.ogc.WMSCapabilities_v1_0_0,
ol.parser.ogc.WMSCapabilities_v1_1_0);

View File

@@ -79,7 +79,7 @@ ol.parser.ogc.WMTSCapabilities_v1_0_0 = function() {
var topLeftCorner = this.getChildValue(node);
var coords = topLeftCorner.split(' ');
var axisOrientation =
ol.projection.getFromCode(obj['supportedCRS']).getAxisOrientation();
ol.projection.get(obj['supportedCRS']).getAxisOrientation();
obj['topLeftCorner'] = ol.Coordinate.fromProjectedArray(
[parseFloat(coords[0]), parseFloat(coords[1])], axisOrientation);
},

View File

@@ -1,17 +1,21 @@
@exportSymbol ol.Projection
@exportClass ol.Projection ol.ProjectionOptions
@exportProperty ol.Projection.prototype.getAxisOrientation
@exportProperty ol.Projection.prototype.getCode
@exportProperty ol.Projection.prototype.getExtent
@exportProperty ol.Projection.prototype.getPointResolution
@exportProperty ol.Projection.prototype.getUnits
@exportProperty ol.Projection.prototype.getMetersPerUnit
@exportProperty ol.Projection.prototype.isGlobal
@exportSymbol ol.ProjectionUnits
@exportProperty ol.ProjectionUnits.DEGREES
@exportProperty ol.ProjectionUnits.FEET
@exportProperty ol.ProjectionUnits.METERS
@exportSymbol ol.projection.addProjection
@exportSymbol ol.projection.getFromCode
@exportSymbol ol.projection.get
@exportSymbol ol.projection.getTransform
@exportSymbol ol.projection.getTransformFromCodes
@exportSymbol ol.projection.getTransformFromProjections
@exportSymbol ol.projection.transform
@exportSymbol ol.projection.transformWithCodes
@exportSymbol ol.projection.transformWithProjections
@exportSymbol ol.projection.configureProj4jsProjection

View File

@@ -1,4 +1,5 @@
goog.provide('ol.Projection');
goog.provide('ol.ProjectionLike');
goog.provide('ol.ProjectionUnits');
goog.provide('ol.projection');
@@ -23,6 +24,12 @@ ol.ENABLE_PROJ4JS = true;
ol.HAVE_PROJ4JS = ol.ENABLE_PROJ4JS && typeof Proj4js == 'object';
/**
* @typedef {ol.Projection|string|undefined}
*/
ol.ProjectionLike;
/**
* @enum {string}
*/
@@ -33,40 +40,54 @@ ol.ProjectionUnits = {
};
/**
* @const {Object.<ol.ProjectionUnits, number>} Meters per unit lookup table.
*/
ol.METERS_PER_UNIT = {};
ol.METERS_PER_UNIT[ol.ProjectionUnits.DEGREES] =
2 * Math.PI * ol.sphere.NORMAL.radius / 360;
ol.METERS_PER_UNIT[ol.ProjectionUnits.FEET] = 0.3048;
ol.METERS_PER_UNIT[ol.ProjectionUnits.METERS] = 1;
/**
* @constructor
* @param {string} code Code.
* @param {ol.ProjectionUnits} units Units.
* @param {ol.Extent} extent Extent.
* @param {string=} opt_axisOrientation Axis orientation.
* @param {ol.ProjectionOptions} options Options object.
*/
ol.Projection = function(code, units, extent, opt_axisOrientation) {
ol.Projection = function(options) {
/**
* @private
* @type {string}
*/
this.code_ = code;
this.code_ = options.code;
/**
* @private
* @type {ol.ProjectionUnits}
*/
this.units_ = units;
this.units_ = options.units;
/**
* @private
* @type {ol.Extent}
*/
this.extent_ = extent;
this.extent_ = options.extent;
/**
* @private
* @type {string}
*/
this.axisOrientation_ = goog.isDef(opt_axisOrientation) ?
opt_axisOrientation : 'enu';
this.axisOrientation_ = goog.isDef(options.axisOrientation) ?
options.axisOrientation : 'enu';
/**
* @private
* @type {boolean}
*/
this.global_ = goog.isDef(options.global) ?
options.global : false;
/**
* @private
@@ -109,6 +130,14 @@ ol.Projection.prototype.getUnits = function() {
};
/**
* @return {number} Meters.
*/
ol.Projection.prototype.getMetersPerUnit = function() {
return ol.METERS_PER_UNIT[this.units_];
};
/**
* @return {string} Axis orientation.
*/
@@ -117,6 +146,14 @@ ol.Projection.prototype.getAxisOrientation = function() {
};
/**
* @return {boolean} Wether the projection is global.
*/
ol.Projection.prototype.isGlobal = function() {
return this.global_;
};
/**
* @return {ol.tilegrid.TileGrid} The default tile grid.
*/
@@ -137,15 +174,21 @@ ol.Projection.prototype.setDefaultTileGrid = function(tileGrid) {
/**
* @constructor
* @extends {ol.Projection}
* @param {string} code Code.
* @param {Proj4js.Proj} proj4jsProj Proj4js projection.
* @param {ol.Proj4jsProjectionOptions} options Projection config options.
* @private
*/
ol.Proj4jsProjection_ = function(code, proj4jsProj) {
ol.Proj4jsProjection_ = function(proj4jsProj, options) {
var units = /** @type {ol.ProjectionUnits} */ (proj4jsProj.units);
goog.base(this, code, units, null, proj4jsProj.axis);
var config = /** @type {ol.ProjectionOptions} */ ({
units: units,
axisOrientation: proj4jsProj.axis
});
goog.object.extend(config, options);
goog.base(this, config);
/**
* @private
@@ -175,8 +218,11 @@ ol.Proj4jsProjection_.prototype.getPointResolution =
// measuring its width and height on the normal sphere, and taking the
// average of the width and height.
if (goog.isNull(this.toEPSG4326_)) {
this.toEPSG4326_ = ol.projection.getTransform(
this, ol.projection.getProj4jsProjectionFromCode_('EPSG:4326'));
this.toEPSG4326_ = ol.projection.getTransformFromProjections(
this, ol.projection.getProj4jsProjectionFromCode_({
code: 'EPSG:4326',
extent: null
}));
}
var vertices = [
point.x - resolution / 2, point.y,
@@ -326,9 +372,9 @@ ol.projection.clearAllProjections = function() {
*/
ol.projection.createProjection = function(projection, defaultCode) {
if (!goog.isDefAndNotNull(projection)) {
return ol.projection.getFromCode(defaultCode);
return ol.projection.get(defaultCode);
} else if (goog.isString(projection)) {
return ol.projection.getFromCode(projection);
return ol.projection.get(projection);
} else {
goog.asserts.assert(projection instanceof ol.Projection);
return projection;
@@ -383,17 +429,29 @@ ol.projection.removeTransform = function(source, destination) {
/**
* @param {string} code Code which is a combination of authority and identifier
* such as EPSG:4326”.
* @param {ol.ProjectionLike} projectionLike Either a code string which is a
* combination of authority and identifier such as "EPSG:4326", or an
* existing projection object, or undefined.
* @return {ol.Projection} Projection.
*/
ol.projection.getFromCode = function(code) {
var projection = ol.projection.projections_[code];
if (ol.HAVE_PROJ4JS && !goog.isDef(projection)) {
projection = ol.projection.getProj4jsProjectionFromCode_(code);
}
if (!goog.isDef(projection)) {
goog.asserts.assert(goog.isDef(projection));
ol.projection.get = function(projectionLike) {
var projection;
if (projectionLike instanceof ol.Projection) {
projection = projectionLike;
} else if (goog.isString(projectionLike)) {
var code = projectionLike;
projection = ol.projection.projections_[code];
if (ol.HAVE_PROJ4JS && !goog.isDef(projection)) {
projection = ol.projection.getProj4jsProjectionFromCode_({
code: code,
extent: null
});
}
if (!goog.isDef(projection)) {
goog.asserts.assert(goog.isDef(projection));
projection = null;
}
} else {
projection = null;
}
return projection;
@@ -401,11 +459,12 @@ ol.projection.getFromCode = function(code) {
/**
* @param {string} code Code.
* @param {ol.Proj4jsProjectionOptions} options Projection config options.
* @private
* @return {ol.Proj4jsProjection_} Proj4js projection.
*/
ol.projection.getProj4jsProjectionFromCode_ = function(code) {
ol.projection.getProj4jsProjectionFromCode_ = function(options) {
var code = options.code;
var proj4jsProjections = ol.projection.proj4jsProjections_;
var proj4jsProjection = proj4jsProjections[code];
if (!goog.isDef(proj4jsProjection)) {
@@ -413,7 +472,10 @@ ol.projection.getProj4jsProjectionFromCode_ = function(code) {
var srsCode = proj4jsProj.srsCode;
proj4jsProjection = proj4jsProjections[srsCode];
if (!goog.isDef(proj4jsProjection)) {
proj4jsProjection = new ol.Proj4jsProjection_(srsCode, proj4jsProj);
var config = /** @type {ol.Proj4jsProjectionOptions} */
(goog.object.clone(options));
config.code = srsCode;
proj4jsProjection = new ol.Proj4jsProjection_(proj4jsProj, config);
proj4jsProjections[srsCode] = proj4jsProjection;
}
proj4jsProjections[code] = proj4jsProjection;
@@ -437,24 +499,43 @@ ol.projection.equivalent = function(projection1, projection2) {
} else if (projection1.getUnits() != projection2.getUnits()) {
return false;
} else {
var transformFn = ol.projection.getTransform(projection1, projection2);
var transformFn = ol.projection.getTransformFromProjections(
projection1, projection2);
return transformFn === ol.projection.cloneTransform;
}
};
/**
* Given the projection-like objects this method searches for a transformation
* function to convert a coordinates array from the source projection to the
* destination projection.
*
* @param {ol.ProjectionLike} source Source.
* @param {ol.ProjectionLike} destination Destination.
* @return {ol.TransformFunction} Transform.
*/
ol.projection.getTransform = function(source, destination) {
var sourceProjection = ol.projection.get(source);
var destinationProjection = ol.projection.get(destination);
return ol.projection.getTransformFromProjections(
sourceProjection, destinationProjection);
};
/**
* Searches a function that can be used to convert coordinates from the source
* projection to the destination projection.
*
* @param {ol.Projection} source Source.
* @param {ol.Projection} destination Destination.
* @param {ol.Projection} sourceProjection Source projection.
* @param {ol.Projection} destinationProjection Destination projection.
* @return {ol.TransformFunction} Transform.
*/
ol.projection.getTransform = function(source, destination) {
ol.projection.getTransformFromProjections =
function(sourceProjection, destinationProjection) {
var transforms = ol.projection.transforms_;
var sourceCode = source.getCode();
var destinationCode = destination.getCode();
var sourceCode = sourceProjection.getCode();
var destinationCode = destinationProjection.getCode();
var transform;
if (goog.object.containsKey(transforms, sourceCode) &&
goog.object.containsKey(transforms[sourceCode], destinationCode)) {
@@ -462,19 +543,25 @@ ol.projection.getTransform = function(source, destination) {
}
if (ol.HAVE_PROJ4JS && !goog.isDef(transform)) {
var proj4jsSource;
if (source instanceof ol.Proj4jsProjection_) {
proj4jsSource = source;
if (sourceProjection instanceof ol.Proj4jsProjection_) {
proj4jsSource = sourceProjection;
} else {
proj4jsSource =
ol.projection.getProj4jsProjectionFromCode_(source.getCode());
ol.projection.getProj4jsProjectionFromCode_({
code: sourceCode,
extent: null
});
}
var sourceProj4jsProj = proj4jsSource.getProj4jsProj();
var proj4jsDestination;
if (destination instanceof ol.Proj4jsProjection_) {
proj4jsDestination = destination;
if (destinationProjection instanceof ol.Proj4jsProjection_) {
proj4jsDestination = destinationProjection;
} else {
proj4jsDestination =
ol.projection.getProj4jsProjectionFromCode_(destination.getCode());
ol.projection.getProj4jsProjectionFromCode_({
code: destinationCode,
extent: null
});
}
var destinationProj4jsProj = proj4jsDestination.getProj4jsProj();
transform =
@@ -507,7 +594,8 @@ ol.projection.getTransform = function(source, destination) {
}
return output;
};
ol.projection.addTransform(source, destination, transform);
ol.projection.addTransform(
sourceProjection, destinationProjection, transform);
}
if (!goog.isDef(transform)) {
goog.asserts.assert(goog.isDef(transform));
@@ -517,22 +605,6 @@ ol.projection.getTransform = function(source, destination) {
};
/**
* Given the projection codes this method searches for a transformation function
* to convert a coordinates array from the source projection to the destination
* projection.
*
* @param {string} sourceCode Source code.
* @param {string} destinationCode Destination code.
* @return {ol.TransformFunction} Transform.
*/
ol.projection.getTransformFromCodes = function(sourceCode, destinationCode) {
var source = ol.projection.getFromCode(sourceCode);
var destination = ol.projection.getFromCode(destinationCode);
return ol.projection.getTransform(source, destination);
};
/**
* @param {Array.<number>} input Input coordinate array.
* @param {Array.<number>=} opt_output Output array of coordinate values.
@@ -574,11 +646,9 @@ ol.projection.cloneTransform = function(input, opt_output, opt_dimension) {
/**
* Transforms the given point to the destination projection.
*
* @param {ol.Coordinate} point Point.
* @param {ol.Projection} source Source.
* @param {ol.Projection} destination Destination.
* @param {ol.ProjectionLike} source Source.
* @param {ol.ProjectionLike} destination Destination.
* @return {ol.Coordinate} Point.
*/
ol.projection.transform = function(point, source, destination) {
@@ -590,16 +660,29 @@ ol.projection.transform = function(point, source, destination) {
/**
* Transforms the given point to the destination projection.
*
* @param {ol.Coordinate} point Point.
* @param {string} sourceCode Source code.
* @param {string} destinationCode Destination code.
* @param {ol.Projection} sourceProjection Source projection.
* @param {ol.Projection} destinationProjection Destination projection.
* @return {ol.Coordinate} Point.
*/
ol.projection.transformWithCodes =
function(point, sourceCode, destinationCode) {
var transformFn = ol.projection.getTransformFromCodes(
sourceCode, destinationCode);
ol.projection.transformWithProjections =
function(point, sourceProjection, destinationProjection) {
var transformFn = ol.projection.getTransformFromProjections(
sourceProjection, destinationProjection);
var vertex = [point.x, point.y];
vertex = transformFn(vertex, vertex, 2);
return new ol.Coordinate(vertex[0], vertex[1]);
};
/**
* @param {ol.Proj4jsProjectionOptions} options Projection config options.
* @return {ol.Proj4jsProjection_} Proj4js projection.
*/
ol.projection.configureProj4jsProjection = function(options) {
goog.asserts.assert(!goog.object.containsKey(
ol.projection.proj4jsProjections_, options.code));
return ol.projection.getProj4jsProjectionFromCode_(options);
};

View File

@@ -15,8 +15,12 @@ goog.require('ol.projection');
* @param {string} code Code.
*/
ol.projection.EPSG3857 = function(code) {
goog.base(
this, code, ol.ProjectionUnits.METERS, ol.projection.EPSG3857.EXTENT);
goog.base(this, {
code: code,
units: ol.ProjectionUnits.METERS,
extent: ol.projection.EPSG3857.EXTENT,
global: true
});
};
goog.inherits(ol.projection.EPSG3857, ol.Projection);

View File

@@ -14,8 +14,13 @@ goog.require('ol.projection');
* @param {string=} opt_axisOrientation Axis orientation.
*/
ol.projection.EPSG4326 = function(code, opt_axisOrientation) {
goog.base(this, code, ol.ProjectionUnits.DEGREES,
ol.projection.EPSG4326.EXTENT, opt_axisOrientation);
goog.base(this, {
code: code,
units: ol.ProjectionUnits.DEGREES,
extent: ol.projection.EPSG4326.EXTENT,
axisOrientation: opt_axisOrientation,
global: true
});
};
goog.inherits(ol.projection.EPSG4326, ol.Projection);

View File

@@ -158,10 +158,11 @@ ol.renderer.canvas.TileLayer.prototype.renderFrame =
tileState = tile.getState();
if (tileState == ol.TileState.IDLE) {
this.listenToTileChange(tile);
this.updateWantedTiles(frameState.wantedTiles, tileSource, tileCoord);
tileCenter = tileGrid.getTileCoordCenter(tileCoord);
frameState.tileQueue.enqueue(tile, tileSourceKey, tileCenter);
} else if (tileState == ol.TileState.LOADING) {
this.listenToTileChange(tile);
} else if (tileState == ol.TileState.LOADED) {
tilesToDrawByZ[z][tileCoord.toString()] = tile;
continue;

View File

@@ -116,10 +116,11 @@ ol.renderer.dom.TileLayer.prototype.renderFrame =
tileState = tile.getState();
if (tileState == ol.TileState.IDLE) {
this.listenToTileChange(tile);
this.updateWantedTiles(frameState.wantedTiles, tileSource, tileCoord);
tileCenter = tileGrid.getTileCoordCenter(tileCoord);
frameState.tileQueue.enqueue(tile, tileSourceKey, tileCenter);
} else if (tileState == ol.TileState.LOADING) {
this.listenToTileChange(tile);
} else if (tileState == ol.TileState.LOADED) {
tilesToDrawByZ[z][tileCoord.toString()] = tile;
continue;

View File

@@ -231,11 +231,13 @@ ol.renderer.Layer.prototype.scheduleExpireCache =
*/
ol.renderer.Layer.prototype.updateAttributions =
function(attributionsSet, attributions) {
var i;
var attribution;
for (i = 0; i < attributions.length; ++i) {
attribution = attributions[i];
attributionsSet[goog.getUid(attribution).toString()] = attribution;
if (goog.isDefAndNotNull(attributions)) {
var i;
var attribution;
for (i = 0; i < attributions.length; ++i) {
attribution = attributions[i];
attributionsSet[goog.getUid(attribution).toString()] = attribution;
}
}
};

View File

@@ -391,10 +391,11 @@ ol.renderer.webgl.TileLayer.prototype.renderFrame =
tileState = tile.getState();
if (tileState == ol.TileState.IDLE) {
this.listenToTileChange(tile);
this.updateWantedTiles(frameState.wantedTiles, tileSource, tileCoord);
tileCenter = tileGrid.getTileCoordCenter(tileCoord);
frameState.tileQueue.enqueue(tile, tileSourceKey, tileCenter);
} else if (tileState == ol.TileState.LOADING) {
this.listenToTileChange(tile);
} else if (tileState == ol.TileState.LOADED) {
if (mapRenderer.isTileTextureLoaded(tile)) {
tilesToDrawByZ[z][tileCoord.toString()] = tile;

View File

@@ -24,7 +24,7 @@ ol.source.BingMaps = function(bingMapsOptions) {
goog.base(this, {
opaque: true,
projection: ol.projection.getFromCode('EPSG:3857')
projection: ol.projection.get('EPSG:3857')
});
/**
@@ -111,8 +111,8 @@ ol.source.BingMaps.prototype.handleImageryMetadataResponse =
};
})));
var transform = ol.projection.getTransform(
ol.projection.getFromCode('EPSG:4326'), this.getProjection());
var transform = ol.projection.getTransformFromProjections(
ol.projection.get('EPSG:4326'), this.getProjection());
var attributions = goog.array.map(
resource.imageryProviders,
function(imageryProvider) {

View File

@@ -16,7 +16,7 @@ goog.require('ol.source.Source');
* @typedef {{attributions: (Array.<ol.Attribution>|undefined),
* crossOrigin: (null|string|undefined),
* extent: (null|ol.Extent|undefined),
* projection: (ol.Projection|undefined),
* projection: ol.ProjectionLike,
* resolutions: (Array.<number>|undefined),
* imageUrlFunction: (ol.ImageUrlFunctionType|
* undefined)}}

View File

@@ -18,7 +18,7 @@ goog.require('ol.tilegrid.TileGrid');
* crossOrigin: (null|string|undefined),
* extent: (ol.Extent|undefined),
* opaque: (boolean|undefined),
* projection: (ol.Projection|undefined),
* projection: ol.ProjectionLike,
* tileGrid: (ol.tilegrid.TileGrid|undefined),
* tileUrlFunction: (ol.TileUrlFunctionType|undefined)}}
*/

View File

@@ -5,13 +5,13 @@ goog.require('goog.events.EventType');
goog.require('goog.functions');
goog.require('ol.Attribution');
goog.require('ol.Extent');
goog.require('ol.Projection');
goog.require('ol.projection');
/**
* @typedef {{attributions: (Array.<ol.Attribution>|undefined),
* extent: (ol.Extent|undefined),
* projection: (ol.Projection|undefined)}}
* projection: ol.ProjectionLike}}
*/
ol.source.SourceOptions;
@@ -30,8 +30,7 @@ ol.source.Source = function(sourceOptions) {
* @private
* @type {ol.Projection}
*/
this.projection_ = goog.isDef(sourceOptions.projection) ?
sourceOptions.projection : null;
this.projection_ = ol.projection.get(sourceOptions.projection);
/**
* @private
@@ -39,7 +38,7 @@ ol.source.Source = function(sourceOptions) {
*/
this.extent_ = goog.isDef(sourceOptions.extent) ?
sourceOptions.extent : goog.isDef(sourceOptions.projection) ?
sourceOptions.projection.getExtent() : null;
this.projection_.getExtent() : null;
/**
* @private

View File

@@ -74,6 +74,16 @@ ol.source.StamenProviderConfig = {
};
/**
* @const {Array.<ol.Attribution>}
*/
ol.source.STAMEN_ATTRIBUTIONS = [new ol.Attribution(
'Map tiles by <a href="http://stamen.com">Stamen Design</a>, under ' +
'<a href="http://creativecommons.org/licenses/by/3.0">CC BY 3.0</a>. ' +
'Data by <a href="http://openstreetmap.org">OpenStreetMap</a>, under ' +
'<a href="http://creativecommons.org/licenses/by-sa/3.0">CC BY SA</a>.')];
/**
* @constructor
@@ -82,14 +92,6 @@ ol.source.StamenProviderConfig = {
*/
ol.source.Stamen = function(options) {
var attribution = new ol.Attribution(
'Map tiles by <a href="http://stamen.com">Stamen Design</a>, ' +
'under ' +
'<a href="http://creativecommons.org/licenses/by/3.0">CC BY 3.0</a>. ' +
'Data by <a href="http://openstreetmap.org">OpenStreetMap</a>, ' +
'under ' +
'<a href="http://creativecommons.org/licenses/by-sa/3.0">CC BY SA</a>.');
var i = options.layer.indexOf('-');
var provider = i == -1 ? options.layer : options.layer.slice(0, i);
goog.asserts.assert(provider in ol.source.StamenProviderConfig);
@@ -103,7 +105,7 @@ ol.source.Stamen = function(options) {
layerConfig.extension;
goog.base(this, {
attributions: [attribution],
attributions: ol.source.STAMEN_ATTRIBUTIONS,
maxZoom: providerConfig.maxZoom,
// FIXME uncomment the following when tilegrid supports minZoom
//minZoom: providerConfig.minZoom,

View File

@@ -2,6 +2,7 @@ goog.provide('ol.source.StaticImage');
goog.require('ol.Image');
goog.require('ol.ImageUrlFunctionType');
goog.require('ol.projection');
goog.require('ol.source.ImageSource');
@@ -19,7 +20,7 @@ ol.source.StaticImage = function(options) {
var imageExtent = options.imageExtent;
var imageSize = options.imageSize;
var imageResolution = imageExtent.getHeight() / imageSize.height;
var projection = goog.isDef(options.projection) ? options.projection : null;
var projection = ol.projection.get(options.projection);
goog.base(this, {
attributions: options.attributions,

View File

@@ -1 +1 @@
@exportSymbol ol.source.TiledWMS
@exportSymbol ol.source.TiledWMS

View File

@@ -49,9 +49,9 @@ ol.source.TiledWMS = function(tiledWMSOptions) {
var tileExtent = tileGrid.getTileCoordExtent(tileCoord);
var projectionExtent = projection.getExtent();
extent = goog.isDef(extent) ? extent : projectionExtent;
// FIXME do we want a wrapDateLine param? The code below will break maps
// with projections that do not span the whole world width.
if (extent.minX === projectionExtent.minX &&
if (!goog.isNull(extent) && projection.isGlobal() &&
extent.minX === projectionExtent.minX &&
extent.maxX === projectionExtent.maxX) {
var numCols = Math.ceil(
(extent.maxX - extent.minX) / (tileExtent.maxX - tileExtent.minX));

View File

@@ -52,7 +52,7 @@ goog.exportSymbol('grid', grid);
ol.source.TileJSON = function(tileJsonOptions) {
goog.base(this, {
projection: ol.projection.getFromCode('EPSG:3857')
projection: ol.projection.get('EPSG:3857')
});
/**
@@ -80,15 +80,15 @@ ol.source.TileJSON.prototype.handleTileJSONResponse = function() {
var tileJSON = ol.tilejson.grids_.pop();
var epsg4326Projection = ol.projection.getFromCode('EPSG:4326');
var epsg4326Projection = ol.projection.get('EPSG:4326');
var epsg4326Extent, extent;
if (goog.isDef(tileJSON.bounds)) {
var bounds = tileJSON.bounds;
epsg4326Extent = new ol.Extent(
bounds[0], bounds[1], bounds[2], bounds[3]);
extent = epsg4326Extent.transform(
ol.projection.getTransform(epsg4326Projection, this.getProjection()));
extent = epsg4326Extent.transform(ol.projection.getTransformFromProjections(
epsg4326Projection, this.getProjection()));
this.setExtent(extent);
} else {
epsg4326Extent = null;

View File

@@ -4,7 +4,6 @@ goog.provide('ol.source.TileSourceOptions');
goog.require('goog.functions');
goog.require('ol.Attribution');
goog.require('ol.Extent');
goog.require('ol.Projection');
goog.require('ol.Tile');
goog.require('ol.TileCoord');
goog.require('ol.TileRange');
@@ -16,7 +15,7 @@ goog.require('ol.tilegrid.TileGrid');
* @typedef {{attributions: (Array.<ol.Attribution>|undefined),
* extent: (ol.Extent|undefined),
* opaque: (boolean|undefined),
* projection: (ol.Projection|undefined),
* projection: ol.ProjectionLike,
* tileGrid: (ol.tilegrid.TileGrid|undefined)}}
*/
ol.source.TileSourceOptions;

View File

@@ -17,8 +17,8 @@ ol.source.wms.getUrl =
'REQUEST': 'GetMap',
'FORMAT': 'image/png',
'TRANSPARENT': true,
'WIDTH': size.width,
'HEIGHT': size.height
'WIDTH': Math.round(size.width),
'HEIGHT': Math.round(size.height)
};
goog.object.extend(baseParams, params);

View File

@@ -37,7 +37,7 @@ ol.source.XYZOptions;
ol.source.XYZ = function(xyzOptions) {
var projection = xyzOptions.projection ||
ol.projection.getFromCode('EPSG:3857');
ol.projection.get('EPSG:3857');
/**
* @type {ol.TileUrlFunctionType}

View File

@@ -30,13 +30,6 @@ ol.Tile = function(tileCoord) {
goog.base(this);
/**
* A count incremented each time the tile is inQueue in a tile queue,
* and decremented each time the tile is dequeued from a tile queue.
* @type {number}
*/
this.inQueue = 0;
/**
* @type {ol.TileCoord}
*/

View File

@@ -89,8 +89,6 @@ ol.TileQueue.prototype.dequeue_ = function() {
}
var tileKey = tile.getKey();
delete this.queuedTileKeys_[tileKey];
tile.inQueue--;
goog.asserts.assert(tile.inQueue >= 0);
return tile;
};
@@ -112,8 +110,6 @@ ol.TileQueue.prototype.enqueue = function(tile, tileSourceKey, tileCenter) {
this.heap_.push([priority, tile, tileSourceKey, tileCenter]);
this.queuedTileKeys_[tileKey] = true;
this.siftDown_(0, this.heap_.length - 1);
tile.inQueue++;
goog.asserts.assert(tile.inQueue > 0);
}
}
};
@@ -172,7 +168,7 @@ ol.TileQueue.prototype.heapify_ = function() {
/**
* FIXME empty description for jsdoc
* @return {boolean} New loading tiles?
*/
ol.TileQueue.prototype.loadMoreTiles = function() {
var tile;
@@ -183,6 +179,7 @@ ol.TileQueue.prototype.loadMoreTiles = function() {
tile.load();
++this.tilesLoading_;
}
return goog.isDef(tile);
};
@@ -250,11 +247,6 @@ ol.TileQueue.prototype.reprioritize = function() {
if (priority == ol.TileQueue.DROP) {
tileKey = tile.getKey();
delete this.queuedTileKeys_[tileKey];
tile.inQueue--;
goog.asserts.assert(tile.inQueue >= 0);
if (tile.inQueue === 0) {
goog.events.removeAll(tile);
}
} else {
node[0] = priority;
heap[n++] = node;

View File

@@ -1 +1,3 @@
@exportClass ol.View2D ol.View2DOptions
@exportProperty ol.View2D.prototype.fitExtent
@exportProperty ol.View2D.prototype.getView2D