Permalink
Browse files

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

Resolved conflicts:
  src/ol/renderer/canvas/canvasrenderer.js
  • Loading branch information...
2 parents d642628 + eef683f commit 176f18c9378de7578243254ce7ef349a13fc3cfa @tschaub tschaub committed Feb 20, 2013
Showing with 1,712 additions and 214 deletions.
  1. +4 −3 src/ol/canvas/canvas.js
  2. +49 −40 src/ol/control/attributioncontrol.js
  3. +16 −0 src/ol/coordinate.js
  4. +2 −0 src/ol/framestate.js
  5. +3 −2 src/ol/geolocation.js
  6. +17 −1 src/ol/image.js
  7. +7 −6 src/ol/map.js
  8. +214 −0 src/ol/parser/ogc/owscommon_v1.js
  9. +45 −0 src/ol/parser/ogc/owscommon_v1_1_0.js
  10. +2 −0 src/ol/parser/ogc/wmtscapabilities.exports
  11. +19 −0 src/ol/parser/ogc/wmtscapabilities.js
  12. +161 −0 src/ol/parser/ogc/wmtscapabilities_v1_0_0.js
  13. +6 −0 src/ol/parser/xml.js
  14. +28 −12 src/ol/projection.js
  15. +3 −0 src/ol/renderer/canvas/canvasimagelayerrenderer.js
  16. +4 −4 src/ol/renderer/canvas/canvasrenderer.js
  17. +2 −0 src/ol/renderer/dom/domimagelayerrenderer.js
  18. +4 −5 src/ol/renderer/dom/domrenderer.js
  19. +18 −0 src/ol/renderer/layerrenderer.js
  20. +2 −0 src/ol/renderer/webgl/webglimagelayerrenderer.js
  21. +4 −3 src/ol/renderer/webgl/webglrenderer.js
  22. +2 −1 src/ol/source/imagesource.js
  23. +34 −46 src/ol/tilegrid/tilegrid.js
  24. +2 −2 src/ol/tilegrid/xyztilegrid.js
  25. +24 −1 src/ol/tilerange.js
  26. +1 −1 src/ol/view2d.js
  27. +4 −3 src/ol/webgl/webgl.js
  28. +6 −6 test/spec/ol/map.test.js
  29. +183 −0 test/spec/ol/parser/ogc/wmtscapabilities_v1_0_0.test.js
  30. +70 −0 test/spec/ol/parser/ogc/xml/wmtscapabilities_v1_0_0/arcgis.xml
  31. +92 −0 test/spec/ol/parser/ogc/xml/wmtscapabilities_v1_0_0/multi-getile-1.xml
  32. +78 −0 test/spec/ol/parser/ogc/xml/wmtscapabilities_v1_0_0/multi-getile-2.xml
  33. +158 −0 test/spec/ol/parser/ogc/xml/wmtscapabilities_v1_0_0/ogcsample.xml
  34. +72 −0 test/spec/ol/parser/ogc/xml/wmtscapabilities_v1_0_0/restsample-alternate-proj1.xml
  35. +72 −0 test/spec/ol/parser/ogc/xml/wmtscapabilities_v1_0_0/restsample-alternate-proj2.xml
  36. +126 −0 test/spec/ol/parser/ogc/xml/wmtscapabilities_v1_0_0/restsample.xml
  37. +111 −78 test/spec/ol/tilegrid.test.js
  38. +67 −0 test/spec/ol/tilerange.test.js
