Unable to decode WKB of MultiLineString with no coordinates
axelson opened this issue · comments
Geo is currently unable to decode a MultiLineString that has an empty list of coordinates (although it is able to encode it):
iex(8)> Jason.decode!(~s/{"type":"MultiLineString","coordinates":[[]]}/)
|> Geo.JSON.decode!()
|> Geo.WKB.encode!()
|> Geo.WKB.decode!()
** (FunctionClauseError) no function clause matching in anonymous fn/2 in Geo.WKB.Decoder.do_decode/4
The following arguments were given to anonymous fn/2 in Geo.WKB.Decoder.do_decode/4:
# 1
1
# 2
""
(geo 3.4.2) lib/geo/wkb/decoder.ex:108: anonymous fn/2 in Geo.WKB.Decoder.do_decode/4
(elixir 1.12.3) lib/enum.ex:1710: anonymous fn/3 in Enum.map_reduce/3
(elixir 1.12.3) lib/enum.ex:3950: Enum.reduce_range/5
(elixir 1.12.3) lib/enum.ex:2389: Enum.map_reduce/3
(geo 3.4.2) lib/geo/wkb/decoder.ex:108: Geo.WKB.Decoder.do_decode/4
(geo 3.4.2) lib/geo/wkb/decoder.ex:235: anonymous fn/2 in Geo.WKB.Decoder.do_decode/4
(elixir 1.12.3) lib/enum.ex:1704: Enum."-map_reduce/3-lists^mapfoldl/2-0-"/3
(geo 3.4.2) lib/geo/wkb/decoder.ex:234: Geo.WKB.Decoder.do_decode/4
(geo 3.4.2) lib/geo/wkb.ex:82: Geo.WKB.decode!/1
The WKB that is generated is "000000000500000001000000000200000000"
, which appears to be valid and on an online conversion website (https://rodic.fr/blog/online-conversion-between-geometric-formats/) it decodes to {"type":"MultiLineString","coordinates":[[]]}
.