use of org.opentripplanner.util.NonLocalizedString 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