Documentation ¶
Index ¶
- Constants
- Variables
- func CreateSVG(fname string, elements [][]Boundable, options SVGOptions) error
- func DecodeOSM(path string, options OSMOptions, f func(v interface{})) error
- func DrawLineOnCells(startX int, startY int, endX int, endY int, maxX int, maxY int) [][2]int
- func IsOSMBlacklisted(highway string) bool
- func IsOSMBlacklistedWithList(highway string, blacklist []string) bool
- func KDE(traces Traces, cellSize float64, sigma float64) [][]float64
- func NormalizeTraces(traces []*Trace)
- func RtreegoRect(r Rectangle) *rtreego.Rect
- func SaveChicagoTraces(tracePath string, traces Traces) error
- func SaveKharitaTraces(fname string, traces Traces) error
- func SaveTraces(tracePath string, traces Traces) error
- func VisualizeGraphs(scale float64, fname string, graphs []*Graph, traces []*Trace) error
- func Viterbi(graph *Graph, traces []*Trace, tolerance float64)
- func Viterbi2(traces []*Trace, graph *Graph, opts Viterbi2Options) (edgeHits map[int]int)
- type AstarParams
- type Boundable
- type CMTOptions
- type ColoredBoundable
- type Edge
- type EdgePos
- type EmbeddedImage
- type FollowParams
- type Graph
- func GraphFromEdges(edges []*Edge) *Graph
- func LoadOSM(path string, bounds Rectangle) (*Graph, error)
- func LoadOSMMultiple(path string, regions []Rectangle, options OSMOptions) ([]*Graph, error)
- func LoadOSMMultiple2(path string, regions []Rectangle, options OSMOptions) ([]*Graph, error)
- func ReadAhmedMap(verticesFname string, edgesFname string) (*Graph, error)
- func ReadChicagoMap(fname string) (*Graph, error)
- func ReadDaviesMap(verticesFname string, edgesFname string) (*Graph, error)
- func ReadEdelkampMap(fname string) (*Graph, error)
- func ReadGraph(fname string) (*Graph, error)
- func ReadKharitaMap(fname string) (*Graph, error)
- func (graph *Graph) AddBidirectionalEdge(v1 *Node, v2 *Node) [2]*Edge
- func (graph *Graph) AddEdge(src *Node, dst *Node) *Edge
- func (graph *Graph) AddNode(point Point) *Node
- func (graph *Graph) Astar(src *Node, dst *Node, params AstarParams) ShortestPathResult
- func (graph *Graph) Bounds() Rectangle
- func (graph *Graph) Clone() *Graph
- func (graph *Graph) FilterEdges(badEdges map[int]bool) *Graph
- func (graph *Graph) FilterEdgesWithMaps(badEdges map[int]bool) (*Graph, map[int]*Node, map[int]*Edge)
- func (graph *Graph) FindEdge(src *Node, dst *Node) *Edge
- func (graph *Graph) Follow(params FollowParams) []EdgePos
- func (graph *Graph) GetRoadSegmentGraph() (*Graph, map[int]RoadSegment, map[int]*Node)
- func (graph *Graph) GetRoadSegments() []RoadSegment
- func (graph *Graph) GetSubgraphInRect(r Rectangle) *Graph
- func (graph *Graph) GridIndex(gridSize float64) GraphGridIndex
- func (graph *Graph) LonLatToMeters(origin Point)
- func (graph *Graph) MakeBidirectional()
- func (graph *Graph) MetersToLonLat(origin Point)
- func (graph *Graph) Rtree() Rtree
- func (graph *Graph) ShortestDistancesFromSource(src *Node) map[int]float64
- func (graph *Graph) ShortestPath(src *Node, params ShortestPathParams) ShortestPathResult
- func (graph *Graph) SplitEdge(edge *Edge, length float64) *Edge
- func (graph *Graph) Write(fname string) error
- type GraphGridIndex
- type GridIndex
- type Line
- type Node
- type OSMOptions
- type Observation
- type Point
- func (point Point) Add(other Point) Point
- func (point Point) AngleTo(other Point) float64
- func (point Point) Bounds() Rectangle
- func (point Point) Cross(other Point) float64
- func (point Point) Distance(other Point) float64
- func (point Point) Dot(other Point) float64
- func (point Point) LonLatToMeters(origin Point) Point
- func (point Point) Magnitude() float64
- func (point Point) MetersToLonLat(origin Point) Point
- func (point Point) MulPairwise(other Point) Point
- func (point Point) Rectangle() Rectangle
- func (point Point) RectangleTol(tol float64) Rectangle
- func (point Point) Scale(f float64) Point
- func (point Point) SignedAngle(other Point) float64
- func (point Point) Sub(other Point) Point
- type Polygon
- type Rectangle
- func (rect Rectangle) AddTol(tol float64) Rectangle
- func (rect Rectangle) Area() float64
- func (rect Rectangle) Bounds() Rectangle
- func (rect Rectangle) Center() Point
- func (rect Rectangle) Contains(point Point) bool
- func (rect Rectangle) ContainsRect(other Rectangle) bool
- func (rect Rectangle) Diagonal() float64
- func (rect Rectangle) Extend(point Point) Rectangle
- func (rect Rectangle) ExtendRect(other Rectangle) Rectangle
- func (rect Rectangle) IOU(other Rectangle) float64
- func (rect Rectangle) Intersection(other Rectangle) Rectangle
- func (rect Rectangle) Intersects(other Rectangle) bool
- func (rect Rectangle) Lengths() Point
- func (rect Rectangle) ToPolygon() Polygon
- type RoadSegment
- func (rs RoadSegment) Bounds() Rectangle
- func (rs RoadSegment) ClosestPos(p Point) EdgePos
- func (rs RoadSegment) DistanceOfEdge(edge *Edge) float64
- func (rs RoadSegment) DistanceToEdge(t float64) *Edge
- func (rs RoadSegment) DistanceToIndex(t float64) int
- func (rs RoadSegment) Dst() *Node
- func (rs RoadSegment) Length() float64
- func (rs RoadSegment) PosAtFactor(t float64) EdgePos
- func (rs RoadSegment) Src() *Node
- type Rtree
- type SVGOptions
- type Segment
- func (segment Segment) AngleTo(other Segment) float64
- func (segment Segment) Bounds() Rectangle
- func (segment Segment) Distance(point Point) float64
- func (segment Segment) DistanceToSegment(other Segment) float64
- func (segment Segment) Intersection(other Segment) *Point
- func (segment Segment) Length() float64
- func (segment Segment) Line() Line
- func (segment Segment) PointAtFactor(factor float64, normalized bool) Point
- func (segment Segment) Project(point Point, normalized bool) float64
- func (segment Segment) ProjectPoint(point Point) Point
- func (segment Segment) ProjectWithWidth(point Point, width float64) Point
- func (segment Segment) Sample(d float64) []Point
- func (segment Segment) Vector() Point
- type ShortestPathParams
- type ShortestPathResult
- type SvgLabel
- type Trace
- type Traces
- type Viterbi2Options
- type WeightedBoundable
- type WidthBoundable
- type WrappingBoundable
Constants ¶
const OSM_INDEX_SCALE = 2
const VITERBI2_GRANULARITY = 50
const VITERBI2_MODE = "new"
const VITERBI2_SIGMA = 30
const VITERBI2_START_TOLERANCE = 100
const VITERBI2_THREADS = 36
const VITERBI_NORMALIZE_DELTA time.Duration = time.Second
const VITERBI_SIGMA = 25
Variables ¶
var HIGHWAY_BLACKLIST []string = []string{
"pedestrian",
"footway",
"bridleway",
"steps",
"path",
"sidewalk",
"cycleway",
"proposed",
"construction",
"bus_stop",
"crossing",
"elevator",
"emergency_access_point",
"escape",
"give_way",
}
Functions ¶
func DecodeOSM ¶
func DecodeOSM(path string, options OSMOptions, f func(v interface{})) error
func DrawLineOnCells ¶
Use Bresenham's algorithm to get indices of cells to draw a line.
func IsOSMBlacklisted ¶
func NormalizeTraces ¶
func NormalizeTraces(traces []*Trace)
func RtreegoRect ¶
func SaveChicagoTraces ¶
func SaveKharitaTraces ¶
func SaveTraces ¶
func VisualizeGraphs ¶
Types ¶
type AstarParams ¶
type AstarParams struct { // maximum distance to travel from src MaxDistance float64 }
type CMTOptions ¶
type ColoredBoundable ¶
func (ColoredBoundable) Bounds ¶
func (b ColoredBoundable) Bounds() Rectangle
type EmbeddedImage ¶
func (EmbeddedImage) Bounds ¶
func (img EmbeddedImage) Bounds() Rectangle
type FollowParams ¶
type FollowParams struct { // Source, only one should be specified. SourceNodes []*Node SourcePos EdgePos // Distance to travel along graph from source. Distance float64 // If true, don't search forwards. NoForwards bool // If true, search backwards (in addition to searching forwards). Backwards bool // If set, will be populated with nodes that we pass during following. SeenNodes map[int]bool // If set, we will stop immediately before these nodes rather than passing them. StopNodes map[int]bool }
type Graph ¶
func GraphFromEdges ¶
func LoadOSMMultiple ¶
func LoadOSMMultiple(path string, regions []Rectangle, options OSMOptions) ([]*Graph, error)
func LoadOSMMultiple2 ¶
func LoadOSMMultiple2(path string, regions []Rectangle, options OSMOptions) ([]*Graph, error)
New version improves performance when there are many bounding boxes.
func ReadChicagoMap ¶
func ReadEdelkampMap ¶
func ReadKharitaMap ¶
func (*Graph) AddBidirectionalEdge ¶
func (*Graph) Astar ¶
func (graph *Graph) Astar(src *Node, dst *Node, params AstarParams) ShortestPathResult
func (*Graph) FilterEdgesWithMaps ¶
func (*Graph) Follow ¶
func (graph *Graph) Follow(params FollowParams) []EdgePos
Find locations after traveling along the graph from pos for distance.
func (*Graph) GetRoadSegmentGraph ¶
func (*Graph) GetRoadSegments ¶
func (graph *Graph) GetRoadSegments() []RoadSegment
Get road segments, i.e., sequences of edges between junctions. Junctions are vertices where the number of incident edges != 2. This function only works for bidirectional graphs.
func (*Graph) GetSubgraphInRect ¶
func (*Graph) GridIndex ¶
func (graph *Graph) GridIndex(gridSize float64) GraphGridIndex
func (*Graph) LonLatToMeters ¶
func (*Graph) MakeBidirectional ¶
func (graph *Graph) MakeBidirectional()
func (*Graph) MetersToLonLat ¶
func (*Graph) ShortestDistancesFromSource ¶
returns shortest distances from the given source node to all vertices in the graph
func (*Graph) ShortestPath ¶
func (graph *Graph) ShortestPath(src *Node, params ShortestPathParams) ShortestPathResult
type GraphGridIndex ¶
type GraphGridIndex struct {
// contains filtered or unexported fields
}
func (GraphGridIndex) Search ¶
func (idx GraphGridIndex) Search(rect Rectangle) []*Edge
type GridIndex ¶
type GridIndex struct {
// contains filtered or unexported fields
}
func NewGridIndex ¶
type Line ¶
func (Line) ProjectPoint ¶
type Node ¶
func (*Node) RemoveEdge ¶
type OSMOptions ¶
type OSMOptions struct { Verbose bool EdgeWidths []map[int]float64 NoParking bool NoTunnels bool LayerEdges []map[int]bool EdgeTags []map[int]map[string]string NodeTags []map[int]map[string]string OneWay bool OnlyMotorways bool MotorwayEdges []map[int]bool TunnelEdges []map[int]bool Bytes []byte CustomBlacklist []string CustomWhitelist []string IncludeRailway bool }
type Observation ¶
func (*Observation) GetMetadata ¶
func (obs *Observation) GetMetadata(k string) interface{}
func (*Observation) SetMetadata ¶
func (obs *Observation) SetMetadata(k string, val interface{})
type Point ¶
func (Point) Cross ¶
computes the z-coordinate of the cross product, assuming that both points are on the z=0 plane
func (Point) LonLatToMeters ¶
func (Point) MetersToLonLat ¶
Converts from meters back to longitude/latitude origin should be the same point passed to LonLatToMeters (origin should be longitude/latitude)
func (Point) MulPairwise ¶
func (Point) RectangleTol ¶
func (Point) SignedAngle ¶
type Polygon ¶
type Polygon []Point
func (Polygon) Contains ¶
Ray casting algorithm (https://stackoverflow.com/questions/217578/how-can-i-determine-whether-a-2d-point-is-within-a-polygon). We count the number of polygon segments that a ray from outside the polygon to p intersects. even -> p is outside, odd -> p is inside
func (Polygon) SegmentIntersections ¶
type Rectangle ¶
func (Rectangle) ContainsRect ¶
func (Rectangle) ExtendRect ¶
func (Rectangle) Intersection ¶
func (Rectangle) Intersects ¶
type RoadSegment ¶
func NewRoadSegment ¶
func NewRoadSegment(edges []*Edge) (RoadSegment, error)
func (RoadSegment) Bounds ¶
func (rs RoadSegment) Bounds() Rectangle
func (RoadSegment) ClosestPos ¶
func (rs RoadSegment) ClosestPos(p Point) EdgePos
func (RoadSegment) DistanceOfEdge ¶
func (rs RoadSegment) DistanceOfEdge(edge *Edge) float64
func (RoadSegment) DistanceToEdge ¶
func (rs RoadSegment) DistanceToEdge(t float64) *Edge
func (RoadSegment) DistanceToIndex ¶
func (rs RoadSegment) DistanceToIndex(t float64) int
func (RoadSegment) Dst ¶
func (rs RoadSegment) Dst() *Node
func (RoadSegment) Length ¶
func (rs RoadSegment) Length() float64
func (RoadSegment) PosAtFactor ¶
func (rs RoadSegment) PosAtFactor(t float64) EdgePos
func (RoadSegment) Src ¶
func (rs RoadSegment) Src() *Node
type SVGOptions ¶
type Segment ¶
func (Segment) DistanceToSegment ¶
2D implementation of "On fast computation of distance between line segments" (V. Lumelsky)
func (Segment) Intersection ¶
func (Segment) PointAtFactor ¶
func (Segment) ProjectPoint ¶
func (Segment) ProjectWithWidth ¶
type ShortestPathParams ¶
type ShortestPathParams struct { // maximum distance to travel from src MaxDistance float64 // terminate search once we reach any of these nodes StopNodes []*Node // override edge length EdgeLengths map[int]float64 }
func (ShortestPathParams) IsStopNode ¶
func (params ShortestPathParams) IsStopNode(node *Node) bool
type ShortestPathResult ¶
type ShortestPathResult struct { Distances map[int]float64 Remaining map[int]bool Backpointers map[int]int // contains filtered or unexported fields }
func (ShortestPathResult) GetFullPathTo ¶
func (result ShortestPathResult) GetFullPathTo(node *Node) []*Node
func (ShortestPathResult) GetPathTo ¶
func (result ShortestPathResult) GetPathTo(node *Node) []*Node
type Trace ¶
type Trace struct { Name string Observations []*Observation }
func (*Trace) LastObservation ¶
func (trace *Trace) LastObservation() *Observation
func (*Trace) LonLatToMeters ¶
type Traces ¶
type Traces []*Trace
func LoadCMTTraces ¶
func LoadCMTTraces(tracePath string, rect *Rectangle, options CMTOptions) (Traces, error)
func LoadCartelTraces ¶
func LoadChicagoTraces ¶
func LoadTraces ¶
func (Traces) LonLatToMeters ¶
Convert coordinate system from longitude/latitude to Cartesian meters. This assumes that the GPS sequences cover a small region so that curvature can be ignored.
type Viterbi2Options ¶
type Viterbi2Options struct { Granularity float64 Sigma float64 StartTolerance float64 Threads int // only compute edgeHits, do not store the map-matched data HitsOnly bool // a map from edge IDs to weight of the ID. If nil, the transition probabilities // are weighted based on the angle difference between the source and destination edges. EdgeWeights map[int]float64 // use constant 0.5 weight if not at junction, and 0.05 if at junction // and also don't allow u-turn NewMode bool Output map[int][]EdgePos }
func (Viterbi2Options) GetGranularity ¶
func (opts Viterbi2Options) GetGranularity() float64
func (Viterbi2Options) GetSigma ¶
func (opts Viterbi2Options) GetSigma() float64
func (Viterbi2Options) GetStartTolerance ¶
func (opts Viterbi2Options) GetStartTolerance() float64
func (Viterbi2Options) GetThreads ¶
func (opts Viterbi2Options) GetThreads() int
type WeightedBoundable ¶
func (WeightedBoundable) Bounds ¶
func (wb WeightedBoundable) Bounds() Rectangle
type WidthBoundable ¶
func (WidthBoundable) Bounds ¶
func (b WidthBoundable) Bounds() Rectangle
type WrappingBoundable ¶
type WrappingBoundable interface {
Unwrap() Boundable
}