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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations