From 1622394767976b99d896f1cf50714fdf271b8636 Mon Sep 17 00:00:00 2001 From: mscno Date: Thu, 29 Feb 2024 11:07:39 +0100 Subject: [PATCH] add support for empty geometry --- cmd/feature.geojson | 1 + cmd/feature.multipolygon.geobuf.base64.txt | 1 + cmd/feature.point.geobuf.base64.txt | 1 + ...ure.point_with_precision.geobuf.base64.txt | 1 + cmd/main.go | 80 ++ decode.go | 10 +- elixir/geobufpb/geobuf.pb.ex | 87 ++ encode.go | 22 +- encode_test.go | 68 ++ gen/doc/doc.json | 618 ++++++++++++++ gen/doc/index.html | 755 ++++++++++++++++++ gen/doc/index.md | 169 ++++ geobufpb/buf.go.yaml | 30 + {proto => geobufpb}/buf.lock | 0 {proto => geobufpb}/buf.yaml | 0 {proto => geobufpb}/doc.go | 2 +- {proto => geobufpb}/geobuf.pb.go | 326 ++++---- {proto => geobufpb}/geobuf.proto | 17 +- {proto => geobufpb}/geobuf_vtproto.pb.go | 4 +- internal/decode/feature.go | 20 +- internal/decode/geometry.go | 18 +- internal/encode/feature.go | 14 +- internal/encode/feature_collection.go | 8 +- internal/encode/geometry.go | 71 +- internal/encode/geometry_test.go | 11 +- internal/encode/id.go | 14 +- internal/encode/options.go | 1 + internal/encode/values.go | 40 +- internal/encode/values_test.go | 14 +- justfile | 2 +- proto/buf.go.yaml | 22 - 31 files changed, 2140 insertions(+), 287 deletions(-) create mode 100644 cmd/feature.geojson create mode 100644 cmd/feature.multipolygon.geobuf.base64.txt create mode 100644 cmd/feature.point.geobuf.base64.txt create mode 100644 cmd/feature.point_with_precision.geobuf.base64.txt create mode 100644 cmd/main.go create mode 100644 elixir/geobufpb/geobuf.pb.ex create mode 100644 encode_test.go create mode 100644 gen/doc/doc.json create mode 100644 gen/doc/index.html create mode 100644 gen/doc/index.md create mode 100644 geobufpb/buf.go.yaml rename {proto => geobufpb}/buf.lock (100%) rename {proto => geobufpb}/buf.yaml (100%) rename {proto => geobufpb}/doc.go (73%) rename {proto => geobufpb}/geobuf.pb.go (58%) rename {proto => geobufpb}/geobuf.proto (84%) rename {proto => geobufpb}/geobuf_vtproto.pb.go (99%) delete mode 100644 proto/buf.go.yaml diff --git a/cmd/feature.geojson b/cmd/feature.geojson new file mode 100644 index 0000000..473de74 --- /dev/null +++ b/cmd/feature.geojson @@ -0,0 +1 @@ +{"id":"1000001","type":"Feature","geometry":{"type":"MultiPolygon","coordinates":[[[[-83.537385,33.9659119],[-83.5084519,33.931233],[-83.4155119,33.918541],[-83.275933,33.847977],[-83.306619,33.811444],[-83.28034,33.7617739],[-83.29145,33.7343149],[-83.406189,33.698307],[-83.479523,33.802265],[-83.505928,33.81776],[-83.533165,33.820923],[-83.647031,33.9061979],[-83.537385,33.9659119]]],[[[-83.537385,33.9659119],[-83.5084519,33.931233],[-83.4155119,33.918541],[-83.275933,33.847977],[-83.306619,33.811444],[-83.28034,33.7617739],[-83.29145,33.7343149],[-83.406189,33.698307],[-83.479523,33.802265],[-83.505928,33.81776],[-83.533165,33.820923],[-83.647031,33.9061979],[-83.537385,33.9659119]]],[[[-83.537385,33.9659119],[-83.5084519,33.931233],[-83.4155119,33.918541],[-83.275933,33.847977],[-83.306619,33.811444],[-83.28034,33.7617739],[-83.29145,33.7343149],[-83.406189,33.698307],[-83.479523,33.802265],[-83.505928,33.81776],[-83.533165,33.820923],[-83.647031,33.9061979],[-83.537385,33.9659119]]]]},"properties":{"AREA":"13219","COLORKEY":"#03E174","area":"13219","index":1109}} \ No newline at end of file diff --git a/cmd/feature.multipolygon.geobuf.base64.txt b/cmd/feature.multipolygon.geobuf.base64.txt new file mode 100644 index 0000000..acd6a32 --- /dev/null +++ b/cmd/feature.multipolygon.geobuf.base64.txt @@ -0,0 +1 @@ +0a04415245410a08434f4c4f524b45590a04617265610a05696e646578100218072ab9020afb010806120703010c010c010c1aed01b3acd69c06dea5f6c302e6a823c9aa2af0b9718fbf0f9ab1aa01cf9156d7ba25a3cc2c8c8a20f9d03cf7c70dbbc221fb878c019dfa2bb7c259b8f37ee39d208cf512e39f219cee03c7ff8a019a8c68b3acd69c06dea5f6c302e6a823c9aa2af0b9718fbf0f9ab1aa01cf9156d7ba25a3cc2c8c8a20f9d03cf7c70dbbc221fb878c019dfa2bb7c259b8f37ee39d208cf512e39f219cee03c7ff8a019a8c68b3acd69c06dea5f6c302e6a823c9aa2af0b9718fbf0f9ab1aa01cf9156d7ba25a3cc2c8c8a20f9d03cf7c70dbbc221fb878c019dfa2bb7c259b8f37ee39d208cf512e39f219cee03c7ff8a019a8c686a070a0531333231396a090a07233033453137346a070a0531333231396a09110000000000549140720800000101020203035a0731303030303031 \ No newline at end of file diff --git a/cmd/feature.point.geobuf.base64.txt b/cmd/feature.point.geobuf.base64.txt new file mode 100644 index 0000000..dce1122 --- /dev/null +++ b/cmd/feature.point.geobuf.base64.txt @@ -0,0 +1 @@ +100218032a0c0a0a08011a06b6930fb0cf1c \ No newline at end of file diff --git a/cmd/feature.point_with_precision.geobuf.base64.txt b/cmd/feature.point_with_precision.geobuf.base64.txt new file mode 100644 index 0000000..5238d61 --- /dev/null +++ b/cmd/feature.point_with_precision.geobuf.base64.txt @@ -0,0 +1 @@ +100218062a0f0a0d08011a09f0ddaf76aa9bccdf01 \ No newline at end of file diff --git a/cmd/main.go b/cmd/main.go new file mode 100644 index 0000000..42c94cc --- /dev/null +++ b/cmd/main.go @@ -0,0 +1,80 @@ +package main + +import ( + "encoding/hex" + "github.com/mscno/go-geobuf" + "github.com/paulmach/orb" + "github.com/paulmach/orb/geojson" + "google.golang.org/protobuf/proto" + "log" + "os" +) + +func main() { + demoPoint() + demoPointWithPrecision() + demoMultiPolygon() + +} + +func demoMultiPolygon() { + f, err := os.ReadFile("cmd/feature.geojson") + if err != nil { + log.Fatal(err) + } + + feature, err := geojson.UnmarshalFeature(f) + if err != nil { + log.Fatal(err) + } + + data, err := geobuf.Encode(feature) + if err != nil { + log.Fatal(err) + } + + payload, err := proto.Marshal(data) + if err != nil { + log.Fatal(err) + } + + payloadBase64 := hex.EncodeToString(payload) + + err = os.WriteFile("cmd/feature.multipolygon.geobuf.base64.txt", []byte(payloadBase64), 0644) +} + +func demoPoint() { + p := orb.Point([2]float64{124.123, 234.456}) + feature := geojson.NewFeature(p) + data, err := geobuf.Encode(feature) + if err != nil { + log.Fatal(err) + } + + payload, err := proto.Marshal(data) + if err != nil { + log.Fatal(err) + } + + payloadBase64 := hex.EncodeToString(payload) + + err = os.WriteFile("cmd/feature.point.geobuf.base64.txt", []byte(payloadBase64), 0644) +} + +func demoPointWithPrecision() { + p := orb.Point([2]float64{124.123, 234.456_789}) + feature := geojson.NewFeature(p) + data, err := geobuf.Encode(feature, geobuf.WithPrecision(6)) + if err != nil { + log.Fatal(err) + } + + payload, err := proto.Marshal(data) + if err != nil { + log.Fatal(err) + } + + payloadBase64 := hex.EncodeToString(payload) + + err = os.WriteFile("cmd/feature.point_with_precision.geobuf.base64.txt", []byte(payloadBase64), 0644) +} diff --git a/decode.go b/decode.go index cab210a..6b27be9 100644 --- a/decode.go +++ b/decode.go @@ -1,19 +1,19 @@ package geobuf import ( + "github.com/mscno/go-geobuf/geobufpb" "github.com/mscno/go-geobuf/internal/decode" - "github.com/mscno/go-geobuf/proto" "github.com/paulmach/orb/geojson" ) -func Decode(msg *proto.Data) (interface{}, error) { +func Decode(msg *geobufpb.Data) (interface{}, error) { switch v := msg.DataType.(type) { - case *proto.Data_Geometry_: + case *geobufpb.Data_Geometry_: geo := v.Geometry return decode.DecodeGeometry(geo, msg.Precision, msg.Dimensions), nil - case *proto.Data_Feature_: + case *geobufpb.Data_Feature_: return decode.DecodeFeature(msg, v.Feature, msg.Precision, msg.Dimensions), nil - case *proto.Data_FeatureCollection_: + case *geobufpb.Data_FeatureCollection_: collection := geojson.NewFeatureCollection() for _, feature := range v.FeatureCollection.Features { collection.Append(decode.DecodeFeature(msg, feature, msg.Precision, msg.Dimensions)) diff --git a/elixir/geobufpb/geobuf.pb.ex b/elixir/geobufpb/geobuf.pb.ex new file mode 100644 index 0000000..32ac62b --- /dev/null +++ b/elixir/geobufpb/geobuf.pb.ex @@ -0,0 +1,87 @@ +defmodule Geobuf.Data.Geometry.Type do + @moduledoc false + + use Protobuf, enum: true, syntax: :proto3, protoc_gen_elixir_version: "0.12.0" + + field :EMPTY, 0 + field :POINT, 1 + field :MULTIPOINT, 2 + field :LINESTRING, 3 + field :MULTILINESTRING, 4 + field :POLYGON, 5 + field :MULTIPOLYGON, 6 + field :GEOMETRYCOLLECTION, 7 +end + +defmodule Geobuf.Data.Feature do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.12.0" + + oneof :id_type, 0 + + field :geometry, 1, type: Geobuf.Data.Geometry + field :id, 11, type: :string, oneof: 0 + field :int_id, 12, type: :sint64, json_name: "intId", oneof: 0 + field :values, 13, repeated: true, type: Geobuf.Data.Value + field :properties, 14, repeated: true, type: :uint32 + field :custom_properties, 15, repeated: true, type: :uint32, json_name: "customProperties" +end + +defmodule Geobuf.Data.Geometry do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.12.0" + + field :type, 1, type: Geobuf.Data.Geometry.Type, enum: true + field :lengths, 2, repeated: true, type: :uint32 + field :coords, 3, repeated: true, type: :sint64 + field :geometries, 4, repeated: true, type: Geobuf.Data.Geometry + field :values, 13, repeated: true, type: Geobuf.Data.Value + field :custom_properties, 15, repeated: true, type: :uint32, json_name: "customProperties" +end + +defmodule Geobuf.Data.FeatureCollection do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.12.0" + + field :features, 1, repeated: true, type: Geobuf.Data.Feature + field :values, 13, repeated: true, type: Geobuf.Data.Value + field :custom_properties, 15, repeated: true, type: :uint32, json_name: "customProperties" +end + +defmodule Geobuf.Data.Value do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.12.0" + + oneof :value_type, 0 + + field :string_value, 1, type: :string, json_name: "stringValue", oneof: 0 + field :double_value, 2, type: :double, json_name: "doubleValue", oneof: 0 + field :pos_int_value, 3, type: :uint64, json_name: "posIntValue", oneof: 0 + field :neg_int_value, 4, type: :uint64, json_name: "negIntValue", oneof: 0 + field :bool_value, 5, type: :bool, json_name: "boolValue", oneof: 0 + field :json_value, 6, type: :bytes, json_name: "jsonValue", oneof: 0 +end + +defmodule Geobuf.Data do + @moduledoc false + + use Protobuf, syntax: :proto3, protoc_gen_elixir_version: "0.12.0" + + oneof :data_type, 0 + + field :keys, 1, repeated: true, type: :string + field :dimensions, 2, type: :uint32 + field :precision, 3, type: :uint32 + + field :feature_collection, 4, + type: Geobuf.Data.FeatureCollection, + json_name: "featureCollection", + oneof: 0 + + field :feature, 5, type: Geobuf.Data.Feature, oneof: 0 + field :geometry, 6, type: Geobuf.Data.Geometry, oneof: 0 +end \ No newline at end of file diff --git a/encode.go b/encode.go index b36d81e..365d7a3 100644 --- a/encode.go +++ b/encode.go @@ -1,12 +1,16 @@ package geobuf import ( + "errors" + geoproto "github.com/mscno/go-geobuf/geobufpb" "github.com/mscno/go-geobuf/internal/encode" "github.com/mscno/go-geobuf/internal/math" - geoproto "github.com/mscno/go-geobuf/proto" "github.com/paulmach/orb/geojson" ) +var ErrUnsupportedType = errors.New("unsupported type: object is not geojson") +var ErrNilInput = errors.New("invalid input: object is nil") + type EncodingOption func(o *encode.EncodingConfig) func WithPrecision(precision uint) EncodingOption { @@ -28,6 +32,12 @@ func WithKeys(keys []string) EncodingOption { } } +func WithAllowEmptyGeometry(allow bool) EncodingOption { + return func(o *encode.EncodingConfig) { + o.AllowEmptyGeometry = allow + } +} + func Encode(obj interface{}, opts ...EncodingOption) (*geoproto.Data, error) { cfg := &encode.EncodingConfig{ Dimension: 2, @@ -53,6 +63,8 @@ func Encode(obj interface{}, opts ...EncodingOption) (*geoproto.Data, error) { } switch t := obj.(type) { + case nil: + return nil, ErrNilInput case *geojson.FeatureCollection: collection, err := encode.EncodeFeatureCollection(t, cfg) if err != nil { @@ -70,9 +82,15 @@ func Encode(obj interface{}, opts ...EncodingOption) (*geoproto.Data, error) { Feature: feature, } case *geojson.Geometry: + geom, err := encode.EncodeGeometry(t.Geometry(), cfg) + if err != nil { + return nil, err + } data.DataType = &geoproto.Data_Geometry_{ - Geometry: encode.EncodeGeometry(t.Geometry(), cfg), + Geometry: geom, } + default: + return nil, ErrUnsupportedType } return data, nil diff --git a/encode_test.go b/encode_test.go new file mode 100644 index 0000000..7b6ee74 --- /dev/null +++ b/encode_test.go @@ -0,0 +1,68 @@ +package geobuf + +import ( + "github.com/mscno/go-geobuf/internal/encode" + "github.com/paulmach/orb/geojson" + "github.com/stretchr/testify/require" + "testing" +) + +func TestEncodeEmpty(t *testing.T) { + _, err := Encode(nil) + require.Error(t, err) + require.ErrorIs(t, err, ErrNilInput) +} + +func TestEncodeBadType(t *testing.T) { + _, err := Encode("bad type") + require.Error(t, err) + require.ErrorIs(t, err, ErrUnsupportedType) +} + +func TestEncodeEmptyFeatureCollection(t *testing.T) { + fc := geojson.NewFeatureCollection() + data, err := Encode(fc) + require.NoError(t, err) + require.NotNil(t, data) +} + +func TestEncodeEmptyFeature(t *testing.T) { + fc := geojson.NewFeature(nil) + data, err := Encode(fc, WithAllowEmptyGeometry(true)) + require.NoError(t, err) + require.NotNil(t, data) + + fc2, err := Decode(data) + require.NoError(t, err) + require.NotNil(t, fc2) + fc3, ok := fc2.(*geojson.Feature) + require.True(t, ok) + require.NotNil(t, fc3) + require.Nil(t, fc3.Geometry) +} + +var emptyGeometryFeature = `{"type":"Feature","geometry":null}` + +func TestEncodeEmptyGeometryFeature(t *testing.T) { + f, err := geojson.UnmarshalFeature([]byte(emptyGeometryFeature)) + + data, err := Encode(f, WithAllowEmptyGeometry(false)) + require.Error(t, err) + require.ErrorIs(t, err, encode.ErrEmptyGeometry) + + data, err = Encode(f) + require.Error(t, err) + require.ErrorIs(t, err, encode.ErrEmptyGeometry) + + data, err = Encode(f, WithAllowEmptyGeometry(true)) + require.NoError(t, err) + require.NotNil(t, data) + + f2, err := Decode(data) + require.NoError(t, err) + require.NotNil(t, f2) + f3, ok := f2.(*geojson.Feature) + require.True(t, ok) + require.NotNil(t, f3) + require.Nil(t, f3.Geometry) +} diff --git a/gen/doc/doc.json b/gen/doc/doc.json new file mode 100644 index 0000000..221dad4 --- /dev/null +++ b/gen/doc/doc.json @@ -0,0 +1,618 @@ +{ + "files": [ + { + "name": "geobufpb/geobuf.proto", + "description": "", + "package": "geobuf", + "hasEnums": false, + "hasExtensions": false, + "hasMessages": true, + "hasServices": false, + "enums": [ + { + "name": "Type", + "longName": "Data.Geometry.Type", + "fullName": "geobuf.Data.Geometry.Type", + "description": "", + "values": [ + { + "name": "EMPTY", + "number": "0", + "description": "" + }, + { + "name": "POINT", + "number": "1", + "description": "" + }, + { + "name": "MULTIPOINT", + "number": "2", + "description": "" + }, + { + "name": "LINESTRING", + "number": "3", + "description": "" + }, + { + "name": "MULTILINESTRING", + "number": "4", + "description": "" + }, + { + "name": "POLYGON", + "number": "5", + "description": "" + }, + { + "name": "MULTIPOLYGON", + "number": "6", + "description": "" + }, + { + "name": "GEOMETRYCOLLECTION", + "number": "7", + "description": "" + } + ] + } + ], + "extensions": [], + "messages": [ + { + "name": "Data", + "longName": "Data", + "fullName": "geobuf.Data", + "description": "", + "hasExtensions": false, + "hasFields": true, + "hasOneofs": true, + "extensions": [], + "fields": [ + { + "name": "keys", + "description": "global arrays of unique keys", + "label": "repeated", + "type": "string", + "longType": "string", + "fullType": "string", + "ismap": false, + "isoneof": false, + "oneofdecl": "", + "defaultValue": "" + }, + { + "name": "dimensions", + "description": "max coordinate dimensions, default 2", + "label": "", + "type": "uint32", + "longType": "uint32", + "fullType": "uint32", + "ismap": false, + "isoneof": false, + "oneofdecl": "", + "defaultValue": "" + }, + { + "name": "precision", + "description": "number of digits after decimal point for coordinates, default 6", + "label": "", + "type": "uint32", + "longType": "uint32", + "fullType": "uint32", + "ismap": false, + "isoneof": false, + "oneofdecl": "", + "defaultValue": "" + }, + { + "name": "feature_collection", + "description": "", + "label": "", + "type": "FeatureCollection", + "longType": "Data.FeatureCollection", + "fullType": "geobuf.Data.FeatureCollection", + "ismap": false, + "isoneof": true, + "oneofdecl": "data_type", + "defaultValue": "" + }, + { + "name": "feature", + "description": "", + "label": "", + "type": "Feature", + "longType": "Data.Feature", + "fullType": "geobuf.Data.Feature", + "ismap": false, + "isoneof": true, + "oneofdecl": "data_type", + "defaultValue": "" + }, + { + "name": "geometry", + "description": "", + "label": "", + "type": "Geometry", + "longType": "Data.Geometry", + "fullType": "geobuf.Data.Geometry", + "ismap": false, + "isoneof": true, + "oneofdecl": "data_type", + "defaultValue": "" + } + ] + }, + { + "name": "Feature", + "longName": "Data.Feature", + "fullName": "geobuf.Data.Feature", + "description": "", + "hasExtensions": false, + "hasFields": true, + "hasOneofs": true, + "extensions": [], + "fields": [ + { + "name": "geometry", + "description": "", + "label": "", + "type": "Geometry", + "longType": "Data.Geometry", + "fullType": "geobuf.Data.Geometry", + "ismap": false, + "isoneof": false, + "oneofdecl": "", + "defaultValue": "" + }, + { + "name": "id", + "description": "", + "label": "", + "type": "string", + "longType": "string", + "fullType": "string", + "ismap": false, + "isoneof": true, + "oneofdecl": "id_type", + "defaultValue": "" + }, + { + "name": "int_id", + "description": "", + "label": "", + "type": "sint64", + "longType": "sint64", + "fullType": "sint64", + "ismap": false, + "isoneof": true, + "oneofdecl": "id_type", + "defaultValue": "" + }, + { + "name": "values", + "description": "unique values", + "label": "repeated", + "type": "Value", + "longType": "Data.Value", + "fullType": "geobuf.Data.Value", + "ismap": false, + "isoneof": false, + "oneofdecl": "", + "defaultValue": "" + }, + { + "name": "properties", + "description": "pairs of key/value indexes", + "label": "repeated", + "type": "uint32", + "longType": "uint32", + "fullType": "uint32", + "ismap": false, + "isoneof": false, + "oneofdecl": "", + "defaultValue": "" + }, + { + "name": "custom_properties", + "description": "arbitrary properties", + "label": "repeated", + "type": "uint32", + "longType": "uint32", + "fullType": "uint32", + "ismap": false, + "isoneof": false, + "oneofdecl": "", + "defaultValue": "" + } + ] + }, + { + "name": "FeatureCollection", + "longName": "Data.FeatureCollection", + "fullName": "geobuf.Data.FeatureCollection", + "description": "", + "hasExtensions": false, + "hasFields": true, + "hasOneofs": false, + "extensions": [], + "fields": [ + { + "name": "features", + "description": "", + "label": "repeated", + "type": "Feature", + "longType": "Data.Feature", + "fullType": "geobuf.Data.Feature", + "ismap": false, + "isoneof": false, + "oneofdecl": "", + "defaultValue": "" + }, + { + "name": "values", + "description": "", + "label": "repeated", + "type": "Value", + "longType": "Data.Value", + "fullType": "geobuf.Data.Value", + "ismap": false, + "isoneof": false, + "oneofdecl": "", + "defaultValue": "" + }, + { + "name": "custom_properties", + "description": "", + "label": "repeated", + "type": "uint32", + "longType": "uint32", + "fullType": "uint32", + "ismap": false, + "isoneof": false, + "oneofdecl": "", + "defaultValue": "" + } + ] + }, + { + "name": "Geometry", + "longName": "Data.Geometry", + "fullName": "geobuf.Data.Geometry", + "description": "", + "hasExtensions": false, + "hasFields": true, + "hasOneofs": false, + "extensions": [], + "fields": [ + { + "name": "type", + "description": "", + "label": "", + "type": "Type", + "longType": "Data.Geometry.Type", + "fullType": "geobuf.Data.Geometry.Type", + "ismap": false, + "isoneof": false, + "oneofdecl": "", + "defaultValue": "" + }, + { + "name": "lengths", + "description": "coordinate structure in lengths", + "label": "repeated", + "type": "uint32", + "longType": "uint32", + "fullType": "uint32", + "ismap": false, + "isoneof": false, + "oneofdecl": "", + "defaultValue": "" + }, + { + "name": "coords", + "description": "delta-encoded integer values", + "label": "repeated", + "type": "sint64", + "longType": "sint64", + "fullType": "sint64", + "ismap": false, + "isoneof": false, + "oneofdecl": "", + "defaultValue": "" + }, + { + "name": "geometries", + "description": "", + "label": "repeated", + "type": "Geometry", + "longType": "Data.Geometry", + "fullType": "geobuf.Data.Geometry", + "ismap": false, + "isoneof": false, + "oneofdecl": "", + "defaultValue": "" + }, + { + "name": "values", + "description": "", + "label": "repeated", + "type": "Value", + "longType": "Data.Value", + "fullType": "geobuf.Data.Value", + "ismap": false, + "isoneof": false, + "oneofdecl": "", + "defaultValue": "" + }, + { + "name": "custom_properties", + "description": "", + "label": "repeated", + "type": "uint32", + "longType": "uint32", + "fullType": "uint32", + "ismap": false, + "isoneof": false, + "oneofdecl": "", + "defaultValue": "" + } + ] + }, + { + "name": "Value", + "longName": "Data.Value", + "fullName": "geobuf.Data.Value", + "description": "", + "hasExtensions": false, + "hasFields": true, + "hasOneofs": true, + "extensions": [], + "fields": [ + { + "name": "string_value", + "description": "", + "label": "", + "type": "string", + "longType": "string", + "fullType": "string", + "ismap": false, + "isoneof": true, + "oneofdecl": "value_type", + "defaultValue": "" + }, + { + "name": "double_value", + "description": "", + "label": "", + "type": "double", + "longType": "double", + "fullType": "double", + "ismap": false, + "isoneof": true, + "oneofdecl": "value_type", + "defaultValue": "" + }, + { + "name": "pos_int_value", + "description": "", + "label": "", + "type": "uint64", + "longType": "uint64", + "fullType": "uint64", + "ismap": false, + "isoneof": true, + "oneofdecl": "value_type", + "defaultValue": "" + }, + { + "name": "neg_int_value", + "description": "", + "label": "", + "type": "uint64", + "longType": "uint64", + "fullType": "uint64", + "ismap": false, + "isoneof": true, + "oneofdecl": "value_type", + "defaultValue": "" + }, + { + "name": "bool_value", + "description": "", + "label": "", + "type": "bool", + "longType": "bool", + "fullType": "bool", + "ismap": false, + "isoneof": true, + "oneofdecl": "value_type", + "defaultValue": "" + }, + { + "name": "json_value", + "description": "", + "label": "", + "type": "bytes", + "longType": "bytes", + "fullType": "bytes", + "ismap": false, + "isoneof": true, + "oneofdecl": "value_type", + "defaultValue": "" + } + ] + } + ], + "services": [] + } + ], + "scalarValueTypes": [ + { + "protoType": "double", + "notes": "", + "cppType": "double", + "csType": "double", + "goType": "float64", + "javaType": "double", + "phpType": "float", + "pythonType": "float", + "rubyType": "Float" + }, + { + "protoType": "float", + "notes": "", + "cppType": "float", + "csType": "float", + "goType": "float32", + "javaType": "float", + "phpType": "float", + "pythonType": "float", + "rubyType": "Float" + }, + { + "protoType": "int32", + "notes": "Uses variable-length encoding. Inefficient for encoding negative numbers – if your field is likely to have negative values, use sint32 instead.", + "cppType": "int32", + "csType": "int", + "goType": "int32", + "javaType": "int", + "phpType": "integer", + "pythonType": "int", + "rubyType": "Bignum or Fixnum (as required)" + }, + { + "protoType": "int64", + "notes": "Uses variable-length encoding. Inefficient for encoding negative numbers – if your field is likely to have negative values, use sint64 instead.", + "cppType": "int64", + "csType": "long", + "goType": "int64", + "javaType": "long", + "phpType": "integer/string", + "pythonType": "int/long", + "rubyType": "Bignum" + }, + { + "protoType": "uint32", + "notes": "Uses variable-length encoding.", + "cppType": "uint32", + "csType": "uint", + "goType": "uint32", + "javaType": "int", + "phpType": "integer", + "pythonType": "int/long", + "rubyType": "Bignum or Fixnum (as required)" + }, + { + "protoType": "uint64", + "notes": "Uses variable-length encoding.", + "cppType": "uint64", + "csType": "ulong", + "goType": "uint64", + "javaType": "long", + "phpType": "integer/string", + "pythonType": "int/long", + "rubyType": "Bignum or Fixnum (as required)" + }, + { + "protoType": "sint32", + "notes": "Uses variable-length encoding. Signed int value. These more efficiently encode negative numbers than regular int32s.", + "cppType": "int32", + "csType": "int", + "goType": "int32", + "javaType": "int", + "phpType": "integer", + "pythonType": "int", + "rubyType": "Bignum or Fixnum (as required)" + }, + { + "protoType": "sint64", + "notes": "Uses variable-length encoding. Signed int value. These more efficiently encode negative numbers than regular int64s.", + "cppType": "int64", + "csType": "long", + "goType": "int64", + "javaType": "long", + "phpType": "integer/string", + "pythonType": "int/long", + "rubyType": "Bignum" + }, + { + "protoType": "fixed32", + "notes": "Always four bytes. More efficient than uint32 if values are often greater than 2^28.", + "cppType": "uint32", + "csType": "uint", + "goType": "uint32", + "javaType": "int", + "phpType": "integer", + "pythonType": "int", + "rubyType": "Bignum or Fixnum (as required)" + }, + { + "protoType": "fixed64", + "notes": "Always eight bytes. More efficient than uint64 if values are often greater than 2^56.", + "cppType": "uint64", + "csType": "ulong", + "goType": "uint64", + "javaType": "long", + "phpType": "integer/string", + "pythonType": "int/long", + "rubyType": "Bignum" + }, + { + "protoType": "sfixed32", + "notes": "Always four bytes.", + "cppType": "int32", + "csType": "int", + "goType": "int32", + "javaType": "int", + "phpType": "integer", + "pythonType": "int", + "rubyType": "Bignum or Fixnum (as required)" + }, + { + "protoType": "sfixed64", + "notes": "Always eight bytes.", + "cppType": "int64", + "csType": "long", + "goType": "int64", + "javaType": "long", + "phpType": "integer/string", + "pythonType": "int/long", + "rubyType": "Bignum" + }, + { + "protoType": "bool", + "notes": "", + "cppType": "bool", + "csType": "bool", + "goType": "bool", + "javaType": "boolean", + "phpType": "boolean", + "pythonType": "boolean", + "rubyType": "TrueClass/FalseClass" + }, + { + "protoType": "string", + "notes": "A string must always contain UTF-8 encoded or 7-bit ASCII text.", + "cppType": "string", + "csType": "string", + "goType": "string", + "javaType": "String", + "phpType": "string", + "pythonType": "str/unicode", + "rubyType": "String (UTF-8)" + }, + { + "protoType": "bytes", + "notes": "May contain any arbitrary sequence of bytes.", + "cppType": "string", + "csType": "ByteString", + "goType": "[]byte", + "javaType": "ByteString", + "phpType": "string", + "pythonType": "str", + "rubyType": "String (ASCII-8BIT)" + } + ] +} \ No newline at end of file diff --git a/gen/doc/index.html b/gen/doc/index.html new file mode 100644 index 0000000..8777bc6 --- /dev/null +++ b/gen/doc/index.html @@ -0,0 +1,755 @@ + + + + + Protocol Documentation + + + + + + + + + + +

Protocol Documentation

+ +

Table of Contents

+ +
+ +
+ + + +
+

geobufpb/geobuf.proto

Top +
+

+ + +

Data

+

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FieldTypeLabelDescription
keysstringrepeated

global arrays of unique keys

dimensionsuint32

max coordinate dimensions, default 2

precisionuint32

number of digits after decimal point for coordinates, default 6

feature_collectionData.FeatureCollection

featureData.Feature

geometryData.Geometry

+ + + + + +

Data.Feature

+

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FieldTypeLabelDescription
geometryData.Geometry

idstring

int_idsint64

valuesData.Valuerepeated

unique values

propertiesuint32repeated

pairs of key/value indexes

custom_propertiesuint32repeated

arbitrary properties

+ + + + + +

Data.FeatureCollection

+

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FieldTypeLabelDescription
featuresData.Featurerepeated

valuesData.Valuerepeated

custom_propertiesuint32repeated

+ + + + + +

Data.Geometry

+

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FieldTypeLabelDescription
typeData.Geometry.Type

lengthsuint32repeated

coordinate structure in lengths

coordssint64repeated

delta-encoded integer values

geometriesData.Geometryrepeated

valuesData.Valuerepeated

custom_propertiesuint32repeated

+ + + + + +

Data.Value

+

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FieldTypeLabelDescription
string_valuestring

double_valuedouble

pos_int_valueuint64

neg_int_valueuint64

bool_valuebool

json_valuebytes

+ + + + + + + +

Data.Geometry.Type

+

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameNumberDescription
EMPTY0

POINT1

MULTIPOINT2

LINESTRING3

MULTILINESTRING4

POLYGON5

MULTIPOLYGON6

GEOMETRYCOLLECTION7

+ + + + + + + +

Scalar Value Types

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
.proto TypeNotesC++JavaPythonGoC#PHPRuby
doubledoubledoublefloatfloat64doublefloatFloat
floatfloatfloatfloatfloat32floatfloatFloat
int32Uses variable-length encoding. Inefficient for encoding negative numbers – if your field is likely to have negative values, use sint32 instead.int32intintint32intintegerBignum or Fixnum (as required)
int64Uses variable-length encoding. Inefficient for encoding negative numbers – if your field is likely to have negative values, use sint64 instead.int64longint/longint64longinteger/stringBignum
uint32Uses variable-length encoding.uint32intint/longuint32uintintegerBignum or Fixnum (as required)
uint64Uses variable-length encoding.uint64longint/longuint64ulonginteger/stringBignum or Fixnum (as required)
sint32Uses variable-length encoding. Signed int value. These more efficiently encode negative numbers than regular int32s.int32intintint32intintegerBignum or Fixnum (as required)
sint64Uses variable-length encoding. Signed int value. These more efficiently encode negative numbers than regular int64s.int64longint/longint64longinteger/stringBignum
fixed32Always four bytes. More efficient than uint32 if values are often greater than 2^28.uint32intintuint32uintintegerBignum or Fixnum (as required)
fixed64Always eight bytes. More efficient than uint64 if values are often greater than 2^56.uint64longint/longuint64ulonginteger/stringBignum
sfixed32Always four bytes.int32intintint32intintegerBignum or Fixnum (as required)
sfixed64Always eight bytes.int64longint/longint64longinteger/stringBignum
boolboolbooleanbooleanboolboolbooleanTrueClass/FalseClass
stringA string must always contain UTF-8 encoded or 7-bit ASCII text.stringStringstr/unicodestringstringstringString (UTF-8)
bytesMay contain any arbitrary sequence of bytes.stringByteStringstr[]byteByteStringstringString (ASCII-8BIT)
+ + + diff --git a/gen/doc/index.md b/gen/doc/index.md new file mode 100644 index 0000000..a1ba1d6 --- /dev/null +++ b/gen/doc/index.md @@ -0,0 +1,169 @@ +# Protocol Documentation + + +## Table of Contents + +- [geobufpb/geobuf.proto](#geobufpb_geobuf-proto) + - [Data](#geobuf-Data) + - [Data.Feature](#geobuf-Data-Feature) + - [Data.FeatureCollection](#geobuf-Data-FeatureCollection) + - [Data.Geometry](#geobuf-Data-Geometry) + - [Data.Value](#geobuf-Data-Value) + + - [Data.Geometry.Type](#geobuf-Data-Geometry-Type) + +- [Scalar Value Types](#scalar-value-types) + + + + +

Top

+ +## geobufpb/geobuf.proto + + + + + +### Data + + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| keys | [string](#string) | repeated | global arrays of unique keys | +| dimensions | [uint32](#uint32) | | max coordinate dimensions, default 2 | +| precision | [uint32](#uint32) | | number of digits after decimal point for coordinates, default 6 | +| feature_collection | [Data.FeatureCollection](#geobuf-Data-FeatureCollection) | | | +| feature | [Data.Feature](#geobuf-Data-Feature) | | | +| geometry | [Data.Geometry](#geobuf-Data-Geometry) | | | + + + + + + + + +### Data.Feature + + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| geometry | [Data.Geometry](#geobuf-Data-Geometry) | | | +| id | [string](#string) | | | +| int_id | [sint64](#sint64) | | | +| values | [Data.Value](#geobuf-Data-Value) | repeated | unique values | +| properties | [uint32](#uint32) | repeated | pairs of key/value indexes | +| custom_properties | [uint32](#uint32) | repeated | arbitrary properties | + + + + + + + + +### Data.FeatureCollection + + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| features | [Data.Feature](#geobuf-Data-Feature) | repeated | | +| values | [Data.Value](#geobuf-Data-Value) | repeated | | +| custom_properties | [uint32](#uint32) | repeated | | + + + + + + + + +### Data.Geometry + + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| type | [Data.Geometry.Type](#geobuf-Data-Geometry-Type) | | | +| lengths | [uint32](#uint32) | repeated | coordinate structure in lengths | +| coords | [sint64](#sint64) | repeated | delta-encoded integer values | +| geometries | [Data.Geometry](#geobuf-Data-Geometry) | repeated | | +| values | [Data.Value](#geobuf-Data-Value) | repeated | | +| custom_properties | [uint32](#uint32) | repeated | | + + + + + + + + +### Data.Value + + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| string_value | [string](#string) | | | +| double_value | [double](#double) | | | +| pos_int_value | [uint64](#uint64) | | | +| neg_int_value | [uint64](#uint64) | | | +| bool_value | [bool](#bool) | | | +| json_value | [bytes](#bytes) | | | + + + + + + + + + + +### Data.Geometry.Type + + +| Name | Number | Description | +| ---- | ------ | ----------- | +| EMPTY | 0 | | +| POINT | 1 | | +| MULTIPOINT | 2 | | +| LINESTRING | 3 | | +| MULTILINESTRING | 4 | | +| POLYGON | 5 | | +| MULTIPOLYGON | 6 | | +| GEOMETRYCOLLECTION | 7 | | + + + + + + + + + + +## Scalar Value Types + +| .proto Type | Notes | C++ | Java | Python | Go | C# | PHP | Ruby | +| ----------- | ----- | --- | ---- | ------ | -- | -- | --- | ---- | +| double | | double | double | float | float64 | double | float | Float | +| float | | float | float | float | float32 | float | float | Float | +| int32 | Uses variable-length encoding. Inefficient for encoding negative numbers – if your field is likely to have negative values, use sint32 instead. | int32 | int | int | int32 | int | integer | Bignum or Fixnum (as required) | +| int64 | Uses variable-length encoding. Inefficient for encoding negative numbers – if your field is likely to have negative values, use sint64 instead. | int64 | long | int/long | int64 | long | integer/string | Bignum | +| uint32 | Uses variable-length encoding. | uint32 | int | int/long | uint32 | uint | integer | Bignum or Fixnum (as required) | +| uint64 | Uses variable-length encoding. | uint64 | long | int/long | uint64 | ulong | integer/string | Bignum or Fixnum (as required) | +| sint32 | Uses variable-length encoding. Signed int value. These more efficiently encode negative numbers than regular int32s. | int32 | int | int | int32 | int | integer | Bignum or Fixnum (as required) | +| sint64 | Uses variable-length encoding. Signed int value. These more efficiently encode negative numbers than regular int64s. | int64 | long | int/long | int64 | long | integer/string | Bignum | +| fixed32 | Always four bytes. More efficient than uint32 if values are often greater than 2^28. | uint32 | int | int | uint32 | uint | integer | Bignum or Fixnum (as required) | +| fixed64 | Always eight bytes. More efficient than uint64 if values are often greater than 2^56. | uint64 | long | int/long | uint64 | ulong | integer/string | Bignum | +| sfixed32 | Always four bytes. | int32 | int | int | int32 | int | integer | Bignum or Fixnum (as required) | +| sfixed64 | Always eight bytes. | int64 | long | int/long | int64 | long | integer/string | Bignum | +| bool | | bool | boolean | boolean | bool | bool | boolean | TrueClass/FalseClass | +| string | A string must always contain UTF-8 encoded or 7-bit ASCII text. | string | String | str/unicode | string | string | string | String (UTF-8) | +| bytes | May contain any arbitrary sequence of bytes. | string | ByteString | str | []byte | ByteString | string | String (ASCII-8BIT) | + diff --git a/geobufpb/buf.go.yaml b/geobufpb/buf.go.yaml new file mode 100644 index 0000000..64d5beb --- /dev/null +++ b/geobufpb/buf.go.yaml @@ -0,0 +1,30 @@ +version: v1 +plugins: + # Documentation + - name: doc + out: gen/doc + opt: html,index.html + strategy: all + + - name: doc + out: gen/doc + opt: markdown,index.md + strategy: all + + - name: doc + out: gen/doc + opt: json,doc.json + strategy: all + + # Go + - plugin: go + out: . + opt: paths=source_relative + - plugin: elixir + out: ./elixir + opt: paths=source_relative + - name: go-vtproto + out: . + opt: + - paths=source_relative + - features=marshal+unmarshal+size+pool \ No newline at end of file diff --git a/proto/buf.lock b/geobufpb/buf.lock similarity index 100% rename from proto/buf.lock rename to geobufpb/buf.lock diff --git a/proto/buf.yaml b/geobufpb/buf.yaml similarity index 100% rename from proto/buf.yaml rename to geobufpb/buf.yaml diff --git a/proto/doc.go b/geobufpb/doc.go similarity index 73% rename from proto/doc.go rename to geobufpb/doc.go index 46d059a..8a18983 100644 --- a/proto/doc.go +++ b/geobufpb/doc.go @@ -1,3 +1,3 @@ //go:generate protoc --go_out=. geobuf.proto -package proto +package geobufpb diff --git a/proto/geobuf.pb.go b/geobufpb/geobuf.pb.go similarity index 58% rename from proto/geobuf.pb.go rename to geobufpb/geobuf.pb.go index e96dd02..e7b21b1 100644 --- a/proto/geobuf.pb.go +++ b/geobufpb/geobuf.pb.go @@ -2,9 +2,9 @@ // versions: // protoc-gen-go v1.31.0 // protoc (unknown) -// source: proto/geobuf.proto +// source: geobufpb/geobuf.proto -package proto +package geobufpb import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" @@ -23,34 +23,37 @@ const ( type Data_Geometry_Type int32 const ( - Data_Geometry_POINT Data_Geometry_Type = 0 - Data_Geometry_MULTIPOINT Data_Geometry_Type = 1 - Data_Geometry_LINESTRING Data_Geometry_Type = 2 - Data_Geometry_MULTILINESTRING Data_Geometry_Type = 3 - Data_Geometry_POLYGON Data_Geometry_Type = 4 - Data_Geometry_MULTIPOLYGON Data_Geometry_Type = 5 - Data_Geometry_GEOMETRYCOLLECTION Data_Geometry_Type = 6 + Data_Geometry_EMPTY Data_Geometry_Type = 0 + Data_Geometry_POINT Data_Geometry_Type = 1 + Data_Geometry_MULTIPOINT Data_Geometry_Type = 2 + Data_Geometry_LINESTRING Data_Geometry_Type = 3 + Data_Geometry_MULTILINESTRING Data_Geometry_Type = 4 + Data_Geometry_POLYGON Data_Geometry_Type = 5 + Data_Geometry_MULTIPOLYGON Data_Geometry_Type = 6 + Data_Geometry_GEOMETRYCOLLECTION Data_Geometry_Type = 7 ) // Enum value maps for Data_Geometry_Type. var ( Data_Geometry_Type_name = map[int32]string{ - 0: "POINT", - 1: "MULTIPOINT", - 2: "LINESTRING", - 3: "MULTILINESTRING", - 4: "POLYGON", - 5: "MULTIPOLYGON", - 6: "GEOMETRYCOLLECTION", + 0: "EMPTY", + 1: "POINT", + 2: "MULTIPOINT", + 3: "LINESTRING", + 4: "MULTILINESTRING", + 5: "POLYGON", + 6: "MULTIPOLYGON", + 7: "GEOMETRYCOLLECTION", } Data_Geometry_Type_value = map[string]int32{ - "POINT": 0, - "MULTIPOINT": 1, - "LINESTRING": 2, - "MULTILINESTRING": 3, - "POLYGON": 4, - "MULTIPOLYGON": 5, - "GEOMETRYCOLLECTION": 6, + "EMPTY": 0, + "POINT": 1, + "MULTIPOINT": 2, + "LINESTRING": 3, + "MULTILINESTRING": 4, + "POLYGON": 5, + "MULTIPOLYGON": 6, + "GEOMETRYCOLLECTION": 7, } ) @@ -65,11 +68,11 @@ func (x Data_Geometry_Type) String() string { } func (Data_Geometry_Type) Descriptor() protoreflect.EnumDescriptor { - return file_proto_geobuf_proto_enumTypes[0].Descriptor() + return file_geobufpb_geobuf_proto_enumTypes[0].Descriptor() } func (Data_Geometry_Type) Type() protoreflect.EnumType { - return &file_proto_geobuf_proto_enumTypes[0] + return &file_geobufpb_geobuf_proto_enumTypes[0] } func (x Data_Geometry_Type) Number() protoreflect.EnumNumber { @@ -78,7 +81,7 @@ func (x Data_Geometry_Type) Number() protoreflect.EnumNumber { // Deprecated: Use Data_Geometry_Type.Descriptor instead. func (Data_Geometry_Type) EnumDescriptor() ([]byte, []int) { - return file_proto_geobuf_proto_rawDescGZIP(), []int{0, 1, 0} + return file_geobufpb_geobuf_proto_rawDescGZIP(), []int{0, 1, 0} } type Data struct { @@ -100,7 +103,7 @@ type Data struct { func (x *Data) Reset() { *x = Data{} if protoimpl.UnsafeEnabled { - mi := &file_proto_geobuf_proto_msgTypes[0] + mi := &file_geobufpb_geobuf_proto_msgTypes[0] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -113,7 +116,7 @@ func (x *Data) String() string { func (*Data) ProtoMessage() {} func (x *Data) ProtoReflect() protoreflect.Message { - mi := &file_proto_geobuf_proto_msgTypes[0] + mi := &file_geobufpb_geobuf_proto_msgTypes[0] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -126,7 +129,7 @@ func (x *Data) ProtoReflect() protoreflect.Message { // Deprecated: Use Data.ProtoReflect.Descriptor instead. func (*Data) Descriptor() ([]byte, []int) { - return file_proto_geobuf_proto_rawDescGZIP(), []int{0} + return file_geobufpb_geobuf_proto_rawDescGZIP(), []int{0} } func (x *Data) GetKeys() []string { @@ -219,7 +222,7 @@ type Data_Feature struct { func (x *Data_Feature) Reset() { *x = Data_Feature{} if protoimpl.UnsafeEnabled { - mi := &file_proto_geobuf_proto_msgTypes[1] + mi := &file_geobufpb_geobuf_proto_msgTypes[1] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -232,7 +235,7 @@ func (x *Data_Feature) String() string { func (*Data_Feature) ProtoMessage() {} func (x *Data_Feature) ProtoReflect() protoreflect.Message { - mi := &file_proto_geobuf_proto_msgTypes[1] + mi := &file_geobufpb_geobuf_proto_msgTypes[1] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -245,7 +248,7 @@ func (x *Data_Feature) ProtoReflect() protoreflect.Message { // Deprecated: Use Data_Feature.ProtoReflect.Descriptor instead. func (*Data_Feature) Descriptor() ([]byte, []int) { - return file_proto_geobuf_proto_rawDescGZIP(), []int{0, 0} + return file_geobufpb_geobuf_proto_rawDescGZIP(), []int{0, 0} } func (x *Data_Feature) GetGeometry() *Data_Geometry { @@ -329,7 +332,7 @@ type Data_Geometry struct { func (x *Data_Geometry) Reset() { *x = Data_Geometry{} if protoimpl.UnsafeEnabled { - mi := &file_proto_geobuf_proto_msgTypes[2] + mi := &file_geobufpb_geobuf_proto_msgTypes[2] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -342,7 +345,7 @@ func (x *Data_Geometry) String() string { func (*Data_Geometry) ProtoMessage() {} func (x *Data_Geometry) ProtoReflect() protoreflect.Message { - mi := &file_proto_geobuf_proto_msgTypes[2] + mi := &file_geobufpb_geobuf_proto_msgTypes[2] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -355,14 +358,14 @@ func (x *Data_Geometry) ProtoReflect() protoreflect.Message { // Deprecated: Use Data_Geometry.ProtoReflect.Descriptor instead. func (*Data_Geometry) Descriptor() ([]byte, []int) { - return file_proto_geobuf_proto_rawDescGZIP(), []int{0, 1} + return file_geobufpb_geobuf_proto_rawDescGZIP(), []int{0, 1} } func (x *Data_Geometry) GetType() Data_Geometry_Type { if x != nil { return x.Type } - return Data_Geometry_POINT + return Data_Geometry_EMPTY } func (x *Data_Geometry) GetLengths() []uint32 { @@ -413,7 +416,7 @@ type Data_FeatureCollection struct { func (x *Data_FeatureCollection) Reset() { *x = Data_FeatureCollection{} if protoimpl.UnsafeEnabled { - mi := &file_proto_geobuf_proto_msgTypes[3] + mi := &file_geobufpb_geobuf_proto_msgTypes[3] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -426,7 +429,7 @@ func (x *Data_FeatureCollection) String() string { func (*Data_FeatureCollection) ProtoMessage() {} func (x *Data_FeatureCollection) ProtoReflect() protoreflect.Message { - mi := &file_proto_geobuf_proto_msgTypes[3] + mi := &file_geobufpb_geobuf_proto_msgTypes[3] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -439,7 +442,7 @@ func (x *Data_FeatureCollection) ProtoReflect() protoreflect.Message { // Deprecated: Use Data_FeatureCollection.ProtoReflect.Descriptor instead. func (*Data_FeatureCollection) Descriptor() ([]byte, []int) { - return file_proto_geobuf_proto_rawDescGZIP(), []int{0, 2} + return file_geobufpb_geobuf_proto_rawDescGZIP(), []int{0, 2} } func (x *Data_FeatureCollection) GetFeatures() []*Data_Feature { @@ -482,7 +485,7 @@ type Data_Value struct { func (x *Data_Value) Reset() { *x = Data_Value{} if protoimpl.UnsafeEnabled { - mi := &file_proto_geobuf_proto_msgTypes[4] + mi := &file_geobufpb_geobuf_proto_msgTypes[4] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -495,7 +498,7 @@ func (x *Data_Value) String() string { func (*Data_Value) ProtoMessage() {} func (x *Data_Value) ProtoReflect() protoreflect.Message { - mi := &file_proto_geobuf_proto_msgTypes[4] + mi := &file_geobufpb_geobuf_proto_msgTypes[4] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -508,7 +511,7 @@ func (x *Data_Value) ProtoReflect() protoreflect.Message { // Deprecated: Use Data_Value.ProtoReflect.Descriptor instead. func (*Data_Value) Descriptor() ([]byte, []int) { - return file_proto_geobuf_proto_rawDescGZIP(), []int{0, 3} + return file_geobufpb_geobuf_proto_rawDescGZIP(), []int{0, 3} } func (m *Data_Value) GetValueType() isData_Value_ValueType { @@ -600,113 +603,114 @@ func (*Data_Value_BoolValue) isData_Value_ValueType() {} func (*Data_Value_JsonValue) isData_Value_ValueType() {} -var File_proto_geobuf_proto protoreflect.FileDescriptor - -var file_proto_geobuf_proto_rawDesc = []byte{ - 0x0a, 0x12, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x67, 0x65, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x06, 0x67, 0x65, 0x6f, 0x62, 0x75, 0x66, 0x22, 0x9a, 0x0a, 0x0a, - 0x04, 0x44, 0x61, 0x74, 0x61, 0x12, 0x12, 0x0a, 0x04, 0x6b, 0x65, 0x79, 0x73, 0x18, 0x01, 0x20, - 0x03, 0x28, 0x09, 0x52, 0x04, 0x6b, 0x65, 0x79, 0x73, 0x12, 0x1e, 0x0a, 0x0a, 0x64, 0x69, 0x6d, - 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0a, 0x64, - 0x69, 0x6d, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x1c, 0x0a, 0x09, 0x70, 0x72, 0x65, - 0x63, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x09, 0x70, 0x72, - 0x65, 0x63, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x4f, 0x0a, 0x12, 0x66, 0x65, 0x61, 0x74, 0x75, - 0x72, 0x65, 0x5f, 0x63, 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x04, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x67, 0x65, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x44, 0x61, 0x74, - 0x61, 0x2e, 0x46, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x43, 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, - 0x69, 0x6f, 0x6e, 0x48, 0x00, 0x52, 0x11, 0x66, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x43, 0x6f, - 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x30, 0x0a, 0x07, 0x66, 0x65, 0x61, 0x74, - 0x75, 0x72, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x65, 0x6f, 0x62, - 0x75, 0x66, 0x2e, 0x44, 0x61, 0x74, 0x61, 0x2e, 0x46, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x48, - 0x00, 0x52, 0x07, 0x66, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x12, 0x33, 0x0a, 0x08, 0x67, 0x65, - 0x6f, 0x6d, 0x65, 0x74, 0x72, 0x79, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x67, - 0x65, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x44, 0x61, 0x74, 0x61, 0x2e, 0x47, 0x65, 0x6f, 0x6d, 0x65, - 0x74, 0x72, 0x79, 0x48, 0x00, 0x52, 0x08, 0x67, 0x65, 0x6f, 0x6d, 0x65, 0x74, 0x72, 0x79, 0x1a, - 0xeb, 0x01, 0x0a, 0x07, 0x46, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x12, 0x31, 0x0a, 0x08, 0x67, - 0x65, 0x6f, 0x6d, 0x65, 0x74, 0x72, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15, 0x2e, - 0x67, 0x65, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x44, 0x61, 0x74, 0x61, 0x2e, 0x47, 0x65, 0x6f, 0x6d, - 0x65, 0x74, 0x72, 0x79, 0x52, 0x08, 0x67, 0x65, 0x6f, 0x6d, 0x65, 0x74, 0x72, 0x79, 0x12, 0x10, - 0x0a, 0x02, 0x69, 0x64, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x02, 0x69, 0x64, - 0x12, 0x17, 0x0a, 0x06, 0x69, 0x6e, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x12, - 0x48, 0x00, 0x52, 0x05, 0x69, 0x6e, 0x74, 0x49, 0x64, 0x12, 0x2a, 0x0a, 0x06, 0x76, 0x61, 0x6c, - 0x75, 0x65, 0x73, 0x18, 0x0d, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x67, 0x65, 0x6f, 0x62, - 0x75, 0x66, 0x2e, 0x44, 0x61, 0x74, 0x61, 0x2e, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x06, 0x76, - 0x61, 0x6c, 0x75, 0x65, 0x73, 0x12, 0x1e, 0x0a, 0x0a, 0x70, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, - 0x69, 0x65, 0x73, 0x18, 0x0e, 0x20, 0x03, 0x28, 0x0d, 0x52, 0x0a, 0x70, 0x72, 0x6f, 0x70, 0x65, - 0x72, 0x74, 0x69, 0x65, 0x73, 0x12, 0x2b, 0x0a, 0x11, 0x63, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x5f, - 0x70, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x69, 0x65, 0x73, 0x18, 0x0f, 0x20, 0x03, 0x28, 0x0d, - 0x52, 0x10, 0x63, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x50, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x69, - 0x65, 0x73, 0x42, 0x09, 0x0a, 0x07, 0x69, 0x64, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x1a, 0xfb, 0x02, - 0x0a, 0x08, 0x47, 0x65, 0x6f, 0x6d, 0x65, 0x74, 0x72, 0x79, 0x12, 0x2e, 0x0a, 0x04, 0x74, 0x79, - 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1a, 0x2e, 0x67, 0x65, 0x6f, 0x62, 0x75, - 0x66, 0x2e, 0x44, 0x61, 0x74, 0x61, 0x2e, 0x47, 0x65, 0x6f, 0x6d, 0x65, 0x74, 0x72, 0x79, 0x2e, - 0x54, 0x79, 0x70, 0x65, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x6c, 0x65, - 0x6e, 0x67, 0x74, 0x68, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0d, 0x52, 0x07, 0x6c, 0x65, 0x6e, - 0x67, 0x74, 0x68, 0x73, 0x12, 0x16, 0x0a, 0x06, 0x63, 0x6f, 0x6f, 0x72, 0x64, 0x73, 0x18, 0x03, - 0x20, 0x03, 0x28, 0x12, 0x52, 0x06, 0x63, 0x6f, 0x6f, 0x72, 0x64, 0x73, 0x12, 0x35, 0x0a, 0x0a, - 0x67, 0x65, 0x6f, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x65, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, +var File_geobufpb_geobuf_proto protoreflect.FileDescriptor + +var file_geobufpb_geobuf_proto_rawDesc = []byte{ + 0x0a, 0x15, 0x67, 0x65, 0x6f, 0x62, 0x75, 0x66, 0x70, 0x62, 0x2f, 0x67, 0x65, 0x6f, 0x62, 0x75, + 0x66, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x06, 0x67, 0x65, 0x6f, 0x62, 0x75, 0x66, 0x22, + 0xa6, 0x0a, 0x0a, 0x04, 0x44, 0x61, 0x74, 0x61, 0x12, 0x12, 0x0a, 0x04, 0x6b, 0x65, 0x79, 0x73, + 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x04, 0x6b, 0x65, 0x79, 0x73, 0x12, 0x1e, 0x0a, 0x0a, + 0x64, 0x69, 0x6d, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, + 0x52, 0x0a, 0x64, 0x69, 0x6d, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x1c, 0x0a, 0x09, + 0x70, 0x72, 0x65, 0x63, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0d, 0x52, + 0x09, 0x70, 0x72, 0x65, 0x63, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x4f, 0x0a, 0x12, 0x66, 0x65, + 0x61, 0x74, 0x75, 0x72, 0x65, 0x5f, 0x63, 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, + 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x67, 0x65, 0x6f, 0x62, 0x75, 0x66, 0x2e, + 0x44, 0x61, 0x74, 0x61, 0x2e, 0x46, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x43, 0x6f, 0x6c, 0x6c, + 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x48, 0x00, 0x52, 0x11, 0x66, 0x65, 0x61, 0x74, 0x75, 0x72, + 0x65, 0x43, 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x30, 0x0a, 0x07, 0x66, + 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, + 0x65, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x44, 0x61, 0x74, 0x61, 0x2e, 0x46, 0x65, 0x61, 0x74, 0x75, + 0x72, 0x65, 0x48, 0x00, 0x52, 0x07, 0x66, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x12, 0x33, 0x0a, + 0x08, 0x67, 0x65, 0x6f, 0x6d, 0x65, 0x74, 0x72, 0x79, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x15, 0x2e, 0x67, 0x65, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x44, 0x61, 0x74, 0x61, 0x2e, 0x47, 0x65, + 0x6f, 0x6d, 0x65, 0x74, 0x72, 0x79, 0x48, 0x00, 0x52, 0x08, 0x67, 0x65, 0x6f, 0x6d, 0x65, 0x74, + 0x72, 0x79, 0x1a, 0xeb, 0x01, 0x0a, 0x07, 0x46, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x12, 0x31, + 0x0a, 0x08, 0x67, 0x65, 0x6f, 0x6d, 0x65, 0x74, 0x72, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x67, 0x65, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x44, 0x61, 0x74, 0x61, 0x2e, 0x47, - 0x65, 0x6f, 0x6d, 0x65, 0x74, 0x72, 0x79, 0x52, 0x0a, 0x67, 0x65, 0x6f, 0x6d, 0x65, 0x74, 0x72, - 0x69, 0x65, 0x73, 0x12, 0x2a, 0x0a, 0x06, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x18, 0x0d, 0x20, - 0x03, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x67, 0x65, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x44, 0x61, 0x74, - 0x61, 0x2e, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x06, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x12, - 0x2b, 0x0a, 0x11, 0x63, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x5f, 0x70, 0x72, 0x6f, 0x70, 0x65, 0x72, - 0x74, 0x69, 0x65, 0x73, 0x18, 0x0f, 0x20, 0x03, 0x28, 0x0d, 0x52, 0x10, 0x63, 0x75, 0x73, 0x74, - 0x6f, 0x6d, 0x50, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x69, 0x65, 0x73, 0x22, 0x7d, 0x0a, 0x04, - 0x54, 0x79, 0x70, 0x65, 0x12, 0x09, 0x0a, 0x05, 0x50, 0x4f, 0x49, 0x4e, 0x54, 0x10, 0x00, 0x12, - 0x0e, 0x0a, 0x0a, 0x4d, 0x55, 0x4c, 0x54, 0x49, 0x50, 0x4f, 0x49, 0x4e, 0x54, 0x10, 0x01, 0x12, - 0x0e, 0x0a, 0x0a, 0x4c, 0x49, 0x4e, 0x45, 0x53, 0x54, 0x52, 0x49, 0x4e, 0x47, 0x10, 0x02, 0x12, - 0x13, 0x0a, 0x0f, 0x4d, 0x55, 0x4c, 0x54, 0x49, 0x4c, 0x49, 0x4e, 0x45, 0x53, 0x54, 0x52, 0x49, - 0x4e, 0x47, 0x10, 0x03, 0x12, 0x0b, 0x0a, 0x07, 0x50, 0x4f, 0x4c, 0x59, 0x47, 0x4f, 0x4e, 0x10, - 0x04, 0x12, 0x10, 0x0a, 0x0c, 0x4d, 0x55, 0x4c, 0x54, 0x49, 0x50, 0x4f, 0x4c, 0x59, 0x47, 0x4f, - 0x4e, 0x10, 0x05, 0x12, 0x16, 0x0a, 0x12, 0x47, 0x45, 0x4f, 0x4d, 0x45, 0x54, 0x52, 0x59, 0x43, - 0x4f, 0x4c, 0x4c, 0x45, 0x43, 0x54, 0x49, 0x4f, 0x4e, 0x10, 0x06, 0x1a, 0x9e, 0x01, 0x0a, 0x11, - 0x46, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x43, 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, - 0x6e, 0x12, 0x30, 0x0a, 0x08, 0x66, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x73, 0x18, 0x01, 0x20, - 0x03, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x65, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x44, 0x61, 0x74, - 0x61, 0x2e, 0x46, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x52, 0x08, 0x66, 0x65, 0x61, 0x74, 0x75, - 0x72, 0x65, 0x73, 0x12, 0x2a, 0x0a, 0x06, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x18, 0x0d, 0x20, - 0x03, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x67, 0x65, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x44, 0x61, 0x74, - 0x61, 0x2e, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x06, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x12, - 0x2b, 0x0a, 0x11, 0x63, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x5f, 0x70, 0x72, 0x6f, 0x70, 0x65, 0x72, - 0x74, 0x69, 0x65, 0x73, 0x18, 0x0f, 0x20, 0x03, 0x28, 0x0d, 0x52, 0x10, 0x63, 0x75, 0x73, 0x74, - 0x6f, 0x6d, 0x50, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x69, 0x65, 0x73, 0x1a, 0xed, 0x01, 0x0a, - 0x05, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x23, 0x0a, 0x0c, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, - 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x0b, - 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x23, 0x0a, 0x0c, 0x64, - 0x6f, 0x75, 0x62, 0x6c, 0x65, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x01, 0x48, 0x00, 0x52, 0x0b, 0x64, 0x6f, 0x75, 0x62, 0x6c, 0x65, 0x56, 0x61, 0x6c, 0x75, 0x65, - 0x12, 0x24, 0x0a, 0x0d, 0x70, 0x6f, 0x73, 0x5f, 0x69, 0x6e, 0x74, 0x5f, 0x76, 0x61, 0x6c, 0x75, - 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, 0x48, 0x00, 0x52, 0x0b, 0x70, 0x6f, 0x73, 0x49, 0x6e, - 0x74, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x24, 0x0a, 0x0d, 0x6e, 0x65, 0x67, 0x5f, 0x69, 0x6e, - 0x74, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x04, 0x48, 0x00, 0x52, - 0x0b, 0x6e, 0x65, 0x67, 0x49, 0x6e, 0x74, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x1f, 0x0a, 0x0a, - 0x62, 0x6f, 0x6f, 0x6c, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, - 0x48, 0x00, 0x52, 0x09, 0x62, 0x6f, 0x6f, 0x6c, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x1f, 0x0a, - 0x0a, 0x6a, 0x73, 0x6f, 0x6e, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, - 0x0c, 0x48, 0x00, 0x52, 0x09, 0x6a, 0x73, 0x6f, 0x6e, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x42, 0x0c, - 0x0a, 0x0a, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x42, 0x0b, 0x0a, 0x09, - 0x64, 0x61, 0x74, 0x61, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x42, 0x22, 0x5a, 0x20, 0x67, 0x69, 0x74, - 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6d, 0x73, 0x63, 0x6e, 0x6f, 0x2f, 0x67, 0x6f, - 0x2d, 0x67, 0x65, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x65, 0x6f, 0x6d, 0x65, 0x74, 0x72, 0x79, 0x52, 0x08, 0x67, 0x65, 0x6f, 0x6d, 0x65, 0x74, 0x72, + 0x79, 0x12, 0x10, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, + 0x02, 0x69, 0x64, 0x12, 0x17, 0x0a, 0x06, 0x69, 0x6e, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x0c, 0x20, + 0x01, 0x28, 0x12, 0x48, 0x00, 0x52, 0x05, 0x69, 0x6e, 0x74, 0x49, 0x64, 0x12, 0x2a, 0x0a, 0x06, + 0x76, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x18, 0x0d, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x67, + 0x65, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x44, 0x61, 0x74, 0x61, 0x2e, 0x56, 0x61, 0x6c, 0x75, 0x65, + 0x52, 0x06, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x12, 0x1e, 0x0a, 0x0a, 0x70, 0x72, 0x6f, 0x70, + 0x65, 0x72, 0x74, 0x69, 0x65, 0x73, 0x18, 0x0e, 0x20, 0x03, 0x28, 0x0d, 0x52, 0x0a, 0x70, 0x72, + 0x6f, 0x70, 0x65, 0x72, 0x74, 0x69, 0x65, 0x73, 0x12, 0x2b, 0x0a, 0x11, 0x63, 0x75, 0x73, 0x74, + 0x6f, 0x6d, 0x5f, 0x70, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x69, 0x65, 0x73, 0x18, 0x0f, 0x20, + 0x03, 0x28, 0x0d, 0x52, 0x10, 0x63, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x50, 0x72, 0x6f, 0x70, 0x65, + 0x72, 0x74, 0x69, 0x65, 0x73, 0x42, 0x09, 0x0a, 0x07, 0x69, 0x64, 0x5f, 0x74, 0x79, 0x70, 0x65, + 0x1a, 0x87, 0x03, 0x0a, 0x08, 0x47, 0x65, 0x6f, 0x6d, 0x65, 0x74, 0x72, 0x79, 0x12, 0x2e, 0x0a, + 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1a, 0x2e, 0x67, 0x65, + 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x44, 0x61, 0x74, 0x61, 0x2e, 0x47, 0x65, 0x6f, 0x6d, 0x65, 0x74, + 0x72, 0x79, 0x2e, 0x54, 0x79, 0x70, 0x65, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x18, 0x0a, + 0x07, 0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0d, 0x52, 0x07, + 0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x73, 0x12, 0x16, 0x0a, 0x06, 0x63, 0x6f, 0x6f, 0x72, 0x64, + 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x12, 0x52, 0x06, 0x63, 0x6f, 0x6f, 0x72, 0x64, 0x73, 0x12, + 0x35, 0x0a, 0x0a, 0x67, 0x65, 0x6f, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x65, 0x73, 0x18, 0x04, 0x20, + 0x03, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x67, 0x65, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x44, 0x61, 0x74, + 0x61, 0x2e, 0x47, 0x65, 0x6f, 0x6d, 0x65, 0x74, 0x72, 0x79, 0x52, 0x0a, 0x67, 0x65, 0x6f, 0x6d, + 0x65, 0x74, 0x72, 0x69, 0x65, 0x73, 0x12, 0x2a, 0x0a, 0x06, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x73, + 0x18, 0x0d, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x67, 0x65, 0x6f, 0x62, 0x75, 0x66, 0x2e, + 0x44, 0x61, 0x74, 0x61, 0x2e, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x06, 0x76, 0x61, 0x6c, 0x75, + 0x65, 0x73, 0x12, 0x2b, 0x0a, 0x11, 0x63, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x5f, 0x70, 0x72, 0x6f, + 0x70, 0x65, 0x72, 0x74, 0x69, 0x65, 0x73, 0x18, 0x0f, 0x20, 0x03, 0x28, 0x0d, 0x52, 0x10, 0x63, + 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x50, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x69, 0x65, 0x73, 0x22, + 0x88, 0x01, 0x0a, 0x04, 0x54, 0x79, 0x70, 0x65, 0x12, 0x09, 0x0a, 0x05, 0x45, 0x4d, 0x50, 0x54, + 0x59, 0x10, 0x00, 0x12, 0x09, 0x0a, 0x05, 0x50, 0x4f, 0x49, 0x4e, 0x54, 0x10, 0x01, 0x12, 0x0e, + 0x0a, 0x0a, 0x4d, 0x55, 0x4c, 0x54, 0x49, 0x50, 0x4f, 0x49, 0x4e, 0x54, 0x10, 0x02, 0x12, 0x0e, + 0x0a, 0x0a, 0x4c, 0x49, 0x4e, 0x45, 0x53, 0x54, 0x52, 0x49, 0x4e, 0x47, 0x10, 0x03, 0x12, 0x13, + 0x0a, 0x0f, 0x4d, 0x55, 0x4c, 0x54, 0x49, 0x4c, 0x49, 0x4e, 0x45, 0x53, 0x54, 0x52, 0x49, 0x4e, + 0x47, 0x10, 0x04, 0x12, 0x0b, 0x0a, 0x07, 0x50, 0x4f, 0x4c, 0x59, 0x47, 0x4f, 0x4e, 0x10, 0x05, + 0x12, 0x10, 0x0a, 0x0c, 0x4d, 0x55, 0x4c, 0x54, 0x49, 0x50, 0x4f, 0x4c, 0x59, 0x47, 0x4f, 0x4e, + 0x10, 0x06, 0x12, 0x16, 0x0a, 0x12, 0x47, 0x45, 0x4f, 0x4d, 0x45, 0x54, 0x52, 0x59, 0x43, 0x4f, + 0x4c, 0x4c, 0x45, 0x43, 0x54, 0x49, 0x4f, 0x4e, 0x10, 0x07, 0x1a, 0x9e, 0x01, 0x0a, 0x11, 0x46, + 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x43, 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, + 0x12, 0x30, 0x0a, 0x08, 0x66, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, + 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x65, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x44, 0x61, 0x74, 0x61, + 0x2e, 0x46, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x52, 0x08, 0x66, 0x65, 0x61, 0x74, 0x75, 0x72, + 0x65, 0x73, 0x12, 0x2a, 0x0a, 0x06, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x18, 0x0d, 0x20, 0x03, + 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x67, 0x65, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x44, 0x61, 0x74, 0x61, + 0x2e, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x06, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x12, 0x2b, + 0x0a, 0x11, 0x63, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x5f, 0x70, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, + 0x69, 0x65, 0x73, 0x18, 0x0f, 0x20, 0x03, 0x28, 0x0d, 0x52, 0x10, 0x63, 0x75, 0x73, 0x74, 0x6f, + 0x6d, 0x50, 0x72, 0x6f, 0x70, 0x65, 0x72, 0x74, 0x69, 0x65, 0x73, 0x1a, 0xed, 0x01, 0x0a, 0x05, + 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x23, 0x0a, 0x0c, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x5f, + 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x0b, 0x73, + 0x74, 0x72, 0x69, 0x6e, 0x67, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x23, 0x0a, 0x0c, 0x64, 0x6f, + 0x75, 0x62, 0x6c, 0x65, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x01, + 0x48, 0x00, 0x52, 0x0b, 0x64, 0x6f, 0x75, 0x62, 0x6c, 0x65, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, + 0x24, 0x0a, 0x0d, 0x70, 0x6f, 0x73, 0x5f, 0x69, 0x6e, 0x74, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, + 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, 0x48, 0x00, 0x52, 0x0b, 0x70, 0x6f, 0x73, 0x49, 0x6e, 0x74, + 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x24, 0x0a, 0x0d, 0x6e, 0x65, 0x67, 0x5f, 0x69, 0x6e, 0x74, + 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x04, 0x48, 0x00, 0x52, 0x0b, + 0x6e, 0x65, 0x67, 0x49, 0x6e, 0x74, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x1f, 0x0a, 0x0a, 0x62, + 0x6f, 0x6f, 0x6c, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x48, + 0x00, 0x52, 0x09, 0x62, 0x6f, 0x6f, 0x6c, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x1f, 0x0a, 0x0a, + 0x6a, 0x73, 0x6f, 0x6e, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0c, + 0x48, 0x00, 0x52, 0x09, 0x6a, 0x73, 0x6f, 0x6e, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x42, 0x0c, 0x0a, + 0x0a, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x42, 0x0b, 0x0a, 0x09, 0x64, + 0x61, 0x74, 0x61, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x42, 0x25, 0x5a, 0x23, 0x67, 0x69, 0x74, 0x68, + 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6d, 0x73, 0x63, 0x6e, 0x6f, 0x2f, 0x67, 0x6f, 0x2d, + 0x67, 0x65, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x67, 0x65, 0x6f, 0x62, 0x75, 0x66, 0x70, 0x62, 0x62, + 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( - file_proto_geobuf_proto_rawDescOnce sync.Once - file_proto_geobuf_proto_rawDescData = file_proto_geobuf_proto_rawDesc + file_geobufpb_geobuf_proto_rawDescOnce sync.Once + file_geobufpb_geobuf_proto_rawDescData = file_geobufpb_geobuf_proto_rawDesc ) -func file_proto_geobuf_proto_rawDescGZIP() []byte { - file_proto_geobuf_proto_rawDescOnce.Do(func() { - file_proto_geobuf_proto_rawDescData = protoimpl.X.CompressGZIP(file_proto_geobuf_proto_rawDescData) +func file_geobufpb_geobuf_proto_rawDescGZIP() []byte { + file_geobufpb_geobuf_proto_rawDescOnce.Do(func() { + file_geobufpb_geobuf_proto_rawDescData = protoimpl.X.CompressGZIP(file_geobufpb_geobuf_proto_rawDescData) }) - return file_proto_geobuf_proto_rawDescData + return file_geobufpb_geobuf_proto_rawDescData } -var file_proto_geobuf_proto_enumTypes = make([]protoimpl.EnumInfo, 1) -var file_proto_geobuf_proto_msgTypes = make([]protoimpl.MessageInfo, 5) -var file_proto_geobuf_proto_goTypes = []interface{}{ +var file_geobufpb_geobuf_proto_enumTypes = make([]protoimpl.EnumInfo, 1) +var file_geobufpb_geobuf_proto_msgTypes = make([]protoimpl.MessageInfo, 5) +var file_geobufpb_geobuf_proto_goTypes = []interface{}{ (Data_Geometry_Type)(0), // 0: geobuf.Data.Geometry.Type (*Data)(nil), // 1: geobuf.Data (*Data_Feature)(nil), // 2: geobuf.Data.Feature @@ -714,7 +718,7 @@ var file_proto_geobuf_proto_goTypes = []interface{}{ (*Data_FeatureCollection)(nil), // 4: geobuf.Data.FeatureCollection (*Data_Value)(nil), // 5: geobuf.Data.Value } -var file_proto_geobuf_proto_depIdxs = []int32{ +var file_geobufpb_geobuf_proto_depIdxs = []int32{ 4, // 0: geobuf.Data.feature_collection:type_name -> geobuf.Data.FeatureCollection 2, // 1: geobuf.Data.feature:type_name -> geobuf.Data.Feature 3, // 2: geobuf.Data.geometry:type_name -> geobuf.Data.Geometry @@ -732,13 +736,13 @@ var file_proto_geobuf_proto_depIdxs = []int32{ 0, // [0:10] is the sub-list for field type_name } -func init() { file_proto_geobuf_proto_init() } -func file_proto_geobuf_proto_init() { - if File_proto_geobuf_proto != nil { +func init() { file_geobufpb_geobuf_proto_init() } +func file_geobufpb_geobuf_proto_init() { + if File_geobufpb_geobuf_proto != nil { return } if !protoimpl.UnsafeEnabled { - file_proto_geobuf_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_geobufpb_geobuf_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*Data); i { case 0: return &v.state @@ -750,7 +754,7 @@ func file_proto_geobuf_proto_init() { return nil } } - file_proto_geobuf_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + file_geobufpb_geobuf_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*Data_Feature); i { case 0: return &v.state @@ -762,7 +766,7 @@ func file_proto_geobuf_proto_init() { return nil } } - file_proto_geobuf_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + file_geobufpb_geobuf_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*Data_Geometry); i { case 0: return &v.state @@ -774,7 +778,7 @@ func file_proto_geobuf_proto_init() { return nil } } - file_proto_geobuf_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + file_geobufpb_geobuf_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*Data_FeatureCollection); i { case 0: return &v.state @@ -786,7 +790,7 @@ func file_proto_geobuf_proto_init() { return nil } } - file_proto_geobuf_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + file_geobufpb_geobuf_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*Data_Value); i { case 0: return &v.state @@ -799,16 +803,16 @@ func file_proto_geobuf_proto_init() { } } } - file_proto_geobuf_proto_msgTypes[0].OneofWrappers = []interface{}{ + file_geobufpb_geobuf_proto_msgTypes[0].OneofWrappers = []interface{}{ (*Data_FeatureCollection_)(nil), (*Data_Feature_)(nil), (*Data_Geometry_)(nil), } - file_proto_geobuf_proto_msgTypes[1].OneofWrappers = []interface{}{ + file_geobufpb_geobuf_proto_msgTypes[1].OneofWrappers = []interface{}{ (*Data_Feature_Id)(nil), (*Data_Feature_IntId)(nil), } - file_proto_geobuf_proto_msgTypes[4].OneofWrappers = []interface{}{ + file_geobufpb_geobuf_proto_msgTypes[4].OneofWrappers = []interface{}{ (*Data_Value_StringValue)(nil), (*Data_Value_DoubleValue)(nil), (*Data_Value_PosIntValue)(nil), @@ -820,19 +824,19 @@ func file_proto_geobuf_proto_init() { out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_proto_geobuf_proto_rawDesc, + RawDescriptor: file_geobufpb_geobuf_proto_rawDesc, NumEnums: 1, NumMessages: 5, NumExtensions: 0, NumServices: 0, }, - GoTypes: file_proto_geobuf_proto_goTypes, - DependencyIndexes: file_proto_geobuf_proto_depIdxs, - EnumInfos: file_proto_geobuf_proto_enumTypes, - MessageInfos: file_proto_geobuf_proto_msgTypes, + GoTypes: file_geobufpb_geobuf_proto_goTypes, + DependencyIndexes: file_geobufpb_geobuf_proto_depIdxs, + EnumInfos: file_geobufpb_geobuf_proto_enumTypes, + MessageInfos: file_geobufpb_geobuf_proto_msgTypes, }.Build() - File_proto_geobuf_proto = out.File - file_proto_geobuf_proto_rawDesc = nil - file_proto_geobuf_proto_goTypes = nil - file_proto_geobuf_proto_depIdxs = nil + File_geobufpb_geobuf_proto = out.File + file_geobufpb_geobuf_proto_rawDesc = nil + file_geobufpb_geobuf_proto_goTypes = nil + file_geobufpb_geobuf_proto_depIdxs = nil } diff --git a/proto/geobuf.proto b/geobufpb/geobuf.proto similarity index 84% rename from proto/geobuf.proto rename to geobufpb/geobuf.proto index 4b7ba34..e0f135c 100644 --- a/proto/geobuf.proto +++ b/geobufpb/geobuf.proto @@ -1,6 +1,6 @@ syntax = "proto3"; package geobuf; -option go_package = "github.com/mscno/go-geobuf/proto"; +option go_package = "github.com/mscno/go-geobuf/geobufpb"; message Data { repeated string keys = 1; // global arrays of unique keys @@ -38,13 +38,14 @@ message Data { repeated uint32 custom_properties = 15; enum Type { - POINT = 0; - MULTIPOINT = 1; - LINESTRING = 2; - MULTILINESTRING = 3; - POLYGON = 4; - MULTIPOLYGON = 5; - GEOMETRYCOLLECTION = 6; + EMPTY = 0; + POINT = 1; + MULTIPOINT = 2; + LINESTRING = 3; + MULTILINESTRING = 4; + POLYGON = 5; + MULTIPOLYGON = 6; + GEOMETRYCOLLECTION = 7; } } diff --git a/proto/geobuf_vtproto.pb.go b/geobufpb/geobuf_vtproto.pb.go similarity index 99% rename from proto/geobuf_vtproto.pb.go rename to geobufpb/geobuf_vtproto.pb.go index bda358c..b98ffb3 100644 --- a/proto/geobuf_vtproto.pb.go +++ b/geobufpb/geobuf_vtproto.pb.go @@ -1,8 +1,8 @@ // Code generated by protoc-gen-go-vtproto. DO NOT EDIT. // protoc-gen-go-vtproto version: v0.5.0 -// source: proto/geobuf.proto +// source: geobufpb/geobuf.proto -package proto +package geobufpb import ( binary "encoding/binary" diff --git a/internal/decode/feature.go b/internal/decode/feature.go index d2d76c3..d836f97 100644 --- a/internal/decode/feature.go +++ b/internal/decode/feature.go @@ -2,12 +2,12 @@ package decode import ( "encoding/json" - "github.com/mscno/go-geobuf/proto" + "github.com/mscno/go-geobuf/geobufpb" "github.com/paulmach/orb" "github.com/paulmach/orb/geojson" ) -func DecodeFeature(msg *proto.Data, feature *proto.Data_Feature, precision, dimension uint32) *geojson.Feature { +func DecodeFeature(msg *geobufpb.Data, feature *geobufpb.Data_Feature, precision, dimension uint32) *geojson.Feature { geo := feature.Geometry decodedGeo := DecodeGeometry(geo, msg.Precision, msg.Dimensions) @@ -28,17 +28,17 @@ func DecodeFeature(msg *proto.Data, feature *proto.Data_Feature, precision, dime valIdx := feature.Properties[i+1] val := feature.Values[valIdx] switch actualVal := val.ValueType.(type) { - case *proto.Data_Value_BoolValue: + case *geobufpb.Data_Value_BoolValue: geoFeature.Properties[msg.Keys[keyIdx]] = actualVal.BoolValue - case *proto.Data_Value_DoubleValue: + case *geobufpb.Data_Value_DoubleValue: geoFeature.Properties[msg.Keys[keyIdx]] = actualVal.DoubleValue - case *proto.Data_Value_StringValue: + case *geobufpb.Data_Value_StringValue: geoFeature.Properties[msg.Keys[keyIdx]] = actualVal.StringValue - case *proto.Data_Value_PosIntValue: + case *geobufpb.Data_Value_PosIntValue: geoFeature.Properties[msg.Keys[keyIdx]] = uint(actualVal.PosIntValue) - case *proto.Data_Value_NegIntValue: + case *geobufpb.Data_Value_NegIntValue: geoFeature.Properties[msg.Keys[keyIdx]] = int(actualVal.NegIntValue) * -1 - case *proto.Data_Value_JsonValue: + case *geobufpb.Data_Value_JsonValue: var m map[string]interface{} err := json.Unmarshal(actualVal.JsonValue, &m) if err != nil { @@ -48,11 +48,11 @@ func DecodeFeature(msg *proto.Data, feature *proto.Data_Feature, precision, dime } } switch id := feature.IdType.(type) { - case *proto.Data_Feature_Id: + case *geobufpb.Data_Feature_Id: if id != nil { geoFeature.ID = id.Id } - case *proto.Data_Feature_IntId: + case *geobufpb.Data_Feature_IntId: geoFeature.ID = id.IntId } return geoFeature diff --git a/internal/decode/geometry.go b/internal/decode/geometry.go index 7f04ff2..06a603b 100644 --- a/internal/decode/geometry.go +++ b/internal/decode/geometry.go @@ -1,25 +1,27 @@ package decode import ( + "github.com/mscno/go-geobuf/geobufpb" "github.com/mscno/go-geobuf/internal/math" - "github.com/mscno/go-geobuf/proto" "github.com/paulmach/orb" "github.com/paulmach/orb/geojson" ) -func DecodeGeometry(geo *proto.Data_Geometry, precision, dimensions uint32) *geojson.Geometry { +func DecodeGeometry(geo *geobufpb.Data_Geometry, precision, dimensions uint32) *geojson.Geometry { switch geo.Type { - case proto.Data_Geometry_POINT: + case geobufpb.Data_Geometry_EMPTY: + return geojson.NewGeometry(nil) + case geobufpb.Data_Geometry_POINT: return geojson.NewGeometry(makePoint(geo.Coords, precision)) - case proto.Data_Geometry_MULTIPOINT: + case geobufpb.Data_Geometry_MULTIPOINT: return geojson.NewGeometry(makeMultiPoint(geo.Coords, precision, dimensions)) - case proto.Data_Geometry_LINESTRING: + case geobufpb.Data_Geometry_LINESTRING: return geojson.NewGeometry(makeLineString(geo.Coords, precision, dimensions)) - case proto.Data_Geometry_MULTILINESTRING: + case geobufpb.Data_Geometry_MULTILINESTRING: return geojson.NewGeometry(makeMultiLineString(geo.Lengths, geo.Coords, precision, dimensions)) - case proto.Data_Geometry_POLYGON: + case geobufpb.Data_Geometry_POLYGON: return geojson.NewGeometry(makePolygon(geo.Lengths, geo.Coords, precision, dimensions)) - case proto.Data_Geometry_MULTIPOLYGON: + case geobufpb.Data_Geometry_MULTIPOLYGON: return geojson.NewGeometry(makeMultiPolygon(geo.Lengths, geo.Coords, precision, dimensions)) } return &geojson.Geometry{} diff --git a/internal/encode/feature.go b/internal/encode/feature.go index 6002e97..ba1c527 100644 --- a/internal/encode/feature.go +++ b/internal/encode/feature.go @@ -1,14 +1,18 @@ package encode import ( - "github.com/mscno/go-geobuf/proto" + "github.com/mscno/go-geobuf/geobufpb" "github.com/paulmach/orb/geojson" ) -func EncodeFeature(feature *geojson.Feature, opts *EncodingConfig) (*proto.Data_Feature, error) { +func EncodeFeature(feature *geojson.Feature, opts *EncodingConfig) (*geobufpb.Data_Feature, error) { oldGeo := geojson.NewGeometry(feature.Geometry) // TODO Do we ned this line? - geo := EncodeGeometry(oldGeo.Geometry(), opts) - f := &proto.Data_Feature{ + geo, err := EncodeGeometry(oldGeo.Geometry(), opts) + if err != nil { + return nil, err + + } + f := &geobufpb.Data_Feature{ Geometry: geo, } @@ -24,7 +28,7 @@ func EncodeFeature(feature *geojson.Feature, opts *EncodingConfig) (*proto.Data_ } properties := make([]uint32, 0, 2*len(feature.Properties)) - values := make([]*proto.Data_Value, 0, len(feature.Properties)) + values := make([]*geobufpb.Data_Value, 0, len(feature.Properties)) for key, val := range feature.Properties { encoded, err := EncodeValue(val) if err != nil { diff --git a/internal/encode/feature_collection.go b/internal/encode/feature_collection.go index 5df4f12..4b689a2 100644 --- a/internal/encode/feature_collection.go +++ b/internal/encode/feature_collection.go @@ -1,12 +1,12 @@ package encode import ( - "github.com/mscno/go-geobuf/proto" + "github.com/mscno/go-geobuf/geobufpb" "github.com/paulmach/orb/geojson" ) -func EncodeFeatureCollection(collection *geojson.FeatureCollection, opts *EncodingConfig) (*proto.Data_FeatureCollection, error) { - features := make([]*proto.Data_Feature, len(collection.Features)) +func EncodeFeatureCollection(collection *geojson.FeatureCollection, opts *EncodingConfig) (*geobufpb.Data_FeatureCollection, error) { + features := make([]*geobufpb.Data_Feature, len(collection.Features)) for i, feature := range collection.Features { encoded, err := EncodeFeature(feature, opts) @@ -16,7 +16,7 @@ func EncodeFeatureCollection(collection *geojson.FeatureCollection, opts *Encodi features[i] = encoded } - return &proto.Data_FeatureCollection{ + return &geobufpb.Data_FeatureCollection{ Features: features, }, nil } diff --git a/internal/encode/geometry.go b/internal/encode/geometry.go index a3f90e0..ca88a67 100644 --- a/internal/encode/geometry.go +++ b/internal/encode/geometry.go @@ -1,8 +1,9 @@ package encode import ( + "errors" + "github.com/mscno/go-geobuf/geobufpb" "github.com/mscno/go-geobuf/internal/math" - "github.com/mscno/go-geobuf/proto" "github.com/paulmach/orb" "github.com/paulmach/orb/geojson" ) @@ -16,52 +17,82 @@ const ( GeometryMultiPolygon = "MultiPolygon" ) -func EncodeGeometry(g orb.Geometry, opt *EncodingConfig) *proto.Data_Geometry { +const GeometryCollection = "GeometryCollection" + +var ErrEmptyGeometry = errors.New("empty geometry") +var ErrGeometryCollectionUnsupported = errors.New("geometry collection not supported") +var ErrUnsupportInputType = errors.New("unsupported input type") + +func EncodeGeometry(g orb.Geometry, opt *EncodingConfig) (*geobufpb.Data_Geometry, error) { + if g == nil { + if !opt.AllowEmptyGeometry { + return nil, ErrEmptyGeometry + } + return &geobufpb.Data_Geometry{ + Type: geobufpb.Data_Geometry_EMPTY, + }, nil + } switch g.GeoJSONType() { case geojson.TypePoint: p := g.(orb.Point) - return &proto.Data_Geometry{ - Type: proto.Data_Geometry_POINT, + return &geobufpb.Data_Geometry{ + Type: geobufpb.Data_Geometry_POINT, Coords: translateCoords(opt.Precision, p[:]), - } + }, nil case geojson.TypeMultiPoint: p := g.(orb.MultiPoint) - return &proto.Data_Geometry{ - Type: proto.Data_Geometry_MULTIPOINT, + return &geobufpb.Data_Geometry{ + Type: geobufpb.Data_Geometry_MULTIPOINT, Coords: translateLine(opt.Precision, opt.Dimension, p, false), - } + }, nil case geojson.TypeLineString: p := g.(orb.LineString) - return &proto.Data_Geometry{ - Type: proto.Data_Geometry_LINESTRING, + return &geobufpb.Data_Geometry{ + Type: geobufpb.Data_Geometry_LINESTRING, Coords: translateLine(opt.Precision, opt.Dimension, p, false), - } + }, nil case geojson.TypeMultiLineString: p := g.(orb.MultiLineString) coords, lengths := translateMultiLine(opt.Precision, opt.Dimension, p) - return &proto.Data_Geometry{ - Type: proto.Data_Geometry_MULTILINESTRING, + return &geobufpb.Data_Geometry{ + Type: geobufpb.Data_Geometry_MULTILINESTRING, Coords: coords, Lengths: lengths, - } + }, nil case geojson.TypePolygon: p := []orb.Ring(g.(orb.Polygon)) coords, lengths := translateMultiRing(opt.Precision, opt.Dimension, p) - return &proto.Data_Geometry{ - Type: proto.Data_Geometry_POLYGON, + return &geobufpb.Data_Geometry{ + Type: geobufpb.Data_Geometry_POLYGON, Coords: coords, Lengths: lengths, - } + }, nil case geojson.TypeMultiPolygon: p := []orb.Polygon(g.(orb.MultiPolygon)) coords, lengths := translateMultiPolygon(opt.Precision, opt.Dimension, p) - return &proto.Data_Geometry{ - Type: proto.Data_Geometry_MULTIPOLYGON, + return &geobufpb.Data_Geometry{ + Type: geobufpb.Data_Geometry_MULTIPOLYGON, Coords: coords, Lengths: lengths, + }, nil + case GeometryCollection: + // Hack to ensure that the geometry collection is not empty and that it contains at least one point + // This is because geojson.GeoJSONType() returns "GeometryCollection" for empty geometries + if x, ok := g.(orb.Collection); ok { + if len(x) == 0 { + if !opt.AllowEmptyGeometry { + return nil, ErrEmptyGeometry + } + return &geobufpb.Data_Geometry{ + Type: geobufpb.Data_Geometry_EMPTY, + }, nil + } + return nil, ErrGeometryCollectionUnsupported } + return nil, ErrGeometryCollectionUnsupported + default: + return nil, ErrUnsupportInputType } - return nil } func translateMultiLine(e uint, dim uint, lines []orb.LineString) ([]int64, []uint32) { diff --git a/internal/encode/geometry_test.go b/internal/encode/geometry_test.go index f505f3c..6b3721c 100644 --- a/internal/encode/geometry_test.go +++ b/internal/encode/geometry_test.go @@ -1,7 +1,7 @@ package encode import ( - "github.com/mscno/go-geobuf/proto" + "github.com/mscno/go-geobuf/geobufpb" "github.com/paulmach/orb" "github.com/paulmach/orb/geojson" "reflect" @@ -35,14 +35,17 @@ func TestEncodePoint(t *testing.T) { p := geojson.NewGeometry(orb.Point([2]float64{124.123, 234.456})) for i, test := range testCases { - expected := &proto.Data_Geometry{ - Type: proto.Data_Geometry_POINT, + expected := &geobufpb.Data_Geometry{ + Type: geobufpb.Data_Geometry_POINT, Coords: test.Expected, } - encoded := EncodeGeometry(p.Geometry(), &EncodingConfig{ + encoded, err := EncodeGeometry(p.Geometry(), &EncodingConfig{ Dimension: 2, Precision: test.Precision, }) + if err != nil { + t.Errorf("Case [%d]: Unexpected error: %s", i, err) + } if !reflect.DeepEqual(encoded, expected) { t.Errorf("Case [%d]: Expected %+v, got %+v", i, expected, encoded) diff --git a/internal/encode/id.go b/internal/encode/id.go index e21bc95..5750d04 100644 --- a/internal/encode/id.go +++ b/internal/encode/id.go @@ -4,10 +4,10 @@ import ( "encoding/json" "fmt" - "github.com/mscno/go-geobuf/proto" + "github.com/mscno/go-geobuf/geobufpb" ) -func EncodeIntId(id interface{}) (*proto.Data_Feature_IntId, error) { +func EncodeIntId(id interface{}) (*geobufpb.Data_Feature_IntId, error) { switch t := id.(type) { case int: return encodeIntId(int64(t)), nil @@ -33,7 +33,7 @@ func EncodeIntId(id interface{}) (*proto.Data_Feature_IntId, error) { } } -func EncodeId(id interface{}) (*proto.Data_Feature_Id, error) { +func EncodeId(id interface{}) (*geobufpb.Data_Feature_Id, error) { switch t := id.(type) { case nil: return nil, nil @@ -50,14 +50,14 @@ func EncodeId(id interface{}) (*proto.Data_Feature_Id, error) { } } -func encodeIntId(id int64) *proto.Data_Feature_IntId { - return &proto.Data_Feature_IntId{ +func encodeIntId(id int64) *geobufpb.Data_Feature_IntId { + return &geobufpb.Data_Feature_IntId{ IntId: id, } } -func encodeId(id string) *proto.Data_Feature_Id { - return &proto.Data_Feature_Id{ +func encodeId(id string) *geobufpb.Data_Feature_Id { + return &geobufpb.Data_Feature_Id{ Id: id, } } diff --git a/internal/encode/options.go b/internal/encode/options.go index e158478..1b10338 100644 --- a/internal/encode/options.go +++ b/internal/encode/options.go @@ -10,6 +10,7 @@ type EncodingConfig struct { Dimension uint Precision uint HardcodedPrecision bool + AllowEmptyGeometry bool Keys KeyStore } diff --git a/internal/encode/values.go b/internal/encode/values.go index 16b1d88..0c3a2b5 100644 --- a/internal/encode/values.go +++ b/internal/encode/values.go @@ -4,15 +4,15 @@ import ( "encoding/json" "reflect" - "github.com/mscno/go-geobuf/proto" + "github.com/mscno/go-geobuf/geobufpb" ) -func EncodeValue(val interface{}) (*proto.Data_Value, error) { +func EncodeValue(val interface{}) (*geobufpb.Data_Value, error) { v := reflect.ValueOf(val) return encodeValue(v, val) } -func encodeValue(v reflect.Value, val interface{}) (*proto.Data_Value, error) { +func encodeValue(v reflect.Value, val interface{}) (*geobufpb.Data_Value, error) { switch v.Kind() { case reflect.Bool: return encodeBool(v.Bool()) @@ -44,50 +44,50 @@ func encodeValue(v reflect.Value, val interface{}) (*proto.Data_Value, error) { } } -func encodeInt(val uint64, positive bool) (*proto.Data_Value, error) { +func encodeInt(val uint64, positive bool) (*geobufpb.Data_Value, error) { if positive { - return &proto.Data_Value{ - ValueType: &proto.Data_Value_PosIntValue{ + return &geobufpb.Data_Value{ + ValueType: &geobufpb.Data_Value_PosIntValue{ PosIntValue: val, }, }, nil } - return &proto.Data_Value{ - ValueType: &proto.Data_Value_NegIntValue{ + return &geobufpb.Data_Value{ + ValueType: &geobufpb.Data_Value_NegIntValue{ NegIntValue: val, }, }, nil } -func encodeDouble(val float64) (*proto.Data_Value, error) { - return &proto.Data_Value{ - ValueType: &proto.Data_Value_DoubleValue{ +func encodeDouble(val float64) (*geobufpb.Data_Value, error) { + return &geobufpb.Data_Value{ + ValueType: &geobufpb.Data_Value_DoubleValue{ DoubleValue: val, }, }, nil } -func encodeString(val string) (*proto.Data_Value, error) { - return &proto.Data_Value{ - ValueType: &proto.Data_Value_StringValue{ +func encodeString(val string) (*geobufpb.Data_Value, error) { + return &geobufpb.Data_Value{ + ValueType: &geobufpb.Data_Value_StringValue{ StringValue: val, }, }, nil } -func encodeBool(val bool) (*proto.Data_Value, error) { - return &proto.Data_Value{ - ValueType: &proto.Data_Value_BoolValue{ +func encodeBool(val bool) (*geobufpb.Data_Value, error) { + return &geobufpb.Data_Value{ + ValueType: &geobufpb.Data_Value_BoolValue{ BoolValue: val, }, }, nil } -func encodeJSON(val interface{}) (*proto.Data_Value, error) { +func encodeJSON(val interface{}) (*geobufpb.Data_Value, error) { encoded, err := json.Marshal(val) - return &proto.Data_Value{ - ValueType: &proto.Data_Value_JsonValue{ + return &geobufpb.Data_Value{ + ValueType: &geobufpb.Data_Value_JsonValue{ JsonValue: encoded, }, }, err diff --git a/internal/encode/values_test.go b/internal/encode/values_test.go index b72ffcd..1ecf385 100644 --- a/internal/encode/values_test.go +++ b/internal/encode/values_test.go @@ -4,8 +4,8 @@ import ( "fmt" "testing" + "github.com/mscno/go-geobuf/geobufpb" . "github.com/mscno/go-geobuf/internal/encode" - "github.com/mscno/go-geobuf/proto" ) func TestEncodeIntValue(t *testing.T) { @@ -119,11 +119,11 @@ func TestEncodeIntValue(t *testing.T) { } switch cast := val.ValueType.(type) { - case *proto.Data_Value_PosIntValue: + case *geobufpb.Data_Value_PosIntValue: if uint64(test.Expected) != cast.PosIntValue { t.Errorf("Case [%d]: Expected %d, got %d", i, test.Expected, cast.PosIntValue) } - case *proto.Data_Value_NegIntValue: + case *geobufpb.Data_Value_NegIntValue: if uint64(test.Expected) != cast.NegIntValue { t.Errorf("Case [%d]: Expected %d, got %d", i, test.Expected, cast.NegIntValue) } @@ -155,7 +155,7 @@ func TestEncodeStringValue(t *testing.T) { } switch cast := val.ValueType.(type) { - case *proto.Data_Value_StringValue: + case *geobufpb.Data_Value_StringValue: if test.Expected != cast.StringValue { t.Errorf("Case [%d]: Expected %s, got %s", i, test.Expected, cast.StringValue) } @@ -195,7 +195,7 @@ func TestEncodeFloatValue(t *testing.T) { } switch cast := val.ValueType.(type) { - case *proto.Data_Value_DoubleValue: + case *geobufpb.Data_Value_DoubleValue: if test.Expected != cast.DoubleValue { t.Errorf("Case [%d]: Expected %f, got %f", i, test.Expected, cast.DoubleValue) } @@ -235,7 +235,7 @@ func TestEncodeBoolValue(t *testing.T) { } switch cast := val.ValueType.(type) { - case *proto.Data_Value_BoolValue: + case *geobufpb.Data_Value_BoolValue: if test.Expected != cast.BoolValue { t.Errorf("Case [%d]: Expected %t, got %t", i, test.Expected, cast.BoolValue) } @@ -275,7 +275,7 @@ func TestEncodeJsonValue(t *testing.T) { } switch cast := val.ValueType.(type) { - case *proto.Data_Value_JsonValue: + case *geobufpb.Data_Value_JsonValue: if test.Expected != string(cast.JsonValue) { t.Errorf("Case [%d]: Expected %s, got %s", i, test.Expected, cast.JsonValue) } diff --git a/justfile b/justfile index 187672d..95bb46d 100644 --- a/justfile +++ b/justfile @@ -1,7 +1,7 @@ run: test cover buf: - buf generate --template proto/buf.go.yaml + buf generate --template geobufpb/buf.go.yaml check: go vet ./... diff --git a/proto/buf.go.yaml b/proto/buf.go.yaml deleted file mode 100644 index 5a56a01..0000000 --- a/proto/buf.go.yaml +++ /dev/null @@ -1,22 +0,0 @@ -version: v1 -plugins: -# # Documentation -# - name: doc -# out: gen/doc -# opt: html,index.html -# strategy: all -# -# - name: doc -# out: gen/doc -# opt: markdown,index.md -# strategy: all -# -# - name: doc -# out: gen/doc -# opt: json,doc.json -# strategy: all - - # Go - - plugin: go - out: . - opt: paths=source_relative \ No newline at end of file