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

Change default WKT output to honor a space between geometry type and Z, M or ZM #58010

Merged
merged 10 commits into from
Sep 24, 2024

Conversation

jgrocha
Copy link
Member

@jgrocha jgrocha commented Jul 7, 2024

Previous discussion

The discussion started on the developers mailing list.

https://lists.osgeo.org/pipermail/qgis-developer/2024-July/066901.html

Description

This PR changes the default WKT output to honor a space between the geometry type and the modifier Z, M, or ZM (when applied).

Example: 'PointZ (0 0 0)' will be written as 'Point Z (0 0 0)'.

Nothing was changed related to WKT parsing. Parsing is already quite flexible.
Different notations are allowed:

print( QgsGeometry.fromWkt( 'Point (0 0 0)' ).asWkt() )
print( QgsGeometry.fromWkt( 'PointZ (0 0 0)' ).asWkt() )
print( QgsGeometry.fromWkt( 'Point Z(0 0 0)' ).asWkt() )
print( QgsGeometry.fromWkt( 'Point Z (0 0 0)' ).asWkt() )

Output based on this PR:

Point Z (0 0 0)
Point Z (0 0 0)
Point Z (0 0 0)
Point Z (0 0 0)

Output based on current master:

PointZ (0 0 0)
PointZ (0 0 0)
PointZ (0 0 0)
PointZ (0 0 0)

Interoperability ensured by a new GDAL PR

The tools tested and discussed on the mailing list, namely, GDAL, GEOS, and QGIS support both forms for reading.

The new OSGeo/gdal#10370 enhances GDAL parsing to support also reading PointZ and Point Z.

With such enhancement, all three tools can interoperate based on WKT representations.

Proposal

Since the interoperability is already ensured, we can decide the best way to write WKT representations.

The WKT specification is defined in the OGC document https://portal.ogc.org/files/?artifact_id=25355

According to the BNF Productions for Three-Dimension Geometry WKT (pages 55, 56), the WKT should be written as point z <point z text>, linestring z <linestring z text>, etc.

Tests

Many tests use the WKT notation to compare generated and expected geometries. All tests were improved to support the new WKT writing.

OS tools side by side

QGIS GDAL shapely Postgis OpenLayers GEOS
Point Z (1 2 3) POINT Z (1 2 3) POINT Z (1 2 3) POINT Z (1 2 3) POINT Z(1 2 3) POINT Z (1 2 3)

QGIS

a = QgsGeometry.fromWkt( 'Point Z (1 2 3)' )
print(a.asWkt())

GDAL

from osgeo import ogr
a = ogr.CreateGeometryFromWkt("POINT Z (1 2 3)")
print(a.ExportToIsoWkt())

Shapely

import shapely
a = shapely.from_wkt('POINT Z (1 2 3)')
print(shapely.to_wkt(a))

PostGIS

select st_astext(st_pointfromtext('POINT Z (1 2 3)'));

OpenLayers

import WKT from 'ol/format/WKT';
var format = new WKT();
let a = format.readFeature('POINT Z (1 2 3)');
console.log(format.writeFeature(a));

GEOS

echo 'POINT Z (1 2 3)' | geosop -a stdin -f wkt

@github-actions github-actions bot added this to the 3.40.0 milestone Jul 7, 2024
@nyalldawson
Copy link
Collaborator

@mhugent do you have any insights as to why the current form was originally chosen?

Copy link

github-actions bot commented Jul 7, 2024

🪟 Windows builds ready!

Windows builds of this PR are available for testing here. Debug symbols for this build are available here.

(Built from commit 63cd7bc)

@lbartoletti
Copy link
Member

@jgrocha this is a very good idea! I made several tests, not yet released, some months ago. QGIS WKT is not readable by some other software. So +1. Let me just a couple of times to retrieve/finish my comparison/test and to review your PR. Thanks!

@lbartoletti lbartoletti self-assigned this Jul 8, 2024
jgrocha and others added 2 commits July 8, 2024 08:53
Co-authored-by: Nyall Dawson <nyall.dawson@gmail.com>
Copy link

The QGIS project highly values your contribution and would love to see this work merged! Unfortunately this PR has not had any activity in the last 14 days and is being automatically marked as "stale". If you think this pull request should be merged, please check

  • that all unit tests are passing

  • that all comments by reviewers have been addressed

  • that there is enough information for reviewers, in particular

    • link to any issues which this pull request fixes

    • add a description of workflows which this pull request fixes

    • add screenshots if applicable

  • that you have written unit tests where possible
    In case you should have any uncertainty, please leave a comment and we will be happy to help you proceed with this pull request.
    If there is no further activity on this pull request, it will be closed in a week.

@github-actions github-actions bot added the stale Uh oh! Seems this work is abandoned, and the PR is about to close. label Jul 23, 2024
@lbartoletti lbartoletti removed the stale Uh oh! Seems this work is abandoned, and the PR is about to close. label Jul 23, 2024
Copy link

github-actions bot commented Aug 7, 2024

