-
Notifications
You must be signed in to change notification settings - Fork 10
feature_info_service handlePointZ in geomcentroid #20
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
feature_info_service handlePointZ in geomcentroid #20
Conversation
src/feature_info_service.py
Outdated
| for i, c in enumerate(gj["coordinates"]): gj["coordinates"][i] = c[:2] | ||
| geometry = wkt.dumps({ | ||
| "type": "Point", | ||
| "coordinates": geom_center(gj["type"], gj["coordinates"]) |
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 about just doing
"coordinates": geom_center(gj["type"], gj["coordinates"])[0:2]
here?
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.
@manisandro I think that won't work for Mulitpoint, where the coords are in an array like [[2534804.731, 1154040.505]]. So it would send the first two Positions of the Mulitpoint. But I had to add a upper() to match geometry type.
If we want to sent all geometries correct to the geom_center function, I could add a geom_to_2d function to utils. So all the Z-coordinates will be removed. Also from polygons and points.
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.
Uhm, geom_center should always return a single coordinate (and is type: Point)?
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.
Yes the geom_center returns type point. For PointZ and MultipointZ it returns a 3D coordinate. So the type = Point and the coordinates 3D doesn't match. That brings other functions in the qwc2 to fail. When we do this
gj = wkt.loads(geometry.upper().replace('Z', ''))
we produce incorrect geometries, because type will not match the coordinates dimensions. Correct would be to remove Z and the corresponding coordinate value. Or we accept the incorrect geometry and just handle the case for pointZ and MultipointZ where qwc2 will fail later on.
Another option would be to fix it here: https://github.com/qwc-services/qwc-feature-info-service/blob/0ada216f1b2551d7c49a89d7b105c3b4f04474e6/src/utils.py#L6C4-L7C27
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.
Yes this is clear. Hence
geometry = wkt.dumps({
"type": "Point",
"coordinates": geom_center(gj["type"], gj["coordinates"])[0:2]
})
should ensure always a 2D point is returned?
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.
Ahh the [0:2] is outside the geomcenter and handling the response. Then you are right, sorry I tested "coordinates": geom_center(gj["type"], gj["coordinates"][0:2])
So yes, this is working. I change my PR
|
Thanks! |
|
thank you :-) |
This should fix the issue here: qgis/qwc2#525