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

fromWKT should fail if neither EMPTY or coordinates are supplied #28574

Closed
qgib opened this issue Dec 7, 2018 · 5 comments
Closed

fromWKT should fail if neither EMPTY or coordinates are supplied #28574

qgib opened this issue Dec 7, 2018 · 5 comments
Assignees
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! Expressions Related to the QGIS expression engine or specific expression functions

Comments

@qgib
Copy link
Contributor

qgib commented Dec 7, 2018

Author Name: Johannes Kroeger (Johannes Kroeger)
Original Redmine Issue: 20754
Affected QGIS version: 3.5(master)
Redmine category:geometry


QGIS allows geometries to be created using a string like "GeometryType" without either specifying the coordinates or EMPTY.

http://www.opengeospatial.org/standards/sfa defines for example for a POINT:

<empty set> ::= EMPTY

<point text> ::= <empty set> | <left paren> <point> <right
paren>

So "Point" would not be ok. QGIS however, does allow and produce weird stuff...

>>> for type in "POINT", "LINESTRING", "POLYGON", "GEOMETRYCOLLECTION", "MULTIPOINT":
>>>   g = QgsGeometry.fromWkt(type)
>>>   print(type)
>>>   print(g)
>>>   print(g.asWkt())
POINT
<QgsGeometry: >

LINESTRING
<QgsGeometry: LineString ()>
LineString ()
POLYGON
<QgsGeometry: >

GEOMETRYCOLLECTION
<QgsGeometry: GeometryCollection ()>
GeometryCollection ()
MULTIPOINT
<QgsGeometry: MultiPoint ()>
MultiPoint ()

Related #22604

@qgib
Copy link
Contributor Author

qgib commented Dec 17, 2018

Author Name: Jürgen Fischer (@jef-n)


  • description was changed from QGIS allows geometries to be created using a string like "GeometryType" without either specifying the coordinates or EMPTY.

http://www.opengeospatial.org/standards/sfa defines for example for a POINT:

 ::= EMPTY

 ::=  |   

So "Point" would not be ok. QGIS however, does allow and produce weird stuff...

for type in "POINT", "LINESTRING", "POLYGON", "GEOMETRYCOLLECTION", "MULTIPOINT":
g = QgsGeometry.fromWkt(type)
print(type)
print(g)
print(g.asWkt())
POINT
<QgsGeometry: >

LINESTRING
<QgsGeometry: LineString ()>
LineString ()
POLYGON
<QgsGeometry: >

GEOMETRYCOLLECTION
<QgsGeometry: GeometryCollection ()>
GeometryCollection ()
MULTIPOINT
<QgsGeometry: MultiPoint ()>
MultiPoint ()

Also see https://issues.qgis.org/issues/14640 to QGIS allows geometries to be created using a string like "GeometryType" without either specifying the coordinates or EMPTY.

http://www.opengeospatial.org/standards/sfa defines for example for a POINT:

 ::= EMPTY

 ::=  |   

So "Point" would not be ok. QGIS however, does allow and produce weird stuff...

>>> for type in "POINT", "LINESTRING", "POLYGON", "GEOMETRYCOLLECTION", "MULTIPOINT":
>>>   g = QgsGeometry.fromWkt(type)
>>>   print(type)
>>>   print(g)
>>>   print(g.asWkt())
POINT


LINESTRING

LineString ()
POLYGON


GEOMETRYCOLLECTION

GeometryCollection ()
MULTIPOINT

MultiPoint ()

Related #22604

@qgib
Copy link
Contributor Author

qgib commented Dec 17, 2018

Author Name: Nyall Dawson (@nyalldawson)


I don't think there's an issue here. By design, QGIS' WKT parser is very forgiving and is designed to accept many types of invalid WKT strings, converting them wherever possible to actual geometries.

POINT
<QgsGeometry: >

<QgsGeometry: > is a null geometry, so that's correct -- we can't convert the string "point" to a meaningful geometry.

LINESTRING
<QgsGeometry: LineString ()>
LineString ()

This looks correct - we've been forgiving and interpreted the string as an empty linestring (ignoring the issue that .asWkt() should return "LineString EMPTY" here -- that's a different issue).

POLYGON
<QgsGeometry: >

In this case we haven't been able to parse the invalid WKT -- without even an exterior ring there's nothing here, so the returned geometry is null.

GEOMETRYCOLLECTION
<QgsGeometry: GeometryCollection ()>
GeometryCollection ()

Again, looks correct to me -- we've been forgiving and interpreted this as an empty geometry collection.

MULTIPOINT
<QgsGeometry: MultiPoint ()>
MultiPoint ()

Same again -- we've interpreted as an empty multipoint.


  • status_id was changed from Open to Feedback

@qgib
Copy link
Contributor Author

qgib commented Jan 29, 2019

Author Name: Loïc BARTOLETTI (@lbartoletti)


related issues #27019 and #28573

@qgib
Copy link
Contributor Author

qgib commented Mar 9, 2019

Author Name: Giovanni Manghi (@gioman)


Nyall Dawson wrote:

I don't think there's an issue here.

Nyall should this be closed?

@qgib qgib added Feedback Waiting on the submitter for answers Bug Either a bug report, or a bug fix. Let's hope for the latter! Expressions Related to the QGIS expression engine or specific expression functions labels May 25, 2019
@lbartoletti lbartoletti self-assigned this Jun 26, 2019
@lbartoletti lbartoletti removed the Feedback Waiting on the submitter for answers label Jun 26, 2019
@lbartoletti
Copy link
Member

Fixed in #9645

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! Expressions Related to the QGIS expression engine or specific expression functions
Projects
None yet
Development

No branches or pull requests

2 participants