Skip to content

Cannot decode geobuf from PostGIS #128

@Monzyy

Description

@Monzyy

I have a geobuf string from PostGIS that look like this:
CgVjb3VudCLTAwoeChQIAhoQzvjgCNKYhzbmC/4F1jTIIGoCGAtyAgAAChoKEAgCGgyKueEImL+H NvIjlBZqAhgLcgIAAAomChwIAhoY/NzhCKzVhzbSEIQKygfsA5oKggS6C9gDagIYC3ICAAAKHgoU CAIaEOyK4gj26oc2/ArSApAMiAJqAhgLcgIAAAoaChAIAhoM+KHiCNDvhzbsWKIKagIYC3ICAAAK JgocCAIaGOT64gjy+Yc23gnkAd4IyALKB/ICkAfKA2oCGAtyAgAACiIKGAgCGhT6m+MI2oSINvIG ngSgF6QQvgykCmoCGAtyAgAACiAKFggCGhLO+OAI0piHNj7jASGNAZcopzlqAhgLcgIAAAoaChAI AhoM0tDgCLjchjaXDs0TagIYC3ICAAAKGgoQCAIaDLrC4AjqyIY28xHdGWoCGAtyAgAACkEKNwgC GjPGsOAIjK+GNtsC2wZBtQQTwQSWAZMFlgKpBMgJuQ3sAbMD7AGVBhW/A2vtA3+dA68GjRBqAhgL cgIAAAoZCg8IAhoLrrXgCJzkhTZs6wFqAhgLcgIAAAotCiMIAhofmrbgCLDihTaWAqUC/BXVENIZ wwzKBMcBqAMnxAXQAWoCGA1yAgAA

When I decode this I get an error:
Uncaught (in promise) Error: Unimplemented type: 4
at o.skip (index.js:211:20)

I'm using dash-leaflet to parse the geobuf:
https://github.com/thedirtyfew/dash-leaflet/blob/master/src/lib/utils.js#L54

As a temporary solution I instead use pygeobuf to decode the string, which works perfectly fine:
https://github.com/pygeobuf/pygeobuf

If I decode with pygeobuf and encode back, I can decode the string with geobuf.js/dash-leaflet. I also notice there are fewer newlines in the string after this:
CgVjb3VudCLTAwoeChQIAhoQzvjgCNKYhzbmC/4F1jTIIGoCGAtyAgAAChoKEAgCGgyKueEImL+HNvIjlBZqAhgLcgIAAAomChwIAhoY/NzhCKzVhzbSEIQKygfsA5oKggS6C9gDagIYC3ICAAAKHgoUCAIaEOyK4gj26oc2/ArSApAMiAJqAhgLcgIAAAoaChAIAhoM+KHiCNDvhzbsWKIKagIYC3ICAAAKJgocCAIaGOT64gjy+Yc23gnkAd4IyALKB/ICkAfKA2oCGAtyAgAACiIKGAgCGhT6m+MI2oSINvIGngSgF6QQvgykCmoCGAtyAgAACiAKFggCGhLO+OAI0piHNj7jASGNAZcopzlqAhgLcgIAAAoaChAIAhoM0tDgCLjchjaXDs0TagIYC3ICAAAKGgoQCAIaDLrC4AjqyIY28xHdGWoCGAtyAgAACkEKNwgCGjPGsOAIjK+GNtsC2wZBtQQTwQSWAZMFlgKpBMgJuQ3sAbMD7AGVBhW/A2vtA3+dA68GjRBqAhgLcgIAAAoZCg8IAhoLrrXgCJzkhTZs6wFqAhgLcgIAAAotCiMIAhofmrbgCLDihTaWAqUC/BXVENIZwwzKBMcBqAMnxAXQAWoCGA1yAgAA

I think there must be a problem with the js decoder, since the python decoder works fine with PostGIS.

For context this is the GeoJson:
{"type":"FeatureCollection","features":[{"type":"Feature","geometry":{"type":"LineString","coordinates":[[9.1827584,56.6820249],[9.1835135,56.6824076],[9.1868848,56.684492]]},"properties":{"count":"11"}},{"type":"Feature","geometry":{"type":"LineString","coordinates":[[9.1868848,56.684492],[9.1891818,56.6859091]]},"properties":{"count":"11"}},{"type":"Feature","geometry":{"type":"LineString","coordinates":[[9.1891818,56.6859091],[9.1902469,56.6865514],[9.1907314,56.6867975],[9.1913843,56.6870543],[9.1921178,56.6872902]]},"properties":{"count":"11"}},{"type":"Feature","geometry":{"type":"LineString","coordinates":[[9.1921178,56.6872902],[9.1928196,56.6874594],[9.1935952,56.6875912]]},"properties":{"count":"11"}},{"type":"Feature","geometry":{"type":"LineString","coordinates":[[9.1935952,56.6875912],[9.1992813,56.6882486]]},"properties":{"count":"11"}},{"type":"Feature","geometry":{"type":"LineString","coordinates":[[9.1992813,56.6882486],[9.1999049,56.6883627],[9.2004634,56.6885262],[9.2009485,56.688712],[9.2014049,56.6889408]]},"properties":{"count":"11"}},{"type":"Feature","geometry":{"type":"LineString","coordinates":[[9.2014049,56.6889408],[9.2018453,56.6892112],[9.2033332,56.6902532],[9.2041326,56.6909117]]},"properties":{"count":"11"}},{"type":"Feature","geometry":{"type":"LineString","coordinates":[[9.1827584,56.6820249],[9.1827898,56.6819101],[9.1827726,56.6818394],[9.1802005,56.6781717]]},"properties":{"count":"11"}},{"type":"Feature","geometry":{"type":"LineString","coordinates":[[9.1802005,56.6781717],[9.1792926,56.676917]]},"properties":{"count":"11"}},{"type":"Feature","geometry":{"type":"LineString","coordinates":[[9.1792926,56.676917],[9.1781464,56.6752693]]},"properties":{"count":"11"}},{"type":"Feature","geometry":{"type":"LineString","coordinates":[[9.1781464,56.6752693],[9.1779721,56.6748395],[9.1779399,56.6745565],[9.1779292,56.6742677],[9.1780043,56.6739376],[9.1781437,56.6736606],[9.1787553,56.6728],[9.1788733,56.6725819],[9.1789913,56.6721869],[9.1789806,56.6719629],[9.178927,56.6717153],[9.1788626,56.671509],[9.1784549,56.6704774]]},"properties":{"count":"11"}},{"type":"Feature","geometry":{"type":"LineString","coordinates":[[9.1784549,56.6704774],[9.1785085,56.6703595]]},"properties":{"count":"11"}},{"type":"Feature","geometry":{"type":"LineString","coordinates":[[9.1785085,56.6703595],[9.178648,56.6702121],[9.1800535,56.6691451],[9.181695,56.6683434],[9.1819873,56.6682431],[9.1821992,56.668224],[9.1825533,56.6683271]]},"properties":{"count":"13"}}]}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions