From 7136927a4197a15f4199d677ed27508e93fd3891 Mon Sep 17 00:00:00 2001 From: Guillaume Beraudo Date: Fri, 22 Jan 2016 14:43:44 +0100 Subject: [PATCH 1/5] Remove deprecated OpenStreetMapImageryProvider --- Cesium.externs.js | 22 ---------------------- cesium | 2 +- 2 files changed, 1 insertion(+), 23 deletions(-) diff --git a/Cesium.externs.js b/Cesium.externs.js index f311f5f5d..49e07168e 100644 --- a/Cesium.externs.js +++ b/Cesium.externs.js @@ -3134,28 +3134,6 @@ Cesium.UrlTemplateImageryProvider = function(options) {}; Cesium.UrlTemplateImageryProviderOptions; - -/** - * @typedef {{ - * url: (string|undefined), - * fileExtension: (string|undefined), - * proxy: (Object|undefined), - * rectangle: (Cesium.Rectangle|undefined), - * minimumLevel: (number|undefined), - * maximumLevel: (number|undefined), - * credit: (Cesium.Credit|string|undefined) - * }} - */ -Cesium.OpenStreetMapImageryProviderOptions; - -/** - * @constructor - * @param {Cesium.OpenStreetMapImageryProviderOptions=} opt_opts - * @extends {Cesium.ImageryProvider} - */ -Cesium.OpenStreetMapImageryProvider = function(opt_opts) {}; - - /** * @typedef {{ * url: string, diff --git a/cesium b/cesium index cc86e3189..e93e92931 160000 --- a/cesium +++ b/cesium @@ -1 +1 @@ -Subproject commit cc86e318964dc0ea92f2b6e6db5368be1d7a28eb +Subproject commit e93e9293191075c8bd41ba8bd9c496869f6c09b9 From a8f27e1ee138cd4f4f53f6d657a5f25ff47deef3 Mon Sep 17 00:00:00 2001 From: Guillaume Beraudo Date: Fri, 22 Jan 2016 14:53:25 +0100 Subject: [PATCH 2/5] Replace deprecated frustrum.getPixelSize() --- Cesium.externs.js | 9 +++++---- src/core.js | 7 +++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Cesium.externs.js b/Cesium.externs.js index 49e07168e..02a6e12d0 100644 --- a/Cesium.externs.js +++ b/Cesium.externs.js @@ -2346,12 +2346,13 @@ Cesium.PerspectiveFrustrum.prototype.projectionMatrix; /** - * @param {!Cesium.Cartesian2} canvasDim . - * @param {number=} opt_dist . + * @param {!number} drawingBufferWidth + * @param {!number} drawingBufferHeight + * @param {!number} dist + * @param {!Cesium.Cartesian2} result * @return {!Cesium.Cartesian2} */ -Cesium.PerspectiveFrustrum.prototype.getPixelSize = function(canvasDim, opt_dist) {}; - +Cesium.PerspectiveFrustrum.prototype.getPixelDimensions = function(drawingBufferWidth, drawingBufferHeight, dist, result) {}; /** diff --git a/src/core.js b/src/core.js index 06f410f11..7aa5a7875 100644 --- a/src/core.js +++ b/src/core.js @@ -27,12 +27,11 @@ olcs.core.computePixelSizeAtCoordinate = function(scene, target) { var camera = scene.camera; var canvas = scene.canvas; var frustum = camera.frustum; - var canvasDimensions = new Cesium.Cartesian2( - canvas.clientWidth, canvas.clientHeight); var distance = Cesium.Cartesian3.magnitude(Cesium.Cartesian3.subtract( camera.position, target, new Cesium.Cartesian3())); - var pixelSize = frustum.getPixelSize(canvasDimensions, distance); - return pixelSize; + var pixelSize = new Cesium.Cartesian2(); + return frustum.getPixelDimensions(canvas.clientWidth, canvas.clientHeight, + distance, pixelSize); }; From d44afa02701e6dcf09ebdc040a81a1d433cd6516 Mon Sep 17 00:00:00 2001 From: Guillaume Beraudo Date: Fri, 22 Jan 2016 16:08:55 +0100 Subject: [PATCH 3/5] Remove broken dragbox feature The dragbox feature depended on Cesium.RectanglePrimitive which has been removed upstream. The feature should be reimplemented based on a grounded Primitive + RectangleGeometry, which will be better than what we had, since it supports rectangles drapped on terrain. See https://cesiumjs.org/Cesium/Build/Documentation/GroundPrimitive.html and https://github.com/AnalyticalGraphicsInc/cesium/blob/master/CHANGES.md. --- examples/dragbox.html | 19 ---- examples/dragbox.js | 32 ------ src/dragbox.js | 222 ------------------------------------------ 3 files changed, 273 deletions(-) delete mode 100644 examples/dragbox.html delete mode 100644 examples/dragbox.js delete mode 100644 src/dragbox.js diff --git a/examples/dragbox.html b/examples/dragbox.html deleted file mode 100644 index a145c74bf..000000000 --- a/examples/dragbox.html +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - ol3cesium dragbox example - - - -
-
-
A zone may be selected in ol3 or Cesium map using maj+drag and trigger an event. -
Then application code may react to the event by zooming, selecting features, ...
- - - - - diff --git a/examples/dragbox.js b/examples/dragbox.js deleted file mode 100644 index 6add59a96..000000000 --- a/examples/dragbox.js +++ /dev/null @@ -1,32 +0,0 @@ -var ol2d = new ol.Map({ - layers: [ - new ol.layer.Tile({ - source: new ol.source.OSM() - }) - ], - target: 'map2d', - view: new ol.View({ - center: [0, 0], - zoom: 3 - }) -}); - -var ol3d = new olcs.OLCesium({map: ol2d, target: 'map3d'}); -var scene = ol3d.getCesiumScene(); -var terrainProvider = new Cesium.CesiumTerrainProvider({ - url : '//assets.agi.com/stk-terrain/world' -}); -scene.terrainProvider = terrainProvider; - -var box = new olcs.DragBox(); -box.setScene(scene); - -box.listen('boxstart', function(event) { - console.log('boxstart', event); -}); - -box.listen('boxend', function(event) { - console.log('boxend', event); -}); - -ol3d.setEnabled(true); diff --git a/src/dragbox.js b/src/dragbox.js deleted file mode 100644 index 2dc72a5c9..000000000 --- a/src/dragbox.js +++ /dev/null @@ -1,222 +0,0 @@ -// FIXME: box style -goog.provide('olcs.DragBox'); -goog.provide('olcs.DragBoxEventType'); - -goog.require('goog.asserts'); -goog.require('goog.events.EventTarget'); - - -/** - * @enum {string} - */ -olcs.DragBoxEventType = { - /** - * Triggered upon drag box start. - */ - BOXSTART: 'boxstart', - /** - * Triggered upon drag box end. - */ - BOXEND: 'boxend' -}; - - - -/** - * @constructor - * @extends {goog.events.EventTarget} - * @param {Object=} opt_options Options. - * @api - * @struct - */ -olcs.DragBox = function(opt_options) { - - var options = goog.isDef(opt_options) ? opt_options : {}; - - goog.base(this); - - /** - * @private - * @type {Cesium.Scene} - */ - this.scene_ = null; - - /** - * @private - * @type {Cesium.ScreenSpaceEventHandler} - */ - this.handler_ = null; - - /** - * @private - * @type {Cesium.RectanglePrimitive} - */ - this.box_ = new Cesium.RectanglePrimitive({ - asynchronous: false, - rectangle: new Cesium.Rectangle(), - material: Cesium.Material.fromType(Cesium.Material.ColorType) - }); - - // FIXME: configurable - this.box_.material.uniforms.color = new Cesium.Color(0.0, 0.0, 1.0, 0.5); - - /** - * @private - * @type {Cesium.KeyboardEventModifier|undefined} - */ - this.modifier_ = goog.isDef(options.modifier) ? - options.modifier : Cesium.KeyboardEventModifier.SHIFT; - - /** - * @private - * @type {Cesium.Cartographic} - */ - this.startPosition_ = null; - -}; -goog.inherits(olcs.DragBox, goog.events.EventTarget); - - -/** - * @param {Object} event Mouse down event. - */ -olcs.DragBox.prototype.handleMouseDown = function(event) { - var ellipsoid = this.scene_.globe.ellipsoid; - var ray = this.scene_.camera.getPickRay(event.position); - var intersection = this.scene_.globe.pick(ray, this.scene_); - if (goog.isDef(intersection)) { - this.handler_.setInputAction(this.handleMouseMove.bind(this), - Cesium.ScreenSpaceEventType.MOUSE_MOVE); - this.handler_.setInputAction(this.handleMouseUp.bind(this), - Cesium.ScreenSpaceEventType.LEFT_UP); - - if (goog.isDef(this.modifier_)) { - // listen to the event with and without the modifier to be able to start - // a box with the key pressed and finish it without. - this.handler_.setInputAction(this.handleMouseMove.bind(this), - Cesium.ScreenSpaceEventType.MOUSE_MOVE, this.modifier_); - this.handler_.setInputAction(this.handleMouseUp.bind(this), - Cesium.ScreenSpaceEventType.LEFT_UP, this.modifier_); - } - var cartographic = ellipsoid.cartesianToCartographic(intersection); - var rectangle = this.box_.rectangle; - rectangle.north = rectangle.south = cartographic.latitude; - rectangle.east = rectangle.west = cartographic.longitude; - this.box_.height = cartographic.height; - - this.box_.show = true; - - this.dispatchEvent({ - type: olcs.DragBoxEventType.BOXSTART, - position: cartographic - }); - - goog.asserts.assert(!goog.isNull(this.box_)); - if (!this.scene_.primitives.contains(this.box_)) { - this.scene_.primitives.add(this.box_); - } - this.scene_.screenSpaceCameraController.enableInputs = false; - - this.startPosition_ = cartographic; - } -}; - - -/** - * @param {Object} event Mouse move event. - */ -olcs.DragBox.prototype.handleMouseMove = function(event) { - var ellipsoid = this.scene_.globe.ellipsoid; - var ray = this.scene_.camera.getPickRay(event.endPosition); - var intersection = this.scene_.globe.pick(ray, this.scene_); - if (goog.isDef(intersection)) { - var cartographic = ellipsoid.cartesianToCartographic(intersection); - this.box_.height = Math.max(this.box_.height, cartographic.height); - - if (cartographic.latitude < this.startPosition_.latitude) { - this.box_.rectangle.south = cartographic.latitude; - } else { - this.box_.rectangle.north = cartographic.latitude; - } - if (cartographic.longitude < this.startPosition_.longitude) { - this.box_.rectangle.west = cartographic.longitude; - } else { - this.box_.rectangle.east = cartographic.longitude; - } - } -}; - - -/** - * @param {Object} event Mouse up event. - */ -olcs.DragBox.prototype.handleMouseUp = function(event) { - var ellipsoid = this.scene_.globe.ellipsoid; - var ray = this.scene_.camera.getPickRay(event.position); - var intersection = this.scene_.globe.pick(ray, this.scene_); - if (goog.isDef(intersection)) { - var cartographic = ellipsoid.cartesianToCartographic(intersection); - - this.box_.show = false; - - this.dispatchEvent({ - type: olcs.DragBoxEventType.BOXEND, - position: cartographic - }); - - this.handler_.removeInputAction(Cesium.ScreenSpaceEventType.LEFT_UP); - this.handler_.removeInputAction(Cesium.ScreenSpaceEventType.MOUSE_MOVE); - if (goog.isDef(this.modifier_)) { - this.handler_.removeInputAction(Cesium.ScreenSpaceEventType.LEFT_UP, - this.modifier_); - this.handler_.removeInputAction(Cesium.ScreenSpaceEventType.MOUSE_MOVE, - this.modifier_); - } - } - this.scene_.screenSpaceCameraController.enableInputs = true; -}; - - -/** - * @param {Cesium.Scene} scene Scene. - * @api - */ -olcs.DragBox.prototype.setScene = function(scene) { - if (goog.isNull(scene)) { - goog.asserts.assert(!goog.isNull(this.box_)); - if (this.scene_.primitives.contains(this.box_)) { - this.scene_.primitives.remove(this.box_); - } - if (!goog.isNull(this.handler_)) { - this.handler_.destroy(); - this.handler_ = null; - } - } else { - goog.asserts.assert(scene.canvas); - this.handler_ = new Cesium.ScreenSpaceEventHandler(scene.canvas); - this.handler_.setInputAction(this.handleMouseDown.bind(this), - Cesium.ScreenSpaceEventType.LEFT_DOWN, this.modifier_); - } - this.scene_ = scene; -}; - - -/** - * Adds an event listener. A listener can only be added once to an - * object and if it is added again the key for the listener is - * returned. Note that if the existing listener is a one-off listener - * (registered via listenOnce), it will no longer be a one-off - * listener after a call to listen(). - * - * @param {string|!goog.events.EventId.} type The event type id. - * @param {function(this:SCOPE, EVENTOBJ):(boolean|undefined)} listener Callback - * method. - * @param {boolean=} opt_useCapture Whether to fire in capture phase - * (defaults to false). - * @param {SCOPE=} opt_listenerScope Object in whose scope to call the - * listener. - * @return {goog.events.ListenableKey} Unique key for the listener. - * @template SCOPE,EVENTOBJ - * @api - */ -olcs.DragBox.prototype.listen; From c7cefe67d6c14d36a80fdaee3ccb4055df84aaf9 Mon Sep 17 00:00:00 2001 From: Guillaume Beraudo Date: Fri, 22 Jan 2016 16:10:49 +0100 Subject: [PATCH 4/5] Remove obsolete Cesium.RectanglePrimitive from externs --- Cesium.externs.js | 27 --------------------------- 1 file changed, 27 deletions(-) diff --git a/Cesium.externs.js b/Cesium.externs.js index 02a6e12d0..3c0eac742 100644 --- a/Cesium.externs.js +++ b/Cesium.externs.js @@ -2081,33 +2081,6 @@ Cesium.Rectangle.fromDegrees = function(west, south, east, north, opt_result) {} Cesium.Rectangle.fromCartographicArray = function(cartographics, opt_result) {}; -/** - * @typedef {{asynchronous: (boolean|undefined), - * height: (number|undefined), - * rectangle: (Cesium.Rectangle|undefined), - * material: (Cesium.Material|undefined)}} - */ -Cesium.RectanglePrimitiveOptions; - -/** - * @constructor - * @param {Cesium.RectanglePrimitiveOptions} options . - * @extends {Cesium.Primitive} - */ -Cesium.RectanglePrimitive = function(options) {}; - - -/** - * @type {!Cesium.Material} material . - */ -Cesium.RectanglePrimitive.prototype.material; - -/** - * @type {!Cesium.Rectangle} rectangle . - */ -Cesium.RectanglePrimitive.prototype.rectangle; - - /** * @constructor */ From c70a7fade1379f5e8029faf1401d1d0537df86ef Mon Sep 17 00:00:00 2001 From: Guillaume Beraudo Date: Fri, 22 Jan 2016 16:19:21 +0100 Subject: [PATCH 5/5] Update CHANGES.md --- CHANGES.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index 7111fe70e..769a1fac6 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -2,8 +2,14 @@ ## v1.12 +* Breaking changes + * Remove dragbox functionality due to the removal of the Cesium.RectanglePrimitive + by upstream. See the commit message for hints about how to reimplement it. + * Remove Cesium.RectanglePrimitive, Cesium.PerspectiveFrustrum.getPixelSize, + Cesium.OpenStreetMapImageryProvider from Cesium externs. * Changes * Port to OL 3.13.0. + * Port to Cesium 1.17. ## v1.11 - 2015-12-23