Permalink
Browse files

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

  • Loading branch information...
2 parents 2082ba7 + 012cb50 commit 59a203b2b74d397a3fee1742c1d0f7dd8d60baa5 @tschaub tschaub committed Feb 15, 2013
Showing with 7,601 additions and 62 deletions.
  1. +2 −2 build.py
  2. +53 −0 examples/wms-capabilities.html
  3. +26 −0 examples/wms-capabilities.js
  4. +17 −18 src/ol/interaction/dragrotateandzoominteraction.js
  5. +17 −20 src/ol/interaction/dragrotateinteraction.js
  6. +96 −0 src/ol/parser/ogc/exceptionreport.js
  7. +121 −0 src/ol/parser/ogc/versioned.js
  8. +2 −0 src/ol/parser/ogc/wmscapabilities.exports
  9. +58 −0 src/ol/parser/ogc/wmscapabilities.js
  10. +320 −0 src/ol/parser/ogc/wmscapabilities_v1.js
  11. +99 −0 src/ol/parser/ogc/wmscapabilities_v1_1.js
  12. +25 −0 src/ol/parser/ogc/wmscapabilities_v1_1_0.js
  13. +21 −0 src/ol/parser/ogc/wmscapabilities_v1_1_1.js
  14. +46 −0 src/ol/parser/ogc/wmscapabilities_v1_1_1_WMSC.js
  15. +109 −0 src/ol/parser/ogc/wmscapabilities_v1_3_0.js
  16. +141 −0 src/ol/parser/xml.js
  17. +1 −1 src/ol/renderer/webgl/webgllayerrenderer.js
  18. +9 −8 src/ol/renderer/webgl/webglmaprenderer.js
  19. +8 −8 src/ol/renderer/webgl/webgltilelayerrenderer.js
  20. +1 −1 src/ol/tilequeue.js
  21. +19 −4 src/ol/view2d.js
  22. +101 −0 test/spec/ol/parser/ogc/exceptionreport.test.js
  23. +28 −0 test/spec/ol/parser/ogc/versioned.test.js
  24. +45 −0 test/spec/ol/parser/ogc/wmscapabilities.test.js
  25. +444 −0 test/spec/ol/parser/ogc/wmscapabilities_v1_1_1.test.js
  26. +74 −0 test/spec/ol/parser/ogc/wmscapabilities_v1_1_1_WMSC.test.js
  27. +297 −0 test/spec/ol/parser/ogc/wmscapabilities_v1_3_0.test.js
  28. +9 −0 test/spec/ol/parser/ogc/xml/exceptionreport/ows1_0_0.xml
  29. +9 −0 test/spec/ol/parser/ogc/xml/exceptionreport/ows1_1_0.xml
  30. +16 −0 test/spec/ol/parser/ogc/xml/exceptionreport/wms1_3_0.xml
  31. +4 −0 test/spec/ol/parser/ogc/xml/wmscapabilities_v1_1_1/exceptionsample.xml
  32. +4,497 −0 test/spec/ol/parser/ogc/xml/wmscapabilities_v1_1_1/gssample.xml
  33. +283 −0 test/spec/ol/parser/ogc/xml/wmscapabilities_v1_1_1/ogcsample.xml
  34. +124 −0 test/spec/ol/parser/ogc/xml/wmscapabilities_v1_1_1_WMSC/fallback.xml
  35. +178 −0 test/spec/ol/parser/ogc/xml/wmscapabilities_v1_1_1_WMSC/wmsc.xml
  36. +17 −0 test/spec/ol/parser/ogc/xml/wmscapabilities_v1_3_0/exceptionsample.xml
  37. +284 −0 test/spec/ol/parser/ogc/xml/wmscapabilities_v1_3_0/ogcsample.xml
