Examples of BikeRentalStationService


Examples of org.opentripplanner.routing.bike_rental.BikeRentalStationService

            @QueryParam("upperRight") String upperRight,
            @PathParam("routerId") String routerId) {

        Graph graph = server.graphService.getGraph(routerId);
        if (graph == null) return null;
        BikeRentalStationService bikeRentalService = graph.getService(BikeRentalStationService.class);
        if (bikeRentalService == null) return new BikeRentalStationList();
        Envelope envelope;
        if (lowerLeft != null) {
            envelope = getEnvelope(lowerLeft, upperRight);
        } else {
            envelope = new Envelope(-180,180,-90,90);
        }
        Collection<BikeRentalStation> stations = bikeRentalService.getBikeRentalStations();
        List<BikeRentalStation> out = new ArrayList<BikeRentalStation>();
        for (BikeRentalStation station : stations) {
            if (envelope.contains(station.x, station.y)) {
                out.add(station);
            }
View Full Code Here

Examples of org.opentripplanner.routing.bike_rental.BikeRentalStationService

        linker.buildGraph(graph, extra);

    }

    private void initBikeRental() {
        BikeRentalStationService service = graph.getService(BikeRentalStationService.class, true);
        BikeRentalStation station = new BikeRentalStation();
        station.x = -122.637634;
        station.y = 45.513084;
        station.bikesAvailable = 5;
        station.spacesAvailable = 4;
        station.id = "1";
        station.name = "bike rental station";
        service.addBikeRentalStation(station);
    }
View Full Code Here

Examples of org.opentripplanner.routing.bike_rental.BikeRentalStationService

        } // END buildGraph()

        private void processBikeRentalNodes() {
            LOG.info("Processing bike rental nodes...");
            int n = 0;
            BikeRentalStationService bikeRentalService = graph.getService(
                    BikeRentalStationService.class, true);
            graph.putService(BikeRentalStationService.class, bikeRentalService);
            for (OSMNode node : osmdb.getBikeRentalNodes()) {
                n++;
                String creativeName = wayPropertySet.getCreativeNameForWay(node);
                int capacity = Integer.MAX_VALUE;
                if (node.hasTag("capacity")) {
                    try {
                        capacity = node.getCapacity();
                    } catch (NumberFormatException e) {
                        LOG.warn("Capacity for osm node " + node.getId() + " (" + creativeName
                                + ") is not a number: " + node.getTag("capacity"));
                    }
                }
                String networks = node.getTag("network");
                String operators = node.getTag("operator");
                Set<String> networkSet = new HashSet<String>();
                if (networks != null)
                    networkSet.addAll(Arrays.asList(networks.split(";")));
                if (operators != null)
                    networkSet.addAll(Arrays.asList(operators.split(";")));
                if (networkSet.isEmpty()) {
                    LOG.warn("Bike rental station at osm node " + node.getId() + " ("
                            + creativeName + ") with no network; including as compatible-with-all.");
                    networkSet = null; // Special "catch-all" value
                }
                BikeRentalStation station = new BikeRentalStation();
                station.id = "" + node.getId();
                station.name = creativeName;
                station.x = node.lon;
                station.y = node.lat;
                // The following make sure that spaces+bikes=capacity, always.
                // Also, for the degenerate case of capacity=1, we should have 1
                // bike available, not 0.
                station.spacesAvailable = capacity / 2;
                station.bikesAvailable = capacity - station.spacesAvailable;
                station.realTimeData = false;
                bikeRentalService.addBikeRentalStation(station);
                BikeRentalStationVertex stationVertex = new BikeRentalStationVertex(graph, station);
                new RentABikeOnEdge(stationVertex, stationVertex, networkSet);
                new RentABikeOffEdge(stationVertex, stationVertex, networkSet);
            }
            LOG.info("Created " + n + " bike rental stations.");
View Full Code Here

Examples of org.opentripplanner.routing.bike_rental.BikeRentalStationService

        }

        private void processBikeParkAndRideNodes() {
            LOG.info("Processing bike P+R nodes...");
            int n = 0;
            BikeRentalStationService bikeRentalService = graph.getService(
                    BikeRentalStationService.class, true);
            for (OSMNode node : osmdb.getBikeParkingNodes()) {
                n++;
                String creativeName = wayPropertySet.getCreativeNameForWay(node);
                if (creativeName == null)
                    creativeName = "P+R";
                BikePark bikePark = new BikePark();
                bikePark.id = "" + node.getId();
                bikePark.name = creativeName;
                bikePark.x = node.lon;
                bikePark.y = node.lat;
                bikeRentalService.addBikePark(bikePark);
                BikeParkVertex parkVertex = new BikeParkVertex(graph, bikePark);
                new BikeParkEdge(parkVertex);
            }
            LOG.info("Created " + n + " bike P+R.");
        }
