Documentation ¶
Overview ¶
Package proj provides an interface to PROJ. See https://proj.org.
Index ¶
- Constants
- func CoordsToFloat64Slices(coords []Coord) [][]float64
- type Area
- type Bounds
- type Context
- func (c *Context) Destroy()
- func (c *Context) Lock()
- func (c *Context) New(definition string) (*PJ, error)
- func (c *Context) NewCRSToCRS(sourceCRS, targetCRS string, area *Area) (*PJ, error)
- func (c *Context) NewCRSToCRSFromPJ(sourcePJ, targetPJ *PJ, area *Area, options string) (*PJ, error)
- func (c *Context) NewFromArgs(args ...string) (*PJ, error)
- func (c *Context) SetSearchPaths(paths []string)
- func (c *Context) Unlock()
- type Coord
- type Direction
- type Error
- type PJ
- func (pj *PJ) Destroy()
- func (pj *PJ) Forward(coord Coord) (Coord, error)
- func (pj *PJ) ForwardArray(coords []Coord) error
- func (pj *PJ) ForwardBounds(bounds Bounds, densifyPoints int) (Bounds, error)
- func (pj *PJ) ForwardFlatCoords(flatCoords []float64, stride, zIndex, mIndex int) error
- func (pj *PJ) ForwardFloat64Slice(float64Slice []float64) ([]float64, error)
- func (pj *PJ) ForwardFloat64Slices(float64Slices [][]float64) error
- func (pj *PJ) Geod(a, b Coord) (float64, float64, float64)
- func (pj *PJ) GetLastUsedOperation() (*PJ, error)
- func (pj *PJ) Info() PJInfo
- func (pj *PJ) Inverse(coord Coord) (Coord, error)
- func (pj *PJ) InverseArray(coords []Coord) error
- func (pj *PJ) InverseBounds(bounds Bounds, densifyPoints int) (Bounds, error)
- func (pj *PJ) InverseFlatCoords(flatCoords []float64, stride, zIndex, mIndex int) error
- func (pj *PJ) InverseFloat64Slice(float64Slice []float64) ([]float64, error)
- func (pj *PJ) InverseFloat64Slices(float64Slices [][]float64) error
- func (pj *PJ) IsCRS() bool
- func (pj *PJ) LPDist(a, b Coord) float64
- func (pj *PJ) LPZDist(a, b Coord) float64
- func (pj *PJ) NormalizeForVisualization() (*PJ, error)
- func (pj *PJ) Trans(direction Direction, coord Coord) (Coord, error)
- func (pj *PJ) TransArray(direction Direction, coords []Coord) error
- func (pj *PJ) TransBounds(direction Direction, bounds Bounds, densifyPoints int) (Bounds, error)
- func (pj *PJ) TransFlatCoords(direction Direction, flatCoords []float64, stride, zIndex, mIndex int) error
- func (pj *PJ) TransFloat64Slice(direction Direction, float64Slice []float64) ([]float64, error)
- func (pj *PJ) TransFloat64Slices(direction Direction, float64Slices [][]float64) error
- func (pj *PJ) TransGeneric(direction Direction, x *float64, sx, nx int, y *float64, sy, ny int, ...) error
- type PJInfo
Examples ¶
Constants ¶
const ( VersionMajor = C.PROJ_VERSION_MAJOR VersionMinor = C.PROJ_VERSION_MINOR VersionPatch = C.PROJ_VERSION_PATCH )
Version.
Variables ¶
This section is empty.
Functions ¶
func CoordsToFloat64Slices ¶ added in v10.2.0
CoordsToFloat64Slices is a convenience function that converts a slice of Coords to a slice of []float64s. For performance, the returned []float64s alias coords.
Types ¶
type Area ¶
type Area struct {
// contains filtered or unexported fields
}
An Area is an area.
type Context ¶
type Context struct {
// contains filtered or unexported fields
}
A Context is a context.
func (*Context) Destroy ¶
func (c *Context) Destroy()
Destroy frees all resources associated with c.
func (*Context) NewCRSToCRS ¶
NewCRSToCRS returns a new PJ from sourceCRS to targetCRS and optional area.
func (*Context) NewCRSToCRSFromPJ ¶ added in v10.1.0
func (c *Context) NewCRSToCRSFromPJ(sourcePJ, targetPJ *PJ, area *Area, options string) (*PJ, error)
NewCRSToCRSFromPJ returns a new PJ from two CRSs.
func (*Context) NewFromArgs ¶
NewFromArgs returns a new PJ from args.
func (*Context) SetSearchPaths ¶ added in v10.4.0
SetSearchPaths sets the paths PROJ should be exploring to find the PROJ Data files.
type Coord ¶
type Coord [4]float64
A coord is a coordinate.
func Float64SlicesToCoords ¶ added in v10.2.0
Float64Slices is a convenience function that converts a slice of []float64s to a slice of Coords.
func (Coord) DegToRad ¶
DegToRad returns a new Coord with the first two elements transformed from degrees to radians.
type PJ ¶
type PJ struct {
// contains filtered or unexported fields
}
A PJ is a projection or a transformation.
func NewCRSToCRS ¶
NewCRSToCRS returns a new PJ from sourceCRS to targetCRS and optional area.
func NewCRSToCRSFromPJ ¶ added in v10.1.0
NewCRSToCRSFromPJ returns a new PJ from two CRSs.
func NewFromArgs ¶ added in v10.1.0
NewFromArgs returns a PJ with the given args.
func (*PJ) Forward ¶
Forward transforms coord in the forward direction.
Example ¶
pj, err := proj.NewCRSToCRS("EPSG:4326", "EPSG:3857", nil) if err != nil { panic(err) } defer pj.Destroy() // Start with Zürich's WGS84 latitude/longitude. zurich4326 := proj.NewCoord(47.374444, 8.541111, 408, 0) fmt.Printf("initial: x=%.6f y=%.6f z=%.6f\n", zurich4326.X(), zurich4326.Y(), zurich4326.Z()) // Convert Zürich's WGS84 latitude/longitude to Web Mercator. zurich3857, err := pj.Forward(zurich4326) if err != nil { panic(err) } fmt.Printf("forward: x=%.6f y=%.6f z=%.6f\n", zurich3857.X(), zurich3857.Y(), zurich3857.Z()) // ...and convert back. zurich4326After, err := pj.Inverse(zurich3857) if err != nil { panic(err) } fmt.Printf("inverse: x=%.6f y=%.6f z=%.6f", zurich4326After.X(), zurich4326After.Y(), zurich4326After.Z())
Output: initial: x=47.374444 y=8.541111 z=408.000000 forward: x=950792.127329 y=6003408.475803 z=408.000000 inverse: x=47.374444 y=8.541111 z=408.000000
func (*PJ) ForwardArray ¶
ForwardArray transforms coords in the forward direction.
func (*PJ) ForwardBounds ¶
ForwardBounds transforms bounds in the forward direction.
func (*PJ) ForwardFlatCoords ¶
ForwardFlatCoords transforms flatCoords in the forward direction.
func (*PJ) ForwardFloat64Slice ¶ added in v10.2.0
ForwardFloat64Slice transforms float64 in place in the forward direction.
func (*PJ) ForwardFloat64Slices ¶ added in v10.2.0
ForwardFloat64Slices transforms float64Slices in the forward direction.
func (*PJ) GetLastUsedOperation ¶
GetLastUsedOperation returns the operation used in the last call to Trans.
func (*PJ) InverseArray ¶
InverseArray transforms coords in the inverse direction.
func (*PJ) InverseBounds ¶
InverseBounds transforms bounds in the forward direction.
func (*PJ) InverseFlatCoords ¶
InverseFlatCoords transforms flatCoords in the inverse direction.
func (*PJ) InverseFloat64Slice ¶ added in v10.2.0
InverseFloat64Slice transforms float64 in place in the forward direction.
func (*PJ) InverseFloat64Slices ¶ added in v10.2.0
InverseFloat64Slices transforms float64Slices in the inverse direction.
func (*PJ) LPZDist ¶
LPZDist returns the geodesic distance between a and b in geodetic coordinates, taking height above the ellipsoid into account.
func (*PJ) NormalizeForVisualization ¶ added in v10.1.0
Returns a new PJ instance whose axis order is the one expected for visualization purposes. If the axis order of its source or target CRS is northing, easting, then an axis swap operation will be inserted.
The axis order of geographic CRS will be longitude, latitude[, height], and the one of projected CRS will be easting, northing [, height].
func (*PJ) TransArray ¶
TransArray transforms an array of Coords.
func (*PJ) TransBounds ¶
TransBounds transforms bounds.
func (*PJ) TransFlatCoords ¶
func (pj *PJ) TransFlatCoords(direction Direction, flatCoords []float64, stride, zIndex, mIndex int) error
TransFlatCoords transforms an array of flat coordinates.
func (*PJ) TransFloat64Slice ¶ added in v10.2.0
TransFloat64Slice transforms a []float64 in place.
func (*PJ) TransFloat64Slices ¶ added in v10.2.0
TransFloat64Slices transforms float64Slices.