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
Improve name fallback for GeoJSON #11633
Comments
Thanks for the proposal @mfarmer-ara! It looks like there is no defined behavior for this detailed in the GeoJSON spec. So we should be free to add additional behavior as needed, as long as it is documented. Can you explain more what you mean by the "next" key? In JavaScript, object properties do not have a guaranteed order.
|
It seems like the order Cesium will loop through the keys in that linked function is dependent on the original order it is in the file (observation not guaranteed). So, while it doesn't really matter what order the keys are in usually, since it appears their order is kept based on the original file, that function will return what it thinks is the best name based on the order they're lopped through. Though now I'm confusing myself with the precedence that's in that function. I may play around with this today/tomorrow to see if I can pin things down. |
@ggetz I'm still poking at this, but it looks like my example files might have been too simple. I am not able to make it happen with my simpler files but a geojson file with a polygon with 212 points (x,y,z) is consistently saying name (properties.title) is defined and skipping the extra property check. Since I am not sure I can share that one, I made a crazy shape with geojson.io with a similar number of points. My tests were bad but in the sort of I was tricking myself way. I've figured out a way around this and will put a PR up that will hopefully work for eveyr Keeping below, but I had an error in my testing files where title was set to be Dragging and dropping this with the -- putting
Files shared earlier (simple shape) |
Sorry for the extra comments while I explored this issue. The fix I've looked is to simply check if title is empty next to the defined() check for GeoJSON data sources. With only title (no name or includes name/title keys) present and title equal to empty string, the below behavior happens. Is that fine? It behaves just as if title didn't exist at all. |
This seems in line with expect behavior, yes. |
We have files that are generated with empty title and descriptions, but a filled key called
country-name
.Eg:
The GeoJsonDataSource file loops through and attempts to figure out what name property to use. If
country-name
comes before title, it uses that, but if it comes after it assumes title, which is empty.Current behavior:
https://github.com/CesiumGS/cesium/blob/main/packages/engine/Source/DataSources/GeoJsonDataSource.js#L151C11-L164
Is it possible/would it be ok to add an additional check to:
The preferred behavior is to show
x-name
even if it shows up after an empty title but only if the title is empty.The text was updated successfully, but these errors were encountered: