Search in sources :

Example 21 with BikeRentalStation

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;
}
Also used : NonLocalizedString(org.opentripplanner.util.NonLocalizedString) BikeRentalStation(org.opentripplanner.routing.bike_rental.BikeRentalStation)

Example 22 with BikeRentalStation

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;
}
Also used : NonLocalizedString(org.opentripplanner.util.NonLocalizedString) NonLocalizedString(org.opentripplanner.util.NonLocalizedString) BikeRentalStation(org.opentripplanner.routing.bike_rental.BikeRentalStation)

Example 23 with BikeRentalStation

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;
}
Also used : NonLocalizedString(org.opentripplanner.util.NonLocalizedString) NonLocalizedString(org.opentripplanner.util.NonLocalizedString) BikeRentalStation(org.opentripplanner.routing.bike_rental.BikeRentalStation)

Aggregations

BikeRentalStation (org.opentripplanner.routing.bike_rental.BikeRentalStation)23 NonLocalizedString (org.opentripplanner.util.NonLocalizedString)16 ArrayList (java.util.ArrayList)4 JsonNode (com.fasterxml.jackson.databind.JsonNode)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 BikeRentalStationService (org.opentripplanner.routing.bike_rental.BikeRentalStationService)2 RoutingRequest (org.opentripplanner.routing.core.RoutingRequest)2 BikeRentalStationVertex (org.opentripplanner.routing.vertextype.BikeRentalStationVertex)2 TripDescriptor (com.google.transit.realtime.GtfsRealtime.TripDescriptor)1 TripUpdate (com.google.transit.realtime.GtfsRealtime.TripUpdate)1 StopTimeEvent (com.google.transit.realtime.GtfsRealtime.TripUpdate.StopTimeEvent)1 StopTimeUpdate (com.google.transit.realtime.GtfsRealtime.TripUpdate.StopTimeUpdate)1 Coordinate (com.vividsolutions.jts.geom.Coordinate)1 Envelope (com.vividsolutions.jts.geom.Envelope)1 GeometryFactory (com.vividsolutions.jts.geom.GeometryFactory)1 LineString (com.vividsolutions.jts.geom.LineString)1 HashSet (java.util.HashSet)1 Locale (java.util.Locale)1 GET (javax.ws.rs.GET)1 Produces (javax.ws.rs.Produces)1