From 1783ea98e5c2ecd4c62b8afd33677b2b59690a5e Mon Sep 17 00:00:00 2001 From: Sean Lilley Date: Wed, 1 Mar 2017 11:26:24 -0500 Subject: [PATCH 1/4] Removed url and key from GeocoderViewModel --- CHANGES.md | 1 + Source/Widgets/Geocoder/GeocoderViewModel.js | 56 +++++-------------- Specs/Widgets/Geocoder/GeocoderSpec.js | 4 +- .../Widgets/Geocoder/GeocoderViewModelSpec.js | 4 +- 4 files changed, 18 insertions(+), 47 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index f860aa2aeadc..ba5f208fe4c7 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -12,6 +12,7 @@ Change Log * Corrected spelling of `Color.FUCHSIA` from `Color.FUSCHIA`. [#4977](https://github.com/AnalyticalGraphicsInc/cesium/pull/4977) * The enums `MIDDLE_DOUBLE_CLICK` and `RIGHT_DOUBLE_CLICK` from `ScreenSpaceEventType` have been removed. [#5052](https://github.com/AnalyticalGraphicsInc/cesium/pull/5052) * Removed the function `GeometryPipeline.computeBinormalAndTangent`. Use `GeometryPipeline.computeTangentAndBitangent`. [#5053](https://github.com/AnalyticalGraphicsInc/cesium/pull/5053) + * Removed the `url` and `key` properties from `GeocoderViewModel`. * Added support to `DebugCameraPrimitive` to draw multifrustum planes. The attribute `debugShowFrustumPlanes` of `Scene` and `frustumPlanes` of `CesiumInspector` toggles this. `FrameState` has been augmented to include `frustumSplits` which is a `Number[]` of the near/far planes of the camera frustums. * Enable rendering `GroundPrimitives` on hardware without the `EXT_frag_depth` extension; however, this could cause artifacts for certain viewing angles. * Always outline KML line extrusions so that they show up properly in 2D and other straight down views. diff --git a/Source/Widgets/Geocoder/GeocoderViewModel.js b/Source/Widgets/Geocoder/GeocoderViewModel.js index 6a7071c5a161..10f79073e980 100644 --- a/Source/Widgets/Geocoder/GeocoderViewModel.js +++ b/Source/Widgets/Geocoder/GeocoderViewModel.js @@ -1,26 +1,24 @@ /*global define*/ define([ - '../../Core/BingMapsApi', - '../../Core/BingMapsGeocoderService', - '../../Core/defaultValue', - '../../Core/defined', - '../../Core/defineProperties', - '../../Core/deprecationWarning', - '../../Core/DeveloperError', - '../../Core/Event', - '../../Core/CartographicGeocoderService', - '../../Core/Matrix4', - '../../ThirdParty/knockout', - '../../ThirdParty/when', - '../createCommand', - '../getElement' + '../../Core/BingMapsApi', + '../../Core/BingMapsGeocoderService', + '../../Core/defaultValue', + '../../Core/defined', + '../../Core/defineProperties', + '../../Core/DeveloperError', + '../../Core/Event', + '../../Core/CartographicGeocoderService', + '../../Core/Matrix4', + '../../ThirdParty/knockout', + '../../ThirdParty/when', + '../createCommand', + '../getElement' ], function( BingMapsApi, BingMapsGeocoderService, defaultValue, defined, defineProperties, - deprecationWarning, DeveloperError, Event, CartographicGeocoderService, @@ -263,34 +261,6 @@ define([ } defineProperties(GeocoderViewModel.prototype, { - /** - * Gets the Bing maps url. - * @deprecated - * @memberof GeocoderViewModel.prototype - * - * @type {String} - */ - url : { - get : function() { - deprecationWarning('url is deprecated', 'The url property was deprecated in Cesium 1.30 and will be removed in version 1.31.'); - return this._url; - } - }, - - /** - * Gets the Bing maps key. - * @deprecated - * @memberof GeocoderViewModel.prototype - * - * @type {String} - */ - key : { - get : function() { - deprecationWarning('key is deprecated', 'The key property was deprecated in Cesium 1.30 and will be removed in version 1.31.'); - return this._key; - } - }, - /** * Gets the event triggered on flight completion. * @memberof GeocoderViewModel.prototype diff --git a/Specs/Widgets/Geocoder/GeocoderSpec.js b/Specs/Widgets/Geocoder/GeocoderSpec.js index dc6bd8772caf..035fec463627 100644 --- a/Specs/Widgets/Geocoder/GeocoderSpec.js +++ b/Specs/Widgets/Geocoder/GeocoderSpec.js @@ -55,8 +55,8 @@ defineSuite([ var viewModel = geocoder.viewModel; expect(viewModel.scene).toBe(scene); expect(viewModel.flightDuration).toBe(flightDuration); - expect(viewModel.url).toBe(url); - expect(viewModel.key).toBe(key); + expect(viewModel._url).toBe(url); + expect(viewModel._key).toBe(key); geocoder.destroy(); }); diff --git a/Specs/Widgets/Geocoder/GeocoderViewModelSpec.js b/Specs/Widgets/Geocoder/GeocoderViewModelSpec.js index 861ec5a10a10..298ab8353fda 100644 --- a/Specs/Widgets/Geocoder/GeocoderViewModelSpec.js +++ b/Specs/Widgets/Geocoder/GeocoderViewModelSpec.js @@ -73,8 +73,8 @@ defineSuite([ expect(viewModel.scene).toBe(scene); expect(viewModel.flightDuration).toBe(flightDuration); - expect(viewModel.url).toBe(url); - expect(viewModel.key).toBe(key); + expect(viewModel._url).toBe(url); + expect(viewModel._key).toBe(key); expect(viewModel.keepExpanded).toBe(false); }); From fa93bbe2111cccae014dd22e01f346d9f5528d71 Mon Sep 17 00:00:00 2001 From: Sean Lilley Date: Wed, 1 Mar 2017 11:33:03 -0500 Subject: [PATCH 2/4] Update CHANGES.md --- CHANGES.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index ba5f208fe4c7..26471289abab 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -12,7 +12,7 @@ Change Log * Corrected spelling of `Color.FUCHSIA` from `Color.FUSCHIA`. [#4977](https://github.com/AnalyticalGraphicsInc/cesium/pull/4977) * The enums `MIDDLE_DOUBLE_CLICK` and `RIGHT_DOUBLE_CLICK` from `ScreenSpaceEventType` have been removed. [#5052](https://github.com/AnalyticalGraphicsInc/cesium/pull/5052) * Removed the function `GeometryPipeline.computeBinormalAndTangent`. Use `GeometryPipeline.computeTangentAndBitangent`. [#5053](https://github.com/AnalyticalGraphicsInc/cesium/pull/5053) - * Removed the `url` and `key` properties from `GeocoderViewModel`. + * Removed the `url` and `key` properties from `GeocoderViewModel`. [#5056](https://github.com/AnalyticalGraphicsInc/cesium/pull/5056) * Added support to `DebugCameraPrimitive` to draw multifrustum planes. The attribute `debugShowFrustumPlanes` of `Scene` and `frustumPlanes` of `CesiumInspector` toggles this. `FrameState` has been augmented to include `frustumSplits` which is a `Number[]` of the near/far planes of the camera frustums. * Enable rendering `GroundPrimitives` on hardware without the `EXT_frag_depth` extension; however, this could cause artifacts for certain viewing angles. * Always outline KML line extrusions so that they show up properly in 2D and other straight down views. From 5c2708d36c346166d37dda172bc15b01accf5dda Mon Sep 17 00:00:00 2001 From: hpinkos Date: Wed, 1 Mar 2017 12:09:54 -0500 Subject: [PATCH 3/4] remove url and key options from Geocoder --- CHANGES.md | 1 + Source/Core/BingMapsGeocoderService.js | 20 ++++++++++-- Source/Widgets/Geocoder/Geocoder.js | 8 ----- Source/Widgets/Geocoder/GeocoderViewModel.js | 31 +------------------ Specs/Core/BingMapsGeocoderServiceSpec.js | 23 ++++++++++++-- Specs/Widgets/Geocoder/GeocoderSpec.js | 8 +---- .../Widgets/Geocoder/GeocoderViewModelSpec.js | 8 +---- 7 files changed, 41 insertions(+), 58 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 26471289abab..c2ff4c44b9a2 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -13,6 +13,7 @@ Change Log * The enums `MIDDLE_DOUBLE_CLICK` and `RIGHT_DOUBLE_CLICK` from `ScreenSpaceEventType` have been removed. [#5052](https://github.com/AnalyticalGraphicsInc/cesium/pull/5052) * Removed the function `GeometryPipeline.computeBinormalAndTangent`. Use `GeometryPipeline.computeTangentAndBitangent`. [#5053](https://github.com/AnalyticalGraphicsInc/cesium/pull/5053) * Removed the `url` and `key` properties from `GeocoderViewModel`. [#5056](https://github.com/AnalyticalGraphicsInc/cesium/pull/5056) + * `BingMapsGeocoderServices` requires a options.scene paramaeter * Added support to `DebugCameraPrimitive` to draw multifrustum planes. The attribute `debugShowFrustumPlanes` of `Scene` and `frustumPlanes` of `CesiumInspector` toggles this. `FrameState` has been augmented to include `frustumSplits` which is a `Number[]` of the near/far planes of the camera frustums. * Enable rendering `GroundPrimitives` on hardware without the `EXT_frag_depth` extension; however, this could cause artifacts for certain viewing angles. * Always outline KML line extrusions so that they show up properly in 2D and other straight down views. diff --git a/Source/Core/BingMapsGeocoderService.js b/Source/Core/BingMapsGeocoderService.js index 7f9c4fc4ced8..168a5da6a8a4 100644 --- a/Source/Core/BingMapsGeocoderService.js +++ b/Source/Core/BingMapsGeocoderService.js @@ -25,12 +25,26 @@ define([ * @constructor * * @param {Object} options Object with the following properties: + * @param {String} options.scene The scene * @param {String} [options.key] A key to use with the Bing Maps geocoding service */ function BingMapsGeocoderService(options) { options = defaultValue(options, defaultValue.EMPTY_OBJECT); - this._url = 'https://dev.virtualearth.net/REST/v1/Locations'; - this._key = BingMapsApi.getKey(options.key); + //>>includeStart('debug', pragmas.debug); + if (!defined(options.scene)) { + throw new DeveloperError('options.scene is required.'); + } + //>>includeEnd('debug'); + + var key = options.key; + this._key = BingMapsApi.getKey(key); + + if (defined(key)) { + var errorCredit = BingMapsApi.getErrorCredit(key); + if (defined(errorCredit)) { + options.scene._frameState.creditDisplay.addDefaultCredit(errorCredit); + } + } } defineProperties(BingMapsGeocoderService.prototype, { @@ -42,7 +56,7 @@ define([ */ url : { get : function () { - return this._url; + return url; } }, diff --git a/Source/Widgets/Geocoder/Geocoder.js b/Source/Widgets/Geocoder/Geocoder.js index 2b42e86a2ccb..3d21be2dd4fd 100644 --- a/Source/Widgets/Geocoder/Geocoder.js +++ b/Source/Widgets/Geocoder/Geocoder.js @@ -34,14 +34,6 @@ define([ * @param {Scene} options.scene The Scene instance to use. * @param {GeocoderService[]} [options.geocoderServices] The geocoder services to be used * @param {Boolean} [options.autoComplete = true] True if the geocoder should query as the user types to autocomplete - * @param {String} [options.url='https://dev.virtualearth.net'] The base URL of the Bing Maps API. - * @param {String} [options.key] The Bing Maps key for your application, which can be - * created at {@link https://www.bingmapsportal.com}. - * If this parameter is not provided, {@link BingMapsApi.defaultKey} is used. - * If {@link BingMapsApi.defaultKey} is undefined as well, a message is - * written to the console reminding you that you must create and supply a Bing Maps - * key as soon as possible. Please do not deploy an application that uses - * this widget without creating a separate key for your application. * @param {Number} [options.flightDuration=1.5] The duration of the camera flight to an entered location, in seconds. */ function Geocoder(options) { diff --git a/Source/Widgets/Geocoder/GeocoderViewModel.js b/Source/Widgets/Geocoder/GeocoderViewModel.js index 10f79073e980..c12e42e7a8a9 100644 --- a/Source/Widgets/Geocoder/GeocoderViewModel.js +++ b/Source/Widgets/Geocoder/GeocoderViewModel.js @@ -1,6 +1,5 @@ /*global define*/ define([ - '../../Core/BingMapsApi', '../../Core/BingMapsGeocoderService', '../../Core/defaultValue', '../../Core/defined', @@ -14,7 +13,6 @@ define([ '../createCommand', '../getElement' ], function( - BingMapsApi, BingMapsGeocoderService, defaultValue, defined, @@ -39,14 +37,6 @@ define([ * @param {GeocoderService[]} [options.geocoderServices] Geocoder services to use for geocoding queries. * If more than one are supplied, suggestions will be gathered for the geocoders that support it, * and if no suggestion is selected the result from the first geocoder service wil be used. - * @param {String} [options.url='https://dev.virtualearth.net'] The base URL of the Bing Maps API. - * @param {String} [options.key] The Bing Maps key for your application, which can be - * created at {@link https://www.bingmapsportal.com}. - * If this parameter is not provided, {@link BingMapsApi.defaultKey} is used. - * If {@link BingMapsApi.defaultKey} is undefined as well, a message is - * written to the console reminding you that you must create and supply a Bing Maps - * key as soon as possible. Please do not deploy an application that uses - * this widget without creating a separate key for your application. * @param {Number} [options.flightDuration] The duration of the camera flight to an entered location, in seconds. */ function GeocoderViewModel(options) { @@ -61,29 +51,10 @@ define([ } else { this._geocoderServices = [ new CartographicGeocoderService(), - new BingMapsGeocoderService() + new BingMapsGeocoderService({scene: options.scene}) ]; } - var errorCredit; - this._url = defaultValue(options.url, 'https://dev.virtualearth.net/'); - if (this._url.length > 0 && this._url[this._url.length - 1] !== '/') { - this._url += '/'; - } - - this._key = BingMapsApi.getKey(options.key); - this._defaultGeocoderOptions = { - url: this._url, - key: this._key - }; - - if (defined(options.key)) { - errorCredit = BingMapsApi.getErrorCredit(options.key); - } - if (defined(errorCredit)) { - options.scene._frameState.creditDisplay.addDefaultCredit(errorCredit); - } - this._viewContainer = options.container; this._scene = options.scene; this._flightDuration = options.flightDuration; diff --git a/Specs/Core/BingMapsGeocoderServiceSpec.js b/Specs/Core/BingMapsGeocoderServiceSpec.js index 954bdca5504c..7543deb78d4c 100644 --- a/Specs/Core/BingMapsGeocoderServiceSpec.js +++ b/Specs/Core/BingMapsGeocoderServiceSpec.js @@ -2,14 +2,31 @@ defineSuite([ 'Core/BingMapsGeocoderService', 'Core/loadJsonp', - 'Core/Rectangle' + 'Core/Rectangle', + 'Specs/createScene' ], function( BingMapsGeocoderService, loadJsonp, - Rectangle) { + Rectangle, + createScene) { 'use strict'; - var service = new BingMapsGeocoderService(); + var service; + var scene; + beforeEach(function() { + scene = createScene(); + service = new BingMapsGeocoderService({scene: scene}); + }); + + afterEach(function() { + scene.destroyForSpecs(); + }); + + it('constructor throws without scene', function() { + expect(function() { + return new BingMapsGeocoderService(); + }).toThrowDeveloperError(); + }); it('returns geocoder results', function (done) { var query = 'some query'; diff --git a/Specs/Widgets/Geocoder/GeocoderSpec.js b/Specs/Widgets/Geocoder/GeocoderSpec.js index 035fec463627..affff0d4fbf2 100644 --- a/Specs/Widgets/Geocoder/GeocoderSpec.js +++ b/Specs/Widgets/Geocoder/GeocoderSpec.js @@ -41,22 +41,16 @@ defineSuite([ it('constructor sets expected properties', function() { var flightDuration = 1234; - var url = 'bing.invalid/'; - var key = 'testKey'; var geocoder = new Geocoder({ container : document.body, scene : scene, - flightDuration : flightDuration, - url : url, - key : key + flightDuration : flightDuration }); var viewModel = geocoder.viewModel; expect(viewModel.scene).toBe(scene); expect(viewModel.flightDuration).toBe(flightDuration); - expect(viewModel._url).toBe(url); - expect(viewModel._key).toBe(key); geocoder.destroy(); }); diff --git a/Specs/Widgets/Geocoder/GeocoderViewModelSpec.js b/Specs/Widgets/Geocoder/GeocoderViewModelSpec.js index 298ab8353fda..833f977b4886 100644 --- a/Specs/Widgets/Geocoder/GeocoderViewModelSpec.js +++ b/Specs/Widgets/Geocoder/GeocoderViewModelSpec.js @@ -61,20 +61,14 @@ defineSuite([ it('constructor sets expected properties', function() { var flightDuration = 1234; - var url = 'bing.invalid/'; - var key = 'testKey'; var viewModel = new GeocoderViewModel({ scene : scene, - flightDuration : flightDuration, - url : url, - key : key + flightDuration : flightDuration }); expect(viewModel.scene).toBe(scene); expect(viewModel.flightDuration).toBe(flightDuration); - expect(viewModel._url).toBe(url); - expect(viewModel._key).toBe(key); expect(viewModel.keepExpanded).toBe(false); }); From 67b66edad89fbc6f66d348ce58befa05289da956 Mon Sep 17 00:00:00 2001 From: Sean Lilley Date: Wed, 1 Mar 2017 13:00:13 -0500 Subject: [PATCH 4/4] Cleanup --- CHANGES.md | 2 +- Source/Core/BingMapsGeocoderService.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index c2ff4c44b9a2..4ac023a5b2ca 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -13,7 +13,7 @@ Change Log * The enums `MIDDLE_DOUBLE_CLICK` and `RIGHT_DOUBLE_CLICK` from `ScreenSpaceEventType` have been removed. [#5052](https://github.com/AnalyticalGraphicsInc/cesium/pull/5052) * Removed the function `GeometryPipeline.computeBinormalAndTangent`. Use `GeometryPipeline.computeTangentAndBitangent`. [#5053](https://github.com/AnalyticalGraphicsInc/cesium/pull/5053) * Removed the `url` and `key` properties from `GeocoderViewModel`. [#5056](https://github.com/AnalyticalGraphicsInc/cesium/pull/5056) - * `BingMapsGeocoderServices` requires a options.scene paramaeter + * `BingMapsGeocoderServices` now requires `options.scene`. [#5056](https://github.com/AnalyticalGraphicsInc/cesium/pull/5056) * Added support to `DebugCameraPrimitive` to draw multifrustum planes. The attribute `debugShowFrustumPlanes` of `Scene` and `frustumPlanes` of `CesiumInspector` toggles this. `FrameState` has been augmented to include `frustumSplits` which is a `Number[]` of the near/far planes of the camera frustums. * Enable rendering `GroundPrimitives` on hardware without the `EXT_frag_depth` extension; however, this could cause artifacts for certain viewing angles. * Always outline KML line extrusions so that they show up properly in 2D and other straight down views. diff --git a/Source/Core/BingMapsGeocoderService.js b/Source/Core/BingMapsGeocoderService.js index 168a5da6a8a4..e4130d8ed61a 100644 --- a/Source/Core/BingMapsGeocoderService.js +++ b/Source/Core/BingMapsGeocoderService.js @@ -17,7 +17,7 @@ define([ Rectangle) { 'use strict'; - var url = 'https://dev.virtualearth.net/REST/v1/Locations'; + var url = 'https://dev.virtualearth.net/REST/v1/Locations'; /** * Provides geocoding through Bing Maps.