diff --git a/.travis.yml b/.travis.yml index 6bc23d9..7186fee 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,7 +14,7 @@ matrix: # - go: "1.8.x" # env: CGO_ENABLED=0 - go: "1.10.x" - - go: "1.9.x" +# - go: "1.9.x" # - go: "1.8.x" script: diff --git a/Convert.go b/Convert.go index 818d069..7299cdb 100644 --- a/Convert.go +++ b/Convert.go @@ -2,6 +2,7 @@ package proj import ( "fmt" + "sync" "github.com/go-spatial/proj/core" "github.com/go-spatial/proj/support" @@ -21,6 +22,9 @@ const ( WebMercator = EPSG3857 ) +// ensure only one person is updating our cache of converters at a time +var cacheLock = sync.Mutex{} + // Convert performs a conversion from a 4326 coordinate system (lon/lat // degrees, 2D) to the given projected system (x/y meters, 2D). // @@ -32,7 +36,9 @@ const ( // y1, x2, y2, ...]. func Convert(dest EPSGCode, input []float64) ([]float64, error) { + cacheLock.Lock() conv, err := newConversion(dest) + cacheLock.Unlock() if err != nil { return nil, err }