Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Marshalling to Proto Objects #154

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion encoding/mvt/marshal.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func MarshalGzipped(layers Layers) ([]byte, error) {

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

return vt
}

// Marshal will take a set of layers and encode them into a Mapbox Vector Tile format.
// Features that have a nil geometry, for some reason, will be skipped and not included.
func Marshal(layers Layers) ([]byte, error) {
vt, err := MarshalToVectorTile(layers)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pretty straight forward, i just moved the guts out into another function right before marshalling to bytes. and leave the proto marshaling here for callers of this function

if err != nil {
return nil, err
}
return proto.Marshal(vt)
}

Expand Down