Documentation
¶
Overview ¶
Package geom implements efficient geometry types for geospatial applications.
Index ¶
- Constants
- func BooleanPointOnLine(pt Coord, line []Coord, opts ...) bool
- func ElevationStats(ls *LineString) (Meters, Meters)
- func ElevationStatsSmoothed(ls *LineString) (Meters, Meters)
- func EqualCoords(a, b Coord) bool
- func IsPointOnLineSegment(start, end, pt Coord, exclude BoundaryExclusion, epsilon *float64) bool
- func PointEmptyCoord() float64
- type BoundaryExclusion
- type Bounds
- func (b *Bounds) Clone() *Bounds
- func (b *Bounds) Extend(g T) *Bounds
- func (b *Bounds) IsEmpty() bool
- func (b *Bounds) Layout() Layout
- func (b *Bounds) Max(dim int) float64
- func (b *Bounds) Min(dim int) float64
- func (b *Bounds) Overlaps(layout Layout, b2 *Bounds) bool
- func (b *Bounds) OverlapsPoint(layout Layout, point Coord) bool
- func (b *Bounds) Polygon() *Polygon
- func (b *Bounds) Set(args ...float64) *Bounds
- func (b *Bounds) SetCoords(minCoord, maxCoord Coord) *Bounds
- type Coord
- type Degree
- type Degrees
- type GeometryCollection
- func (g *GeometryCollection) Bounds() *Bounds
- func (g *GeometryCollection) CheckLayout(layout Layout) error
- func (g *GeometryCollection) Empty() bool
- func (g *GeometryCollection) Ends() []int
- func (g *GeometryCollection) Endss() [][]int
- func (g *GeometryCollection) FlatCoords() []float64
- func (g *GeometryCollection) Geom(i int) T
- func (g *GeometryCollection) Geoms() []T
- func (g *GeometryCollection) Layout() Layout
- func (g *GeometryCollection) MustPush(gs ...T) *GeometryCollection
- func (g *GeometryCollection) MustSetLayout(layout Layout) *GeometryCollection
- func (g *GeometryCollection) NumGeoms() int
- func (g *GeometryCollection) Push(gs ...T) error
- func (g *GeometryCollection) SRID() int
- func (g *GeometryCollection) SetLayout(layout Layout) error
- func (g *GeometryCollection) SetSRID(srid int) *GeometryCollection
- func (g *GeometryCollection) Stride() int
- type Inch
- type Inches
- type Layout
- type LayoutMismatchError
- type LineString
- func (g *LineString) Area() float64
- func (g *LineString) Clone() *LineString
- func (g *LineString) Coord(i int) Coord
- func (g *LineString) Coords() []Coord
- func (g *LineString) Interpolate(val float64, dim int) (int, float64)
- func (g *LineString) Length() float64
- func (g *LineString) MustSetCoords(coords []Coord) *LineString
- func (g *LineString) NumCoords() int
- func (g *LineString) Reverse()
- func (g *LineString) SetCoords(coords []Coord) (*LineString, error)
- func (g *LineString) SetSRID(srid int) *LineString
- func (g *LineString) SubLineString(start, stop int) *LineString
- func (g *LineString) Swap(g2 *LineString)
- type LinearRing
- func (g *LinearRing) Area() float64
- func (g *LinearRing) Clone() *LinearRing
- func (g *LinearRing) Coord(i int) Coord
- func (g *LinearRing) Coords() []Coord
- func (g *LinearRing) Length() float64
- func (g *LinearRing) MustSetCoords(coords []Coord) *LinearRing
- func (g *LinearRing) NumCoords() int
- func (g *LinearRing) Reverse()
- func (g *LinearRing) SetCoords(coords []Coord) (*LinearRing, error)
- func (g *LinearRing) SetSRID(srid int) *LinearRing
- func (g *LinearRing) Swap(g2 *LinearRing)
- type Meter
- type Meters
- func Crossarc(a, b, c Coord) Meters
- func Distance(from Coord, to Coord) Meters
- func ElevationGain(ls *LineString) Meters
- func ElevationGainSmoothed(ls *LineString, window ...Meters) Meters
- func ElevationLoss(ls *LineString) Meters
- func ElevationLossSmoothed(ls *LineString, window ...Meters) Meters
- func Length(ls *LineString) Meters
- func RadiansToLength(radians Radians) Meters
- type Mile
- type Miles
- type MultiLineString
- func (g *MultiLineString) Area() float64
- func (g *MultiLineString) Clone() *MultiLineString
- func (g *MultiLineString) Coords() [][]Coord
- func (g *MultiLineString) Ends() []int
- func (g *MultiLineString) Length() float64
- func (g *MultiLineString) LineString(i int) *LineString
- func (g *MultiLineString) MustSetCoords(coords [][]Coord) *MultiLineString
- func (g *MultiLineString) NumLineStrings() int
- func (g *MultiLineString) Push(ls *LineString) error
- func (g *MultiLineString) Reverse()
- func (g *MultiLineString) SetCoords(coords [][]Coord) (*MultiLineString, error)
- func (g *MultiLineString) SetSRID(srid int) *MultiLineString
- func (g *MultiLineString) Swap(g2 *MultiLineString)
- type MultiPoint
- func (g *MultiPoint) Area() float64
- func (g *MultiPoint) Clone() *MultiPoint
- func (g *MultiPoint) Coord(i int) Coord
- func (g *MultiPoint) Coords() []Coord
- func (g *MultiPoint) Ends() []int
- func (g *MultiPoint) Length() float64
- func (g *MultiPoint) MustSetCoords(coords []Coord) *MultiPoint
- func (g *MultiPoint) NumCoords() int
- func (g *MultiPoint) NumPoints() int
- func (g *MultiPoint) Point(i int) *Point
- func (g *MultiPoint) Push(p *Point) error
- func (g *MultiPoint) Reverse()
- func (g *MultiPoint) SetCoords(coords []Coord) (*MultiPoint, error)
- func (g *MultiPoint) SetSRID(srid int) *MultiPoint
- func (g *MultiPoint) Swap(g2 *MultiPoint)
- type MultiPolygon
- func (g *MultiPolygon) Area() float64
- func (g *MultiPolygon) Clone() *MultiPolygon
- func (g *MultiPolygon) Coords() [][][]Coord
- func (g *MultiPolygon) Endss() [][]int
- func (g *MultiPolygon) Length() float64
- func (g *MultiPolygon) MustSetCoords(coords [][][]Coord) *MultiPolygon
- func (g *MultiPolygon) NumPolygons() int
- func (g *MultiPolygon) Polygon(i int) *Polygon
- func (g *MultiPolygon) Push(p *Polygon) error
- func (g *MultiPolygon) Reverse()
- func (g *MultiPolygon) SetCoords(coords [][][]Coord) (*MultiPolygon, error)
- func (g *MultiPolygon) SetSRID(srid int) *MultiPolygon
- func (g *MultiPolygon) Swap(g2 *MultiPolygon)
- type NauticalMile
- type NauticalMiles
- type NearestPointResult
- type NewMultiPointFlatOption
- type Point
- func Along(line *LineString, distance Meters) *Point
- func Destination(origin *Point, distance Meters, bearing Degrees) *Point
- func NewPoint(l Layout) *Point
- func NewPointEmpty(l Layout) *Point
- func NewPointFlat(l Layout, flatCoords []float64) *Point
- func NewPointFlatMaybeEmpty(layout Layout, flatCoords []float64) *Point
- func (g *Point) Area() float64
- func (g *Point) Bounds() *Bounds
- func (g *Point) Clone() *Point
- func (g *Point) Convert(f func(x, y float64) (float64, float64))
- func (g *Point) Coords() Coord
- func (g *Point) Empty() bool
- func (g *Point) Ends() []int
- func (g *Point) Endss() [][]int
- func (g *Point) FlatCoords() []float64
- func (g *Point) Layout() Layout
- func (g *Point) Length() float64
- func (g *Point) M() float64
- func (g *Point) MustSetCoords(coords Coord) *Point
- func (g *Point) NumCoords() int
- func (g *Point) Reserve(n int)
- func (g *Point) SRID() int
- func (g *Point) SetCoords(coords Coord) (*Point, error)
- func (g *Point) SetSRID(srid int) *Point
- func (g *Point) Stride() int
- func (g *Point) Swap(g2 *Point)
- func (g *Point) X() float64
- func (g *Point) Y() float64
- func (g *Point) Z() float64
- type Polygon
- func (g *Polygon) Area() float64
- func (g *Polygon) Clone() *Polygon
- func (g *Polygon) Coords() [][]Coord
- func (g *Polygon) Ends() []int
- func (g *Polygon) Length() float64
- func (g *Polygon) LinearRing(i int) *LinearRing
- func (g *Polygon) MustSetCoords(coords [][]Coord) *Polygon
- func (g *Polygon) NumLinearRings() int
- func (g *Polygon) Push(lr *LinearRing) error
- func (g *Polygon) Reverse()
- func (g *Polygon) SetCoords(coords [][]Coord) (*Polygon, error)
- func (g *Polygon) SetSRID(srid int) *Polygon
- func (g *Polygon) Swap(g2 *Polygon)
- type Radian
- type Radians
- type StrideMismatchError
- type T
- type UnsupportedLayoutError
- type UnsupportedTypeError
- type Vector
- type Yard
- type Yards
Examples ¶
Constants ¶
const EarthRadius = 6371008.8
The Earth radius in meters. Used by geom functions that model the Earth as a sphere. The [mean radius](https://en.wikipedia.org/wiki/Earth_radius#Arithmetic_mean_radius) was selected because it is [recommended](https://rosettacode.org/wiki/Haversine_formula#:~:text=This%20value%20is%20recommended) by the Haversine formula to reduce error.
const PointEmptyCoordHex = 0x7FF8000000000000
PointEmptyCoordHex is the hex representation of a NaN that represents an empty coord in a shape.
Variables ¶
This section is empty.
Functions ¶
func BooleanPointOnLine ¶
func BooleanPointOnLine(pt Coord, line []Coord, opts *struct { IgnoreEndVertices bool Epsilon *float64 }) bool
BooleanPointOnLine returns true if pt lies on any segment of line. If opts.IgnoreEndVertices is true, the line's first and last vertices are excluded. If opts.Epsilon is nil, exact arithmetic is used for collinearity; otherwise |cross| <= *Epsilon.
func ElevationStats ¶
func ElevationStats(ls *LineString) (Meters, Meters)
ElevationStats returns elevation gain and loss (respectively).
func ElevationStatsSmoothed ¶
func ElevationStatsSmoothed(ls *LineString) (Meters, Meters)
ElevationStats returns smoothed elevation gain and loss (respectively).
func EqualCoords ¶
func IsPointOnLineSegment ¶
func IsPointOnLineSegment(start, end, pt Coord, exclude BoundaryExclusion, epsilon *float64) bool
IsPointOnLineSegment checks if pt lies on the finite segment [start,end]. If epsilon is nil, exact arithmetic is used for collinearity; otherwise |cross| <= *epsilon. Boundary handling follows the JS reference: inclusive by default, or exclude start/end/both.
func PointEmptyCoord ¶
func PointEmptyCoord() float64
PointEmptyCoord is the NaN float64 representation of the empty coordinate.
Types ¶
type BoundaryExclusion ¶
type BoundaryExclusion string
BoundaryExclusion controls whether endpoints are considered "on" the segment.
const ( ExcludeNone BoundaryExclusion = "none" ExcludeStart BoundaryExclusion = "start" ExcludeEnd BoundaryExclusion = "end" ExcludeBoth BoundaryExclusion = "both" )
type Bounds ¶
type Bounds struct {
// contains filtered or unexported fields
}
A Bounds represents a multi-dimensional bounding box.
func (*Bounds) OverlapsPoint ¶
OverlapsPoint determines if the bounding box overlaps the point (point is within or on the border of the bounds).
func (*Bounds) Set ¶
Set sets the minimum and maximum values. args must be an even number of values: the first half are the minimum values for each dimension and the second half are the maximum values for each dimension. If necessary, the layout of b will be extended to cover all the supplied dimensions implied by args.
type Coord ¶
type Coord []float64
A Coord represents an N-dimensional coordinate.
func (Coord) Equal ¶
Equal compares that all ordinates are the same in this and the other coords. It is assumed that this coord and other coord both have the same (provided) layout.
type Degrees ¶
type Degrees float64
func AzimuthToBearing ¶
AzimuthToBearing converts any azimuth angle from the north line direction (positive clockwise) and returns an angle between -180 and +180 degrees (positive clockwise), 0 being the north line.
func Bearing ¶
Bearing takes two Coord and finds the geographic bearing between them, i.e. the angle measured in degrees from the north line (0 degrees). Returns bearing in decimal degrees, between -180 and 180 degrees (positive clockwise)
func BearingToAzimuth ¶
BearingToAzimuth converts any bearing angle from the north line direction (positive clockwise) and returns an angle between 0-360 degrees (positive clockwise), 0 being the north line.
func CalculateFinalBearing ¶
CalculateFinalBearing calculates Final Bearing
func RadiansToDegrees ¶
Converts an angle in radians to degrees.
type GeometryCollection ¶
type GeometryCollection struct {
// contains filtered or unexported fields
}
A GeometryCollection is a collection of arbitrary geometries with the same SRID.
func NewGeometryCollection ¶
func NewGeometryCollection() *GeometryCollection
NewGeometryCollection returns a new empty GeometryCollection.
func (*GeometryCollection) Bounds ¶
func (g *GeometryCollection) Bounds() *Bounds
Bounds returns the bounds of all the geometries in g.
func (*GeometryCollection) CheckLayout ¶
func (g *GeometryCollection) CheckLayout(layout Layout) error
CheckLayout checks all geometries in the collection match the given layout.
func (*GeometryCollection) Empty ¶
func (g *GeometryCollection) Empty() bool
Empty returns true if the collection is empty. This can return true if the GeometryCollection contains multiple Geometry objects which are all empty.
func (*GeometryCollection) FlatCoords ¶
func (g *GeometryCollection) FlatCoords() []float64
FlatCoords panics.
func (*GeometryCollection) Geom ¶
func (g *GeometryCollection) Geom(i int) T
Geom returns the ith geometry in g.
func (*GeometryCollection) Geoms ¶
func (g *GeometryCollection) Geoms() []T
Geoms returns the geometries in g.
func (*GeometryCollection) Layout ¶
func (g *GeometryCollection) Layout() Layout
Layout returns the smallest layout that covers all of the layouts in g's geometries.
func (*GeometryCollection) MustPush ¶
func (g *GeometryCollection) MustPush(gs ...T) *GeometryCollection
MustPush pushes gs to g. It panics on any error.
func (*GeometryCollection) MustSetLayout ¶
func (g *GeometryCollection) MustSetLayout(layout Layout) *GeometryCollection
MustSetLayout sets g's layout. It panics on any error.
func (*GeometryCollection) NumGeoms ¶
func (g *GeometryCollection) NumGeoms() int
NumGeoms returns the number of geometries in g.
func (*GeometryCollection) Push ¶
func (g *GeometryCollection) Push(gs ...T) error
Push appends geometries.
func (*GeometryCollection) SetLayout ¶
func (g *GeometryCollection) SetLayout(layout Layout) error
SetLayout sets g's layout.
func (*GeometryCollection) SetSRID ¶
func (g *GeometryCollection) SetSRID(srid int) *GeometryCollection
SetSRID sets g's SRID and the SRID of all its elements.
func (*GeometryCollection) Stride ¶
func (g *GeometryCollection) Stride() int
Stride returns the stride of g's layout.
type Layout ¶
type Layout int
A Layout describes the meaning of an N-dimensional coordinate. Layout(N) for N > 4 is a valid layout, in which case the first dimensions are interpreted to be X, Y, Z, and M and extra dimensions have no special meaning. M values are considered part of a linear referencing system (e.g. classical time or distance along a path). 1-dimensional layouts are not supported.
func (Layout) MIndex ¶
MIndex returns the index of the M dimension, or -1 if the l does not have an M dimension.
type LayoutMismatchError ¶
LayoutMismatchError is returned when geometries with different layouts cannot be combined.
func (LayoutMismatchError) Error ¶
func (e LayoutMismatchError) Error() string
type LineString ¶
type LineString struct {
// contains filtered or unexported fields
}
A LineString represents a single, unbroken line, linearly interpreted between zero or more control points.
func CleanLine ¶
func CleanLine(line *LineString) *LineString
CleanLine removes redundant collinear points from a polyline. Polygon handling is intentionally skipped.
func LineSlice ¶
func LineSlice(line *LineString, startPt, stopPt Coord) *LineString
LineSlice returns a subsection of a LineString between startPt and stopPt. The coordinates do not need to lie exactly on the line.
func NewLineString ¶
func NewLineString(l Layout) *LineString
NewLineString returns a new LineString with layout l and no control points.
func NewLineStringFlat ¶
func NewLineStringFlat(layout Layout, flatCoords []float64) *LineString
NewLineStringFlat returns a new LineString with layout l and control points flatCoords.
func RamerDouglasPeucker ¶
func RamerDouglasPeucker(ls *LineString, epsilon Meters) *LineString
RamerDouglasPeucker simplifies a line string using the [Ramer–Douglas–Peucker](https://en.wikipedia.org/wiki/Ramer%E2%80%93Douglas%E2%80%93Peucker_algorithm) algorithm.
func (*LineString) Area ¶
func (g *LineString) Area() float64
Area returns the area of g, i.e. zero.
func (*LineString) Clone ¶
func (g *LineString) Clone() *LineString
Clone returns a copy of g that does not alias g.
func (*LineString) Coords ¶
func (g *LineString) Coords() []Coord
Coords unpacks and returns all of g's coordinates.
func (*LineString) Interpolate ¶
func (g *LineString) Interpolate(val float64, dim int) (int, float64)
Interpolate returns the index and delta of val in dimension dim.
func (*LineString) MustSetCoords ¶
func (g *LineString) MustSetCoords(coords []Coord) *LineString
MustSetCoords is like SetCoords but it panics on any error.
func (*LineString) NumCoords ¶
func (g *LineString) NumCoords() int
NumCoords returns the number of coordinates in g.
func (*LineString) Reverse ¶
func (g *LineString) Reverse()
Reverse reverses the order of g's coordinates.
func (*LineString) SetCoords ¶
func (g *LineString) SetCoords(coords []Coord) (*LineString, error)
SetCoords sets the coordinates of g.
func (*LineString) SetSRID ¶
func (g *LineString) SetSRID(srid int) *LineString
SetSRID sets the SRID of g.
func (*LineString) SubLineString ¶
func (g *LineString) SubLineString(start, stop int) *LineString
SubLineString returns a LineString from starts at index start and stops at index stop of g. The returned LineString aliases g.
func (*LineString) Swap ¶
func (g *LineString) Swap(g2 *LineString)
Swap swaps the values of g and g2.
type LinearRing ¶
type LinearRing struct {
// contains filtered or unexported fields
}
A LinearRing is a linear ring.
func NewLinearRing ¶
func NewLinearRing(layout Layout) *LinearRing
NewLinearRing returns a new LinearRing with no coordinates.
func NewLinearRingFlat ¶
func NewLinearRingFlat(layout Layout, flatCoords []float64) *LinearRing
NewLinearRingFlat returns a new LinearRing with the given flat coordinates.
func (*LinearRing) Coords ¶
func (g *LinearRing) Coords() []Coord
Coords unpacks and returns all of g's coordinates.
func (*LinearRing) Length ¶
func (g *LinearRing) Length() float64
Length returns the length of the perimeter.
func (*LinearRing) MustSetCoords ¶
func (g *LinearRing) MustSetCoords(coords []Coord) *LinearRing
MustSetCoords sets the coordinates and panics if there is any error.
func (*LinearRing) NumCoords ¶
func (g *LinearRing) NumCoords() int
NumCoords returns the number of coordinates in g.
func (*LinearRing) Reverse ¶
func (g *LinearRing) Reverse()
Reverse reverses the order of g's coordinates.
func (*LinearRing) SetCoords ¶
func (g *LinearRing) SetCoords(coords []Coord) (*LinearRing, error)
SetCoords sets the coordinates.
func (*LinearRing) SetSRID ¶
func (g *LinearRing) SetSRID(srid int) *LinearRing
SetSRID sets the SRID of g.
func (*LinearRing) Swap ¶
func (g *LinearRing) Swap(g2 *LinearRing)
Swap swaps the values of g and g2.
type Meters ¶
type Meters float64
func Distance ¶
Distance calculates the distance between two Coord in a desired unit. This uses the [Haversine formula](http://en.wikipedia.org/wiki/Haversine_formula) to account for global curvature.
func ElevationGain ¶
func ElevationGain(ls *LineString) Meters
func ElevationGainSmoothed ¶
func ElevationGainSmoothed(ls *LineString, window ...Meters) Meters
func ElevationLoss ¶
func ElevationLoss(ls *LineString) Meters
func ElevationLossSmoothed ¶
func ElevationLossSmoothed(ls *LineString, window ...Meters) Meters
func Length ¶
func Length(ls *LineString) Meters
Length measures a length of a geometry in the specified units, (Multi)Point's distance are ignored.
func RadiansToLength ¶
RadiansToLength convert a distance measurement (assuming a spherical Earth) from radians to meters.
type MultiLineString ¶
type MultiLineString struct {
// contains filtered or unexported fields
}
A MultiLineString is a collection of LineStrings.
func NewMultiLineString ¶
func NewMultiLineString(layout Layout) *MultiLineString
NewMultiLineString returns a new MultiLineString with no LineStrings.
func NewMultiLineStringFlat ¶
func NewMultiLineStringFlat(layout Layout, flatCoords []float64, ends []int) *MultiLineString
NewMultiLineStringFlat returns a new MultiLineString with the given flat coordinates.
func (*MultiLineString) Area ¶
func (g *MultiLineString) Area() float64
Area returns the area of g, i.e. 0.
func (*MultiLineString) Clone ¶
func (g *MultiLineString) Clone() *MultiLineString
Clone returns a deep copy.
func (*MultiLineString) Coords ¶
func (g *MultiLineString) Coords() [][]Coord
Coords returns all of g's coordinates.
func (*MultiLineString) Ends ¶
func (g *MultiLineString) Ends() []int
Ends returns the end indexes of all sub-structures in g.
func (*MultiLineString) Length ¶
func (g *MultiLineString) Length() float64
Length returns the sum of the length of the LineStrings.
func (*MultiLineString) LineString ¶
func (g *MultiLineString) LineString(i int) *LineString
LineString returns the ith LineString.
func (*MultiLineString) MustSetCoords ¶
func (g *MultiLineString) MustSetCoords(coords [][]Coord) *MultiLineString
MustSetCoords sets the coordinates and panics on any error.
func (*MultiLineString) NumLineStrings ¶
func (g *MultiLineString) NumLineStrings() int
NumLineStrings returns the number of LineStrings.
func (*MultiLineString) Push ¶
func (g *MultiLineString) Push(ls *LineString) error
Push appends a LineString.
func (*MultiLineString) Reverse ¶
func (g *MultiLineString) Reverse()
Reverse reverses the order of coordinates for each sub-structure in g.
func (*MultiLineString) SetCoords ¶
func (g *MultiLineString) SetCoords(coords [][]Coord) (*MultiLineString, error)
SetCoords sets the coordinates.
func (*MultiLineString) SetSRID ¶
func (g *MultiLineString) SetSRID(srid int) *MultiLineString
SetSRID sets the SRID of g.
func (*MultiLineString) Swap ¶
func (g *MultiLineString) Swap(g2 *MultiLineString)
Swap swaps the values of g and g2.
type MultiPoint ¶
type MultiPoint struct {
// contains filtered or unexported fields
}
A MultiPoint is a collection of Points.
func NewMultiPoint ¶
func NewMultiPoint(layout Layout) *MultiPoint
NewMultiPoint returns a new, empty, MultiPoint.
func NewMultiPointFlat ¶
func NewMultiPointFlat( layout Layout, flatCoords []float64, opts ...NewMultiPointFlatOption, ) *MultiPoint
NewMultiPointFlat returns a new MultiPoint with the given flat coordinates. Assumes no points are empty by default. Use `NewMultiPointFlatOptionWithEnds` to specify empty points.
func (*MultiPoint) Area ¶
func (g *MultiPoint) Area() float64
Area returns the area of g, i.e. zero.
func (*MultiPoint) Coord ¶
func (g *MultiPoint) Coord(i int) Coord
Coord returns the ith coord of g.
func (*MultiPoint) Coords ¶
func (g *MultiPoint) Coords() []Coord
Coords unpacks and returns all of g's coordinates.
func (*MultiPoint) Ends ¶
func (g *MultiPoint) Ends() []int
Ends returns the end indexes of all sub-structures in g.
func (*MultiPoint) MustSetCoords ¶
func (g *MultiPoint) MustSetCoords(coords []Coord) *MultiPoint
MustSetCoords sets the coordinates and panics on any error.
func (*MultiPoint) NumCoords ¶
func (g *MultiPoint) NumCoords() int
NumCoords returns the number of coordinates in g.
func (*MultiPoint) NumPoints ¶
func (g *MultiPoint) NumPoints() int
NumPoints returns the number of Points.
func (*MultiPoint) Reverse ¶
func (g *MultiPoint) Reverse()
Reverse reverses the order of coordinates for each sub-structure in g.
func (*MultiPoint) SetCoords ¶
func (g *MultiPoint) SetCoords(coords []Coord) (*MultiPoint, error)
SetCoords sets the coordinates.
func (*MultiPoint) SetSRID ¶
func (g *MultiPoint) SetSRID(srid int) *MultiPoint
SetSRID sets the SRID of g.
func (*MultiPoint) Swap ¶
func (g *MultiPoint) Swap(g2 *MultiPoint)
Swap swaps the values of g and g2.
type MultiPolygon ¶
type MultiPolygon struct {
// contains filtered or unexported fields
}
A MultiPolygon is a collection of Polygons.
func NewMultiPolygon ¶
func NewMultiPolygon(layout Layout) *MultiPolygon
NewMultiPolygon returns a new MultiPolygon with no Polygons.
func NewMultiPolygonFlat ¶
func NewMultiPolygonFlat(layout Layout, flatCoords []float64, endss [][]int) *MultiPolygon
NewMultiPolygonFlat returns a new MultiPolygon with the given flat coordinates.
func (*MultiPolygon) Area ¶
func (g *MultiPolygon) Area() float64
Area returns the sum of the area of the individual Polygons.
func (*MultiPolygon) Clone ¶
func (g *MultiPolygon) Clone() *MultiPolygon
Clone returns a deep copy.
func (*MultiPolygon) Coords ¶
func (g *MultiPolygon) Coords() [][][]Coord
Coords returns all the coordinates in g.
func (*MultiPolygon) Endss ¶
func (g *MultiPolygon) Endss() [][]int
Endss returns a list of all the sub-sub-structures in g.
func (*MultiPolygon) Length ¶
func (g *MultiPolygon) Length() float64
Length returns the sum of the perimeters of the Polygons.
func (*MultiPolygon) MustSetCoords ¶
func (g *MultiPolygon) MustSetCoords(coords [][][]Coord) *MultiPolygon
MustSetCoords sets the coordinates and panics on any error.
func (*MultiPolygon) NumPolygons ¶
func (g *MultiPolygon) NumPolygons() int
NumPolygons returns the number of Polygons.
func (*MultiPolygon) Polygon ¶
func (g *MultiPolygon) Polygon(i int) *Polygon
Polygon returns the ith Polygon.
func (*MultiPolygon) Reverse ¶
func (g *MultiPolygon) Reverse()
Reverse reverses the order of coordinates for each sub-sub-structure in g.
func (*MultiPolygon) SetCoords ¶
func (g *MultiPolygon) SetCoords(coords [][][]Coord) (*MultiPolygon, error)
SetCoords sets the coordinates.
func (*MultiPolygon) SetSRID ¶
func (g *MultiPolygon) SetSRID(srid int) *MultiPolygon
SetSRID sets the SRID of g.
func (*MultiPolygon) Swap ¶
func (g *MultiPolygon) Swap(g2 *MultiPolygon)
Swap swaps the values of g and g2.
type NauticalMile ¶
type NauticalMile struct{}
type NauticalMiles ¶
type NauticalMiles float64
type NearestPointResult ¶
func NearestPointOnLine ¶
func NearestPointOnLine(line *LineString, pt Coord) NearestPointResult
NearestPointOnLine returns the closest point on a line to a given point.
type NewMultiPointFlatOption ¶
type NewMultiPointFlatOption func(*MultiPoint)
NewMultiPointFlatOption represents an option that can be passed into NewMultiPointFlat.
func NewMultiPointFlatOptionWithEnds ¶
func NewMultiPointFlatOptionWithEnds(ends []int) NewMultiPointFlatOption
NewMultiPointFlatOptionWithEnds allows passing ends to NewMultiPointFlat, which allows the representation of empty points.
type Point ¶
type Point struct {
// contains filtered or unexported fields
}
A Point represents a single point.
func Along ¶
func Along(line *LineString, distance Meters) *Point
Along takes a LineString and returns a Point at a specified distance along the line.
func Destination ¶
Destination takes a Point and calculates the location of a destination Point given a distance and bearing in degrees. This uses the [Haversine formula](http://en.wikipedia.org/wiki/Haversine_formula) to account for global curvature.
func NewPointEmpty ¶
NewPointEmpty allocates a new Point with no coordinates.
func NewPointFlat ¶
NewPointFlat allocates a new Point with layout l and flat coordinates flatCoords.
func NewPointFlatMaybeEmpty ¶
NewPointFlatMaybeEmpty returns a new point, checking whether the point may be empty by checking wther all the points are NaN.
func (*Point) Coords ¶
func (g *Point) Coords() Coord
Coords returns all the coordinates in g, i.e. a single coordinate.
func (*Point) Ends ¶
func (g *Point) Ends() []int
Ends returns the end indexes of sub-structures of g, i.e. an empty slice.
func (*Point) Endss ¶
func (g *Point) Endss() [][]int
Endss returns the end indexes of sub-sub-structures of g, i.e. an empty slice.
func (*Point) FlatCoords ¶
func (g *Point) FlatCoords() []float64
FlatCoords returns the flat coordinates of g.
func (*Point) MustSetCoords ¶
MustSetCoords is like SetCoords but panics on any error.
func (*Point) NumCoords ¶
func (g *Point) NumCoords() int
NumCoords returns the number of coordinates in g, i.e. 1.
func (*Point) Reserve ¶
func (g *Point) Reserve(n int)
Reserve reserves space in g for n coordinates.
type Polygon ¶
type Polygon struct {
// contains filtered or unexported fields
}
A Polygon represents a polygon as a collection of LinearRings. The first LinearRing is the outer boundary. Subsequent LinearRings are inner boundaries (holes).
func NewPolygon ¶
NewPolygon returns a new, empty, Polygon.
Example ¶
unitSquare := NewPolygon(XY).MustSetCoords([][]Coord{
{{0, 0}, {1, 0}, {1, 1}, {0, 1}, {0, 0}},
})
fmt.Printf("unitSquare.Area() == %f", unitSquare.Area())
Output: unitSquare.Area() == 1.000000
func NewPolygonFlat ¶
NewPolygonFlat returns a new Polygon with the given flat coordinates.
func (*Polygon) Coords ¶
func (g *Polygon) Coords() [][]Coord
Coords returns all of g's coordinates.
func (*Polygon) Ends ¶
func (g *Polygon) Ends() []int
Ends returns the end indexes of all sub-structures in g.
func (*Polygon) LinearRing ¶
func (g *Polygon) LinearRing(i int) *LinearRing
LinearRing returns the ith LinearRing.
func (*Polygon) MustSetCoords ¶
MustSetCoords sets the coordinates and panics on any error.
func (*Polygon) NumLinearRings ¶
NumLinearRings returns the number of LinearRings.
func (*Polygon) Reverse ¶
func (g *Polygon) Reverse()
Reverse reverses the order of coordinates for each sub-structure in g.
type Radians ¶
type Radians float64
func DegreesToRadians ¶
DegreesToRadians converts an angle in degrees to radians.
func LengthToRadians ¶
Convert a distance measurement (assuming a spherical Earth) from a real-world unit into radians.
type StrideMismatchError ¶
StrideMismatchError is returned when the stride does not match the expected stride.
func (StrideMismatchError) Error ¶
func (e StrideMismatchError) Error() string
type T ¶
type T interface {
Layout() Layout
Stride() int
Bounds() *Bounds
FlatCoords() []float64
Ends() []int
Endss() [][]int
SRID() int
Empty() bool
}
T is a generic interface implemented by all geometry types.
func TransformInPlace ¶
TransformInPlace replaces all coordinates in g using f.
type UnsupportedLayoutError ¶
type UnsupportedLayoutError Layout
UnsupportedLayoutError is returned when the requested layout is not supported.
func (UnsupportedLayoutError) Error ¶
func (e UnsupportedLayoutError) Error() string
type UnsupportedTypeError ¶
type UnsupportedTypeError struct {
Value any
}
UnsupportedTypeError is returned when the requested type is not supported.
func (UnsupportedTypeError) Error ¶
func (e UnsupportedTypeError) Error() string
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
encoding
|
|
|
ewkb
Package ewkb implements Extended Well Known Binary encoding and decoding.
|
Package ewkb implements Extended Well Known Binary encoding and decoding. |
|
ewkbhex
Package ewkbhex implements Extended Well Known Binary encoding and decoding of strings.
|
Package ewkbhex implements Extended Well Known Binary encoding and decoding of strings. |
|
geojson
Package geojson implements GeoJSON encoding and decoding.
|
Package geojson implements GeoJSON encoding and decoding. |
|
igc
Package igc implements an IGC parser.
|
Package igc implements an IGC parser. |
|
igc/cmd/igc2kml
command
|
|
|
kml
Package kml implements KML encoding.
|
Package kml implements KML encoding. |
|
wkb
Package wkb implements Well Known Binary encoding and decoding.
|
Package wkb implements Well Known Binary encoding and decoding. |
|
wkbcommon
Package wkbcommon contains code common to WKB and EWKB encoding.
|
Package wkbcommon contains code common to WKB and EWKB encoding. |
|
wkbhex
Package wkbhex implements Well Known Binary encoding and decoding of strings.
|
Package wkbhex implements Well Known Binary encoding and decoding of strings. |
|
wkt
Package wkt implements Well Known Text encoding and decoding.
|
Package wkt implements Well Known Text encoding and decoding. |
|
goodgeopgx
module
|
|
|
internal
|
|
|
cmd/parse-igc
command
parse-igc parsers all IGC files passed on the command line and prints any errors encountered.
|
parse-igc parsers all IGC files passed on the command line and prints any errors encountered. |