@@ -5,9 +5,10 @@ goog.require('goog.dom.TagName');
/**
- * @return {boolean} Is supported.
+ * @const
+ * @type {boolean} Is supported.
*/
-ol.canvas.isSupported = function() {
+ol.canvas.SUPPORTED = (function() {
if (!('HTMLCanvasElement' in goog.global)) {
return false;
}
@@ -18,4 +19,4 @@ ol.canvas.isSupported = function() {
} catch (e) {
return false;
}
-};
+})();
@@ -1,5 +1,4 @@
// FIXME handle date line wrap
-// FIXME does not handle image sources
goog.provide('ol.control.Attribution');
@@ -10,11 +9,12 @@ goog.require('goog.events');
goog.require('goog.object');
goog.require('goog.style');
goog.require('ol.Attribution');
+goog.require('ol.FrameState');
goog.require('ol.MapEvent');
goog.require('ol.MapEventType');
goog.require('ol.TileRange');
goog.require('ol.control.Control');
-goog.require('ol.source.TileSource');
+goog.require('ol.source.Source');
@@ -67,15 +67,45 @@ goog.inherits(ol.control.Attribution, ol.control.Control);
/**
+ * @param {?Object.<string, Object.<string, ol.TileRange>>} usedTiles Used
+ * tiles.
+ * @param {Object.<string, ol.source.Source>} sources Sources.
+ * @return {Object.<string, ol.Attribution>} Attributions.
+ */
+ol.control.Attribution.prototype.getTileSourceAttributions =
+ function(usedTiles, sources) {
+ /** @type {Object.<string, ol.Attribution>} */
+ var attributions = {};
+ var i, tileRanges, tileSource, tileSourceAttribution,
+ tileSourceAttributionKey, tileSourceAttributions, tileSourceKey, z;
+ for (tileSourceKey in usedTiles) {
+ goog.asserts.assert(tileSourceKey in sources);
+ tileSource = sources[tileSourceKey];
+ tileSourceAttributions = tileSource.getAttributions();
+ if (goog.isNull(tileSourceAttributions)) {
+ continue;
+ }
+ tileRanges = usedTiles[tileSourceKey];
+ for (i = 0; i < tileSourceAttributions.length; ++i) {
+ tileSourceAttribution = tileSourceAttributions[i];
+ tileSourceAttributionKey = goog.getUid(tileSourceAttribution).toString();
+ if (tileSourceAttributionKey in attributions) {
+ continue;
+ }
+ if (tileSourceAttribution.intersectsAnyTileRange(tileRanges)) {
+ attributions[tileSourceAttributionKey] = tileSourceAttribution;
+ }
+ }
+ }
+ return attributions;
+};
+
+
+/**
* @param {ol.MapEvent} mapEvent Map event.
*/
ol.control.Attribution.prototype.handleMapPostrender = function(mapEvent) {
- var frameState = mapEvent.frameState;
- if (goog.isNull(frameState)) {
- this.updateElement_(null);
- } else {
- this.updateElement_(frameState.usedTiles);
- }
+ this.updateElement_(mapEvent.frameState);
};
@@ -99,12 +129,11 @@ ol.control.Attribution.prototype.setMap = function(map) {
/**
* @private
- * @param {?Object.<string, Object.<string, ol.TileRange>>} usedTiles Used
- * tiles.
+ * @param {?ol.FrameState} frameState Frame state.
*/
-ol.control.Attribution.prototype.updateElement_ = function(usedTiles) {
+ol.control.Attribution.prototype.updateElement_ = function(frameState) {
- if (goog.isNull(usedTiles)) {
+ if (goog.isNull(frameState)) {
if (this.renderedVisible_) {
goog.style.showElement(this.element, false);
this.renderedVisible_ = false;
@@ -116,15 +145,13 @@ ol.control.Attribution.prototype.updateElement_ = function(usedTiles) {
/** @type {Object.<string, boolean>} */
var attributionsToRemove = {};
- /** @type {Object.<string, ol.source.TileSource>} */
- var tileSources = {};
+ /** @type {Object.<string, ol.source.Source>} */
+ var sources = {};
var layers = map.getLayers();
if (goog.isDef(layers)) {
layers.forEach(function(layer) {
var source = layer.getSource();
- if (source instanceof ol.source.TileSource) {
- tileSources[goog.getUid(source).toString()] = source;
- }
+ sources[goog.getUid(source).toString()] = source;
var attributions = source.getAttributions();
if (!goog.isNull(attributions)) {
var attribution, i;
@@ -138,34 +165,16 @@ ol.control.Attribution.prototype.updateElement_ = function(usedTiles) {
}
/** @type {Object.<string, ol.Attribution>} */
- var attributions = {};
- var i, tileRanges, tileSource, tileSourceAttribution,
- tileSourceAttributionKey, tileSourceAttributions, tileSourceKey, z;
- for (tileSourceKey in usedTiles) {
- goog.asserts.assert(tileSourceKey in tileSources);
- tileSource = tileSources[tileSourceKey];
- tileSourceAttributions = tileSource.getAttributions();
- if (goog.isNull(tileSourceAttributions)) {
- continue;
- }
- tileRanges = usedTiles[tileSourceKey];
- for (i = 0; i < tileSourceAttributions.length; ++i) {
- tileSourceAttribution = tileSourceAttributions[i];
- tileSourceAttributionKey = goog.getUid(tileSourceAttribution).toString();
- if (tileSourceAttributionKey in attributions) {
- continue;
- }
- if (tileSourceAttribution.intersectsAnyTileRange(tileRanges)) {
- attributions[tileSourceAttributionKey] = tileSourceAttribution;
- }
- }
- }
+ var attributions = goog.object.clone(frameState.attributions);
+ var tileSourceAttributions = this.getTileSourceAttributions(
+ frameState.usedTiles, sources);
+ goog.object.extend(attributions, tileSourceAttributions);
/** @type {Array.<number>} */
var attributionKeys =
goog.array.map(goog.object.getKeys(attributions), Number);
goog.array.sort(attributionKeys);
- var attributionElement, attributionKey;
+ var i, attributionElement, attributionKey;
for (i = 0; i < attributionKeys.length; ++i) {
attributionKey = attributionKeys[i].toString();
if (attributionKey in this.attributionElements_) {
View
@@ -88,3 +88,19 @@ ol.Coordinate.toStringXY = function(coordinate, opt_precision) {
return '';
}
};
+
+
+/**
+ * Create an ol.Coordinate from an Array and take into account axis order.
+ * @param {Array} array The array with coordinates.
+ * @param {string} axis the axis info.
+ * @return {ol.Coordinate} The coordinate created.
+ */
+ol.Coordinate.fromProjectedArray = function(array, axis) {
+ var firstAxis = axis.charAt(0);
+ if (firstAxis === 'n' || firstAxis === 's') {
+ return new ol.Coordinate(array[1], array[0]);
+ } else {
+ return new ol.Coordinate(array[0], array[1]);
+ }
+};
@@ -6,6 +6,7 @@ goog.provide('ol.PostRenderFunction');
goog.provide('ol.PreRenderFunction');
goog.require('goog.vec.Mat4');
+goog.require('ol.Attribution');
goog.require('ol.Color');
goog.require('ol.Extent');
goog.require('ol.Size');
@@ -18,6 +19,7 @@ goog.require('ol.layer.LayerState');
/**
* @typedef {{animate: boolean,
+ * attributions: Object.<string, ol.Attribution>,
* backgroundColor: ol.Color,
* coordinateToPixelMatrix: goog.vec.Mat4.Number,
* extent: (null|ol.Extent),
@@ -42,7 +42,7 @@ ol.Geolocation = function(opt_positionOptions) {
*/
this.position_ = null;
- if (ol.Geolocation.isSupported) {
+ if (ol.Geolocation.SUPPORTED) {
goog.events.listen(
this, ol.Object.getChangedEventType(ol.GeolocationProperty.PROJECTION),
this.handleProjectionChanged_, false, this);
@@ -86,9 +86,10 @@ ol.Geolocation.prototype.handleProjectionChanged_ = function() {
/**
+ * @const
* @type {boolean} Is supported.
*/
-ol.Geolocation.isSupported = 'geolocation' in navigator;
+ol.Geolocation.SUPPORTED = 'geolocation' in navigator;
/**
View
@@ -5,6 +5,7 @@ goog.require('goog.array');
goog.require('goog.events');
goog.require('goog.events.EventTarget');
goog.require('goog.events.EventType');
+goog.require('ol.Attribution');
goog.require('ol.Extent');
@@ -27,8 +28,15 @@ ol.ImageState = {
* @param {number} resolution Resolution.
* @param {string} src Image source URI.
* @param {?string} crossOrigin Cross origin.
+ * @param {Array.<ol.Attribution>} attributions Attributions.
*/
-ol.Image = function(extent, resolution, src, crossOrigin) {
+ol.Image = function(extent, resolution, src, crossOrigin, attributions) {
+
+ /**
+ * @private
+ * @type {Array.<ol.Attribution>}
+ */
+ this.attributions_ = attributions;
/**
* @private
@@ -87,6 +95,14 @@ ol.Image.prototype.dispatchChangeEvent = function() {
/**
+ * @return {Array.<ol.Attribution>} Attributions.
+ */
+ol.Image.prototype.getAttributions = function() {
+ return this.attributions_;
+};
+
+
+/**
* @return {ol.Extent} Extent.
*/
ol.Image.prototype.getExtent = function() {
View
@@ -58,11 +58,11 @@ goog.require('ol.interaction.condition');
goog.require('ol.layer.Layer');
goog.require('ol.renderer.Map');
goog.require('ol.renderer.canvas.Map');
-goog.require('ol.renderer.canvas.isSupported');
+goog.require('ol.renderer.canvas.SUPPORTED');
goog.require('ol.renderer.dom.Map');
-goog.require('ol.renderer.dom.isSupported');
+goog.require('ol.renderer.dom.SUPPORTED');
goog.require('ol.renderer.webgl.Map');
-goog.require('ol.renderer.webgl.isSupported');
+goog.require('ol.renderer.webgl.SUPPORTED');
/**
@@ -664,6 +664,7 @@ ol.Map.prototype.renderFrame_ = function(time) {
var view2DState = view2D.getView2DState();
frameState = {
animate: false,
+ attributions: {},
backgroundColor: goog.isDef(backgroundColor) ?
backgroundColor : new ol.Color(255, 255, 255, 1),
coordinateToPixelMatrix: this.coordinateToPixelMatrix_,
@@ -857,17 +858,17 @@ ol.Map.createOptionsInternal = function(mapOptions) {
for (i = 0; i < rendererHints.length; ++i) {
rendererHint = rendererHints[i];
if (rendererHint == ol.RendererHint.CANVAS) {
- if (ol.ENABLE_CANVAS && ol.renderer.canvas.isSupported()) {
+ if (ol.ENABLE_CANVAS && ol.renderer.canvas.SUPPORTED) {
rendererConstructor = ol.renderer.canvas.Map;
break;
}
} else if (rendererHint == ol.RendererHint.DOM) {
- if (ol.ENABLE_DOM && ol.renderer.dom.isSupported()) {
+ if (ol.ENABLE_DOM && ol.renderer.dom.SUPPORTED) {
rendererConstructor = ol.renderer.dom.Map;
break;
}
} else if (rendererHint == ol.RendererHint.WEBGL) {
- if (ol.ENABLE_WEBGL && ol.renderer.webgl.isSupported()) {
+ if (ol.ENABLE_WEBGL && ol.renderer.webgl.SUPPORTED) {
rendererConstructor = ol.renderer.webgl.Map;
break;
}
Oops, something went wrong. Retry.

0 comments on commit 176f18c

Please sign in to comment.