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

Unable to decode WKB of MultiLineString with no coordinates #163

Closed
axelson opened this issue Sep 10, 2021 · 0 comments · Fixed by #164
Closed

Unable to decode WKB of MultiLineString with no coordinates #163

axelson opened this issue Sep 10, 2021 · 0 comments · Fixed by #164

Comments

@axelson
Copy link
Contributor

axelson commented Sep 10, 2021

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":[[]]}.

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

Successfully merging a pull request may close this issue.

1 participant