Skip to content

Instantly share code, notes, and snippets.

@kurtraschke
kurtraschke / gist:1390328
Created Nov 24, 2011
WMATA bus API says there are no buses...
View gist:1390328
Kurt-Raschke:~ kurt$ curl http://api.wmata.com/Bus.svc/json/JBusPositions?api_key=redacted
{"BusPositions":[]}
View gist:2016817
{
"Routes": [
{
"Name": "10:00:00 AM - 10A HUNT TOWERS-PENT ",
"RouteID": "10A"
},
{
"Name": "10:00:00 AM - 10A HUNT TOWERS-PENT ",
"RouteID": "10Av1"
},
@kurtraschke
kurtraschke / area.py
Created Dec 17, 2012
Find bounding box and convex hull of agency coverage (as WKT) for a OneBusAway TDS.
View area.py
from mustaine.client import HessianProxy
from shapely.geometry import box
from shapely.ops import cascaded_union
service = HessianProxy("http://172.16.2.32:8080/onebusaway-transit-data-federation-webapp/remoting/transit-data-service")
agencies = service.getAgenciesWithCoverage()
boxes = []
View README.md

This Gist contains a script and supporting files for building a OneBusAway GTFS bundle with data for all agencies in the Baltimore/Washington area that have publicly released their data.

Configuration parameters come from two sheets in a Google Docs document:

https://docs.google.com/spreadsheet/ccc?key=0AvrkbWHnoksNdGdYam4wX214SXpoRmdia0FEalZvUHc&usp=sharing

The dependency on Google Docs could easily be removed by removing that part of download.sh and using a locally-maintained CSV file instead.

View gist:6249229
Recently (as in, over the past few months) the WMATA BusPosition feed has been behaving anomalously.
There are three observed problems:
1. The feed doesn't include the entire fleet - during the weekday rush hour we'd expect to see close to 900 buses, but this morning the feed returned fewer than 250 vehicles.
2. Bus positions return the wrong trip, or are lagging badly. Look at this example:
<BusPosition>
<DateTime>2013-08-16T07:32:01</DateTime>
@kurtraschke
kurtraschke / cap.xjb
Created Nov 11, 2013
JAXB bindings file for CAP schema to produce enums from anonymous types.
View cap.xjb
<?xml version="1.0" encoding="UTF-8"?>
<jaxb:bindings xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
jaxb:version="1.0">
<jaxb:bindings schemaLocation="CAP-v1.2.xsd" node="/xsd:schema">
<jaxb:bindings node="//xsd:element[@name='status']">
<jaxb:bindings node="./xsd:simpleType">
<jaxb:typesafeEnumClass name="StatusType" />
View instance-details.json
{
"currentTime": 1391381290937,
"text": "OK",
"data": {
"instanceDetails": [
{
"contactEmail": "onebusaway@kurt-p7-1539",
"instanceName": "OneBusAway on kurt-p7-1539",
"twitterUrl": "",
"language": "en-US",
@kurtraschke
kurtraschke / README.md
Last active Aug 29, 2015
GTFS-realtime test harness for frequency-based trips
View README.md

GTFS-realtime test harness for frequency-based trips

Introduction

This is a Python-based test harness which can be used to simulate a GTFS-realtime feed with trips on a frequency-based route. Specifically, it simulates arrivals on the AirBART route (obtain BART GTFS here), at the AirBART_OAK stop. For convenience, the script simulates two vehicles, which are perpetually three and seven minutes away, respectively.

Setup

View gist:1160365f3d858d3fa1e4
Sort sort = new Sort(_spatialStrategy.makeDistanceValueSource(shape.getCenter()).getSortField(false)).rewrite(_searcher);
View gist:1231aed1520e976e0765
Tue Jun 30 19:59:55 2015 :$GPZDA,235955.00,30,06,2015,00,00*68
Tue Jun 30 19:59:56 2015 :$GPZDA,235956.00,30,06,2015,00,00*6B
Tue Jun 30 19:59:57 2015 :$GPZDA,235957.00,30,06,2015,00,00*6A
Tue Jun 30 19:59:58 2015 :$GPZDA,235958.00,30,06,2015,00,00*65
Tue Jun 30 19:59:59 2015 :$GPZDA,235959.00,30,06,2015,00,00*64
Tue Jun 30 19:59:59 2015 :$GPZDA,235960.00,30,06,2015,00,00*6E
Tue Jun 30 20:00:00 2015 :$GPZDA,000000.00,01,07,2015,00,00*66
Tue Jun 30 20:00:01 2015 :$GPZDA,000001.00,01,07,2015,00,00*67
Tue Jun 30 20:00:02 2015 :$GPZDA,000002.00,01,07,2015,00,00*64
Tue Jun 30 20:00:03 2015 :$GPZDA,000003.00,01,07,2015,00,00*65