The QGIS project highly values your contribution and would love to see this work merged! Unfortunately this PR has not had any activity in the last 14 days and is being automatically marked as "stale". If you think this pull request should be merged, please check

  • that all unit tests are passing

  • that all comments by reviewers have been addressed

  • that there is enough information for reviewers, in particular

    • link to any issues which this pull request fixes

    • add a description of workflows which this pull request fixes

    • add screenshots if applicable

  • that you have written unit tests where possible
    In case you should have any uncertainty, please leave a comment and we will be happy to help you proceed with this pull request.
    If there is no further activity on this pull request, it will be closed in a week.

@github-actions github-actions bot added the stale Uh oh! Seems this work is abandoned, and the PR is about to close. label Aug 7, 2024
Copy link

While we hate to see this happen, this PR has been automatically closed because it has not had any activity in the last 21 days. If this pull request should be reconsidered, please follow the guidelines in the previous comment and reopen this pull request. Or, if you have any further questions, just ask! We love to help, and if there's anything the QGIS project can do to help push this PR forward please let us know how we can assist.

@github-actions github-actions bot closed this Aug 15, 2024
@lbartoletti lbartoletti reopened this Aug 19, 2024
@github-actions github-actions bot removed the stale Uh oh! Seems this work is abandoned, and the PR is about to close. label Aug 19, 2024
@rouault
Copy link
Contributor

rouault commented Aug 25, 2024

@jgrocha There are some remaining tests to adapt. Cf CI failures

Copy link

github-actions bot commented Sep 9, 2024

The QGIS project highly values your contribution and would love to see this work merged! Unfortunately this PR has not had any activity in the last 14 days and is being automatically marked as "stale". If you think this pull request should be merged, please check

  • that all unit tests are passing

  • that all comments by reviewers have been addressed

  • that there is enough information for reviewers, in particular

    • link to any issues which this pull request fixes

    • add a description of workflows which this pull request fixes

    • add screenshots if applicable

  • that you have written unit tests where possible
    In case you should have any uncertainty, please leave a comment and we will be happy to help you proceed with this pull request.
    If there is no further activity on this pull request, it will be closed in a week.

@github-actions github-actions bot added the stale Uh oh! Seems this work is abandoned, and the PR is about to close. label Sep 9, 2024
@github-actions github-actions bot removed the stale Uh oh! Seems this work is abandoned, and the PR is about to close. label Sep 12, 2024
@jgrocha jgrocha marked this pull request as ready for review September 12, 2024 10:44
@jgrocha
Copy link
Member Author

jgrocha commented Sep 12, 2024

@jgrocha There are some remaining tests to adapt. Cf CI failures

Done at 23rd Contributors Meeting in Bucharest :-)

@jef-n
Copy link
Member

jef-n commented Sep 12, 2024

Done at 23rd Contributors Meeting in Bucharest :-)

@jgrocha Is there a parallel one to the one in Bratislava?

@jgrocha
Copy link
Member Author

jgrocha commented Sep 12, 2024

Done at 23rd Contributors Meeting in Bucharest :-)

@jgrocha Is there a parallel one to the one in Bratislava?

Done at 23rd Contributors Meeting in Bucharest :-)

@jgrocha Is there a parallel one to the one in Bratislava?

27th‐Contributor‐Meeting‐in‐Bratislava :-)

@jgrocha
Copy link
Member Author

jgrocha commented Sep 13, 2024

My bad! Tests were failing on CI because of #58616 that was merged after my git merge master on the local development branch, at the beginning of the contributors meeting.

@jgrocha
Copy link
Member Author

jgrocha commented Sep 15, 2024

@jgrocha this is a very good idea! I made several tests, not yet released, some months ago. QGIS WKT is not readable by some other software. So +1. Let me just a couple of times to retrieve/finish my comparison/test and to review your PR. Thanks!

Can you take a look at this @lbartoletti ?

@nyalldawson nyalldawson added the Squash! Remember to squash this PR, instead of merging or rebasing label Sep 15, 2024
@lbartoletti
Copy link
Member

@jgrocha this is a very good idea! I made several tests, not yet released, some months ago. QGIS WKT is not readable by some other software. So +1. Let me just a couple of times to retrieve/finish my comparison/test and to review your PR. Thanks!

Can you take a look at this @lbartoletti ?

yes! Sorry, was busy. I'll take a look, for sure, on monday.

@lbartoletti
Copy link
Member

OK for this change @jgrocha
But you have to fix tests for Oracle, at least, this file and maybe other providers.

@jgrocha
Copy link
Member Author

jgrocha commented Sep 24, 2024

OK for this change @jgrocha But you have to fix tests for Oracle, at least, this file and maybe other providers.

Thank you for the feedback @lbartoletti

ORACLE tests are not running on our CI. Maybe @troopa81 can help with the CI.

Meanwhile, I'll try to enable them on my side and do the tests locally.

@troopa81
Copy link
Contributor

ORACLE tests are not running on our CI. Maybe @troopa81 can help with the CI.

Well, everything seems to work fine now 👍

@lbartoletti lbartoletti merged commit b5d1779 into qgis:master Sep 24, 2024
30 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Squash! Remember to squash this PR, instead of merging or rebasing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants