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

Improvements for writing GeoJson for GML with nested geometries #1765

Merged
merged 2 commits into from
Jan 8, 2025

Conversation

stempler
Copy link
Member

@stempler stempler commented Dec 9, 2024

These changes are related to issues we encountered specifically with GetFeatureInfo requests for INSPIRE Governmental Services data using GeoJson format. The solution probably also covers other GML application schemas with a similar structure for defining geometries.

For these cases the WMS would yield an internal error without helpful message as result for the GFI request.
In the logs error messages similar to this would show up:

java.lang.IllegalStateException: Dangling name: serviceLocationByGeometry

The first commit attempts to solve this problem, by not writing the incomplete Json field, which before resulted in the shown error, as no value was written for the field.

The second commit attempts to retrieve the geometry properties in such a schema (previously it would not identify them), so when the GFI is requested including geometries, they can be included instead of having a null value for the geometry. This has the same restriction as before, that if there are multiple geometries the GeoJson representation can't handle this.

Because geometries are not exported as part of the properties, the
behavior so far when encountering one while exporting the properties was
to ignore it. But this caused problems, as the property name was already
written.
Refactored to check for a geometry property before the property name is
written.
...in case no geometry properties are found with the normal mechanism
checking only the main properties.
@tfr42 tfr42 added this to the 3.6 milestone Dec 18, 2024
@tfr42 tfr42 added enhancement enhancement or improvement WFS deegree Web Feature Service WMS deegree Web Map Service and removed WFS deegree Web Feature Service labels Dec 18, 2024
// geometry was exported before
// need to throw an exception here, because if we do nothing the Json is
// invalid (condition should be handled before)
throw new IOException("Geometry should not be rendered as part of GeoJson properties.");
Copy link
Member

Choose a reason for hiding this comment

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

Can you please explain why do you see the need to throw an exception here or is it intended to prevent misuse of the API here? Does throwing the exception stops the generation of the GFI GeoJSON output?

Copy link
Member Author

Choose a reason for hiding this comment

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

This code should not be reached, the exception is thrown to raise a failure if it does happen nonetheless.

If such a case occurs and the behavior here would be as before, doing nothing, no valid Json would be created and the process would fail with the "Dangling name" exception mentioned in the PR description, because there would be a Json field w/o a value.

So the behavior would be similar, just a different exception.

Now we catch that case earlier though to prevent the field from being written at all and thus to prevent the exception.

The intention here seemed clearly to not export the geometry again, so I guess only other alternative would be creating a null value for the field or an empty object. Depends on what is preferable - I went for omitting the field in that case.

Copy link
Member

@tfr42 tfr42 Jan 8, 2025

Choose a reason for hiding this comment

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

@stempler Thanks for the explanation. Would it be possible that you provide a workspace with a example data set to verify the behaviour in an integration test?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think the added unit tests in GeoJsonFeatureWriterTest already cover the issue and fix quite well.
The data used in the unit tests could be used in test workspaces as well I guess. Do you have an example of a similar integration test like what you have in mind?

@tfr42
Copy link
Member

tfr42 commented Dec 18, 2024

Thank you for your contribution. Your pull request has been discussed by the TMC 2024-12-18. Please see the following remarks from the TMC members inline.
You are welcome to join the next TMC meeting in 2025.

@stephanr stephanr merged commit cbb9ceb into deegree:main Jan 8, 2025
1 check passed
@stempler stempler deleted the fix/govserv-geojson branch January 10, 2025 09:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement enhancement or improvement WMS deegree Web Map Service
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants