use of org.opentripplanner.routing.bike_rental.BikeRentalStation in project OpenTripPlanner by opentripplanner.
the class KeolisRennesBikeRentalDataSource method makeStation.
public BikeRentalStation makeStation(Map<String, String> attributes) {
// FIXME: I have no idea what state actually means
if (!"1".equals(attributes.get("state"))) {
return null;
}
BikeRentalStation brstation = new BikeRentalStation();
brstation.id = attributes.get("number");
brstation.x = Double.parseDouble(attributes.get("longitude"));
brstation.y = Double.parseDouble(attributes.get("latitude"));
brstation.name = new NonLocalizedString(attributes.get("name"));
brstation.bikesAvailable = Integer.parseInt(attributes.get("bikesavailable"));
brstation.spacesAvailable = Integer.parseInt(attributes.get("slotsavailable"));
return brstation;
}
use of org.opentripplanner.routing.bike_rental.BikeRentalStation in project OpenTripPlanner by opentripplanner.
the class OVFietsKMLDataSource method makeStation.
public BikeRentalStation makeStation(Map<String, String> attributes) {
BikeRentalStation brstation = new BikeRentalStation();
brstation.id = attributes.get("name") + attributes.get("Point").trim();
String[] coordinates = attributes.get("Point").trim().split(",");
brstation.x = Double.parseDouble(coordinates[0]);
brstation.y = Double.parseDouble(coordinates[1]);
if (brstation.x == 0 || brstation.y == 0)
return null;
brstation.name = new NonLocalizedString(attributes.get("name"));
return brstation;
}
use of org.opentripplanner.routing.bike_rental.BikeRentalStation in project OpenTripPlanner by opentripplanner.
the class ShareBikeRentalDataSource method makeStation.
/**
* ShareBike format http://www.sharebike.com/
*
* URL for configuration:
* http://map.webservice.sharebike.com:8888/json/MapService/LiveStationData?
* APIKey=<Your API Key>&SystemID=<Bike System ID>
*
* Currently used in Norway (Oslo, Trondheim, Drammen) , Barcelona, Mexico
* City, Milan, Stockholm, Antwerpen among others
*
* <pre>
* {
* "version": "1.1",
* "result": {
* "LastUpdated": "2016-01-18T13:55:25.610",
* "LastUpdatedUTC": "2016-01-18T12:55:25.610",
* "LiveStationData": [
* {
* "Address": "[Offline] storgata",
* "AvailableBikeCount": "0",
* "AvailableSlotCount": "0",
* "LastContact": "",
* "LastContactSeconds": "0",
* "LastContactUTC": "1899-12-30T00:00:00",
* "Latitude": "59.92758",
* "Longitude": "10.71004",
* "MinAvailableBikes": "0",
* "MinAvailableSlots": "0",
* "Online": false,
* "SlotCount": "0",
* "StationID": 1,
* "StationName": "storgata"
* },
* ....
* </pre>
*/
@Override
public BikeRentalStation makeStation(JsonNode rentalStationNode) {
if (networkID == null) {
// Get SystemID url parameter as StationIDs are not globally unique for
// the ShareBike system
List<String> systemIDs = urlParameters.get("SystemID");
if (systemIDs != null && systemIDs.size() == 1) {
networkID = systemIDs.get(0);
log.info("Extracted query parameter 'SystemID 'from sharebike url: " + networkID);
} else {
networkID = UUID.randomUUID().toString();
log.warn("No query parameter 'SystemID' in sharebike url, using random value " + networkID);
}
}
if (!rentalStationNode.path("Online").asBoolean()) {
log.debug("Station is offline: " + rentalStationNode.path("StationName").asText());
return null;
}
BikeRentalStation brstation = new BikeRentalStation();
brstation.networks = new HashSet<String>();
brstation.networks.add(this.networkID);
brstation.id = networkID + "_" + rentalStationNode.path("StationID").toString();
brstation.x = rentalStationNode.path("Longitude").asDouble();
brstation.y = rentalStationNode.path("Latitude").asDouble();
brstation.name = new NonLocalizedString(rentalStationNode.path("StationName").asText("").trim());
brstation.bikesAvailable = rentalStationNode.path("AvailableBikeCount").asInt();
brstation.spacesAvailable = rentalStationNode.path("AvailableSlotCount").asInt();
return brstation;
}
Aggregations