View Full Code Here

Examples of org.opentripplanner.routing.bike_rental.BikeRentalStationService

         * nodes to connect them to the nearest streets.
         *
         * @param area
         */
        private void buildBikeParkAndRideForArea(Area area) {
            BikeRentalStationService bikeRentalService = graph.getService(
                    BikeRentalStationService.class, true);
            Envelope envelope = new Envelope();
            long osmId = area.parent.getId();
            String creativeName = wayPropertySet.getCreativeNameForWay(area.parent);
            for (Ring ring : area.outermostRings) {
                for (OSMNode node : ring.nodes) {
                    envelope.expandToInclude(new Coordinate(node.lon, node.lat));
                }
            }
            BikePark bikePark = new BikePark();
            bikePark.id = "" + osmId;
            bikePark.name = creativeName;
            bikePark.x = (envelope.getMinX() + envelope.getMaxX()) / 2;
            bikePark.y = (envelope.getMinY() + envelope.getMaxY()) / 2;
            bikeRentalService.addBikePark(bikePark);
            BikeParkVertex bikeParkVertex = new BikeParkVertex(graph, bikePark);
            new BikeParkEdge(bikeParkVertex);
            LOG.debug("Created area bike P+R '{}' ({})", creativeName, osmId);
        }
View Full Code Here

Examples of org.opentripplanner.routing.bike_rental.BikeRentalStationService

    @Override
    public void buildGraph(Graph graph, HashMap<Class<?>, Object> extra) {

        LOG.info("Building bike rental stations from static source...");
        BikeRentalStationService service = graph.getService(BikeRentalStationService.class, true);
        if (!dataSource.update()) {
            LOG.warn("No bike rental found from the data source.");
            return;
        }
        Collection<BikeRentalStation> stations = dataSource.getStations();

        for (BikeRentalStation station : stations) {
            service.addBikeRentalStation(station);
            BikeRentalStationVertex vertex = new BikeRentalStationVertex(graph, station);
            new RentABikeOnEdge(vertex, vertex, station.networks);
            if (station.allowDropoff)
                new RentABikeOffEdge(vertex, vertex, station.networks);
        }
View Full Code Here

Examples of org.opentripplanner.routing.bike_rental.BikeRentalStationService

    @Override
    public void buildGraph(Graph graph, HashMap<Class<?>, Object> extra) {

        LOG.info("Building bike parks from static source...");
        BikeRentalStationService service = graph.getService(BikeRentalStationService.class, true);
        if (!dataSource.update()) {
            LOG.warn("No bike parks found from the data source.");
            return;
        }
        Collection<BikePark> bikeParks = dataSource.getBikeParks();

        for (BikePark bikePark : bikeParks) {
            service.addBikePark(bikePark);
            BikeParkVertex bikeParkVertex = new BikeParkVertex(graph, bikePark);
            new BikeParkEdge(bikeParkVertex);
        }
        LOG.info("Created " + bikeParks.size() + " bike parks.");
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.