From e600572d457e4716edfdceacffe65653e01e3a9d Mon Sep 17 00:00:00 2001 From: Gautam Dey Date: Wed, 20 Feb 2019 16:44:37 -0800 Subject: [PATCH] Expose the Bounds package. --- README.md | 2 +- {internal/bounds => bounds}/bounds.go | 0 {internal/bounds => bounds}/bounds_test.go | 24 +++++++++++----------- cmd/snap/cmd/generate.go | 2 +- cmd/snap/cmd/generate_tile.go | 2 +- cmd/snap/cmd/server.go | 11 +++++----- cmd/snap/generate/image.go | 2 +- 7 files changed, 21 insertions(+), 22 deletions(-) rename {internal/bounds => bounds}/bounds.go (100%) rename {internal/bounds => bounds}/bounds_test.go (90%) diff --git a/README.md b/README.md index ae40595..809d742 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ Running the following commands should set up a working development environment docker build -t mbgl . -docker run -it -v it"$(pwd)":/go/src/github.com/go-spatial/go-mbgl +docker run --rm -v "$(pwd)":/go/src/github.com/go-spatial/go-mbgl -it mbgl ``` diff --git a/internal/bounds/bounds.go b/bounds/bounds.go similarity index 100% rename from internal/bounds/bounds.go rename to bounds/bounds.go diff --git a/internal/bounds/bounds_test.go b/bounds/bounds_test.go similarity index 90% rename from internal/bounds/bounds_test.go rename to bounds/bounds_test.go index ca0bd2f..530d734 100644 --- a/internal/bounds/bounds_test.go +++ b/bounds/bounds_test.go @@ -17,7 +17,7 @@ func TestZoom(t *testing.T) { zoom float64 } - fn := func(tc tcase) func(t *testing.T) { + fn := func(tc tcase) func(*testing.T) { return func(t *testing.T) { zoom := Zoom(tc.bounds, tc.width, tc.height) if !cmp.Float(tc.zoom, zoom) { @@ -56,7 +56,7 @@ func TestCenterZoom(t *testing.T) { center [2]float64 } - fn := func(tc tcase) func(t *testing.T) { + fn := func(tc tcase) func(*testing.T) { return func(t *testing.T) { center, zoom := CenterZoom(tc.bounds, tc.width, tc.height) @@ -116,14 +116,14 @@ func TestTransform(t *testing.T) { } type tcase struct { - prj aProjection + prj AProjection cases []subcase } - fn := func(tc tcase) func(t *testing.T) { - return func(t *testing.T) { + fn := func(tc tcase) (string, func(*testing.T)) { + return tc.prj.String(), func(t *testing.T) { - fn := func(prj aProjection, tc subcase) func(t *testing.T) { + fn := func(prj AProjection, tc subcase) func(*testing.T) { return func(t *testing.T) { t.Run("transform", func(t *testing.T) { @@ -168,7 +168,7 @@ func TestTransform(t *testing.T) { } for _, tc := range tests { - t.Run(tc.prj.String(), fn(tc)) + t.Run(fn(tc)) } } @@ -180,14 +180,14 @@ func TestProject(t *testing.T) { } type tcase struct { - prj aProjection + prj AProjection cases []subcase } - fn := func(tc tcase) func(t *testing.T) { - return func(t *testing.T) { + fn := func(tc tcase) (string, func(*testing.T)) { + return tc.prj.String(), func(t *testing.T) { - fn := func(prj aProjection, tc subcase) func(t *testing.T) { + fn := func(prj AProjection, tc subcase) func(t *testing.T) { return func(t *testing.T) { t.Run("Project", func(t *testing.T) { @@ -232,6 +232,6 @@ func TestProject(t *testing.T) { }, } for _, tc := range tests { - t.Run(tc.prj.String(), fn(tc)) + t.Run(fn(tc)) } } diff --git a/cmd/snap/cmd/generate.go b/cmd/snap/cmd/generate.go index c80700a..217a3ab 100644 --- a/cmd/snap/cmd/generate.go +++ b/cmd/snap/cmd/generate.go @@ -13,8 +13,8 @@ import ( "github.com/go-spatial/geom" "github.com/go-spatial/geom/spherical" + "github.com/go-spatial/go-mbgl/bounds" "github.com/go-spatial/go-mbgl/cmd/snap/generate" - "github.com/go-spatial/go-mbgl/internal/bounds" mbgl "github.com/go-spatial/go-mbgl/mbgl/simplified" "github.com/spf13/cobra" ) diff --git a/cmd/snap/cmd/generate_tile.go b/cmd/snap/cmd/generate_tile.go index f621dae..8d9cf1c 100644 --- a/cmd/snap/cmd/generate_tile.go +++ b/cmd/snap/cmd/generate_tile.go @@ -8,7 +8,7 @@ import ( "strings" "github.com/go-spatial/geom/slippy" - "github.com/go-spatial/go-mbgl/internal/bounds" + "github.com/go-spatial/go-mbgl/bounds" mbgl "github.com/go-spatial/go-mbgl/mbgl/simplified" "github.com/spf13/cobra" ) diff --git a/cmd/snap/cmd/server.go b/cmd/snap/cmd/server.go index 2f45e09..c13e230 100644 --- a/cmd/snap/cmd/server.go +++ b/cmd/snap/cmd/server.go @@ -20,7 +20,7 @@ import ( "github.com/go-spatial/geom/slippy" "github.com/go-spatial/geom/spherical" - "github.com/go-spatial/go-mbgl/internal/bounds" + "github.com/go-spatial/go-mbgl/bounds" mbgl "github.com/go-spatial/go-mbgl/mbgl/simplified" "github.com/spf13/cobra" @@ -56,7 +56,6 @@ var cmdServer = &cobra.Command{ Run: commandServer, } - var cmdServerAddress string = ":0" func init() { @@ -65,14 +64,14 @@ func init() { func commandServer(cmd *cobra.Command, args []string) { - listener, err := net.Listen("tcp",cmdServerAddress) + listener, err := net.Listen("tcp", cmdServerAddress) if err != nil { - fmt.Fprintf(os.Stderr, "Unable to bind to address(%v):%v",cmdServerAddress,err) + fmt.Fprintf(os.Stderr, "Unable to bind to address(%v):%v", cmdServerAddress, err) os.Exit(2) return } - fmt.Println("Starting up server on:",listener.Addr()) + fmt.Println("Starting up server on:", listener.Addr()) // start our server router := newRouter() @@ -87,7 +86,7 @@ func commandServer(cmd *cobra.Command, args []string) { err = http.Serve(listener, router) if err != nil { - fmt.Fprintf(os.Stderr, "Error starting server",err) + fmt.Fprintf(os.Stderr, "Error starting server", err) os.Exit(2) return } diff --git a/cmd/snap/generate/image.go b/cmd/snap/generate/image.go index 5c1da97..980d1d8 100644 --- a/cmd/snap/generate/image.go +++ b/cmd/snap/generate/image.go @@ -11,7 +11,7 @@ import ( "os" "github.com/go-spatial/geom" - "github.com/go-spatial/go-mbgl/internal/bounds" + "github.com/go-spatial/go-mbgl/bounds" mbgl "github.com/go-spatial/go-mbgl/mbgl/simplified" )