use of org.opentripplanner.util.NonLocalizedString in project OpenTripPlanner by opentripplanner.
the class WinkkiPollingGraphUpdater method getNote.
protected Alert getNote(SimpleFeature feature) {
Alert alert = Alert.createSimpleAlerts("winkki:" + feature.getAttribute("licence_type"));
alert.alertDescriptionText = feature.getAttribute("event_description") == null ? new NonLocalizedString("") : new NonLocalizedString(feature.getAttribute("event_description").toString());
alert.effectiveStartDate = feature.getAttribute("licence_startdate") == null ? (Date) feature.getAttribute("event_startdate") : (Date) feature.getAttribute("licence_startdate");
return alert;
}
use of org.opentripplanner.util.NonLocalizedString in project OpenTripPlanner by opentripplanner.
the class BCycleBikeRentalDataSource method makeStation.
public BikeRentalStation makeStation(JsonNode kioskNode) {
if (!kioskNode.path("Status").asText().equals("Active")) {
return null;
}
BikeRentalStation brstation = new BikeRentalStation();
brstation.networks = new HashSet<String>();
brstation.networks.add(this.networkName);
brstation.id = kioskNode.path("Id").toString();
brstation.x = kioskNode.path("Location").path("Longitude").asDouble();
brstation.y = kioskNode.path("Location").path("Latitude").asDouble();
brstation.name = new NonLocalizedString(kioskNode.path("Name").asText());
brstation.bikesAvailable = kioskNode.path("BikesAvailable").asInt();
brstation.spacesAvailable = kioskNode.path("DocksAvailable").asInt();
return brstation;
}
use of org.opentripplanner.util.NonLocalizedString in project OpenTripPlanner by opentripplanner.
the class TestHalfEdges method testRouteToSameEdge.
@Test
public void testRouteToSameEdge() {
RoutingRequest options = new RoutingRequest();
HashSet<Edge> turns = new HashSet<Edge>();
turns.add(left);
turns.add(leftBack);
TemporaryStreetLocation start = StreetVertexIndexServiceImpl.createTemporaryStreetLocation(graph, "start", new NonLocalizedString("start"), filter(turns, StreetEdge.class), new LinearLocation(0, 0.4).getCoordinate(left.getGeometry()), false);
TemporaryStreetLocation end = StreetVertexIndexServiceImpl.createTemporaryStreetLocation(graph, "end", new NonLocalizedString("end"), filter(turns, StreetEdge.class), new LinearLocation(0, 0.8).getCoordinate(left.getGeometry()), true);
assertEquals(start.getX(), end.getX(), 0.0001);
assertTrue(start.getY() < end.getY());
Collection<Edge> edges = end.getIncoming();
assertEquals(2, edges.size());
long startTime = TestUtils.dateInSeconds("America/New_York", 2009, 11, 1, 12, 34, 25);
options.dateTime = startTime;
options.setRoutingContext(graph, start, end);
options.setMaxWalkDistance(Double.MAX_VALUE);
ShortestPathTree spt = aStar.getShortestPathTree(options);
GraphPath path = spt.getPath(end, false);
assertNotNull("There must be a path from start to end", path);
assertEquals(1, path.edges.size());
options.cleanup();
}
use of org.opentripplanner.util.NonLocalizedString in project OpenTripPlanner by opentripplanner.
the class TestHalfEdges method testStreetSplittingAlerts.
/**
* Test that alerts on split streets are preserved, i.e. if there are alerts on the street that is split the same alerts should be present on the
* new street.
*/
@Test
public void testStreetSplittingAlerts() {
HashSet<Edge> turns = new HashSet<Edge>();
turns.add(left);
turns.add(leftBack);
Alert alert = Alert.createSimpleAlerts("This is the alert");
Set<Alert> alerts = new HashSet<>();
alerts.add(alert);
graph.streetNotesService.addStaticNote(left, alert, StreetNotesService.ALWAYS_MATCHER);
graph.streetNotesService.addStaticNote(leftBack, alert, StreetNotesService.ALWAYS_MATCHER);
TemporaryStreetLocation start = StreetVertexIndexServiceImpl.createTemporaryStreetLocation(graph, "start", new NonLocalizedString("start"), filter(turns, StreetEdge.class), new LinearLocation(0, 0.4).getCoordinate(left.getGeometry()), false);
// The alert should be preserved
// traverse the FreeEdge from the StreetLocation to the new IntersectionVertex
RoutingRequest req = new RoutingRequest();
req.setMaxWalkDistance(Double.MAX_VALUE);
State traversedOne = new State(start, req);
State currentState;
for (Edge e : start.getOutgoing()) {
currentState = e.traverse(traversedOne);
if (currentState != null) {
traversedOne = currentState;
break;
}
}
assertEquals(alerts, graph.streetNotesService.getNotes(traversedOne));
assertNotSame(left, traversedOne.getBackEdge().getFromVertex());
assertNotSame(leftBack, traversedOne.getBackEdge().getFromVertex());
// now, make sure wheelchair alerts are preserved
Alert wheelchairAlert = Alert.createSimpleAlerts("This is the wheelchair alert");
Set<Alert> wheelchairAlerts = new HashSet<>();
wheelchairAlerts.add(wheelchairAlert);
graph.streetNotesService.removeStaticNotes(left);
graph.streetNotesService.removeStaticNotes(leftBack);
graph.streetNotesService.addStaticNote(left, wheelchairAlert, StreetNotesService.WHEELCHAIR_MATCHER);
graph.streetNotesService.addStaticNote(leftBack, wheelchairAlert, StreetNotesService.WHEELCHAIR_MATCHER);
req.setWheelchairAccessible(true);
start.dispose();
start = StreetVertexIndexServiceImpl.createTemporaryStreetLocation(graph, "start", new NonLocalizedString("start"), filter(turns, StreetEdge.class), new LinearLocation(0, 0.4).getCoordinate(left.getGeometry()), false);
traversedOne = new State(start, req);
for (Edge e : start.getOutgoing()) {
currentState = e.traverse(traversedOne);
if (currentState != null) {
traversedOne = currentState;
break;
}
}
assertEquals(wheelchairAlerts, graph.streetNotesService.getNotes(traversedOne));
assertNotSame(left, traversedOne.getBackEdge().getFromVertex());
assertNotSame(leftBack, traversedOne.getBackEdge().getFromVertex());
start.dispose();
}
use of org.opentripplanner.util.NonLocalizedString in project OpenTripPlanner by opentripplanner.
the class TestHalfEdges method testRouteToSameEdgeBackwards.
@Test
public void testRouteToSameEdgeBackwards() {
RoutingRequest options = new RoutingRequest();
// Sits only on the leftmost edge, not on its reverse.
HashSet<Edge> turns = new HashSet<Edge>();
turns.add(left);
TemporaryStreetLocation start = StreetVertexIndexServiceImpl.createTemporaryStreetLocation(graph, "start", new NonLocalizedString("start"), filter(turns, StreetEdge.class), new LinearLocation(0, 0.8).getCoordinate(left.getGeometry()), false);
TemporaryStreetLocation end = StreetVertexIndexServiceImpl.createTemporaryStreetLocation(graph, "end", new NonLocalizedString("end"), filter(turns, StreetEdge.class), new LinearLocation(0, 0.4).getCoordinate(left.getGeometry()), true);
assertEquals(start.getX(), end.getX(), 0.001);
assertTrue(start.getY() > end.getY());
Collection<Edge> edges = end.getIncoming();
assertEquals(1, edges.size());
long startTime = TestUtils.dateInSeconds("America/New_York", 2009, 11, 1, 12, 34, 25);
options.dateTime = startTime;
options.setRoutingContext(graph, start, end);
options.setMaxWalkDistance(Double.MAX_VALUE);
ShortestPathTree spt = aStar.getShortestPathTree(options);
GraphPath path = spt.getPath(end, false);
assertNotNull("There must be a path from start to end", path);
assertTrue(path.edges.size() > 1);
options.cleanup();
}
Aggregations