Skip to content
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

WMTS support for time-dynamic and static dimensions #5542

Closed
wants to merge 43 commits into from
Closed

Conversation

tfili
Copy link
Contributor

@tfili tfili commented Jun 27, 2017

TO DO:

  • Needs Refresh imagery provider #5536 to be merged first
  • Unit tests for WebMapTileServiceImageryProvider class
  • Unit tests for TimeDynamicImagery class
  • Cleanup Sandcastle example

Tom Fili added 30 commits June 8, 2017 15:05
@pjcozzi
Copy link
Contributor

pjcozzi commented Jun 27, 2017

@kring any chance you could look at this in addition to #5536?

I can do a quick review for the standard stuff but it would be good for someone more familiar to also look at this.

@@ -0,0 +1,95 @@
<!DOCTYPE html>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a thumbnail for this one.

Copy link
Contributor

@pjcozzi pjcozzi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only quickly looked at it, just trivial comments.

At quick glance, the profile for the Sandcastle example looked pretty good. Other than all the textures, do you have any performance or memory concerns?

times: times1
}));

viewer.clock.multiplier = 14400;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps make this quite a bit faster so it is almost as fast as a video - it shows better and seems to run fine.

* @param {TimeIntervalCollection} [result] An existing instance to use for the result.
* @returns {TimeIntervalCollection} The modified result parameter or a new instance if none was provided.
*/
TimeIntervalCollection.fromJulianDateArray = function(options, result) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update CHANGES.md throughout.

}

return {
Time: time
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be pascal case? Or is this specific to the server?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's specific to the server. It has to match their dimension name.

};

var scratchGregorianDate = new GregorianDate();
var monthLengths = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it worth freezing this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you notice I change February's length each iteration of the loop where its used, so it can't be frozen.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does it really mean to add "4 Jan 2008" to "12 Aug 2017" or am I missing something?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the duration parameter is of type gregorian date, but is just really a duration. For instance for something like 2017-01-04/2017-06-28/P1D, we use this function to add 1 day to the julianDate parameter. The duration parameter would have all values of 0, except day would be 1. Durations can also be specified in date formats (where P1D could be written as 0000-00-01), so it just simplified the parsing.

var year = scratchGregorianDate.year + duration.year;

if (millisecond >= 1000) {
second += Math.floor(millisecond/1000);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whitespace here, below, and maybe throughout.

};

/**
* Checks if the next interval is approaching and will start preload the tile if necessary. Otherwise it will
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"to preload"

// We keep prefetching until we hit a throttling limit.
var tilesRequested = this._tilesRequestedForInterval;
var success = true;
do {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just while(success); success is already true here.

@@ -49,6 +55,9 @@ define([
* @param {String} options.style The style name for WMTS requests.
* @param {String} options.tileMatrixSetID The identifier of the TileMatrixSet to use for WMTS requests.
* @param {Array} [options.tileMatrixLabels] A list of identifiers in the TileMatrix to use for WMTS requests, one per TileMatrix level.
* @param {Clock} [options.clock] A Clock instance that is used when determining the value for the time dimension. Required when options.times is specified.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this link to the Sandcastle example and include an @example?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nowhere else in Cesium to we link to a Sandcastle example in the jsdoc as far as I can tell. Do we want to link to the public cesiumjs.org Sandcastle or to a localhost link?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Search for @demo we have links all over the place.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. I was searching for @link and @example.

};

/**
*
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fill this out or remove it.

<script id="cesium_sandcastle_script">
function startup(Cesium) {
'use strict';
//Sandcastle_Begin
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there anything we can do about these console warnings in the Sandcastle example?


Sandcastle-client.js:22 An error occurred in "WebMapTileServiceImageryProvider": Failed to obtain image tile X: 3 Y: 5 Level: 3.
Sandcastle-client.js:22 An error occurred in "WebMapTileServiceImageryProvider": Failed to obtain image tile X: 0 Y: 3 Level: 2.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. This server has missing tiles. If you look at the Capabilities file you see

      <TileMatrix>
        <ows:Identifier>0</ows:Identifier>
        <ScaleDenominator>223632905.6114871</ScaleDenominator>
        <TopLeftCorner>-180 90</TopLeftCorner>
        <TileWidth>512</TileWidth>
        <TileHeight>512</TileHeight>
        <MatrixWidth>2</MatrixWidth>
        <MatrixHeight>1</MatrixHeight>
      </TileMatrix>
      <TileMatrix>
        <ows:Identifier>1</ows:Identifier>
        <ScaleDenominator>111816452.8057436</ScaleDenominator>
        <TopLeftCorner>-180 90</TopLeftCorner>
        <TileWidth>512</TileWidth>
        <TileHeight>512</TileHeight>
        <MatrixWidth>3</MatrixWidth>
        <MatrixHeight>2</MatrixHeight>
      </TileMatrix>
      <TileMatrix>
        <ows:Identifier>2</ows:Identifier>
        <ScaleDenominator>55908226.40287178</ScaleDenominator>
        <TopLeftCorner>-180 90</TopLeftCorner>
        <TileWidth>512</TileWidth>
        <TileHeight>512</TileHeight>
        <MatrixWidth>5</MatrixWidth>
        <MatrixHeight>3</MatrixHeight>
      </TileMatrix>
      <TileMatrix>
        <ows:Identifier>3</ows:Identifier>
        <ScaleDenominator>27954113.20143589</ScaleDenominator>
        <TopLeftCorner>-180 90</TopLeftCorner>
        <TileWidth>512</TileWidth>
        <TileHeight>512</TileHeight>
        <MatrixWidth>10</MatrixWidth>
        <MatrixHeight>5</MatrixHeight>
      </TileMatrix>

Level 0 has the correct 2 columns, 1 row, so Level 1 should have 4 columns and 2 rows but instead has 3 columns and 2 rows. You'll see that the errors you get at Level 2 and 3 don't exist either. It's always been a problem with WMTS, but its server dependent. So we would probably need to make another tiling scheme or allow WebMercator to parse this and handle accordingly. Regardless its out of the scope if this PR.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK.

@tfili
Copy link
Contributor Author

tfili commented Jun 28, 2017

Ok, this should be good to go for another review, then just waiting on #5536 to be merged.

CHANGES.md Outdated
@@ -20,6 +20,7 @@ Change Log
* Added a particle system for effects like smoke, fire, sparks, etc. See `ParticleSystem`, `Particle`, `ParticleBurst`, `BoxEmitter`, `CircleEmitter`, `ConeEmitter`, `ParticleEmitter`, and `SphereEmitter`, and the new Sandcastle examples: `Particle System` and `Particle System Fireworks`. [#5212](https://github.com/AnalyticalGraphicsInc/cesium/pull/5212)
* Added an `options.request` parameter to `loadWithXhr` and a `request` parameter to `loadArrayBuffer`, `loadBlob`, `loadImageViaBlob`, `loadText`, `loadJson`, `loadJsonp`, `loadXML`, `loadImageFromTypedArray`, `loadImage`, `loadCRN`, and `loadKTX`.
* `CzmlDataSource` and `KmlDataSource` load functions now take an optional `query` object, which will append query parameters to all network requests. [#5419](https://github.com/AnalyticalGraphicsInc/cesium/pull/5419), [#5434](https://github.com/AnalyticalGraphicsInc/cesium/pull/5434)
* Added `fromIso8601`, `fromIso8601DateArray`, and `fromIso8601DurationArray` to `TimeIntervalCollection` for handling various ways groups of intervals can be specified in ISO8601 format.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's more public-facing API changes, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep. Added one and must have got side tracked. Should be updated now.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

defineProperties(TimeDynamicImagery.prototype, {
/**
* Gets or sets a clock that is used to get keep the time used for time dynamic parameters.
* @memberof WebMapTileServiceImageryProvider.prototype
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be TimeDynamicImagery.prototype

return this._clock;
},
set : function(value) {
if (this._clock !== value) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These setters should check that the values are defined.

}

var seconds;
var index = times.indexOf(time);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it worth taking advantage of temporal coherence here? The index of the current time is more likely to be in the current , next or previous interval. Could save the linear search.

var index = that._times.indexOf(interval.start);
var tileCache = that._tileCache;
if (!defined(tileCache[index])) {
tileCache[index] = {};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We usually store these in locals to prevent the look ups. So:

var tileTimeCache = tileCache[index];
if (!defined(tileTimeCache)) {
    tileTimeCache = tileCache[index] = {};
    // ...

And use tileTimeCache everywhere else.

var labels = imageryProvider._tileMatrixLabels;
var tileMatrix = defined(labels) ? labels[level] : level.toString();
var subdomains = imageryProvider._subdomains;
var url;
var url, key;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Put these on separate lines.

@bagnell
Copy link
Contributor

bagnell commented Jun 30, 2017

Looks good, just those minor comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants