tlxy

package
v1.0.0-rc0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 18, 2024 License: GPL-3.0 Imports: 8 Imported by: 6

Documentation

Overview

Package tlxy provides simple XY geometry helper functions; these are approximate and designed for our specific use cases.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApproxDistance

func ApproxDistance(lonCheck float64, p Point, s Point) float64

func ApproxLonMeters

func ApproxLonMeters(p Point) float64

func Distance2d

func Distance2d(p1, p2 Point) float64

func Distance2dLength

func Distance2dLength(line []Point) float64

func DistanceHaversine

func DistanceHaversine(a, b Point) float64

func EncodePolyline

func EncodePolyline(coords []Point) []byte

func Length2d

func Length2d(line []Point) float64

Length2d returns the cartesian length of line

func LengthHaversine

func LengthHaversine(line []Point) float64

LengthHaversine returns the Haversine approximate length of a line.

func LineContains

func LineContains(a []Point, b []Point) bool

func LineEquals

func LineEquals(a []Point, b []Point) bool

func LineFlatCoords

func LineFlatCoords(line []Point) []float64

func LineRelativePositions

func LineRelativePositions(line []Point, points []Point) []float64

LineRelativePositions finds the relative position of the closest point along the line for each point. TODO: use Haversine

func LineRelativePositionsFallback

func LineRelativePositionsFallback(line []Point) []float64

LineRelativePositionsFallback returns the relative position along the line for each point. TODO: use Haversine

func LineSimilarity

func LineSimilarity(a []Point, b []Point) (float64, error)

Types

type Approx

type Approx struct {
	// contains filtered or unexported fields
}

func NewApprox

func NewApprox(p Point) Approx

func (*Approx) ApproxDistance

func (a *Approx) ApproxDistance(p Point, s Point) float64

func (*Approx) LatMeters

func (a *Approx) LatMeters() float64

func (*Approx) LonMeters

func (a *Approx) LonMeters() float64

type BoundingBox

type BoundingBox struct {
	MinLon float64 `json:"min_lon"`
	MinLat float64 `json:"min_lat"`
	MaxLon float64 `json:"max_lon"`
	MaxLat float64 `json:"max_lat"`
}

func ParseBbox

func ParseBbox(v string) (BoundingBox, error)

func (*BoundingBox) Contains

func (v *BoundingBox) Contains(pt Point) bool

type GeomCache

type GeomCache interface {
	GetStop(string) Point
	GetShape(eid string) []Point
}

type Line

type Line []Point

type LineM

type LineM struct {
	Coords []Point
	Data   []float64
}

type Point

type Point struct {
	Lon float64
	Lat float64
}

func CutBetweenPoints

func CutBetweenPoints(line []Point, from Point, to Point) []Point

CutBetweenPoints attempts to cut a line based on the relative positions of two nearby points projected onto the line.

func CutBetweenPositions

func CutBetweenPositions(line []Point, dists []float64, startDist float64, endDist float64) []Point

CutBetweenPositions is similar to CutBetweenPoints but takes absolute positions.

func DecodePolyline

func DecodePolyline(p string) ([]Point, error)

func DecodePolylineBytes

func DecodePolylineBytes(p []byte) ([]Point, error)

func LineClosestPoint

func LineClosestPoint(line []Point, point Point) (Point, int, float64)

LineClosestPoint returns the point (and position) on line closest to point. Based on go-geom DistanceFromPointToLineString

func SegmentClosestPoint

func SegmentClosestPoint(a, b, p Point) (Point, float64)

SegmentClosestPoint returns the point (and position) on AB closest to P.

func (*Point) String

func (p *Point) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL