mapbox / geobuf

A compact binary encoding for geographic data.
ISC License
967 stars 84 forks source link

Allow for null geometries in features #94

Closed ivorblockley closed 6 years ago

ivorblockley commented 6 years ago

Attempt at resolving #55

Despite geometry being set as required in the Feature message in geobuf.proto, it appears that not setting it removes it successfully from the serialized message without complaint. The generated protobuf file is interpreted without issue using both pbf and google protobuffers (e.g. a simple display in Python via:

import geobuf_pb2

f = open("issue55.pb", "rb")
data = geobuf_pb2.Data()
data.ParseFromString(f.read())
print(data)

where geobuf_pb2 was generated by protoc using geobuf.proto.

The absence of a message field is a natural and efficient way to encode a null message in protobuf IMHO.

Despite testing suggesting that the approach pursued here is valid, it would be preferable before merging this approach to update geobuf.proto to make the geometry field in Feature messages optional.