Skip to content

Commit 45a6519

Browse files
authored
allow marshalling to proto objects (#154)
1 parent 7627dc6 commit 45a6519

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

encoding/mvt/marshal.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ func MarshalGzipped(layers Layers) ([]byte, error) {
4141

4242
// Marshal will take a set of layers and encode them into a Mapbox Vector Tile format.
4343
// Features that have a nil geometry, for some reason, will be skipped and not included.
44-
func Marshal(layers Layers) ([]byte, error) {
44+
func MarshalToVectorTile(layers Layers) (*vectortile.Tile, error) {
4545
vt := &vectortile.Tile{
4646
Layers: make([]*vectortile.Tile_Layer, 0, len(layers)),
4747
}
@@ -70,6 +70,16 @@ func Marshal(layers Layers) ([]byte, error) {
7070
vt.Layers = append(vt.Layers, layer)
7171
}
7272

73+
return vt
74+
}
75+
76+
// Marshal will take a set of layers and encode them into a Mapbox Vector Tile format.
77+
// Features that have a nil geometry, for some reason, will be skipped and not included.
78+
func Marshal(layers Layers) ([]byte, error) {
79+
vt, err := MarshalToVectorTile(layers)
80+
if err != nil {
81+
return nil, err
82+
}
7383
return proto.Marshal(vt)
7484
}
7585

0 commit comments

Comments
 (0)