View
@@ -213,7 +213,7 @@ def serve_precommit(t):
virtual('lint', 'build/lint-src-timestamp', 'build/lint-spec-timestamp', 'build/check-requires-timestamp')
-@target('build/lint-src-timestamp', SRC, INTERNAL_SRC, EXTERNAL_SRC, EXAMPLES_SRC)
+@target('build/lint-src-timestamp', SRC, INTERNAL_SRC, EXTERNAL_SRC, EXAMPLES_SRC, precious=True)
def build_lint_src_timestamp(t):
limited_doc_files = [path
for path in ifind('externs', 'build/src/external/externs')
@@ -288,7 +288,7 @@ def build_check_requires_timestamp(t):
t.touch()
-@target('build/lint-spec-timestamp', SPEC)
+@target('build/lint-spec-timestamp', SPEC, precious=True)
def build_lint_spec_timestamp(t):
t.run('%(GJSLINT)s', t.newer(SPEC))
t.touch()
@@ -0,0 +1,53 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+ <meta http-equiv="X-UA-Compatible" content="chrome=1">
+ <meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">
+ <link rel="stylesheet" href="style.css" type="text/css">
+ <style type="text/css">
+ html, body, #map {
+ margin: 0;
+ padding: 0;
+ width: 100%;
+ height: 100%;
+ }
+ #log {
+ height: 500px;
+ position: absolute;
+ top: 130px;
+ }
+ #text {
+ position: absolute;
+ top: 8px;
+ right: 8px;
+ z-index: 20000;
+ background-color: white;
+ padding: 0 0.5em 0.5em 0.5em;
+ border-radius: 4px;
+ }
+ @media only screen and (max-width: 600px) {
+ #text {
+ display: none;
+ }
+ }
+ </style>
+ <title>wms capabilities example</title>
+ </head>
+ <body>
+ <div id="log"></div>
+ <div id="map">
+ <div id="text">
+ <h1 id="title">WMS GetCapabilities parsing example</h1>
+ <div id="shortdesc">Example of parsing a WMS GetCapabilities response.</div>
+ <div id="docs">
+ <p>See the
+ <a href="wms-capabilities.js" target="_blank">wms-capabilities.js source</a>
+ to see how this is done.</p>
+ </div>
+ </div>
+ </div>
+ <div id="tags">wms, capabilities, getcapabilities</div>
+ <script src="loader.js?id=wms-capabilities" type="text/javascript"></script>
+ </body>
+</html>
@@ -0,0 +1,26 @@
+goog.require('goog.debug.Console');
+goog.require('goog.debug.DivConsole');
+goog.require('goog.debug.Logger');
+goog.require('goog.debug.Logger.Level');
+goog.require('goog.json.Serializer');
+goog.require('goog.net.XhrIo');
+goog.require('ol.parser.ogc.WMSCapabilities');
+
+
+if (goog.DEBUG) {
+ goog.debug.Console.autoInstall();
+ goog.debug.Logger.getLogger('ol').setLevel(goog.debug.Logger.Level.INFO);
+ var logconsole = new goog.debug.DivConsole(goog.dom.getElement('log'));
+ logconsole.setCapturing(true);
+}
+
+var parser = new ol.parser.ogc.WMSCapabilities(), result;
+var url = '../test/spec/ol/parser/ogc/xml/wmscapabilities_v1_3_0/ogcsample.xml';
+goog.net.XhrIo.send(url, function(e) {
+ var xhr = e.target;
+ result = parser.read(xhr.getResponseXml());
+ if (goog.DEBUG) {
+ var output = new goog.json.Serializer().serialize(result);
+ goog.debug.Logger.getLogger('ol').info(output);
+ }
+});
@@ -26,15 +26,15 @@ ol.interaction.DragRotateAndZoom = function(condition) {
/**
* @private
- * @type {number}
+ * @type {number|undefined}
*/
- this.startRatio_ = 0;
+ this.lastAngle_;
/**
* @private
- * @type {number}
+ * @type {number|undefined}
*/
- this.startRotation_ = 0;
+ this.lastMagnitude_;
};
goog.inherits(ol.interaction.DragRotateAndZoom, ol.interaction.Drag);
@@ -52,15 +52,23 @@ ol.interaction.DragRotateAndZoom.prototype.handleDrag =
browserEvent.offsetX - size.width / 2,
size.height / 2 - browserEvent.offsetY);
var theta = Math.atan2(delta.y, delta.x);
- var resolution = this.startRatio_ * delta.magnitude();
+ var magnitude = delta.magnitude();
// FIXME works for View2D only
var view = map.getView();
goog.asserts.assert(view instanceof ol.View2D);
map.requestRenderFrame();
// FIXME the calls to map.rotate and map.zoomToResolution should use
// map.withFrozenRendering but an assertion fails :-(
- view.rotate(map, this.startRotation_, -theta);
- view.zoomToResolution(map, resolution);
+ if (goog.isDef(this.lastAngle_)) {
+ var angleDelta = theta - this.lastAngle_;
+ view.rotate(map, view.getRotation() - angleDelta);
+ }
+ this.lastAngle_ = theta;
+ if (goog.isDef(this.lastMagnitude_)) {
+ var resolution = this.lastMagnitude_ * (view.getResolution() / magnitude);
+ view.zoomToResolution(map, resolution);
+ }
+ this.lastMagnitude_ = magnitude;
};
@@ -70,18 +78,9 @@ ol.interaction.DragRotateAndZoom.prototype.handleDrag =
ol.interaction.DragRotateAndZoom.prototype.handleDragStart =
function(mapBrowserEvent) {
var browserEvent = mapBrowserEvent.browserEvent;
- var map = mapBrowserEvent.map;
- var view = map.getView().getView2D();
if (this.condition_(browserEvent)) {
- var resolution = view.getResolution();
- var size = map.getSize();
- var delta = new goog.math.Vec2(
- browserEvent.offsetX - size.width / 2,
- size.height / 2 - browserEvent.offsetY);
- var theta = Math.atan2(delta.y, delta.x);
- this.startRotation_ = view.getRotation() + theta;
- this.startRatio_ = resolution / delta.magnitude();
- map.requestRenderFrame();
+ this.lastAngle_ = undefined;
+ this.lastMagnitude_ = undefined;
return true;
} else {
return false;
@@ -23,9 +23,9 @@ ol.interaction.DragRotate = function(condition) {
/**
* @private
- * @type {number}
+ * @type {number|undefined}
*/
- this.startRotation_ = 0;
+ this.lastAngle_;
};
goog.inherits(ol.interaction.DragRotate, ol.interaction.Drag);
@@ -39,14 +39,16 @@ ol.interaction.DragRotate.prototype.handleDrag = function(mapBrowserEvent) {
var map = mapBrowserEvent.map;
var size = map.getSize();
var offset = mapBrowserEvent.getPixel();
- var theta = Math.atan2(
- size.height / 2 - offset.y,
- offset.x - size.width / 2);
- // FIXME supports View2D only
- var view = map.getView();
- goog.asserts.assert(view instanceof ol.View2D);
- map.requestRenderFrame();
- view.rotate(map, this.startRotation_, -theta);
+ var theta = Math.atan2(size.height / 2 - offset.y, offset.x - size.width / 2);
+ if (goog.isDef(this.lastAngle_)) {
+ var delta = theta - this.lastAngle_;
+ var view = map.getView();
+ // FIXME supports View2D only
+ goog.asserts.assert(view instanceof ol.View2D);
+ map.requestRenderFrame();
+ view.rotate(map, view.getRotation() - delta);
+ }
+ this.lastAngle_ = theta;
};
@@ -56,18 +58,13 @@ ol.interaction.DragRotate.prototype.handleDrag = function(mapBrowserEvent) {
ol.interaction.DragRotate.prototype.handleDragStart =
function(mapBrowserEvent) {
var browserEvent = mapBrowserEvent.browserEvent;
- var map = mapBrowserEvent.map;
- // FIXME supports View2D only
- var view = map.getView();
- goog.asserts.assert(view instanceof ol.View2D);
if (browserEvent.isMouseActionButton() && this.condition_(browserEvent)) {
+ var map = mapBrowserEvent.map;
+ // FIXME supports View2D only
+ var view = map.getView();
+ goog.asserts.assert(view instanceof ol.View2D);
map.requestRenderFrame();
- var size = map.getSize();
- var offset = mapBrowserEvent.getPixel();
- var theta = Math.atan2(
- size.height / 2 - offset.y,
- offset.x - size.width / 2);
- this.startRotation_ = view.getRotation() + theta;
+ this.lastAngle_ = undefined;
return true;
} else {
return false;
@@ -0,0 +1,96 @@
+goog.provide('ol.parser.ogc.ExceptionReport');
+goog.require('goog.dom.xml');
+goog.require('ol.parser.XML');
+
+
+
+/**
+ * @constructor
+ * @extends {ol.parser.XML}
+ */
+ol.parser.ogc.ExceptionReport = function() {
+ var exceptionReader = function(node, exceptionReport) {
+ var exception = {
+ code: node.getAttribute('exceptionCode'),
+ locator: node.getAttribute('locator'),
+ texts: []
+ };
+ exceptionReport.exceptions.push(exception);
+ this.readChildNodes(node, exception);
+ };
+ var exceptionTextReader = function(node, exception) {
+ var text = this.getChildValue(node);
+ exception.texts.push(text);
+ };
+ this.readers = {
+ 'http://www.opengis.net/ogc': {
+ 'ServiceExceptionReport': function(node, obj) {
+ obj['exceptionReport'] = {};
+ obj['exceptionReport']['exceptions'] = [];
+ this.readChildNodes(node, obj['exceptionReport']);
+ },
+ 'ServiceException': function(node, exceptionReport) {
+ var exception = {};
+ exception['code'] = node.getAttribute('code');
+ exception['locator'] = node.getAttribute('locator');
+ exception['text'] = this.getChildValue(node);
+ exceptionReport['exceptions'].push(exception);
+ }
+ },
+ 'http://www.opengis.net/ows': {
+ 'ExceptionReport': function(node, obj) {
+ obj.success = false;
+ obj.exceptionReport = {
+ version: node.getAttribute('version'),
+ language: node.getAttribute('language'),
+ exceptions: []
+ };
+ this.readChildNodes(node, obj.exceptionReport);
+ },
+ 'Exception': function(node, exceptionReport) {
+ exceptionReader.apply(this, arguments);
+ },
+ 'ExceptionText': function(node, exception) {
+ exceptionTextReader.apply(this, arguments);
+ }
+ },
+ 'http://www.opengis.net/ows/1.1': {
+ 'ExceptionReport': function(node, obj) {
+ obj.exceptionReport = {
+ version: node.getAttribute('version'),
+ language: node.getAttribute('xml:lang'),
+ exceptions: []
+ };
+ this.readChildNodes(node, obj.exceptionReport);
+ },
+ 'Exception': function(node, exceptionReport) {
+ exceptionReader.apply(this, arguments);
+ },
+ 'ExceptionText': function(node, exception) {
+ exceptionTextReader.apply(this, arguments);
+ }
+ }
+ };
+ goog.base(this);
+};
+goog.inherits(ol.parser.ogc.ExceptionReport, ol.parser.XML);
+
+
+/**
+ * Read OGC exception report data from a string, and return an object with
+ * information about the exceptions.
+ *
+ * @param {string|Document} data to read/parse.
+ * @return {Object} Information about the exceptions that occurred.
+ */
+ol.parser.ogc.ExceptionReport.prototype.read = function(data) {
+ if (typeof data == 'string') {
+ data = goog.dom.xml.loadXml(data);
+ }
+ var exceptionInfo = {};
+ exceptionInfo['exceptionReport'] = null;
+ if (data) {
+ this.readChildNodes(data, exceptionInfo);
+ }
+ return exceptionInfo;
+};
Oops, something went wrong.

0 comments on commit 59a203b

Please sign in to comment.