26 lines
1.6 KiB
Fennel
26 lines
1.6 KiB
Fennel
(local t (require :faith))
|
|
(local {: encode-wkb : decode-wkb} (require :wkb))
|
|
|
|
(local data {"\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\xe0\x3f\x66\x66\x66\x66\x66\x66\xe6\x3f"
|
|
[:point 0.5 0.7]
|
|
"\x01\x02\x00\x00\x00\x03\x00\x00\x00\x35\x5e\xba\x49\x0c\x02\xbb\xbf\xc5\xfe\xb2\x7b\xf2\xc0\x49\x40\x50\x8d\x97\x6e\x12\x83\xc0\xbf\xb9\x8d\x06\xf0\x16\xc0\x49\x40\x1c\xeb\xe2\x36\x1a\xc0\xc3\xbf\x91\xed\x7c\x3f\x35\xbe\x49\x40"
|
|
[:linestring
|
|
[-0.1055 51.5074]
|
|
[-0.1290 51.5007]
|
|
[-0.1543 51.4860]]
|
|
"\x01\x03\x00\x00\x00\x02\x00\x00\x00\x05\x00\x00\x00\x00\x00\x00\x00\x00\x80\x41\x40\x00\x00\x00\x00\x00\x00\x24\x40\x00\x00\x00\x00\x00\x80\x46\x40\x00\x00\x00\x00\x00\x80\x46\x40\x00\x00\x00\x00\x00\x00\x2e\x40\x00\x00\x00\x00\x00\x00\x44\x40\x00\x00\x00\x00\x00\x00\x24\x40\x00\x00\x00\x00\x00\x00\x34\x40\x00\x00\x00\x00\x00\x80\x41\x40\x00\x00\x00\x00\x00\x00\x24\x40\x04\x00\x00\x00\x00\x00\x00\x00\x00\x00\x34\x40\x00\x00\x00\x00\x00\x00\x3e\x40\x00\x00\x00\x00\x00\x80\x41\x40\x00\x00\x00\x00\x00\x80\x41\x40\x00\x00\x00\x00\x00\x00\x3e\x40\x00\x00\x00\x00\x00\x00\x34\x40\x00\x00\x00\x00\x00\x00\x34\x40\x00\x00\x00\x00\x00\x00\x3e\x40"
|
|
[:polygon
|
|
[[35 10] [45 45] [15 40] [10 20] [35 10]]
|
|
[[20 30] [35 35] [30 20] [20 30]]]})
|
|
|
|
(fn test-decode []
|
|
(each [bstr decoded (pairs data)]
|
|
(t.= decoded (decode-wkb bstr))))
|
|
|
|
(fn test-encode []
|
|
(each [encoded spec (pairs data)]
|
|
(t.= encoded (encode-wkb spec true))))
|
|
|
|
{: test-decode
|
|
: test-encode}
|