[geos-devel] [GEOS] #1049: Inconsistency with POINT(nan nan)

GEOS geos-trac at osgeo.org
Wed Sep 23 04:00:00 PDT 2020


#1049: Inconsistency with POINT(nan nan)
------------------------+--------------------------
 Reporter:  Mike Taves  |      Owner:  geos-devel@…
     Type:  defect      |     Status:  new
 Priority:  major       |  Milestone:
Component:  Default     |    Version:  master
 Severity:  Unassigned  |   Keywords:
------------------------+--------------------------
 Consider two points that use the "NaN" convention to try and create `POINT
 EMPTY`. This example uses shapely:
 {{{
 from shapely import wkt
 from shapely.geometry import Point

 # two different ways to create a point with NaN
 point_nan_from_val = Point(float('nan'), float('nan'))
 point_nan_from_wkt = wkt.loads('point(nan nan)')

 point_nan_from_val.is_empty  # False
 point_nan_from_wkt.is_empty  # True

 point_nan_from_val.wkt  # POINT (nan nan)
 point_nan_from_wkt.wkt  # POINT EMPTY
 }}}
 And a similar example with PyGEOS (master), which side-steps #1048 by
 [https://github.com/pygeos/pygeos/pull/179 correctly writing WKB] for
 POINT EMPTY:
 {{{
 import pygeos

 point_nan_from_val = pygeos.points(float('nan'), float('nan'))
 point_nan_from_wkt = pygeos.Geometry('point(nan nan)')

 pygeos.is_empty(point_nan_from_val)  # False
 pygeos.is_empty(point_nan_from_wkt)  # True

 # Different WKT
 pygeos.to_wkt(point_nan_from_val)  # POINT (nan nan)
 pygeos.to_wkt(point_nan_from_wkt)  # POINT EMPTY

 # Same WKB
 pygeos.to_wkb(point_nan_from_val) == pygeos.to_wkb(point_nan_from_wkt)  #
 True
 }}}
 The two points behave very differently, with different WKT and same WKB
 (when #1048 is resolved).

 Seeing that `POINT EMPTY` is generally serialised in WKB as `POINT(nan
 nan)` (#1005), it could be expected that geometries created with nan
 coordinate values should be `POINT EMPTY` too, and not non-empty points
 with nan coordinates.

-- 
Ticket URL: <https://trac.osgeo.org/geos/ticket/1049>
GEOS <http://trac.osgeo.org/geos>
GEOS (Geometry Engine - Open Source) is a C++ port of the Java Topology Suite (JTS).


More information about the geos-devel mailing list