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());
}
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;
}
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;
}
}
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;
}
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;
}
Aggregations