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

WKT round-tripping fail with MULTIPOINT(EMPTY) vs MULTIPOINT EMPTY #951

Closed
mwtoews opened this issue Aug 28, 2023 · 0 comments · Fixed by #952
Closed

WKT round-tripping fail with MULTIPOINT(EMPTY) vs MULTIPOINT EMPTY #951

mwtoews opened this issue Aug 28, 2023 · 0 comments · Fixed by #952
Assignees

Comments

@mwtoews
Copy link
Contributor

mwtoews commented Aug 28, 2023

A MULTIPOINT(EMPTY) geometry has one empty item, while MULTIPOINT EMPTY is the same type but no items. They round-trip fine with WKB, but not with WKT. Here is a bash loop to compare the outputs using GEOS 3.12.0:

for geom_type in MULTIPOINT MULTILINESTRING MULTIPOLYGON; do
  geom="$geom_type(EMPTY)"
  echo "input: $geom"
  echo -n "  wkt: "
  ./bin/geosop -a "$geom" -f wkt
  echo -n "  wkb: "
  ./bin/geosop -a "$geom" -f wkb
done

shows the unexpected WKT differences

input: MULTIPOINT(EMPTY)
  wkt: MULTIPOINT EMPTY
  wkb: 0104000000010000000101000000000000000000F87F000000000000F87F
input: MULTILINESTRING(EMPTY)
  wkt: MULTILINESTRING EMPTY
  wkb: 010500000001000000010200000000000000
input: MULTIPOLYGON(EMPTY)
  wkt: MULTIPOLYGON EMPTY
  wkb: 010600000001000000010300000000000000

Meanwhile, these are all expected:

for geom_type in MULTIPOINT MULTILINESTRING MULTIPOLYGON; do
  geom="$geom_type EMPTY"
  echo "input: $geom"
  echo -n "  wkt: "
  ./bin/geosop -a "$geom" -f wkt
  echo -n "  wkb: "
  ./bin/geosop -a "$geom" -f wkb
done

shows expected zero-length collections:

input: MULTIPOINT EMPTY
  wkt: MULTIPOINT EMPTY
  wkb: 010400000000000000
input: MULTILINESTRING EMPTY
  wkt: MULTILINESTRING EMPTY
  wkb: 010500000000000000
input: MULTIPOLYGON EMPTY
  wkt: MULTIPOLYGON EMPTY
  wkb: 010600000000000000

There are no issues with GeometryCollection, which can round-trip GEOMETRYCOLLECTION(POINT EMPTY) without issue. PostGIS seems to handle these geometries as expected.

I'm almost certain this has been brought up somewhere, but I cannot find this. Empty strikes again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant