Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added lock #23

Merged
merged 2 commits into from
Apr 20, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
added lock
  • Loading branch information
mpgerlek committed Apr 20, 2018
commit cdda2678e492fc9efbdb203e0c28a26feb24a839
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