Closed jeroen closed 8 years ago
Starting a new branch: https://github.com/jeroenooms/protolite/tree/geobuf
Some notes from analyzing the @mourner JavaScript implementation:
uint32 dimensions = 2
field sets the size of a single point. Default is 2 (e.g lat+lon).(int64) y = x * 10^e
where e
is stored in precision. Hence 0.123
with default precision of 6
gets stored as 123000
.coords
array contains the deltas of the coordinates by dimension. So [[100,20], [110, 5]]
becomes 100,2,10,-15
.repeated string keys
and are referred by their index in custom_properties
.message Value: {oneof value_type}
.[[[1,2], [3,4]], [[5,6],[3,3], [1,2]]]
is stored as dimensions = 2
and lengths = 2,3
and coords = 1,2,2,2,2,2,-2,-3,-2,-1
.@sckott I implemented the parser. Could you give this a try? To test, take an arbitrary geojson file and use the npm module to convert it to a proto buffer:
npm install geobuf
json2geobuf geojson.json > geobuf.pb
You can read geobuf.pb
in R using protolite::unserialize_geobuf
or protolite::geobuf2json
.
This is now fully implemented in protolite 1.4/
See https://github.com/mapbox/geobuf