Skip to content

Commit

Permalink
change to out-of-area message
Browse files Browse the repository at this point in the history
  • Loading branch information
sdjacobs committed Dec 18, 2017
1 parent a9b460b commit c06ee74
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 30 deletions.
Expand Up @@ -327,8 +327,7 @@ public static GraphBuilder forDirectory(CommandLineParameters params, File dir)
graphBuilder.addModule(new AnnotationsToHTML(params.build, builderParams.maxHtmlAnnotationsPerFile));
}
if (boundaryFile != null) {
graphBuilder.addModule(new OutOfAreaModule(boundaryFile, builderParams.fromPlaceOutOfAreaMessage,
builderParams.toPlaceOutOfAreaMessage));
graphBuilder.addModule(new OutOfAreaModule(boundaryFile, builderParams.outOfAreaMessage));
}
graphBuilder.serializeGraph = ( ! params.inMemory ) || params.preFlight;
return graphBuilder;
Expand Down
Expand Up @@ -27,12 +27,11 @@ public class OutOfAreaModule implements GraphBuilderModule {

private File geojsonFile;

private String startMessage, endMessage;
private String outOfAreaMessage;

public OutOfAreaModule(File geojsonFile, String startMessage, String endMessage) {
public OutOfAreaModule(File geojsonFile, String outOfAreaMessage) {
this.geojsonFile = geojsonFile;
this.startMessage = startMessage;
this.endMessage = endMessage;
this.outOfAreaMessage = outOfAreaMessage;
}

@Override
Expand All @@ -47,8 +46,7 @@ public void buildGraph(Graph graph, HashMap<Class<?>, Object> extra) {
}
OutOfAreaNotesService svc = new OutOfAreaNotesService();
svc.setArea(area);
svc.setStartLocationMessage(startMessage);
svc.setEndLocationMessage(endMessage);
svc.setOutOfAreaMessage(outOfAreaMessage);
graph.outOfAreaNotesService = svc;
}

Expand Down
Expand Up @@ -28,31 +28,22 @@ public class OutOfAreaNotesService implements Serializable {

private Geometry area;

private String startLocationMessage;

private String endLocationMessage;
private String outOfAreaMessage;

public void setArea(Geometry area) {
this.area = area;
}

public void setStartLocationMessage(String startLocationMessage) {
this.startLocationMessage = startLocationMessage;
}

public void setEndLocationMessage(String endLocationMessage) {
this.endLocationMessage = endLocationMessage;
public void setOutOfAreaMessage(String outOfAreaMessage) {
this.outOfAreaMessage = outOfAreaMessage;
}

public Collection<Alert> getAlerts(RoutingRequest request) {
Point fromPoint = GeometryUtils.getGeometryFactory().createPoint(request.rctx.fromVertex.getCoordinate());
Point toPoint = GeometryUtils.getGeometryFactory().createPoint(request.rctx.toVertex.getCoordinate());
Collection<Alert> alerts = new ArrayList<>();
if (!area.contains(fromPoint)) {
alerts.add(Alert.createSimpleAlerts(startLocationMessage));
}
if (!area.contains(toPoint)) {
alerts.add(Alert.createSimpleAlerts(endLocationMessage));
if (!area.contains(fromPoint) || !area.contains(toPoint)) {
alerts.add(Alert.createSimpleAlerts(outOfAreaMessage));
}
return alerts;
}
Expand Down
Expand Up @@ -149,14 +149,10 @@ public class GraphBuilderParameters {
public final boolean createFlexTransfers;

/**
* Message for from-place out of area
* Message for out of area
*/
public final String fromPlaceOutOfAreaMessage;
public final String outOfAreaMessage;

/**
* Message for from-place out of area
*/
public final String toPlaceOutOfAreaMessage;

/**
* Set all parameters from the given Jackson JSON tree, applying defaults.
Expand Down Expand Up @@ -191,8 +187,7 @@ public GraphBuilderParameters(JsonNode config) {
banDiscouragedWalking = config.path("banDiscouragedWalking").asBoolean(false);
banDiscouragedBiking = config.path("banDiscouragedBiking").asBoolean(false);
createFlexTransfers = config.path("createFlexTransfers").asBoolean(false);
fromPlaceOutOfAreaMessage = config.path("fromPlaceOutOfAreaMessage").asText("From place out of area.");
toPlaceOutOfAreaMessage = config.path("toPlaceOutOfAreaMessage").asText("To place out of area");
outOfAreaMessage = config.path("outOfAreaMessage").asText("One or more endpoints is out of area.");
}

}

0 comments on commit c06ee74

Please sign in to comment.