Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Well-known binary parser for erlang (EWKB/WKB)

branch: master
README
This parser support WKB and EWKB for 2d and 3d geometry.


'SRID=4326;POINT(0 1 2)'
wkb_parser:parse_hex("01010000A0E61000000000000000000000000000000000F03F0000000000000040").
{4326,{'Point',{0.0,1.0,2.0}}}

'MULTIPOLYGON(((0 0, 10 0, 10 10, 0 10, 0 0),(2 2, 2 6, 6 4, 2 2)),((60 60, 60 50, 70 40, 60 60)))'
wkb_parser:parse_hex("000000000600000002000000000300000002000000050000000000000000000000000000000040240000000000000000000000000000402400000000000040240000000000000000000000000000402400000000000000000000000000000000000000000000000000044000000000000000400000000000000040000000000000004018000000000000401800000000000040100000000000004000000000000000400000000000000000000000030000000100000004404E000000000000404E000000000000404E000000000000404900000000000040518000000000004044000000000000404E000000000000404E000000000000").
{none,{'MultiPolygon',[{'Polygon',[[{0.0,0.0},
                                    {10.0,0.0},
                                    {10.0,10.0},
                                    {0.0,10.0},
                                    {0.0,0.0}],
                                   [{2.0,2.0},{2.0,6.0},{6.0,4.0},{2.0,2.0}]]},
                       {'Polygon',[[{60.0,60.0},
                                    {60.0,50.0},
                                    {70.0,40.0},
                                    {60.0,60.0}]]}]}}



'GEOMETRYCOLLECTION(POINT(0 0),LINESTRING(1 2,3 4),POLYGON((0 0,10 0,10 10,0 10,0 0),(2 2,2 6,6 4,2 2)),MULTIPOINT(0 0,10 0,10 10,0 10,0 0),MULTILINESTRING((0 0,10 0,10 10,0 10,10 20),(2 2,2 6,6 4,20 2)),MULTIPOLYGON(((0 0,10 0,10 10,0 10,0 0),(2 2,2 6,6 4,2 2)),((60 60,60 50,70 40,60 60))))'

wkb_parser:parse_hex("010700000006000000010100000000000000000000000000000000000000010200000002000000000000000000F03F00000000000000400000000000000840000000000000104001030000000200000005000000000000000000000000000000000000000000000000002440000000000000000000000000000024400000000000002440000000000000000000000000000024400000000000000000000000000000000004000000000000000000004000000000000000400000000000000040000000000000184000000000000018400000000000001040000000000000004000000000000000400104000000050000000101000000000000000000000000000000000000000101000000000000000000244000000000000000000101000000000000000000244000000000000024400101000000000000000000000000000000000024400101000000000000000000000000000000000000000105000000020000000102000000050000000000000000000000000000000000000000000000000024400000000000000000000000000000244000000000000024400000000000000000000000000000244000000000000024400000000000003440010200000004000000000000000000004000000000000000400000000000000040000000000000184000000000000018400000000000001040000000000000344000000000000000400106000000020000000103000000020000000500000000000000000000000000000000000000000000000000244000000000000000000000000000002440000000000000244000000000000000000000000000002440000000000000000000000000000000000400000000000000000000400000000000000040000000000000004000000000000018400000000000001840000000000000104000000000000000400000000000000040010300000001000000040000000000000000004E400000000000004E400000000000004E400000000000004940000000000080514000000000000044400000000000004E400000000000004E40").

{none,{'GeometryCollection',[{'Point',{0.0,0.0}},
                             {'LineString',[{1.0,2.0},{3.0,4.0}]},
                             {'Polygon',[[{0.0,0.0},
                                          {10.0,0.0},
                                          {10.0,10.0},
                                          {0.0,10.0},
                                          {0.0,0.0}],
                                         [{2.0,2.0},{2.0,6.0},{6.0,4.0},{2.0,2.0}]]},
                             {'MultiPoint',[{'Point',{0.0,0.0}},
                                            {'Point',{10.0,0.0}},
                                            {'Point',{10.0,10.0}},
                                            {'Point',{0.0,10.0}},
                                            {'Point',{0.0,0.0}}]},
                             {'MultiLineString',[{'LineString',[{0.0,0.0},
                                                                {10.0,0.0},
                                                                {10.0,10.0},
                                                                {0.0,10.0},
                                                                {10.0,20.0}]},
                                                 {'LineString',[{2.0,2.0},{2.0,6.0},{6.0,4.0},{20.0,2.0}]}]},
                             {'MultiPolygon',[{'Polygon',[[{0.0,0.0},
                                                           {10.0,0.0},
                                                           {10.0,10.0},
                                                           {0.0,10.0},
                                                           {0.0,0.0}],
                                                          [{2.0,2.0},{2.0,6.0},{6.0,4.0},{2.0,2.0}]]},
                                              {'Polygon',[[{60.0,60.0},
                                                           {60.0,50.0},
                                                           {70.0,40.0},
                                                           {60.0,60.0}]]}]}]}}

Something went wrong with that request. Please try again.