Search in sources :

Example 11 with NonLocalizedString

use of org.opentripplanner.util.NonLocalizedString in project OpenTripPlanner by opentripplanner.

the class CitiBikeNycBikeRentalDataSource method makeStation.

public BikeRentalStation makeStation(JsonNode stationNode) {
    if (!stationNode.path("statusValue").asText().equals("In Service")) {
        return null;
    }
    if (stationNode.path("testStation").asText().equals("true")) {
        return null;
    }
    BikeRentalStation brstation = new BikeRentalStation();
    brstation.networks = new HashSet<String>();
    brstation.networks.add(this.networkName);
    brstation.id = stationNode.path("id").toString();
    brstation.x = stationNode.path("longitude").asDouble();
    brstation.y = stationNode.path("latitude").asDouble();
    brstation.name = new NonLocalizedString(stationNode.path("stationName").asText());
    brstation.bikesAvailable = stationNode.path("availableBikes").asInt();
    brstation.spacesAvailable = stationNode.path("availableDocks").asInt();
    return brstation;
}
Also used : NonLocalizedString(org.opentripplanner.util.NonLocalizedString) NonLocalizedString(org.opentripplanner.util.NonLocalizedString) BikeRentalStation(org.opentripplanner.routing.bike_rental.BikeRentalStation)

Example 12 with NonLocalizedString

use of org.opentripplanner.util.NonLocalizedString in project OpenTripPlanner by opentripplanner.

the class GenericKmlBikeRentalDataSource method makeStation.

public BikeRentalStation makeStation(Map<String, String> attributes) {
    if (!attributes.containsKey("name")) {
        LOG.warn("Missing name in KML Placemark, cannot create bike rental.");
        return null;
    }
    if (!attributes.containsKey("Point")) {
        LOG.warn("Missing Point geometry in KML Placemark, cannot create bike rental.");
        return null;
    }
    BikeRentalStation brStation = new BikeRentalStation();
    brStation.name = new NonLocalizedString(attributes.get("name").trim());
    if (namePrefix != null)
        brStation.name = new NonLocalizedString(namePrefix + brStation.name);
    String[] coords = attributes.get("Point").trim().split(",");
    brStation.x = Double.parseDouble(coords[0]);
    brStation.y = Double.parseDouble(coords[1]);
    // There is no ID in KML, assume unique names and location
    brStation.id = String.format(Locale.US, "%s[%.3f-%.3f]", brStation.name.toString().replace(" ", "_"), brStation.x, brStation.y);
    brStation.realTimeData = false;
    // Unknown, always 1
    brStation.bikesAvailable = 1;
    // Unknown, always 1
    brStation.spacesAvailable = 1;
    brStation.networks = networks;
    brStation.allowDropoff = allowDropoff;
    return brStation;
}
Also used : NonLocalizedString(org.opentripplanner.util.NonLocalizedString) NonLocalizedString(org.opentripplanner.util.NonLocalizedString) BikeRentalStation(org.opentripplanner.routing.bike_rental.BikeRentalStation)

Example 13 with NonLocalizedString

use of org.opentripplanner.util.NonLocalizedString in project OpenTripPlanner by opentripplanner.

the class JCDecauxBikeRentalDataSource method makeStation.

/**
 * JSON JCDecaux API v1 format:
 *
 * <pre>
 * [ {
 *     "number" : 94,
 *     "name" : "00094-PETIT PORT",
 *     "address" : "PETIT PORT - BD DU PETIT PORT",
 *     "position" : {
 *       "lat" : 47.243263914975486,
 *       "lng" : -1.556344610167984 },
 *     "banking" : true,
 *     "bonus" : false,
 *     "status" : "OPEN",
 *     "bike_stands" : 20,
 *     "available_bike_stands" : 1,
 *     "available_bikes" : 19,
 *     "last_update" : 1368611914000
 *   },
 *   ...
 * ]
 * </pre>
 */
public BikeRentalStation makeStation(JsonNode node) {
    if (!node.path("status").asText().equals("OPEN")) {
        return null;
    }
    BikeRentalStation station = new BikeRentalStation();
    station.id = String.format("%d", node.path("number").asInt());
    station.x = node.path("position").path("lng").asDouble();
    station.y = node.path("position").path("lat").asDouble();
    station.name = new NonLocalizedString(node.path("name").asText());
    station.bikesAvailable = node.path("available_bikes").asInt();
    station.spacesAvailable = node.path("available_bike_stands").asInt();
    return station;
}
Also used : NonLocalizedString(org.opentripplanner.util.NonLocalizedString) BikeRentalStation(org.opentripplanner.routing.bike_rental.BikeRentalStation)

Example 14 with NonLocalizedString

use of org.opentripplanner.util.NonLocalizedString in project OpenTripPlanner by opentripplanner.

the class NextBikeRentalDataSource method makeStation.

public BikeRentalStation makeStation(Map<String, String> attributes) {
    // some place entries appear to actually be checked-out bikes, not stations
    if (attributes.get("bike") != null) {
        return null;
    }
    BikeRentalStation brstation = new BikeRentalStation();
    brstation.networks = new HashSet<String>();
    brstation.networks.add(this.networkName);
    brstation.id = attributes.get("number");
    brstation.x = Double.parseDouble(attributes.get("lng"));
    brstation.y = Double.parseDouble(attributes.get("lat"));
    brstation.name = new NonLocalizedString(attributes.get("name"));
    brstation.spacesAvailable = Integer.parseInt(attributes.get("bike_racks"));
    // number of bikes available is reported as "5+" if >= 5
    String numBikes = attributes.get("bikes");
    if (numBikes.equals("5+")) {
        brstation.bikesAvailable = 5;
    } else {
        brstation.bikesAvailable = Integer.parseInt(numBikes);
    }
    return brstation;
}
Also used : NonLocalizedString(org.opentripplanner.util.NonLocalizedString) NonLocalizedString(org.opentripplanner.util.NonLocalizedString) BikeRentalStation(org.opentripplanner.routing.bike_rental.BikeRentalStation)

Example 15 with NonLocalizedString

use of org.opentripplanner.util.NonLocalizedString in project OpenTripPlanner by opentripplanner.

the class SanFranciscoBayAreaBikeRentalDataSource method makeStation.

public BikeRentalStation makeStation(JsonNode stationNode) {
    if (!stationNode.path("statusValue").asText().equals("In Service")) {
        return null;
    }
    if (stationNode.path("testStation").asText().equals("true")) {
        return null;
    }
    BikeRentalStation brstation = new BikeRentalStation();
    brstation.networks = new HashSet<String>();
    brstation.networks.add(this.networkName);
    brstation.id = stationNode.path("id").toString();
    brstation.x = stationNode.path("longitude").asDouble();
    brstation.y = stationNode.path("latitude").asDouble();
    brstation.name = new NonLocalizedString(stationNode.path("stationName").asText());
    brstation.bikesAvailable = stationNode.path("availableBikes").asInt();
    brstation.spacesAvailable = stationNode.path("availableDocks").asInt();
    return brstation;
}
Also used : NonLocalizedString(org.opentripplanner.util.NonLocalizedString) NonLocalizedString(org.opentripplanner.util.NonLocalizedString) BikeRentalStation(org.opentripplanner.routing.bike_rental.BikeRentalStation)

Aggregations

NonLocalizedString (org.opentripplanner.util.NonLocalizedString)31 BikeRentalStation (org.opentripplanner.routing.bike_rental.BikeRentalStation)15 RoutingRequest (org.opentripplanner.routing.core.RoutingRequest)10 StreetEdge (org.opentripplanner.routing.edgetype.StreetEdge)10 TemporaryStreetLocation (org.opentripplanner.routing.location.TemporaryStreetLocation)8 GraphPath (org.opentripplanner.routing.spt.GraphPath)8 Test (org.junit.Test)7 Edge (org.opentripplanner.routing.graph.Edge)7 ShortestPathTree (org.opentripplanner.routing.spt.ShortestPathTree)7 Coordinate (com.vividsolutions.jts.geom.Coordinate)6 HashSet (java.util.HashSet)6 State (org.opentripplanner.routing.core.State)6 LineString (com.vividsolutions.jts.geom.LineString)4 LinearLocation (com.vividsolutions.jts.linearref.LinearLocation)4 TraverseModeSet (org.opentripplanner.routing.core.TraverseModeSet)4 TemporaryFreeEdge (org.opentripplanner.routing.edgetype.TemporaryFreeEdge)4 ArrayList (java.util.ArrayList)3 Alert (org.opentripplanner.routing.alertpatch.Alert)3 IntersectionVertex (org.opentripplanner.routing.vertextype.IntersectionVertex)3 Vertex (org.opentripplanner.routing.graph.Vertex)2