Giter VIP home page Giter VIP logo

tryn-api's People

Contributors

dependabot[bot] avatar eddyionescu avatar enginaryum avatar lucyktan avatar youngj avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

tryn-api's Issues

Migrate to using S3 bucket

This has been long overdue, but given that we're only showing all the vehicles at a given time, having all this data in a Cassandra database is pretty expensive ($200/month) with little benefit.

Using S3 is just as good for supporting the web-app, and as for doing geo-query analysis, Cassandra would've required setting up ElasticSearch or Spark on it, so we might as well make a new database from scratch optimized for geo-analysis. As for trip analysis, reading trips from S3 should be good enough (can be directly used in Jupyter - or use Spark notebook), with aggregated data eventually being stored in a more flexible DB like Postgres.

This ticket tracks modifying the API to use S3 such that it remains unchanged (ie. existing queries will continue to work).

add support for GRT

  • also tracks GTFS-RT for GRT in Orion
  • the map now works for other cities, so adding Waterloo and others is easy now

make geojsons an API endpoint

  • currently the web-app uses geojsons to draw and list routes directly. Instead, we want to rely on the API. This ticket tracks passing in the geojsons for each agency.

Route and Stop Info is duplicated for each State

Right now, a query looks like this:

{
  trynState(agency: "muni", startTime: "1515272617534", endTime: "1515273457194") {
    agency
    startTime
    states {
      time
      routes {
        name
        stops {
          sid
          name
          lat
          lon
        }
        vehicles {
          vid
          lat
          lon
          heading
        }
      }
    }
  }
}

The route name along with all the stop info will be duplicated. The reason stops can't be moved upwards is because a stop belongs to a route. At the same time, the route name is also duplicated, as would any future metadata.

The proposed schema layout is as such:

{
  trynState(agency: "muni", startTime: "1515272617534", endTime: "1515273457194") {
    agency
    startTime
    routes {
      rid
      stops {
        sid
        name
        lat
        lon
      }
      routeStates {
        vtime
        vehicles {
          vid
          lat
          lon
          heading
        }
      }
    }
  }
}

add trips endpoint

  • start by supporting only the day of the muni trips file.
  • it loads the file from S3, then returns the trips for the provided route (a route must be provided) for the hardcoded date.
  • frontend recieves the trip. It determines the distances locally using turf.js

Get stops from route-id for all agencies we support

We currently only return stops for Muni, but not for the other agencies, including the TTC (easy to add as it uses Nextbus), Marin (have to make separate API call), and GRT (on the roadmap).

However, a better solution to this seems to have a separate API called tryn-stops that does this for us by either making an API call, or by looking it up in the GTFS file (it should have all the stops by route in memory).

This would involve:

  • having a GraphQL/Rest API
  • reading GTFS files and storing the data we need in memory (https://github.com/remix/partridge)
  • making API calls to Nextbus or fetching remote GTFS files periodically or on start.
  • It can be in Node, Python, Go, Scala, or any other language you're comfortable with.

make gtfs link an api endpoint

goal: request an agency's gtfs from a certain day using the API
Why? Needed for accurate stops, routes, frequency, and schedule adherence

Remove duplicate muni metro vehicles

2-car Muni trains (on all lines except J) have both their cars show up in Nextbus. This can be observed on the web-app map.

For the MVP, this causes the median/average observed headways between cars to be much lower than what they really were.

Issues:

  1. routes can have a mix of one and two car trains (and in a few years, three).
  2. Muni Metro trains can bunch fairly closely, often staying that way for the entire trip.
  3. each car sends its location separately, meaning that coupled cars could sometimes appear as being a block apart.

Notes:

  1. Muni trains don't get decoupled when in-service, meaning that if two cars are coupled, then they stay coupled for the entire time they're in-service (unlike the previous Boeing ones did back in the day, where K/L/M trains and N/J trains were often coupled together at West Portal and Duboce as to run more efficiently in the subway; they lost that ability with the current Breda LRVs, and don't have plans for doing this with the new Siemens ones).
  2. None of the other agencies available via the API have this issue, so it'll be Muni-specific.

Possible Approaches:

  1. Resolve this in the MVP right before returning the state.
  2. Correct and clean the vehicles in the S3 store. It would require a better way of storing them (like hourly chunks per agency+route or 15-minute chunks per agency), which would require tryn-api and opentransit-map changes.
  3. Clean the vehicles as they are returned by the API. Not recommended since the MVP requests vehicles in 12-minute chunks, which is an issue since two trains could be closely behind one another for the entirety of a 12-minute span.

Add connectivity viz endpoint

  1. Add config file that points to relevant files, stored in S3 (manually updated)
  2. Return those based on the connectivity fields in the graphql query

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.