Opened 4 years ago

Closed 3 years ago

#1049 closed defect (fixed)

Inconsistency with POINT(nan nan)

Reported by: Mike Taves Owned by: geos-devel@…
Priority: major Milestone: 3.10.0
Component: Default Version: main
Severity: Unassigned Keywords:
Cc:

Description

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 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.

Change History (2)

comment:1 by pramsey, 3 years ago

Milestone: 3.10.0

comment:2 by Paul Ramsey <pramsey@…>, 3 years ago

Resolution: fixed
Status: newclosed

In 693c1aa/git:

Correctly return isEmpty for hand-built empty points, closes #1049

Note: See TracTickets for help on using tickets.