-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding support for WMS-T Time parameter to WebMapServiceImageryProvider #6348
Changes from 7 commits
9bd6f5c
9773587
eed558c
cc7d7c5
e3e47ba
7b9c87f
78381d8
24b88cb
19b0d31
b8648f1
d7e2863
3b5b340
08b64b6
42ba843
9501620
2e0327c
d4ca1aa
34a99a1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ define([ | |
'../Core/WebMercatorTilingScheme', | ||
'../ThirdParty/Uri', | ||
'./GetFeatureInfoFormat', | ||
'./TimeDynamicImagery', | ||
'./UrlTemplateImageryProvider' | ||
], function( | ||
combine, | ||
|
@@ -29,7 +30,8 @@ define([ | |
WebMercatorTilingScheme, | ||
Uri, | ||
GetFeatureInfoFormat, | ||
UrlTemplateImageryProvider) { | ||
TimeDynamicImagery, | ||
UrlTemplateImageryProvider ) { | ||
'use strict'; | ||
|
||
/** | ||
|
@@ -69,6 +71,9 @@ define([ | |
* @param {String|String[]} [options.subdomains='abc'] The subdomains to use for the <code>{s}</code> placeholder in the URL template. | ||
* If this parameter is a single string, each character in the string is a subdomain. If it is | ||
* an array, each element in the array is a subdomain. | ||
* @param {Clock} [options.clock] A Clock instance that is used when determining the value for the time dimension. Required when options.times is specified. | ||
* @param {TimeIntervalCollection} [options.times] TimeIntervalCollection with its data property being an object containing time dynamic dimension and their values. | ||
* | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove extra blank line. |
||
* | ||
* @see ArcGisMapServerImageryProvider | ||
* @see BingMapsImageryProvider | ||
|
@@ -103,6 +108,10 @@ define([ | |
} | ||
//>>includeEnd('debug'); | ||
|
||
if (defined(options.times) && !defined(options.clock)) { | ||
throw new DeveloperError('options.times was specified, so options.clock is required.'); | ||
} | ||
|
||
if (defined(options.proxy)) { | ||
deprecationWarning('WebMapServiceImageryProvider.proxy', 'The options.proxy parameter has been deprecated. Specify options.url as a Resource instance and set the proxy property there.'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This deprecation was removed in the master for our release next week. |
||
} | ||
|
@@ -113,6 +122,29 @@ define([ | |
|
||
var pickFeatureResource = resource.clone(); | ||
|
||
var that = this; | ||
this._reload = undefined; | ||
if (defined(options.times)) { | ||
this._timeDynamicImagery = new TimeDynamicImagery({ | ||
clock : options.clock, | ||
times : options.times, | ||
requestImageFunction : function(x, y, level, request, interval) { | ||
return requestImage(that, x, y, level, request, interval); | ||
}, | ||
reloadFunction : function() { | ||
if (defined(that._reload)) { | ||
that._reload(); | ||
} | ||
} | ||
}); | ||
} | ||
|
||
if (defined(options.clock)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The user can pass any parameters they want, but in this case we are building a time parameter out of the time intervals / clock information. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have made changes, but I still get the current time from the clock and create a time parameter if it does not exist in the parameters from the interval. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We shouldn't be hard coding that |
||
if (defined(options.parameters)) { | ||
options.parameters['time'] = options.clock.currentTime.toString(); | ||
} | ||
} | ||
|
||
resource.setQueryParameters(WebMapServiceImageryProvider.DefaultParameters, true); | ||
pickFeatureResource.setQueryParameters(WebMapServiceImageryProvider.GetFeatureInfoDefaultParameters, true); | ||
|
||
|
@@ -174,6 +206,33 @@ define([ | |
}); | ||
} | ||
|
||
function requestImage(imageryProvider, col, row, level, request, interval) { | ||
var dynamicIntervalData = defined(interval) ? interval.data : undefined; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Following the Cesium style guidelines we save off any properties accessed more than once in the same function. Here for instance we would do something like the following because var tileProvider = imageryProvider._tileProvider;
if (defined(dynamicIntervalData)) {
tileProvider._resource.setQueryParameters(dynamicIntervalData);
}
return tileProvider.requestImage(col, row, level, request); Also modifying |
||
var resource = imageryProvider._tileProvider._resource; // We actually want to set the time parameter within the tile provider. | ||
var parameters = {}; | ||
var keys = []; | ||
if (defined(dynamicIntervalData)) { | ||
if (dynamicIntervalData instanceof Object){ | ||
try { | ||
Object.keys(dynamicIntervalData).forEach(function (key, index) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is just copying |
||
parameters[key] = dynamicIntervalData[key]; | ||
keys.push(key.toLowerCase()); | ||
}); | ||
} catch (err){ | ||
// Warn the user, this may not be a problem | ||
console.warn('Data from interval has problems.', err); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In Cesium we don't output errors to the console if its a error by the developer. We occasionally use it if there is an error from a remote server. You can search for DeveloperError to see how we use it and also remove it from the minified build. Although I anticipate that this try/catch will go away. |
||
} | ||
} | ||
} | ||
if (!('time' in keys)){ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be removed like above. |
||
// Get the time from the clock if a value was not provided in the data from the interval. | ||
parameters['time'] = imageryProvider.clock.currentTime; | ||
} | ||
resource.setQueryParameters(parameters); | ||
|
||
return imageryProvider._tileProvider.requestImage(col, row, level, request); | ||
} | ||
|
||
defineProperties(WebMapServiceImageryProvider.prototype, { | ||
/** | ||
* Gets the URL of the WMS server. | ||
|
@@ -388,6 +447,35 @@ define([ | |
set : function(enablePickFeatures) { | ||
this._tileProvider.enablePickFeatures = enablePickFeatures; | ||
} | ||
}, | ||
|
||
/** | ||
* Gets or sets a clock that is used to get keep the time used for time dynamic parameters. | ||
* @memberof WebMapServiceImageryProvider.prototype | ||
* @type {Clock} | ||
*/ | ||
clock : { | ||
get : function() { | ||
return this._timeDynamicImagery.clock; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I know this is already merged, but there's a bug here. If |
||
}, | ||
set : function(value) { | ||
this._timeDynamicImagery.clock = value; | ||
} | ||
}, | ||
/** | ||
* Gets or sets a time interval collection that is used to get time dynamic parameters. The data of each | ||
* TimeInterval is an object containing the keys and values of the properties that are used during | ||
* tile requests. | ||
* @memberof WebMapServiceImageryProvider.prototype | ||
* @type {TimeIntervalCollection} | ||
*/ | ||
times : { | ||
get : function() { | ||
return this._timeDynamicImagery.times; | ||
}, | ||
set : function(value) { | ||
this._timeDynamicImagery.times = value; | ||
} | ||
} | ||
}); | ||
|
||
|
@@ -421,7 +509,32 @@ define([ | |
* @exception {DeveloperError} <code>requestImage</code> must not be called before the imagery provider is ready. | ||
*/ | ||
WebMapServiceImageryProvider.prototype.requestImage = function(x, y, level, request) { | ||
return this._tileProvider.requestImage(x, y, level, request); | ||
var result; | ||
var timeDynamicImagery = this._timeDynamicImagery; | ||
var currentInterval; | ||
|
||
if (!defined(timeDynamicImagery)){ | ||
return this._tileProvider.requestImage(x, y, level, request); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be |
||
} | ||
|
||
// Try and load from cache | ||
if (defined(timeDynamicImagery)) { | ||
currentInterval = timeDynamicImagery.currentInterval; | ||
result = timeDynamicImagery.getFromCache(x, y, level, request); | ||
} | ||
|
||
// Couldn't load from cache | ||
if (!defined(result)) { | ||
result = requestImage(this, x, y, level, request, currentInterval); | ||
} | ||
|
||
// If we are approaching an interval, preload this tile in the next interval | ||
if (defined(result) && defined(timeDynamicImagery)) { | ||
timeDynamicImagery.checkApproachingInterval(x, y, level, request); | ||
} | ||
|
||
return result; | ||
|
||
}; | ||
|
||
/** | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix white space