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

EllipsoidTerrainProvider does not conform to the TerrainProvider interface #12485

Open
angrycat9000 opened this issue Feb 19, 2025 · 4 comments

Comments

@angrycat9000
Copy link
Contributor

What happened?

TerrainProvider has availablity defined as TileAvailablity.

* @type {TileAvailability}

However EllipsoidTerrainProvider returns undefined for availabilty. This does not satisfy TileAvailabity

Found this because sampleHeightsMostDetailed takes a TerrainProvider but throws an error if EllipsoidTerrainProvider is passed.

In the app I was working with the terrain provider may change based on user input. So there isn't a good way to have a single code path that gets the most detailed height. Had to put in a check to to see if the current terrain provider was in instance of EllipsoidTerrainProvider before calling sampleHeightsMostDetailed

Reproduction steps

No response

Sandcastle example

No response

Environment

No response

@ggetz
Copy link
Contributor

ggetz commented Feb 20, 2025

@angrycat9000 I think this is expected, as sampleTerrainMostDetailed does explicitly check for this condition.

If we can agree on that, then the fix here is that @type {TileAvailability} should be @type {TileAvailability|undefined} .

@ggetz ggetz added category - doc good first issue An opportunity for first time contributors and removed needs triage labels Feb 20, 2025
@angrycat9000
Copy link
Contributor Author

angrycat9000 commented Feb 20, 2025

@angrycat9000 I think this is expected, as sampleTerrainMostDetailed does explicitly check for this condition.

For consumers who know the implementation details. For a consumer just reading the documentation, passing EllipsoidTerrainProvider to sampleTerrainMostDetailed appears perfectly valid.

If we can agree on that, then the fix here is that type {TileAvailability} should be type {TileAvailability|undefined} .

That still leaves the case where sampleTerrainMostDetailed takes a TerrainProvider but only some implementations of that interface.

I would like to see the type interfaces / documentation to accurately reflect the implementation logic so there are fewer special situations where the consumer has to read the implementation to use the function. That makes it easier for consumers.

There could be a number of ways to acheive this. Haven't dug that deep into the code to know which is the best effort to value ratio.

  • EllipsoidTerrainProvider has an availabilty that always returns true for isTileAvailable
  • sampleTerrainHeightMostDetailed has a special case that for EllipsoidTerrainProvider that just returns height = 0
    • Does it even need that if it just provides an availabilty?
  • Have a class hiearchy ofTerrainProvider -> TileBasedTerrainProvider and sampleTerrainMostDetailed only takes a TileBasedTerrainProvider to eliminate the possibilty of EllipsoidTerrainProvider not being passed to sampleTerrainMostDetailed
  • Update the documentation to indicate that sampleTerrainMostDetailed will throw for EllipsoidTerrainProvider

@ggetz ggetz added category - architecture / api and removed good first issue An opportunity for first time contributors labels Feb 20, 2025
@ggetz
Copy link
Contributor

ggetz commented Feb 20, 2025

@angrycat9000 To confirm, we are talking about sampleTerrainMostDetailed here, not Scene.sampleHeightMostDetailed correct?

Scene.sampleHeightMostDetailed does not take any TerrainProvider arguments, nor would it need to based on how its implemented.

@angrycat9000
Copy link
Contributor Author

@angrycat9000 To confirm, we are talking about sampleTerrainMostDetailed here, not Scene.sampleHeightMostDetailed correct?

Yes, sorry for the confusion. Edited to clarify

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

No branches or pull requests

2 participants