Skip to content

Commit

Permalink
added lock (#23)
Browse files Browse the repository at this point in the history
* added lock

* debuggin coverage report behaviour
  • Loading branch information
mpgerlek authored Apr 20, 2018
1 parent 03a0773 commit d175991
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
6 changes: 6 additions & 0 deletions Convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package proj

import (
"fmt"
"sync"

"github.com/go-spatial/proj/core"
"github.com/go-spatial/proj/support"
Expand All @@ -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).
//
Expand All @@ -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
}
Expand Down

0 comments on commit d175991

Please sign in to comment.