Documentation
¶
Overview ¶
Package turfgo provides geospatial calculation methods.
Index ¶
- func BboxToCorners(box *BoundingBox) (*Point, *Point)
- func Bearing(point1, point2 *Point) float64
- func BearingToAngle(bearing float64) float64
- func ConvertArea(area float64, originalUnit Unit, finalUnit Unit) (float64, error)
- func ConvertDistance(distance float64, originalUnit Unit, finalUnit Unit) float64
- func DecodeFeatureCollection(gj []byte) (*geojson.FeatureCollection, error)
- func DegreeToRads(degree float64) float64
- func DegreesToRads(first float64, second float64) (float64, float64)
- func Distance(point1 *Point, point2 *Point, unit Unit) float64
- func DistanceToDegrees(distance float64, unit Unit) float64
- func DistanceToRads(distance float64, unit Unit) float64
- func DoesBboxOverlap(b1 *BoundingBox, b2 *BoundingBox) (bool, error)
- func EncodePolyline(coordinates []*Point, dim int) string
- func Inside(point *Point, polygon PolygonI) bool
- func IsPointOnLine(point Point, lineString *LineString, ignoreEnds bool) bool
- func LineDiffPercentage(firstLine *LineString, secondLine *LineString) float64
- func RadsToDegree(rad float64) float64
- func RadsToDistance(radians float64, unit Unit) float64
- type Boundary
- type BoundingBox
- type Geometry
- type LineString
- type MultiLineString
- type MultiPoint
- type MultiPolygon
- type Point
- func Along(lineString *LineString, distance float64, unit Unit) *Point
- func Center(shapes ...Geometry) *Point
- func DecodePolyline(line string, dim int) ([]*Point, error)
- func Destination(start *Point, distance float64, bearing float64, unit Unit) *Point
- func Nearest(reference *Point, points []*Point) *Point
- func NewPoint(lat float64, lon float64) *Point
- func PointOnLine(point *Point, lineString *LineString, unit Unit) (*Point, float64, int, error)
- func TriangularProjection(point *Point, previousPoint *Point, lineString *LineString, unit Unit) (*Point, float64, int, error)
- func Within(points []*Point, polygons []PolygonI) []*Point
- type Polygon
- type PolygonI
- type Unit
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BboxToCorners ¶
func BboxToCorners(box *BoundingBox) (*Point, *Point)
BboxToCorners return the corner points SouthWest and NorthEast from bbox
func BearingToAngle ¶
BearingToAngle 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 ConvertArea ¶
ConvertArea converts an area to the requested unit. Allowed units are Kilometers, Meters, Centimeters, Miles, Yards, Feet, Inches
func ConvertDistance ¶
ConvertDistance converts a distance to the requested unit.
func DecodeFeatureCollection ¶
func DecodeFeatureCollection(gj []byte) (*geojson.FeatureCollection, error)
func DegreeToRads ¶
DegreeToRads convert degrees (assuming a spherical Earth) into radians
func DegreesToRads ¶
DegreesToRads convert a pair of floats (assuming a spherical Earth) into a pair of radians
func Distance ¶
Distance calculates the distance between two points in degress, radians, miles, or kilometers. This uses the Haversine formula to account for global curvature.
func DistanceToDegrees ¶
DistanceToDegrees convert a distance measurement (assuming a spherical Earth) from a real-world unit into degrees
func DistanceToRads ¶
DistanceToRads convert a distance measurement (assuming a spherical Earth) from a real-world unit into radians
func DoesBboxOverlap ¶
func DoesBboxOverlap(b1 *BoundingBox, b2 *BoundingBox) (bool, error)
DoesBboxOverlap takes two bounding box and returns true if there is an overlap. The order of values in array is WSEN(west, south , east, north)
func EncodePolyline ¶
EncodePolyline encodes given coordinates into a polyline for the given dimension
func Inside ¶
Inside takes a Point and a Polygon or MultiPolygon and determines if the point resides inside the polygon. The polygon can be convex or concave. The function accounts for holes.
func IsPointOnLine ¶
func IsPointOnLine(point Point, lineString *LineString, ignoreEnds bool) bool
IsPointOnLine returns true if a point is on a line. Accepts a parameter to ignore the start and end vertices of the linestring.
func LineDiffPercentage ¶
func LineDiffPercentage(firstLine *LineString, secondLine *LineString) float64
LineDiffPercentage take two lines and give the percentage of difference between first and second line with respect to first line. Single coordinate overlaps are ignored. Line should not have duplicate values.
func RadsToDegree ¶
RadsToDegree convert a radians (assuming a spherical Earth) into degrees
func RadsToDistance ¶
RadsToDistance convert a distance measurement (assuming a spherical Earth) from radians to a more friendly unit.
Types ¶
type BoundingBox ¶
BoundingBox represent a bbox
func Expand ¶
func Expand(distance float64, unit Unit, geometries ...Geometry) *BoundingBox
Expand Takes a set of features, calculates a collective bounding box around the features and expand it by the given distance in all directions. It returns a bounding box.
func Extent ¶
func Extent(geometries ...Geometry) *BoundingBox
Extent Takes a set of features, calculates the extent of all input features, and returns a bounding box.
func NewBBox ¶
func NewBBox(w float64, s float64, e float64, n float64) *BoundingBox
NewBBox creates bounding box with given corners
func NewInfiniteBBox ¶
func NewInfiniteBBox() *BoundingBox
NewInfiniteBBox creates a bounding box with corners really far away
type LineString ¶
type LineString struct {
Points []*Point
}
LineString geojson type
func DecodeLineStringFromFeatureJSON ¶
func DecodeLineStringFromFeatureJSON(gj []byte) (*LineString, error)
DecodeLineStringFromFeatureJSON decode geojson feature type lineString into *LineString
func LineDiff ¶
func LineDiff(firstLine *LineString, secondLine *LineString) []*LineString
LineDiff take two lines and gives an array of lines by subracting second from first. Single coordinate overlaps are ignored. Line should not have duplicate values.
func NewLineString ¶
func NewLineString(points []*Point) *LineString
NewLineString creates a new lineString for given points
func (*LineString) GetPoints ¶
func (p *LineString) GetPoints() []*Point
type MultiLineString ¶
type MultiLineString struct {
LineStrings []*LineString
}
MultiLineString geojson type
func NewMultiLineString ¶
func NewMultiLineString(lineStrings []*LineString) *MultiLineString
NewMultiLineString creates a new multiLineString for given lineStrings
func (*MultiLineString) GetPoints ¶
func (p *MultiLineString) GetPoints() []*Point
type MultiPoint ¶
type MultiPoint struct {
Points []*Point
}
MultiPoint geojson type
func NewMultiPoint ¶
func NewMultiPoint(points []*Point) *MultiPoint
NewMultiPoint creates a new multiPoint for given points
func (*MultiPoint) GetPoints ¶
func (p *MultiPoint) GetPoints() []*Point
type MultiPolygon ¶
type MultiPolygon struct {
Polygons []*Polygon
}
MultiPolygon geojson type
func NewMultiPolygon ¶
func NewMultiPolygon(polygons []*Polygon) *MultiPolygon
NewMultiPolygon creates a new multiPolygon for given polygons
func (*MultiPolygon) GetPoints ¶
func (p *MultiPolygon) GetPoints() []*Point
func (*MultiPolygon) GetPolygons ¶
func (p *MultiPolygon) GetPolygons() []*Polygon
type Point ¶
A Point on earth
func Along ¶
func Along(lineString *LineString, distance float64, unit Unit) *Point
Along takes a line and returns a point at a specified distance along the line. Returns the last point if distance is more than the span of the line.
func DecodePolyline ¶
DecodePolyline decodes given polyline for given dimension and return coordinates
func Destination ¶
Destination takes a Point and calculates the location of a destination point given a distance in degrees, radians, miles, or kilometers; and bearing in degrees. This uses the Haversine formula to account for global curvature.
func Nearest ¶
Nearest takes a reference point and a set of points and returns the point from the set closest to the reference.
func PointOnLine ¶
PointOnLine takes a Point and a LineString and calculates the closest Point on the LineString.
func TriangularProjection ¶
func TriangularProjection(point *Point, previousPoint *Point, lineString *LineString, unit Unit) (*Point, float64, int, error)
TriangularProjection calculate the projection of given point on the lineString, base angles for projection should be acute. If bearing should also be considered, pass in a previous point, otherwise it should be nil
type Polygon ¶
type Polygon struct {
LineStrings []*LineString
}
Polygon geojson type
func NewPolygon ¶
func NewPolygon(lineStrings []*LineString) *Polygon
NewPolygon creates a new polygon for given lineStrings