routes

package
v0.0.0-...-9f1768d Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2019 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const AlgoliaPlacesReverseGeocodingURL = "https://places-dsn.algolia.net/1/places/reverse"

AlgoliaPlacesReverseGeocodingURL is the url where we can do our reverse geocoding NOTE API keys ???

View Source
const AlgoliaPlacesURL = "https://places-dsn.algolia.net/1/places/query"

AlgoliaPlacesURL is the url where we can post our query TODO we should implement the 2 others fall back urls

Variables

This section is empty.

Functions

func GetDocs

func GetDocs(c echo.Context) error

GetDocs returns the docs on / and a 200 Code we cant remove it: it is important otherwise services (eq cloudfare) will health check on / and will think the server died

func GetSearchLocation

func GetSearchLocation(c echo.Context) error

GetSearchLocation returns a list of Results from algolia & google

func GetStopDetails

func GetStopDetails(c echo.Context) error

GetStopDetails returns stops between two stops

func GetTrip

func GetTrip(c echo.Context) error

GetTrip returns possible itineraries between two points

func ReverseGeocoding

func ReverseGeocoding(c echo.Context) error

ReverseGeocoding returns the information about a place at lat lng position

Types

type AlgoliaPlacesSuggestion

type AlgoliaPlacesSuggestion struct {
	Hits []algoliaPlacesHit `json:"hits"`
}

AlgoliaPlacesSuggestion describes the structure returned by the Algolia Places API

type GTFSPlan

type GTFSPlan struct {
	// The time and date of travel
	Date int `json:"date"`

	// The origin
	From Place `json:"from"`

	// The destination
	To Place `json:"to"`

	// A list of possible itineraries
	Itineraries []Itinerary `json:"itineraries"`
}

GTFSPlan consists of multiples itineraries

type GTFSResult

type GTFSResult struct {
	Plan GTFSPlan `json:"plan"`
}

GTFSResult has the plan which interest us but also additional parameters such as:

  • requestParameters
  • debugOutput
  • elevationMetadata

but we ignore them for the moment

type Itinerary

type Itinerary struct {
	// Time that the trip departs
	StartTime int `json:"startTime"`
	// Time that the trip arrives
	EndTime int `json:"endTime"`

	// Duration of the trip on this itinerary, in seconds
	Duration int `json:"duration"`
	// How much time is spent walking, in seconds
	WalkTime int `json:"walkTime"`
	// How much time is spent on transit, in seconds
	TransitTime int `json:"transitTime"`
	// How much time is spent waiting for transit to arrive, in seconds
	WaitingTime int `json:"waitingTime"`

	// How far the user has to walk, in meters
	WalkDistance float64 `json:"walkDistance"`
	// The number of transfers this trip has.
	Transfers int `json:"transfers"`

	// A list of Legs. Each Leg is either a walking (cycling, car)
	// portion of the trip, or a transit trip on a particular vehicle.
	// So a trip where the use walks to the Q train, transfers to the 6,
	// then walks to their destination, has four legs.
	Legs []Leg `json:"legs"`
}

An Itinerary is one complete way of getting from the start location to the end location.

type Leg

type Leg struct {
	// timestamps of the start & end time
	StartTime int `json:"startTime"`
	EndTime   int `json:"endTime"`
	// duration in seconds
	Duration float64 `json:"duration"`
	// distance in meters
	Distance float64 `json:"distance"`

	// For transit legs, the type of the route.
	//  - Non transit -1
	//  - When 0-7:
	//    - 0 Tram
	//    - 1 Subway
	//    - 2 Train
	//    - 3 Bus
	//    - 4 Ferry
	//    - 5 Cable Car
	//    - 6 Gondola
	//    - 7 Funicular
	//  - When equal or highter than 100:
	//    it is coded using the Hierarchical Vehicle Type (HVT)
	//    codes from the European TPEG standard
	RouteType int `json:"routeType"`

	// For transit leg:
	//  - the route's (background) color (if one exists)
	// For non-transit legs
	//  - null.
	RouteColor string `json:"routeColor"`

	// RouteID self explanatory
	RouteID string `json:"routeID"`

	// For transit leg:
	//  - the route's text color (if one exists)
	// For non-transit legs
	//  - null.
	RouteTextColor string `json:"routeTextColor"`

	// The mode used when traversing this leg.
	// ex: BUS, WALK
	Mode string `json:"mode"`

	// For transit legs:
	//  - the route of the bus or train being used
	// For non-transit legs
	//  - the name of the street being traversed.
	// ex: 4, eq Line 4
	Route string `json:"route"`

	// For transit legs:
	//  - the headsign of the bus or train being used
	// For non-transit legs: null.
	//
	// ex: Foch Cathedrale ~ Direction
	HeadSign string `json:"headSign"`

	From Place `json:"from"`
	To   Place `json:"to"`

	// The leg's geometry
	LegGeometry `json:"legGeometry"`

	Stops []Stop `json:"stops"`
}

Leg is a struct defining a main step of the whole trip. Example: - Walk till the bus (1st leg) - Take the bus (2nd leg) - Take a second bus (3rd leg)

type LegGeometry

type LegGeometry struct {
	// A list of coordinates encoded as a string
	Points string `json:"points"`
	Length int    `json:"length"`
}

LegGeometry : A leg's geometry

type Pattern

type Pattern struct {
	ID   string `json:"id"`
	Desc string `json:"desc"`

	// Stops are ordered !
	Stops []Stop `json:"stops"`
}

type Place

type Place struct {
	// For transit stops, the name of the stop.
	// For points of interest, the name of the POI
	Name      string  `json:"name"`
	StopID    string  `json:"stopID"`
	Longitude float64 `json:"lon"`
	Latitude  float64 `json:"lat"`

	// The time the rider will depart the place
	Departure int `json:"departure"`
	// The time the rider will arrive at the place
	Arrival int `json:"arrival"`

	// For transit trips, the stop index
	// (numbered from zero from the start of the trip
	StopIndex int `json:"stopIndex"`

	// The "code" of the stop. Depending on the transit
	// agency, this is often something that users care about
	StopCode string `json:"stopCode"`

	// For transit trips, the sequence number of the stop.
	// Per GTFS, these numbers are increasing
	StopSequence int `json:"stopSequence"`
}

A Place is where a journey starts or ends or a transit stop along the way.

type Result

type Result struct {
	// either FREE or STOP
	Type string `json:"type"`
	Name string `json:"name"`

	Latitude  float64 `json:"lat"`
	Longitude float64 `json:"lng"`
}

Result is one object contained in the array returned by the API

type Stop

type Stop struct {
	ID        string  `json:"id"`
	Name      string  `json:"name"`
	Longitude float64 `json:"lon"`
	Latitude  float64 `json:"lat"`
}

Jump to

Keyboard shortcuts

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