routingkit

package
v0.1.18 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2023 License: BSD-2-Clause Imports: 17 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Keep bool = keep.Keep

Keep C++ dependencies by referencing a file from their directory

View Source
var MaxDistance uint32

MaxDistance represents the maximum possible route distance.

Functions

func BikeSpeedMapper added in v0.1.5

func BikeSpeedMapper(_ int, tags map[string]string) int

BikeSpeedMapper sets the speed for bikes according to the map tag

func BikeTagMapFilter added in v0.1.5

func BikeTagMapFilter(_ int, tags map[string]string) bool

BikeTagMapFilter filters the map for map tags usable by bikes

func CarSpeedMapper added in v0.1.5

func CarSpeedMapper(_ int, tags map[string]string) int

CarSpeedMapper sets the speed for cars according to allowed speed, map tag and surface

func CarTagMapFilter added in v0.1.5

func CarTagMapFilter(id int, tags map[string]string) bool

CarTagMapFilter filters the map for map tags usable by a car

func ParseOSMSpeedToKM added in v0.1.2

func ParseOSMSpeedToKM(str string) (float64, bool)

func PedestrianSpeedMapper added in v0.1.5

func PedestrianSpeedMapper(_ int, tags map[string]string) int

PedestrianSpeedMapper sets to 5km/h and reduces the speed according to the surface of the underlying way

func PedestrianTagMapFilter added in v0.1.5

func PedestrianTagMapFilter(id int, tags map[string]string) bool

PedestrianTagMapFilter filters the map for map tags usable by pedestrians

func ShrinkToHullRect added in v0.1.15

func ShrinkToHullRect(
	pbfFile io.ReadSeeker,
	tagMapFilter TagMapFilter,
	points [][]float32,
	margin float64,
	pbfOutput io.Writer,
) ([][]float64, error)

ShrinkToHullRect writes a new .osm.pbf file to the given pbfOutput writer containing only the ways and nodes that are within the bounding box of the convex hull of the given points expanded by the given margin in meters. It will also remove any ways that do not pass the given tagMapFilter. The returned [][]float64 holds the lower left and upper right lon/lat coordinates describing the expanded bounding box.

Types

type DistanceClient

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

func NewDistanceClient

func NewDistanceClient(mapFile string, profile Profile) (DistanceClient, error)

NewDistanceClient initializes a DistanceClient using the provided .osm.pbf file and .ch file. The .ch file will be created if it does not already exist. It is the caller's responsibility to call Delete on the client when it is no longer needed.

func (*DistanceClient) Delete

func (c *DistanceClient) Delete()

Delete deletes the client, releasing memory allocated for C++ routing data structures

func (DistanceClient) Distance

func (c DistanceClient) Distance(from []float32, to []float32) uint32

Distance returns the length of the shortest possible route between the points

func (DistanceClient) Distances

func (c DistanceClient) Distances(source []float32, targets [][]float32) []uint32

Distances returns a slice containing the minimum distances from the source to the points in targets.

func (DistanceClient) Matrix

func (c DistanceClient) Matrix(sources [][]float32, targets [][]float32) [][]uint32

Matrix creates a matrix representing the minimum distances from the points in sources to the points in targets.

func (DistanceClient) Nearest

func (c DistanceClient) Nearest(point []float32) ([]float32, bool)

Nearest returns the nearest point in the road network within the radius configured on the Client. The second argument will be false if no point could be found.

func (DistanceClient) Route

func (c DistanceClient) Route(from []float32, to []float32) (uint32, [][]float32)

Route finds the fastest route between the two points, returning the total route distance and the waypoints describing the route.

func (*DistanceClient) SetSnapRadius

func (c *DistanceClient) SetSnapRadius(n float32)

SetSnapRadius updates Client so that all queries will snap points to the nearest street network point within the given radius in meters.

type Profile added in v0.1.2

type Profile struct {
	Name             string
	TransportMode    TransportMode
	PreventLeftTurns bool
	PreventUTurns    bool
	Filter           TagMapFilter
	SpeedMapper      SpeedMapper
}

func Bike added in v0.1.2

func Bike() Profile

func Car added in v0.1.2

func Car() Profile

func NewProfile added in v0.1.2

func NewProfile(
	name string,
	transportMode TransportMode,
	preventLeftTurns bool,
	preventUTurns bool,
	filter TagMapFilter,
	speedMapper SpeedMapper,
) Profile

func Pedestrian added in v0.1.2

func Pedestrian() Profile

func Truck added in v0.1.2

func Truck(height, width, length, weight float64, speed int) Profile

type SpeedMapper added in v0.1.2

type SpeedMapper func(wayId int, tagMap map[string]string) int

func MaxSpeedMapper added in v0.1.5

func MaxSpeedMapper(maxSpeed int) SpeedMapper

MaxSpeedMapper caps the allowed speed at the given value

type TagMapFilter added in v0.1.2

type TagMapFilter func(wayId int, tagMap map[string]string) bool

func TruckTagMapFilter added in v0.1.5

func TruckTagMapFilter(truckHeight, truckWidth, truckLength, truckWeight float64) TagMapFilter

TruckTagMapFilter filters the map for map tags usable by trucks

type TravelTimeClient

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

func NewTravelTimeClient

func NewTravelTimeClient(mapFile string, profile Profile) (TravelTimeClient, error)

NewTravelTimeClient initializes a TravelTimeClient using the provided .osm.pbf file and .ch file. The .ch file will be created if it does not already exist. It is the caller's responsibility to call Delete on the client when it is no longer needed.

func (TravelTimeClient) Matrix

func (c TravelTimeClient) Matrix(sources [][]float32, targets [][]float32) [][]uint32

Matrix creates a matrix representing the minimum travel times (by car) from the points in sources to the points in targets.

func (TravelTimeClient) Nearest

func (c TravelTimeClient) Nearest(point []float32) ([]float32, bool)

Nearest returns the nearest point in the road network within the radius configured on the Client. The second argument will be false if no point could be found.

func (TravelTimeClient) Route

func (c TravelTimeClient) Route(from []float32, to []float32) (uint32, [][]float32)

Route finds the fastest route between the two points, returning the total route travel time by car and the waypoints describing the route.

func (*TravelTimeClient) SetSnapRadius

func (c *TravelTimeClient) SetSnapRadius(n float32)

SetSnapRadius updates Client so that all queries will snap points to the nearest street network point within the given radius in meters.

func (TravelTimeClient) TravelTime

func (c TravelTimeClient) TravelTime(from []float32, to []float32) uint32

TravelTime returns the travel time by car for the shortest possible route between the points.

func (TravelTimeClient) TravelTimes

func (c TravelTimeClient) TravelTimes(source []float32, targets [][]float32) []uint32

TravelTimes returns a slice containing the minimum car travel times from the source to the points in targets.

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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