Skip to content

Conversation

@rsrg-zwiama
Copy link
Contributor

This should fix the issue here: qgis/qwc2#525

for i, c in enumerate(gj["coordinates"]): gj["coordinates"][i] = c[:2]
geometry = wkt.dumps({
"type": "Point",
"coordinates": geom_center(gj["type"], gj["coordinates"])
Copy link
Member

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?

Copy link
Contributor Author

@rsrg-zwiama rsrg-zwiama Nov 11, 2025

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.

Copy link
Member

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)?

Copy link
Contributor Author

@rsrg-zwiama rsrg-zwiama Nov 11, 2025

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

Copy link
Member

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?

Copy link
Contributor Author

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

@manisandro manisandro merged commit 09704b6 into qwc-services:master Nov 11, 2025
1 check passed
@manisandro
Copy link
Member

Thanks!

@rsrg-zwiama
Copy link
Contributor Author

thank you :-)

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants