lib

package
v0.0.0-...-a99cf2a Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2020 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const CreateVehiclesSQL = `` /* 418-byte string literal not displayed */

Variables

This section is empty.

Functions

This section is empty.

Types

type BusErr

type BusErr struct {
	Rt  string `json:"rt"`
	Msg string `json:"msg"`
}

type BustimeData

type BustimeData struct {
	Vehicles []Vehicle `json:"vehicle"`
	Errors   []BusErr  `json:"error"`
}

type BustimeResponse

type BustimeResponse struct {
	Data BustimeData `json:"bustime-response"`
}

type Scraper

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

func NewScraper

func NewScraper(config *bustime.Config) *Scraper

func (*Scraper) Close

func (v *Scraper) Close()

func (*Scraper) Start

func (s *Scraper) Start()

type Storage

type Storage interface {
	Store(*Vehicle) error
	Close()
}

func NewStorage

func NewStorage() (Storage, error)

type Vehicle

type Vehicle struct {
	Vid        string           `json:"vid"`
	Tmstmp     VehicleTimestamp `json:"tmstmp"`
	SrvTimstmp VehicleTimestamp `json:"srvtmstmp"`
	Lat        float64          `json:"lat,string"`
	Lon        float64          `json:"lon,string"`
	Hdg        string           `json:"hdg"`
	Rt         string           `json:"rt"`
	Tatripid   string           `json:"tatripid"`
	Tablockid  string           `json:"tablockid"`
	Zone       string           `json:"zone"`
	Oid        string           `json:"oid"`
	Rid        string           `json:"rid"`
	Des        string           `json:"des"`
	Pdist      int              `json:"pdist"`
	Pid        int              `json:"pid"`
	Spd        int              `json:"spd"`
	Blk        int              `json:"blk"`
	Tripid     int              `json:"tripid"`
	Dly        bool             `json:"dly"`
	Or         bool             `json:"or"`
}

Vehicle represents an individual reading of a vehicle and it's location at that point in time Example:

{
  "vid": "155",
  "tmstmp": "20200827 11:51",
  "lat": "29.962149326173048",
  "lon": "-90.05214051918121",
  "hdg": "357",
  "pid": 275,
  "rt": "5",
  "des": "Saratoga at Canal",
  "pdist": 10122,
  "dly": false,
  "spd": 20,
  "tatripid": "3130339",
  "tablockid": "15",
  "zone": "",
  "srvtmstmp": "20200827 11:51",
  "oid": "445",
  "or": true,
  "rid": "501",
  "blk": 2102,
  "tripid": 982856020
}

func (*Vehicle) ToSql

func (v *Vehicle) ToSql() ([]string, []string)

type VehicleTimestamp

type VehicleTimestamp struct {
	time.Time
}

func (*VehicleTimestamp) UnmarshalJSON

func (t *VehicleTimestamp) UnmarshalJSON(data []byte) error

UnmarshalJSON We need a special unmarshal method for this string timetstamp. it's of the form "YYYYMMDD hh:mm"

Jump to

Keyboard shortcuts

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