Skip to content

Commit

Permalink
Add support for San Francisco Bay Ferry (Clipper)
Browse files Browse the repository at this point in the history
  • Loading branch information
Bao-Long Nguyen-Trong authored and codebutler committed Oct 27, 2014
1 parent cfc94f4 commit 2f08cb3
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 45 deletions.
Expand Up @@ -6,35 +6,38 @@
import java.util.Map;

final class ClipperData {
static final int AGENCY_ACTRAN = 0x01;
static final int AGENCY_BART = 0x04;
static final int AGENCY_CALTRAIN = 0x06;
static final int AGENCY_GGT = 0x0b;
static final int AGENCY_SAMTRANS = 0x0f;
static final int AGENCY_VTA = 0x11;
static final int AGENCY_MUNI = 0x12;
static final int AGENCY_FERRY = 0x19;
static final int AGENCY_ACTRAN = 0x01;
static final int AGENCY_BART = 0x04;
static final int AGENCY_CALTRAIN = 0x06;
static final int AGENCY_GGT = 0x0b;
static final int AGENCY_SAMTRANS = 0x0f;
static final int AGENCY_VTA = 0x11;
static final int AGENCY_MUNI = 0x12;
static final int AGENCY_GG_FERRY = 0x19;
static final int AGENCY_SF_BAY_FERRY = 0x1b;

static final Map<Integer, String> AGENCIES = new HashMap<Integer, String>() {{
put(AGENCY_ACTRAN, "Alameda-Contra Costa Transit District");
put(AGENCY_BART, "Bay Area Rapid Transit");
put(AGENCY_CALTRAIN, "Caltrain");
put(AGENCY_GGT, "Golden Gate Transit");
put(AGENCY_SAMTRANS, "San Mateo County Transit District");
put(AGENCY_VTA, "Santa Clara Valley Transportation Authority");
put(AGENCY_MUNI, "San Francisco Municipal");
put(AGENCY_FERRY, "Golden Gate Ferry");
put(AGENCY_ACTRAN, "Alameda-Contra Costa Transit District");
put(AGENCY_BART, "Bay Area Rapid Transit");
put(AGENCY_CALTRAIN, "Caltrain");
put(AGENCY_GGT, "Golden Gate Transit");
put(AGENCY_SAMTRANS, "San Mateo County Transit District");
put(AGENCY_VTA, "Santa Clara Valley Transportation Authority");
put(AGENCY_MUNI, "San Francisco Municipal");
put(AGENCY_GG_FERRY, "Golden Gate Ferry");
put(AGENCY_SF_BAY_FERRY, "San Francisco Bay Ferry");
}};

static final Map<Integer, String> SHORT_AGENCIES = new HashMap<Integer, String>() {{
put(AGENCY_ACTRAN, "ACTransit");
put(AGENCY_BART, "BART");
put(AGENCY_CALTRAIN, "Caltrain");
put(AGENCY_GGT, "GGT");
put(AGENCY_SAMTRANS, "SAMTRANS");
put(AGENCY_VTA, "VTA");
put(AGENCY_MUNI, "Muni");
put(AGENCY_FERRY, "Ferry");
put(AGENCY_ACTRAN, "ACTransit");
put(AGENCY_BART, "BART");
put(AGENCY_CALTRAIN, "Caltrain");
put(AGENCY_GGT, "GGT");
put(AGENCY_SAMTRANS, "SAMTRANS");
put(AGENCY_VTA, "VTA");
put(AGENCY_MUNI, "Muni");
put(AGENCY_GG_FERRY, "GG Ferry");
put(AGENCY_SF_BAY_FERRY, "SF Bay Ferry");
}};

static final Map<Long, Station> BART_STATIONS = new HashMap<Long, Station>() {{
Expand Down Expand Up @@ -78,15 +81,20 @@ final class ClipperData {
put((long)0x2c, new Station("West Dublin/Pleasanton Station", "W. Dublin/Pleasanton", "37.699764", "-121.928118"));
}};

static Map<Long, String> FERRY_ROUTES = new HashMap<Long, String>() {{
static Map<Long, String> GG_FERRY_ROUTES = new HashMap<Long, String>() {{
put((long)0x03, "Larkspur");
put((long)0x04, "San Francisco");
}};

static Map<Long, Station> FERRY_TERMINALS = new HashMap<Long, Station>() {{
static Map<Long, Station> GG_FERRY_TERIMINALS = new HashMap<Long, Station>() {{
put((long)0x01, new Station("San Francisco Ferry Building", "San Francisco", "37.795873", "-122.391987"));
put((long)0x03, new Station("Larkspur Ferry Terminal", "Larkspur", "37.945509", "-122.50916"));
}};

static Map<Long, Station> SF_BAY_FERRY_TERMINALS = new HashMap<Long, Station>() {{
put((long)0x01, new Station("Alameda Main Street Terminal", "Alameda Main St.", "37.790668", "-122.294036"));
put((long)0x08, new Station("San Francisco Ferry Building", "Ferry Building", "37.795873", "-122.391987"));
}};

private ClipperData() { }
}
Expand Up @@ -67,9 +67,8 @@ public ClipperTrip[] newArray(int size) {
}

@Override public String getRouteName () {
if (mAgency == ClipperData.AGENCY_FERRY &&
ClipperData.FERRY_ROUTES.containsKey(mRoute)) {
return ClipperData.FERRY_ROUTES.get(mRoute);
if (mAgency == ClipperData.AGENCY_GG_FERRY) {
return ClipperData.GG_FERRY_ROUTES.get(mRoute);
} else {
// FIXME: Need to find bus route #s
// return "(Route 0x" + Long.toString(mRoute, 16) + ")";
Expand All @@ -94,9 +93,13 @@ public ClipperTrip[] newArray(int size) {
if (ClipperData.BART_STATIONS.containsKey(mFrom)) {
return ClipperData.BART_STATIONS.get(mFrom);
}
} else if (mAgency == ClipperData.AGENCY_FERRY) {
if (ClipperData.FERRY_TERMINALS.containsKey(mFrom)) {
return ClipperData.FERRY_TERMINALS.get(mFrom);
} else if (mAgency == ClipperData.AGENCY_GG_FERRY) {
if (ClipperData.GG_FERRY_TERIMINALS.containsKey(mFrom)) {
return ClipperData.GG_FERRY_TERIMINALS.get(mFrom);
}
} else if (mAgency == ClipperData.AGENCY_SF_BAY_FERRY) {
if (ClipperData.SF_BAY_FERRY_TERMINALS.containsKey(mFrom)) {
return ClipperData.SF_BAY_FERRY_TERMINALS.get(mFrom);
}
}
return null;
Expand All @@ -107,16 +110,19 @@ public ClipperTrip[] newArray(int size) {
if (ClipperData.BART_STATIONS.containsKey(mTo)) {
return ClipperData.BART_STATIONS.get(mTo);
}
} else if (mAgency == ClipperData.AGENCY_FERRY) {
if (ClipperData.FERRY_TERMINALS.containsKey(mTo)) {
return ClipperData.FERRY_TERMINALS.get(mTo);
} else if (mAgency == ClipperData.AGENCY_GG_FERRY) {
if (ClipperData.GG_FERRY_TERIMINALS.containsKey(mTo)) {
return ClipperData.GG_FERRY_TERIMINALS.get(mTo);
}
} else if (mAgency == ClipperData.AGENCY_SF_BAY_FERRY) {
if (ClipperData.SF_BAY_FERRY_TERMINALS.containsKey(mTo)) {
return ClipperData.SF_BAY_FERRY_TERMINALS.get(mTo);
}
}
return null;
}

@Override public String getStartStationName () {
if (mAgency == ClipperData.AGENCY_BART || mAgency == ClipperData.AGENCY_FERRY) {
if (mAgency == ClipperData.AGENCY_BART || mAgency == ClipperData.AGENCY_GG_FERRY || mAgency == ClipperData.AGENCY_SF_BAY_FERRY) {
Station station = getStartStation();
if (station != null)
return station.getShortStationName();
Expand All @@ -132,19 +138,19 @@ public ClipperTrip[] newArray(int size) {
}

@Override public String getEndStationName () {
if (mAgency == ClipperData.AGENCY_BART) {
if (mAgency == ClipperData.AGENCY_BART || mAgency == ClipperData.AGENCY_GG_FERRY || mAgency == ClipperData.AGENCY_SF_BAY_FERRY) {
Station station = getEndStation();
if (station != null)
return ClipperData.BART_STATIONS.get(mTo).getShortStationName();
else
if (station != null) {
return station.getShortStationName();
} else {
return "Station #0x" + Long.toString(mTo, 16);
}
} else if (mAgency == ClipperData.AGENCY_MUNI) {
return null; // Coach number is not collected
} else if (mAgency == ClipperData.AGENCY_GGT || mAgency == ClipperData.AGENCY_CALTRAIN ||
mAgency == ClipperData.AGENCY_FERRY) {
} else if (mAgency == ClipperData.AGENCY_GGT || mAgency == ClipperData.AGENCY_CALTRAIN) {
if (mTo == 0xffff)
return "(End of line)";
return "Zone #" + mTo;
return "Zone #0x" + Long.toString(mTo, 16);
} else {
return "(Unknown Station)";
}
Expand All @@ -165,7 +171,9 @@ public ClipperTrip[] newArray(int size) {
return Mode.BUS; // FIXME: or Mode.TRAM for light rail
if (mAgency == ClipperData.AGENCY_MUNI)
return Mode.BUS; // FIXME: or Mode.TRAM for "Muni Metro"
if (mAgency == ClipperData.AGENCY_FERRY)
if (mAgency == ClipperData.AGENCY_GG_FERRY)
return Mode.FERRY;
if (mAgency == ClipperData.AGENCY_SF_BAY_FERRY)
return Mode.FERRY;
return Mode.OTHER;
}
Expand Down

0 comments on commit 2f08cb3

Please sign in to comment.