datacollection

package
v0.0.0-...-6387df7 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	// EdgeDataFileDateFormat time format for the date to save to the EdgeData json files
	EdgeDataFileDateFormat string = "2006-01-02"
	// MaxDuration is a constant that holds the max a duration should be for us (1000 hours)
	MaxDuration time.Duration = time.Hour * 1000
)

Variables

View Source
var EdgeDataTimeLocation, _ = time.LoadLocation("America/New_York")

EdgeDataTimeLocation location that dates and times should be in

Functions

func ExportLocationData

func ExportLocationData(stops []*Stop) error

ExportLocationData exorts the location data from the mbta API

func ExportSpecialEdgesLocationData

func ExportSpecialEdgesLocationData(specialEdges SpecialEdges) error

ExportSpecialEdgesLocationData exorts the location data from the mbta API for the middle stops of special edges

func GetDateFromEdgeDataFilename

func GetDateFromEdgeDataFilename(filename string) (time.Time, error)

GetDateFromEdgeDataFilename return the date from the filename of a EdgeData file

func GetEdgeKey

func GetEdgeKey(stopAName, stopBName string) string

GetEdgeKey returns the map key for an edge between two stops

func GetEdgeKeyWalking

func GetEdgeKeyWalking(stopAName, stopBName string) string

GetEdgeKeyWalking returns the map key for an edge between two stops with walking

func GetStopCoordinatesForGoogleAPI

func GetStopCoordinatesForGoogleAPI()

GetStopCoordinatesForGoogleAPI calculates and saves mbta api location data

func GetTransitDataFilename

func GetTransitDataFilename(startTime time.Time, interval time.Duration) string

GetTransitDataFilename returns the filename that represents this data

func GetTransitDataWithGoogleAPI

func GetTransitDataWithGoogleAPI(startTime, endTime time.Time, interval time.Duration, apiKeyFile string)

GetTransitDataWithGoogleAPI generates a json file of distance data of edges

func ParseDateToEST

func ParseDateToEST(date string) (time.Time, error)

ParseDateToEST takes in a string of format EdgeDataTimeLocation and returns a time.Time variable in EST

func ReconstructRoute

func ReconstructRoute(route []Stop, startTime time.Time, apiKeyFile string)

ReconstructRoute will print out all of the directions and times of each step of the route

func WriteEdgeDataToFile

func WriteEdgeDataToFile(edges Edges, startTime time.Time, interval time.Duration) error

WriteEdgeDataToFile writes the edge data to a file

Types

type EdgeTimes

type EdgeTimes map[int64]time.Duration

EdgeTimes stores the time each edge took to traverse (unix time -> duration for that time)

type Edges

type Edges map[string]EdgeTimes

Edges a map of all edges by edge key

func GetTransitDataForAnEdgeWithGoogleAPI

func GetTransitDataForAnEdgeWithGoogleAPI(stopA, stopB *Stop, startTime, endTime time.Time, interval time.Duration, apiKeyFile string) Edges

GetTransitDataForAnEdgeWithGoogleAPI returns edge data for a particular edge stopA->stopB

func ImportEdgeData

func ImportEdgeData(filename string) (Edges, error)

ImportEdgeData gets the edge data from a file

type SpecialEdge

type SpecialEdge struct {
	Stop      *Stop `json:"Stop"`
	NoWalking bool  `json:"no_walking,omitempty"`
}

SpecialEdge holds data about a special edge, including its midstop and if a walking edge is allowed

type SpecialEdgeFiles

type SpecialEdgeFiles string

SpecialEdgeFiles enum for files containing special edges

const (
	// SpecialEdgesFile the file that stores the edges with multiple ways to go
	SpecialEdgesFile SpecialEdgeFiles = "datacollection/special_edges.json"
	// SpecialEdgesFileWithLocationData the file that stores the edges with multiple ways to go and the middle stop locations
	SpecialEdgesFileWithLocationData SpecialEdgeFiles = "datacollection/special_edges_with_location_data.json"
)

type SpecialEdges

type SpecialEdges map[string]SpecialEdge

SpecialEdges holds which edges need a stop in between them (and can also possibly walk between them)

func ReadSpecialEdgesFromFile

func ReadSpecialEdgesFromFile(filename SpecialEdgeFiles) (SpecialEdges, error)

ReadSpecialEdgesFromFile reads in the special edges from a file (probably special_edges.json)

type Stop

type Stop struct {
	Name                   string `json:"name"`
	LongitudeCommaLatitude string `json:"longitude_comma_latitude,omitempty"`
	WalkToNextStop         bool   `json:"walk_to_next_stop,omitempty"`
}

Stop stores the coordinates of a stop and its name

func ImportStopsFromFile

func ImportStopsFromFile(filename StopFiles) ([]*Stop, error)

ImportStopsFromFile imports a list of stop data

func ImportStopsFromFileNonePointer

func ImportStopsFromFileNonePointer(filename StopFiles) ([]Stop, error)

ImportStopsFromFileNonePointer imports a list of stop data

func NewStop

func NewStop(name string, longitude string, latitude string) *Stop

NewStop returns a new stop struct

func (*Stop) SetLongitudeCommaLatitude

func (s *Stop) SetLongitudeCommaLatitude(longitude float64, latitude float64)

SetLongitudeCommaLatitude sets the LongitudeCommaLatitude field given longitude and latitude floats

type StopFiles

type StopFiles string

StopFiles enum of all stop data files

const (
	// Endpoints the file that stores the endpoint names
	Endpoints StopFiles = "datacollection/endpoint_stops.json"
	// StopLocations the files that stores the locations of mbta stops
	StopLocations StopFiles = "datacollection/stop_locations.json"
)

Jump to

Keyboard shortcuts

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