-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Add support for Z/M geometries in WFS #24994
Comments
I was just testing this with QGIS LTR 3.4.8 and WFS GetFeature request returns geometries with Z value, so this is cool. I tested PointZ and LineStringZ types. You have to use version 1.1.0. On another side, testing WFS create and update transaction with sending 3D geometries, does not work. I ended up with Z coordinate value 0. Briefly looking at that part of code https://github.com/qgis/QGIS/blob/master/src/core/qgsogcutils.cpp I see its just working with plain 2d x,y coordinates. |
This has not been developed yet. I believe it's not so simple task and there is some work required from core developer, like @elpaso to support this. I will post here my PostgreSQL solution which can be used as a workaround until this is resolved.
So, when WFS transaction comes to database, before insert event geometry of new feature will be replaced with 3d geometry from wkt string. |
Hi @uprel it looks good, but how do you view / edit the 3D data ind QGIS? If i make a text field with wkt data, QGIS will not use it as the geometry column. I also tried to convert the wkt field with Database Manager using geomfromwkt(wkt) but i can't get it to work. |
Triggers are special db functions that are triggered automatically on specific event: insert, delete or update. You don't run them manually, they are executed, so in above example geometry of inserted feature will get 3d geometry using data from wkt field. But you need to do both parts, first create trigger function and then attach it to your table. You can attach same function to more tables. Just follow all steps. Trigger function handles geometry from wkt field and creates new geometry which is then stored in db. |
Sorry, I see now what is your problem. QGIS must save geometry into wkt field before sending transaction. Don't know how to do that. My example is from my web solution where I can control client and how WFS request is prepared so I can prepare wkt field with WKT geometry. |
It's a problem with the DB Manager, see #34894 and the PR #45223 |
At the time I opened this issue, QGIS server did not support 3D geometries in WFS-T, meaning only 2D part was stored. Looks like this is still the case. If you wish you can contact someone from QGIS Server team to develop this, I talked with @elpaso about this, but then ended up doing workaround solution explained above. |
Any idea if an implementation of this is in the works or in the roadmap somewhere? |
Requires QgsMultiPolyline with Z/M support + M and ZM support
FYI: Since the WFS server in QGIS only supports X, Y, but not Z and M values, the layer type presented to a client (like QGIS/QField) appears to be Point instead of PointZ or PointZM. For anyone using QField with a WFS-based project, adding features would normally miss Z and M values. Above workaround by using another table field (wkt) and have a trigger update the geom is great. However, when using QField, in order to get the proper values stored via WFS, a simple "geom_to_wkt(@geometry)" is not enough since the WFS layer appears to QField as a "Point" layer instead of "PointZM". So, in order to provide all values in that transaction, configure QField such that the form uses a hidden field (the wkt field) with the following default value: geometry_type(@geometry)||'ZM'||' ('||x(@position_coordinate)||' '||y(@position_coordinate)||' '||z(@position_coordinate)||' '||@position_horizontal_accuracy||')' (example using both Z and M values. This example uses the horizontal accuracy for the M value. Substitute for whatever you store in M, or trim out M if you only need Z values for PointZ layers). This will get the correct geom type, add the missing "Z" or "ZM" behind it, then assemble the wkt string with all values. Again, geom_to_wkt will only use X+Y since the geom type of the WFS layer is Point, not PointZM or PointZ. Meaning, using geom_to_wkt would only produce "Point (123 456)", missing the Z and M values. So building the string "by hand" as listed above will ensure the proper 3D or 4D version of the WKT is written to the database table, and the trigger described above can then build a proper 3D/4D geom. This only works on Point layers of course. I'm unaware of a good solution that would work with LineZM or PolygonZM. |
@elpaso is there any way we can help with the implementation of this - financing or other resources? We are looking for read/write support for WFS-T. |
Hi, yes, I would be happy to help. Please write me in private (apasotti at gmail dot com) if you need a cost estimation. |
Author Name: Alessandro Pasotti (@elpaso)
Original Redmine Issue: 17095
Redmine category:qgis_server
See also #5096
The text was updated successfully, but these errors were encountered: