corvallisbus

package module
v0.0.0-...-dfe4e56 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2016 License: GPL-2.0 Imports: 23 Imported by: 0

README

Corvallis Bus API

An API service for the Corvallis Transit System

GoDoc

The basic documentation can be found on GoDoc

Prerequisites

  • Go (the programming language)
  • Google App Engine SDK for Go
  • Add these to your path (optional)

Getting started

(Install prerequisites)
git clone https://github.com/OSU-App-Club/corvallis-bus-server
cd corvallis-bus-server
goapp serve

This will start a server at http://localhost:8080.

Usage

This API service is an HTTP GET based set of web services

##Paths

/arrivals
  • Default: returns nothing

  • Params:

    1. stops -- comma delimited list of stop ids (required & limited to 20 ids); Default: ""
    2. date -- date in RFC822Z format; Default: "currentDate"
  • Response:

    1. stops: map stopNumber to array of arrival times in RFC822Z
    • Schedule: time bus is scheduled to arrive

    • Expected: time bus will arrive based on real-time data (often equal to scheduled)

    • Example

    URL: http://www.corvallis-bus.appspot.com/arrivals?stops=13713

    {
      "13713":[
        {
          "Expected":"15 Apr 14 16:57 -0700",
          "Route":"4",
          "Scheduled":"15 Apr 14 16:57 -0700"
        },
        {
          "Expected":"15 Apr 14 17:32 -0700",
          "Route":"CVA",
          "Scheduled":"15 Apr 14 17:32 -0700"
        },
        {
          "Expected":"15 Apr 14 18:57 -0700",
          "Route":"4",
          "Scheduled":"15 Apr 14 18:57 -0700"
        }
      ]
    }
  ```

### /routes

* Default:  returns all routes without stops
* Params:
  1. names -- comma delimited list of route numbers (optional); Default: ""
  2. stops -- include stop information ["true" or "false"]; Default: "false"
  3. onlyNames -- only include route names ["true" or "false"]; Default: "false"

* Example

URL: http://www.corvallis-bus.appspot.com/routes


```json
  {
    "routes":[
      {
        "Name":"1",
        "AdditionalName":"OSU, Witham Hill, Hewlett Packard, and Timberhill Shopping Center",
        "Description":"ROUTE 1 provides hourly service to OSU, Witham Hill, Hewlett Packard \u0026 Timberhill Shopping Center  (Equipped with a wheelchair lift.  A bicycle rack is available on a first-come, first-served basis.)",
        "UR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@Jr@N~@PlAFx@DlB?fACr@En@KnAM|AGnBC~@CpA?l@@tB?~QBp@FdB?tA?pAAvA?pB@bCBxAHtATbB~Ag@DAn@Mp@E`AFlBn@lCxBnAt@x@~@d@fAJ`@NvAEvGHnCw@?sEAQ@w@Hu@Lc@FOBSDEtBQrBObAo@jC]dASbAM|@I`A?b@Ap@?v@?pGAhCC|C_A?k@Lk@Zi@f@]v@yAvEg@zAwA~D[r@w@jAs@r@u@h@}@^^dCh@|DTdBL`ARzBBd@NnCHzBBtB@vAj@CXHdA\\`@Nf@T`AZ~@HlAC`B??~H?|HAfBAl@C`AKvAIr@e@xCOz@g@bDQ|ACn@A|@@hA`AIr@O`@_@^c@Ta@NWt@eBZm@r@yALSTMVGX@h@LrAp@^RTTh@f@Z^^b@TXj@|@p@r@VRZPZL\\Fr@JbAAz@Ev@St@c@p@k@Z[p@q@zFyF\\]hCkC~AaBrBsBf@i@`BcBvAqApA{Av@iA`BcCj@}@jCmEFMt@mAbBoCzDkGNStAuBzFAz@AdGAzDAR?dACfBA|D?`EA?_BAyBFwC?q@GiD?_@AcE?oEAaE?U?iE?m@Xg@`AoAf@q@n@w@nCmDbA_BdBuB`@k@N]n@oEn@aFFk@x@}Fz@_Gn@cEn@{Dl@{Dn@_En@wDTwAVcBn@mEXgBZqBt@sEv@sEn@gE@EBMN{@j@ITyA",
        "Color":"00ADEE",
        "Direction":"Clockwise"
      }
    ]
  }
/stops
  • Default: returns all stops

  • Params:

    1. ids: comma delimited list of stop ids (optional); Default: ""
    2. lat: latitude for search; Default: ""
    3. lng: longitude for search; Default: ""
    4. radius: radius in meters to make search; Default: 500
    5. limit: limit the amount of stops returned; Default: none
  • Response:

    • stops: array of stops objects
      • Sort order different based on paramaters 1. location: sorted by distance 2. ids: sorted by ids
  • Example

URL: http://www.corvallis-bus.appspot.com/stops?lat=44.57181000&lng=-123.2910000&radius=200&limit=1

    {
      "stops":[
        {
          "Name":"NW Harrison Blvd \u0026 NW 36th St",
          "Road":"NW Harrison Blvd",
          "Bearing":181.3342,
          "AdherancePoint":false,
          "Lat":44.57181054,
          "Long":-123.2914071,
          "ID":12483,
          "Distance":32.24711617308209
        }
      ]
    }

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Arrivals

func Arrivals(c appengine.Context, w http.ResponseWriter, r *http.Request)

/arrivals (endpoint to access arrival information)

Default: nothing returned Paramaters:

stops:comma delimited list of stop numbers (required); Default: ""
date: date in RFC822Z format; Default: "currentDate"

Response:

stops: map stopNumber to array of arrival times in RFC822Z

func CreateDatabase

func CreateDatabase(w http.ResponseWriter, r *http.Request)

Sets up datastore to fit current structure -- removes all existing

func Routes

/routes (endpoint to access route information)

Default: returns all routes without detailed stops Paramaters:

names: comma delimited list of route names (optional); Default: ""
stops: include stop information ["true" or "false"]; Default: "false"
onlyNames: only include route names ["true" or "false"]; Default: "false"

Response:

routes: array of route objects

func Stops

/stops (endpoint to access stop information)

Default: returns all stops Paramaters:

ids: comma delimited list of stop ids (optional); Default: ""
lat: latitude for search; Default: ""
lng: longitude for search; Default: ""
radius: radius in meters to make search; Default: 500
limit: limit the amount of stops returned; Default: none

Response:

stops: array of stops objects
  -- Sort order different based on paramaters
    -- location: sorted by distance
    -- ids: sorted by ids

Types

type Arrival

type Arrival struct {
	// Key will be an autogenerated incomplete Key (int)
	// Parent will be Stop associated with this time
	// Run query to find
	Route *datastore.Key

	Scheduled time.Duration // Stored as offset from midnight in US/Pacific

	IsScheduled bool // true for values with known schedule times -- others are estimates

	// What days of the week this arrival is valid on
	Monday    bool `json:"-"`
	Tuesday   bool `json:"-"`
	Wednesday bool `json:"-"`
	Thursday  bool `json:"-"`
	Friday    bool `json:"-"`
	Saturday  bool `json:"-"`
	Sunday    bool `json:"-"`
	// contains filtered or unexported fields
}

type ByDistance

type ByDistance struct{ StopSlice }

func (ByDistance) Less

func (s ByDistance) Less(i, j int) bool

type ByID

type ByID []*SchedInfo

func (ByID) Len

func (a ByID) Len() int

func (ByID) Less

func (a ByID) Less(i, j int) bool

func (ByID) Swap

func (a ByID) Swap(i, j int)

type ETA

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

type Route

type Route struct {
	// Key is autogenerated (int64) -- No need to call directly by key
	Name           string `json:",omitempty"` // Treated the same as route number for most routes
	AdditionalName string `json:",omitempty"` // More user-friendly (ie BB_N -> Beaver Bus- North)

	Description string `json:",omitempty"`
	URL         string `json:",omitempty"`

	// https://developers.google.com/maps/documentation/utilities/polylinealgorithm
	Polyline string `datastore:",noindex" json:",omitempty"` // Needed due to length
	Color    string `json:",omitempty"`                      // Route color stored as hexadecimal

	Direction string           `json:",omitempty"`
	Stops     []*datastore.Key `json:"-"`                        // organized by order travelled
	Path      []*Stop          `datastore:"-" json:",omitempty"` // Calculated at runtime

	Start time.Time `json:"-"` // Begining of validity of arrivals
	End   time.Time `json:"-"` // End of validity of arrivals
}

type SchedInfo

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

Temp structure for schedule input

type Stop

type Stop struct {
	// Key equal to platform number (int) -- same value posted at bus signs
	ID int64 `datastore:"-"`

	Name string

	Road           string  // Road Name
	Bearing        float64 // Bearing to road
	AdherancePoint bool    // Stops where bus will stop until scheduled departure time

	Lat  float64
	Long float64

	// Calculated Information
	Distance float64 `datastore:"-" json:",omitempty"`
}

type StopSlice

type StopSlice []*Stop

Implement sorting

func (StopSlice) Len

func (s StopSlice) Len() int

func (StopSlice) Swap

func (s StopSlice) Swap(i, j int)

type TimeInfo

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

Used to represent time information from caledars.txt

Jump to

Keyboard shortcuts

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