-
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
Allow promise to url for Cesium terrain, 3d tiles and TMS imagery #6204
Conversation
…mageryProvider and Cesium3DTileset
@hpinkos, thanks for the pull request! Maintainers, we have a signed CLA from @hpinkos, so you can review this at any time.
I am a bot who helps you make Cesium awesome! Contributions to my configuration are welcome. 🌍 🌎 🌏 |
var metadataError; | ||
|
||
var layers = this._layers = []; | ||
var attribution = ''; | ||
var overallAvailability = []; | ||
when(options.url) |
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.
If options.url rejects, this will fail silently, don't we need to move this entire block into requestMetadata
itself? Also, request Metadata is using old (improper) promise usage, change the success and failure functions off of this promise when you move it.
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.
What do you want the behavior to be when options.url
rejects? I don't think calling metadataFailure
is the right option because it will still try to load the tileset even if fetching the metadata fails. And we literally can't to anything with the URL.
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.
Good point, I assume we want to just propagate the url
rejection to the readyPromise
so that it rejects. This way a user gets the exact error.
var deferred = when.defer(); | ||
var imageryProvider = new UrlTemplateImageryProvider(deferred.promise); | ||
|
||
var metadataError; | ||
var resource; | ||
var xmlResource; | ||
when(options.url) |
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.
Similar comment to CesiumTerrainProvider regarding failure and requestMetadata.
Please add unit tests for the rejection use cases. |
That's all of the comments I have. This approach looks like exactly what I had in mind. Thanks @hpinkos! |
@mramato this should be ready now |
Source/Core/CesiumTerrainProvider.js
Outdated
requestMetadata(); | ||
}) | ||
.otherwise(function() { | ||
deferred.reject(new RuntimeError('An error occurred while loading options.url')); |
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.
Rather than providing our own error here, do deferred.reject(e)
where e
is the argument to otherwise
(which you left out in this case). Same comment in createTileMapServiceXXX function
Update CHANGES. Just those two comments. I'm fine with merging this and updating other providers later (unless you have time/desire to update them all now). |
@mramato ready |
Thanks, I'll merge as soon as this is green. |
@mramato
I looked into adding this functionality to some of the other terrain and imagery providers, but some are a bit more complicated than others. I figured I'd start with these types and open up another PR with the others if this approach is what we want.