Skip to content

Commit d175991

Browse files
authored
added lock (#23)
* added lock * debuggin coverage report behaviour
1 parent 03a0773 commit d175991

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ matrix:
1414
# - go: "1.8.x"
1515
# env: CGO_ENABLED=0
1616
- go: "1.10.x"
17-
- go: "1.9.x"
17+
# - go: "1.9.x"
1818
# - go: "1.8.x"
1919

2020
script:

Convert.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package proj
22

33
import (
44
"fmt"
5+
"sync"
56

67
"github.com/go-spatial/proj/core"
78
"github.com/go-spatial/proj/support"
@@ -21,6 +22,9 @@ const (
2122
WebMercator = EPSG3857
2223
)
2324

25+
// ensure only one person is updating our cache of converters at a time
26+
var cacheLock = sync.Mutex{}
27+
2428
// Convert performs a conversion from a 4326 coordinate system (lon/lat
2529
// degrees, 2D) to the given projected system (x/y meters, 2D).
2630
//
@@ -32,7 +36,9 @@ const (
3236
// y1, x2, y2, ...].
3337
func Convert(dest EPSGCode, input []float64) ([]float64, error) {
3438

39+
cacheLock.Lock()
3540
conv, err := newConversion(dest)
41+
cacheLock.Unlock()
3642
if err != nil {
3743
return nil, err
3844
}

0 commit comments

Comments
 (0)