-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
PyQGIS Creating empty geometry from WKT does not work as expected #22604
Comments
Author Name: Giovanni Manghi (@gioman)
|
Author Name: Giovanni Manghi (@gioman)
|
Author Name: Johannes Kroeger (Johannes Kroeger) Different but still weird in QGIS 3:
|
Author Name: Johannes Kroeger (Johannes Kroeger) And different for Points (empty string twice) but not for LineStrings. Weird!
I am pretty sure that the case of "GeometryType" without an "EMPTY" or coordinates should not be allowed at all. Instead this should fail. |
Author Name: Alessandro Pasotti (@elpaso) What exactly do you mean with "it should fail"? Should it return True from isNull() ? (note that we are not throwing exceptions from core classes in QGIS API).
Using QgsGeometry.fromWkt() works as expected in QGIS 2.8.3, but not in QGIS 2.14.1. See Python console output below: QGIS 2.8.3 Wien:
QGIS 2.14.1 Essen:
to As I understand from section 7 of http://www.opengeospatial.org/standards/sfa, empty geometries in WKT format should be specified as, for example "MultiLineString EMPTY". Using QgsGeometry.fromWkt() works as expected in QGIS 2.8.3, but not in QGIS 2.14.1. See Python console output below: QGIS 2.8.3 Wien:
QGIS 2.14.1 Essen:
|
Author Name: Giovanni Manghi (@gioman)
|
Author Name: Johannes Kroeger (Johannes Kroeger) I haven't used the API much so no idea about how methods react if they are not successful. If isNull is what QGIS uses to signal fail, then that should return true. But as a Python user I would expect a ValueError or something more specific (ParserError?) for @QgsGeometry.fromWkt('LineString')@. |
Author Name: Nyall Dawson (@nyalldawson)
That's the plan for 4.0 (See qgis/qgis4.0_api#85). But it's an API break (existing plugins may depend on the current behaviour of not throwing exceptions), so has to wait for 4.0. |
Author Name: Nyall Dawson (@nyalldawson) To explain your 3.0 testing:
The invalid WKT here has resulted in a null geometry - I'm going to improve the repr string here to reflect that, as this should be something more helpful like <QgsGeometry: null>
QgsGeometry.type() returns a QgsWkbTypes.GeometryType, not a WKB type. From the api docs a GeometryType of 3 = UnknownGeometry. So this is correct.
This looks correct to me, except that the WKT output should really be "MultiLineString EMPTY". |
Author Name: Stephen Beattie (@sb2259) If the WKT output for an empty MultiLineString should be "MultiLineString EMPTY", should QgsGeometry.fromWKT('MultiLineString EMPTY') not return a valid MultiLineString geometry, as it did back in QGIS 2.8.3? My understanding of the WKT specification is still that it requires "EMPTY" to be included in these cases, and would therefore expect "MultiLineString EMPTY" to return a valid geometry, even if "MultiLineString" (without the " EMPTY") is also accepted. In any case, to work around the original problem reported, my plugin first attempts to create a geometry with WKT 'MultiLineString EMPTY'. If None is returned, it then tries 'MultiLineString'. |
Author Name: Nyall Dawson (@nyalldawson) Right - so ultimately I think there's two remaining issues here:
and
|
Author Name: Giovanni Manghi (@gioman) End of life notice: QGIS 2.18 LTR Source: QGIS 3.4 has recently become our new Long Term Release (LTR) version. This is a major step in our history – a long term release version based on the massive updates, library upgrades and improvements that we carried out in the course of the 2.x to 3x upgrade cycle. We strongly encourage all users who are currently using QGIS 2.18 LTR as their preferred QGIS release to migrate to QGIS 3.4. This new LTR version will receive regular bugfixes for at least one year. It also includes hundreds of new functions, usability improvements, bugfixes, and other goodies. See the relevant changelogs for a good sampling of all the new features that have gone into version 3.4 Most plugins have been either migrated or incorporated into the core QGIS code base. We strongly discourage the continued use of QGIS 2.18 LTR as it is now officially unsupported, which means we’ll not provide any bug fix releases for it. You should also note that we intend to close all bug tickets referring to the now obsolete LTR version. Original reporters will receive a notification of the ticket closure and are encouraged to check whether the issue persists in the new LTR, in which case they should reopen the ticket. If you would like to better understand the QGIS release roadmap, check out our roadmap page! It outlines the schedule for upcoming releases and will help you plan your deployment of QGIS into an operational environment. The development of QGIS 3.4 LTR has been made possible by the work of hundreds of volunteers, by the investments of companies, professionals, and administrations, and by continuous donations and financial support from many of you. We sincerely thank you all and encourage you to collaborate and support the project even more, for the long term improvement and sustainability of the QGIS project.
|
Author Name: Stephen Beattie (@sb2259) Re-test in QGIS 3.4.5. Results as follows:
|
Author Name: Giovanni Manghi (@gioman)
|
Fixed in #9645 |
Author Name: Stephen Beattie (@sb2259)
Original Redmine Issue: 14640
Affected QGIS version: 3.4.5
Redmine category:python_bindings_/_sipify
As I understand from section 7 of http://www.opengeospatial.org/standards/sfa, empty geometries in WKT format should be specified as, for example "MultiLineString EMPTY".
Using QgsGeometry.fromWkt() works as expected in QGIS 2.8.3, but not in QGIS 2.14.1. See Python console output below:
QGIS 2.8.3 Wien:
QGIS 2.14.1 Essen:
The text was updated successfully, but these errors were encountered: