Search in sources :

Example 26 with NonLocalizedString

use of org.opentripplanner.util.NonLocalizedString in project OpenTripPlanner by opentripplanner.

the class AStarTest method testForwardExtraEdges.

@Test
public void testForwardExtraEdges() {
    RoutingRequest options = new RoutingRequest();
    options.walkSpeed = 1.0;
    TemporaryStreetLocation from = new TemporaryStreetLocation("near_shilshole_22nd", new Coordinate(-122.385050, 47.666620), new NonLocalizedString("near_shilshole_22nd"), false);
    new TemporaryConcreteEdge(from, _graph.getVertex("shilshole_22nd"));
    TemporaryStreetLocation to = new TemporaryStreetLocation("near_56th_20th", new Coordinate(-122.382347, 47.669518), new NonLocalizedString("near_56th_20th"), true);
    new TemporaryConcreteEdge(_graph.getVertex("56th_20th"), to);
    options.setRoutingContext(_graph, from, to);
    ShortestPathTree tree = new AStar().getShortestPathTree(options);
    options.cleanup();
    GraphPath path = tree.getPath(to, false);
    List<State> states = path.states;
    assertEquals(9, states.size());
    assertEquals("near_shilshole_22nd", states.get(0).getVertex().getLabel());
    assertEquals("shilshole_22nd", states.get(1).getVertex().getLabel());
    assertEquals("ballard_22nd", states.get(2).getVertex().getLabel());
    assertEquals("market_22nd", states.get(3).getVertex().getLabel());
    assertEquals("market_leary", states.get(4).getVertex().getLabel());
    assertEquals("market_russell", states.get(5).getVertex().getLabel());
    assertEquals("market_20th", states.get(6).getVertex().getLabel());
    assertEquals("56th_20th", states.get(7).getVertex().getLabel());
    assertEquals("near_56th_20th", states.get(8).getVertex().getLabel());
}
Also used : TemporaryStreetLocation(org.opentripplanner.routing.location.TemporaryStreetLocation) ShortestPathTree(org.opentripplanner.routing.spt.ShortestPathTree) Coordinate(com.vividsolutions.jts.geom.Coordinate) State(org.opentripplanner.routing.core.State) NonLocalizedString(org.opentripplanner.util.NonLocalizedString) TemporaryConcreteEdge(org.opentripplanner.routing.graph.TemporaryConcreteEdge) GraphPath(org.opentripplanner.routing.spt.GraphPath) RoutingRequest(org.opentripplanner.routing.core.RoutingRequest) Test(org.junit.Test)

Example 27 with NonLocalizedString

use of org.opentripplanner.util.NonLocalizedString in project OpenTripPlanner by opentripplanner.

the class BixiBikeRentalDataSource method makeStation.

public BikeRentalStation makeStation(Map<String, String> attributes) {
    if (!"true".equals(attributes.get("installed"))) {
        return null;
    }
    BikeRentalStation brstation = new BikeRentalStation();
    brstation.id = attributes.get("id");
    brstation.x = Double.parseDouble(attributes.get("long"));
    brstation.y = Double.parseDouble(attributes.get("lat"));
    brstation.name = new NonLocalizedString(attributes.get("name"));
    brstation.bikesAvailable = Integer.parseInt(attributes.get("nbBikes"));
    brstation.spacesAvailable = Integer.parseInt(attributes.get("nbEmptyDocks"));
    return brstation;
}
Also used : NonLocalizedString(org.opentripplanner.util.NonLocalizedString) BikeRentalStation(org.opentripplanner.routing.bike_rental.BikeRentalStation)

Example 28 with NonLocalizedString

use of org.opentripplanner.util.NonLocalizedString in project OpenTripPlanner by opentripplanner.

the class CityBikesBikeRentalDataSource method parseJson.

private void parseJson(String data) throws ParserConfigurationException, SAXException, IOException {
    ArrayList<BikeRentalStation> out = new ArrayList<BikeRentalStation>();
    // Jackson ObjectMapper to read in JSON
    // TODO: test against real data
    ObjectMapper mapper = new ObjectMapper();
    for (JsonNode stationNode : mapper.readTree(data)) {
        BikeRentalStation brStation = new BikeRentalStation();
        // We need string IDs but they are in JSON as numbers. Avoid null from textValue(). See pull req #1450.
        brStation.id = String.valueOf(stationNode.get("id").intValue());
        brStation.x = stationNode.get("lng").doubleValue() / 1000000.0;
        brStation.y = stationNode.get("lat").doubleValue() / 1000000.0;
        brStation.name = new NonLocalizedString(stationNode.get("name").textValue());
        brStation.bikesAvailable = stationNode.get("bikes").intValue();
        brStation.spacesAvailable = stationNode.get("free").intValue();
        if (brStation != null && brStation.id != null) {
            out.add(brStation);
        }
    }
    synchronized (this) {
        stations = out;
    }
}
Also used : NonLocalizedString(org.opentripplanner.util.NonLocalizedString) ArrayList(java.util.ArrayList) JsonNode(com.fasterxml.jackson.databind.JsonNode) BikeRentalStation(org.opentripplanner.routing.bike_rental.BikeRentalStation) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 29 with NonLocalizedString

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

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

Aggregations

NonLocalizedString (org.opentripplanner.util.NonLocalizedString)31 BikeRentalStation (org.opentripplanner.routing.bike_rental.BikeRentalStation)15 RoutingRequest (org.opentripplanner.routing.core.RoutingRequest)10 StreetEdge (org.opentripplanner.routing.edgetype.StreetEdge)10 TemporaryStreetLocation (org.opentripplanner.routing.location.TemporaryStreetLocation)8 GraphPath (org.opentripplanner.routing.spt.GraphPath)8 Test (org.junit.Test)7 Edge (org.opentripplanner.routing.graph.Edge)7 ShortestPathTree (org.opentripplanner.routing.spt.ShortestPathTree)7 Coordinate (com.vividsolutions.jts.geom.Coordinate)6 HashSet (java.util.HashSet)6 State (org.opentripplanner.routing.core.State)6 LineString (com.vividsolutions.jts.geom.LineString)4 LinearLocation (com.vividsolutions.jts.linearref.LinearLocation)4 TraverseModeSet (org.opentripplanner.routing.core.TraverseModeSet)4 TemporaryFreeEdge (org.opentripplanner.routing.edgetype.TemporaryFreeEdge)4 ArrayList (java.util.ArrayList)3 Alert (org.opentripplanner.routing.alertpatch.Alert)3 IntersectionVertex (org.opentripplanner.routing.vertextype.IntersectionVertex)3 Vertex (org.opentripplanner.routing.graph.Vertex)2