@@ -3,26 +3,27 @@ package mvt
33import (
44 "bytes"
55 "compress/gzip"
6+ "errors"
7+ "fmt"
68 "io/ioutil"
79
810 "github.com/paulmach/orb"
911 "github.com/paulmach/orb/encoding/mvt/vectortile"
1012 "github.com/paulmach/orb/geojson"
1113 "github.com/paulmach/protoscan"
12- "github.com/pkg/errors"
1314)
1415
1516// UnmarshalGzipped takes gzipped Mapbox Vector Tile (MVT) data and unzips it
1617// before decoding it into a set of layers, It does not project the coordinates.
1718func UnmarshalGzipped (data []byte ) (Layers , error ) {
1819 gzreader , err := gzip .NewReader (bytes .NewBuffer (data ))
1920 if err != nil {
20- return nil , errors . WithMessage ( err , "failed to create gzreader" )
21+ return nil , fmt . Errorf ( "failed to create gzreader: %v" , err )
2122 }
2223
2324 decoded , err := ioutil .ReadAll (gzreader )
2425 if err != nil {
25- return nil , errors . WithMessage ( err , "failed to unzip" )
26+ return nil , fmt . Errorf ( "failed to unzip: %v" , err )
2627 }
2728
2829 return Unmarshal (decoded )
@@ -235,7 +236,7 @@ func (d *decoder) Geometry(geomType vectortile.Tile_GeomType) (orb.Geometry, err
235236 gd := & geomDecoder {iter : d .geom , count : d .geom .Count (protoscan .WireTypeVarint )}
236237
237238 if gd .count < 2 {
238- return nil , errors .Errorf ("geom is not long enough: %v" , gd .count )
239+ return nil , fmt .Errorf ("geom is not long enough: %v" , gd .count )
239240 }
240241
241242 switch geomType {
@@ -247,7 +248,7 @@ func (d *decoder) Geometry(geomType vectortile.Tile_GeomType) (orb.Geometry, err
247248 return gd .decodePolygon ()
248249 }
249250
250- return nil , errors .Errorf ("unknown geometry type: %v" , geomType )
251+ return nil , fmt .Errorf ("unknown geometry type: %v" , geomType )
251252}
252253
253254// A geomDecoder holds state for geometry decoding.
@@ -392,7 +393,7 @@ func (gd *geomDecoder) cmdAndCount() (uint32, uint32, error) {
392393
393394 if cmd != closePath {
394395 if v := gd .used + int (2 * count ); gd .count < v {
395- return 0 , 0 , errors .Errorf ("data cut short: needed %d, have %d" , v , gd .count )
396+ return 0 , 0 , fmt .Errorf ("data cut short: needed %d, have %d" , v , gd .count )
396397 }
397398 }
398399
0 commit comments