Skip to content

Commit

Permalink
Reproject: Change CRS strings to constants.
Browse files Browse the repository at this point in the history
  • Loading branch information
geofurlong committed May 6, 2024
1 parent 8760ace commit 02afa30
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions pkg/geocode/reproject.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Reprojecting functions Easting / Northing points to and from Longitude / Latitude points.
// Reprojecting functions for Easting / Northing points to and from Longitude / Latitude points.

package geocode

Expand All @@ -7,9 +7,17 @@ import (
"github.com/twpayne/go-proj/v10"
)

const (
// Ordnance Survey National Grid (OSGB36) Co-ordinate Reference System (CRS).
ProjectedCRS = "EPSG:27700"

// World Geodetic System 1984 (WGS84) Co-ordinate Reference System (CRS).
GeographicCRS = "EPSG:4326"
)

// OSGBtoLongLat returns a pointer to the transformer from projected OSGB36 (EPSG:27700) to geographic Longitude / Latitude (EPSG:4326).
func OSGBtoLongLat() *proj.PJ {
pj, err := proj.NewCRSToCRS("EPSG:27700", "EPSG:4326", nil)
pj, err := proj.NewCRSToCRS(ProjectedCRS, GeographicCRS, nil)
Check(err)

return pj
Expand All @@ -27,7 +35,7 @@ func Reproject(point orb.Point, pj *proj.PJ) orb.Point {
// ReprojectMulti takes a slice of projected Easting / Northing points and returns the corresponding Longitude / Latitude points slice.
func ReprojectMulti(points []orb.Point) []orb.Point {
latLons := make([]orb.Point, len(points))
pj, err := proj.NewCRSToCRS("EPSG:27700", "EPSG:4326", nil)
pj, err := proj.NewCRSToCRS(ProjectedCRS, GeographicCRS, nil)
Check(err)

for i, point := range points {
Expand Down

0 comments on commit 02afa30

Please sign in to comment.