-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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 all 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 |
---|---|---|
|
@@ -8,6 +8,7 @@ define([ | |
'../Core/Resource', | ||
'../Core/WebMercatorProjection', | ||
'./GetFeatureInfoFormat', | ||
'./TimeDynamicImagery', | ||
'./UrlTemplateImageryProvider' | ||
], function( | ||
defaultValue, | ||
|
@@ -19,6 +20,7 @@ define([ | |
Resource, | ||
WebMercatorProjection, | ||
GetFeatureInfoFormat, | ||
TimeDynamicImagery, | ||
UrlTemplateImageryProvider) { | ||
'use strict'; | ||
|
||
|
@@ -59,6 +61,8 @@ 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. | ||
* | ||
* @see ArcGisMapServerImageryProvider | ||
* @see BingMapsImageryProvider | ||
|
@@ -93,7 +97,12 @@ define([ | |
} | ||
//>>includeEnd('debug'); | ||
|
||
if (defined(options.times) && !defined(options.clock)) { | ||
throw new DeveloperError('options.times was specified, so options.clock is required.'); | ||
} | ||
|
||
var resource = Resource.createIfNeeded(options.url); | ||
|
||
var pickFeatureResource = resource.clone(); | ||
|
||
resource.setQueryParameters(WebMapServiceImageryProvider.DefaultParameters, true); | ||
|
@@ -107,6 +116,23 @@ define([ | |
pickFeatureResource.setQueryParameters(objectToLowercase(options.getFeatureInfoParameters)); | ||
} | ||
|
||
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(); | ||
} | ||
} | ||
}); | ||
} | ||
|
||
var parameters = {}; | ||
parameters.layers = options.layers; | ||
parameters.bbox = '{westProjected},{southProjected},{eastProjected},{northProjected}'; | ||
|
@@ -157,6 +183,28 @@ 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 tileProvider = imageryProvider._tileProvider; | ||
|
||
if (defined(dynamicIntervalData)) { | ||
// We set the query parameters within the tile provider, because it is managing the query. | ||
tileProvider._resource.setQueryParameters(dynamicIntervalData); | ||
} | ||
return tileProvider.requestImage(col, row, level, request); | ||
} | ||
|
||
function pickFeatures(imageryProvider, x, y, level, longitude, latitude, interval) { | ||
var dynamicIntervalData = defined(interval) ? interval.data : undefined; | ||
var tileProvider = imageryProvider._tileProvider; | ||
|
||
if (defined(dynamicIntervalData)) { | ||
// We set the query parameters within the tile provider, because it is managing the query. | ||
tileProvider._pickFeaturesResource.setQueryParameters(dynamicIntervalData); | ||
} | ||
return tileProvider.pickFeatures(x, y, level, longitude, latitude); | ||
} | ||
|
||
defineProperties(WebMapServiceImageryProvider.prototype, { | ||
/** | ||
* Gets the URL of the WMS server. | ||
|
@@ -371,6 +419,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; | ||
} | ||
} | ||
}); | ||
|
||
|
@@ -404,7 +481,28 @@ 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; | ||
|
||
// 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; | ||
|
||
}; | ||
|
||
/** | ||
|
@@ -423,7 +521,10 @@ define([ | |
* @exception {DeveloperError} <code>pickFeatures</code> must not be called before the imagery provider is ready. | ||
*/ | ||
WebMapServiceImageryProvider.prototype.pickFeatures = function(x, y, level, longitude, latitude) { | ||
return this._tileProvider.pickFeatures(x, y, level, longitude, latitude); | ||
var timeDynamicImagery = this._timeDynamicImagery; | ||
var currentInterval = defined(timeDynamicImagery) ? timeDynamicImagery.currentInterval : undefined; | ||
|
||
return pickFeatures(this, x, y, level, longitude, latitude, currentInterval); | ||
}; | ||
|
||
/** | ||
|
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.
Remove extra blank line.