logo
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Login


Options
View
Go to last post Go to first unread
Benjamin  
#1 Posted : Sunday, July 17, 2011 11:07:07 AM(UTC)
Benjamin

Rank: Advanced Member

Groups: Registered
Joined: 7/10/2011(UTC)
Posts: 34

Thanks: 1 times
I’m writing an app that takes a four-digit text-message code (e.g. 7354) as input and looks up the corresponding stop ID (e.g. “IT:1”). I do this by calling stops.getList and then looking through the stops for one that matches the specified code. (Don’t worry, I use a static copy of this list—I don’t ask the server each time!) The problem is that there are some text-message codes that don’t appear in this list. The example I came across is 7411 for the Transit Plaza. (I believe this would correspond to an ID of “PLAZA”, i.e. “list all of the departures from any of the platforms at the Transit Plaza”.) Is there a list anywhere of all of the text-message codes like this that don’t appear in stops.getList?

Thanks!
Sean  
#2 Posted : Monday, July 18, 2011 9:50:10 AM(UTC)
Sean

Rank: Administration

Groups: Administrators
Joined: 4/11/2011(UTC)
Posts: 42

Was thanked: 3 time(s) in 3 post(s)
There's no method in the API to figure this out. I can tell you right now the only places where this occurs is at the Transit Plaza and Illinois Terminal. Normally a stop code is associated with any stop point at an intersection. However, there are just too many buses at these locations to be useful over SMS so we split the stop points up and gave them individual codes.

Of course this makes things a little goofy with the API, so we opted for showing the specific stop code instead of the more general one. Do you think it would be better to provide an array of stop codes for each stop even though most stops will only have one code?
Benjamin  
#3 Posted : Monday, July 18, 2011 10:41:16 AM(UTC)
Benjamin

Rank: Advanced Member

Groups: Registered
Joined: 7/10/2011(UTC)
Posts: 34

Thanks: 1 times
Hi Sean,

Thanks for the response!

Sean wrote:
There's no method in the API to figure this out. I can tell you right now the only places where this occurs is at the Transit Plaza and Illinois Terminal. Normally a stop code is associated with any stop point at an intersection. However, there are just too many buses at these locations to be useful over SMS so we split the stop points up and gave them individual codes.


OK, that makes sense.

Quote:
Of course this makes things a little goofy with the API, so we opted for showing the specific stop code instead of the more general one. Do you think it would be better to provide an array of stop codes for each stop even though most stops will only have one code?


Maybe you could add a key like "intersection_code" to the stops for which this is the case? So the output of stops.getList would include

Code:
{
  "stop_name": "Transit Plaza",
  "stop_lat": 40.108178000000002,
  "code": "MTD6115",
  "intersection_code": "MTD7411",
  "stop_lon": -88.228827999999993,
  "stop_id": "PLAZA:4"
},
{
  "stop_name": "Illinois Terminal",
  "stop_lat": 40.115935,
  "code": "MTD7534",
  "intersection_code": "MTD3121",
  "stop_lon": -88.240947000000006,
  "stop_id": "IT:1"
},
{
  "stop_name": "Anderson & Harding",
  "stop_lat": 40.093719999999998,
  "code": "MTD3324",
  "stop_lon": -88.198797999999996,
  "stop_id": "ADRSNHRDG:4"
},


You’d then be able to look for the presence of intersection_code to determine whether there’s another code associated with that stop. Of course, since there are only these two exceptions, it’ll be easy enough for me to add code to deal specifically with these two stops.

(I think the “real” Right Way to do this would be to have a call intersections.getList that returns

Code:
{
  "stat": "ok",
  "intersections": [
    {
      "intersection_name": "U.S. 150 & Dale",
      "code": "MTD5437",
      "stops": [
        {
            "code": "MTD5437",
            "stop_id": "150DALE:1",
            "stop_name": "U.S. 150 & Dale",
            "stop_lat": 40.114511999999998,
            "stop_lon": -88.180672999999999
        },
        {
            "code": "MTD5437",
            "stop_id": "150DALE:3",
            "stop_name": "U.S. 150 & Dale",
            "stop_lat": 40.114502999999999,
            "stop_lon": -88.180847999999997
        }
      ]
    },
    {
      "intersection_name": "Illinois Terminal",
      "code": "MTD3121",
      "stops": [
        {
          "code": "MTD7534",
          "stop_id": "IT:1",
          "stop_name": "Illinois Terminal (Platform A)",
          "stop_lat": 40.115935,
          "stop_lon": -88.240947000000006
        },
        {
          "code": "MTD6462",
          "stop_id": "IT:2",
          "stop_name": "Illinois Terminal (Platform B)",
          "stop_lat": 40.115971999999999,
          "stop_lon": -88.240920000000003
        },
        {
          "code": "MTD4217",
          "stop_id": "IT:5",
          "stop_name": "Illinois Terminal (Platform C)",
          "stop_lat": 40.115363000000002,
          "stop_lon": -88.241442000000006
        }
      ]
    },
    // ...
  ]
}


but I don’t know whether the added complexity would be worth it in practice.)

Cheers,

Benjamin
Users browsing this topic
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.