Bug report #20754

fromWKT should fail if neither EMPTY or coordinates are supplied

Added by Johannes Kroeger about 1 year ago. Updated 11 months ago.

Status:Feedback
Priority:Normal
Assignee:-
Category:Geometry
Affected QGIS version:3.5(master) Regression?:No
Operating System: Easy fix?:No
Pull Request or Patch supplied:No Resolution:
Crashes QGIS or corrupts data:No Copied to github as #:28574

Description

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 #14640

History

#1 Updated by Jürgen Fischer about 1 year ago

  • Description updated (diff)

#2 Updated by Nyall Dawson about 1 year ago

  • Status changed from Open to Feedback

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.

#3 Updated by Loïc BARTOLETTI 12 months ago

related issues #19190 and #20753

#4 Updated by Giovanni Manghi 11 months ago

Nyall Dawson wrote:

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

Nyall should this be closed?

Also available in: Atom PDF