Skip to content

Commit

Permalink
coords
Browse files Browse the repository at this point in the history
  • Loading branch information
kdudkov committed Nov 23, 2024
1 parent c4d9d31 commit 60505ce
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 3 additions & 3 deletions pkg/coord/strings.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import (
)

var (
r1 = regexp.MustCompile(`[xX]=?(?P<x>\d{5,}),?\s+[yY]=?(?P<y>\d{5,})`)
r2 = regexp.MustCompile(`(?P<x>-?\d+\.\d+),?\s+(?P<y>-?\d+\.\d+)`)
r3 = regexp.MustCompile(`(?P<x>\d+\.\d+)([nNsS]),?\s+(?P<y>\d+\.\d+)([eEwW])`)
r1 = regexp.MustCompile(`[xX]=?(?P<x>\d{5,})[;,\s]*[yY]=?(?P<y>\d{5,})`)
r2 = regexp.MustCompile(`(?P<x>-?\d+\.\d+)[;,\s]*(?P<y>-?\d+\.\d+)`)
r3 = regexp.MustCompile(`(?P<x>\d+\.\d+)([nNsS])[;,\s]*(?P<y>\d+\.\d+)([eEwW])`)
)

func StringToLatLon(s string) (float64, float64, error) {
Expand Down
2 changes: 2 additions & 0 deletions pkg/coord/strings_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ type testData struct {
func TestStringConvert(t *testing.T) {
data := []testData{
{"x5709130 y6648746", 51.49220977324127, 35.14007432073522},
{"x5709130y6648746", 51.49220977324127, 35.14007432073522},
{"X=5709130, y6648746", 51.49220977324127, 35.14007432073522},
{"X=5709130,y6648746", 51.49220977324127, 35.14007432073522},
{"51.49 35.14", 51.49, 35.14},
{"51.49, -35.14", 51.49, -35.14},
{"51.49N 35.14E", 51.49, 35.14},
Expand Down

0 comments on commit 60505ce

Please sign in to comment.