// Transform a Swiss coordinate value to a GRS80 based latitude and longitude coordinate. Function returns // cartconvert.ErrRange, if the swiss coordinate type is not one of LV03 or LV95 func SwissCoordToGRS80LatLong(coord *SwissCoord) (*cartconvert.PolarCoord, error) { var fn, fe float64 switch coord.CoordType { case LV03: fe = 600000 fn = 200000 case LV95: fe = -2600000 fn = -1200000 default: return nil, cartconvert.ErrRange } gc := cartconvert.InverseTransverseMercator( &cartconvert.GeoPoint{Y: coord.Northing, X: coord.Easting, El: coord.El}, 46.952406, // lat0 7.439583, // long0 1, fe, // fe fn) // fn cart := cartconvert.PolarToCartesian(gc) // According to literature, the Granit87 parameters shall not be used in favour of // higher accuracy of the following shift values // pt := cartconvert.HelmertLV03ToWGS84Granit87.Transform(&cartconvert.Point3D{X: cart.X, Y: cart.Y, Z: cart.Z}) pt := &cartconvert.Point3D{X: cart.X + 674.374, Y: cart.Y + 15.056, Z: cart.Z + 405.346} return cartconvert.CartesianToPolar(&cartconvert.CartPoint{X: pt.X, Y: pt.Y, Z: pt.Z, El: cartconvert.GRS80Ellipsoid}), nil }
// Transform a BMN coordinate value to a WGS84 based latitude and longitude coordinate. Function returns // cartconvert.ErrRange, if the meridian stripe of the bmn-coordinate is not set func BMNToWGS84LatLong(bmncoord *BMNCoord) (*cartconvert.PolarCoord, error) { var long0, fe float64 switch bmncoord.Meridian { case BMNM28: long0 = 10.0 + 20.0/60.0 fe = 150000 case BMNM31: long0 = 13.0 + 20.0/60.0 fe = 450000 case BMNM34: long0 = 16.0 + 20.0/60.0 fe = 750000 default: return nil, cartconvert.ErrRange } gc := cartconvert.InverseTransverseMercator( &cartconvert.GeoPoint{Y: bmncoord.Height, X: bmncoord.Right, El: bmncoord.El}, 0, long0, 1, fe, -5000000) cart := cartconvert.PolarToCartesian(gc) pt := cartconvert.HelmertWGS84ToMGI.InverseTransform(&cartconvert.Point3D{X: cart.X, Y: cart.Y, Z: cart.Z}) return cartconvert.CartesianToPolar(&cartconvert.CartPoint{X: pt.X, Y: pt.Y, Z: pt.Z, El: cartconvert.WGS84Ellipsoid}), nil }
// Convert an OSGB36 coordinate value to a WGS84 based latitude and longitude coordinate. // // Important: A OSGB36 datum like NN11 will be internally expanded to NN1500015000 to point to the middle of the zone. // For the point at NN1000010000 it is necessary to fully qualify northing and easting. // // Plain grid zone specifiers will NOT be shifted towards the middle of the square. func OSGB36ToWGS84LatLong(coord *OSGB36Coord) *cartconvert.PolarCoord { easting, northing := OSGB36ZoneToRefCoords(coord) gc := cartconvert.InverseTransverseMercator( &cartconvert.GeoPoint{Y: float64(northing), X: float64(easting), El: coord.El}, 49, -2, 0.9996012717, 400000, -100000) cart := cartconvert.PolarToCartesian(gc) pt := cartconvert.HelmertWGS84ToOSGB36.InverseTransform(&cartconvert.Point3D{X: cart.X, Y: cart.Y, Z: cart.Z}) return cartconvert.CartesianToPolar(&cartconvert.CartPoint{X: pt.X, Y: pt.Y, Z: pt.Z, El: cartconvert.WGS84Ellipsoid}) }