Skip to content

Commit

Permalink
Merge pull request #327 from HSLdevcom/DT-3257
Browse files Browse the repository at this point in the history
Dt 3257
  • Loading branch information
vesameskanen authored Dec 5, 2019
2 parents dd74f1f + 7dfcbc3 commit d60ad21
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 196 deletions.
10 changes: 10 additions & 0 deletions src/main/java/org/opentripplanner/api/common/RoutingResource.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,13 @@ public abstract class RoutingResource {
@QueryParam("maxPreTransitTime")
protected Integer maxPreTransitTime;

/**
* The maximum slope, up or downhill, that can be used in wheelchair accessible routing.
* Value is between 0 and 1, and calculated by dividing change of elevation by change of distance.
*/
@QueryParam("maxSlope")
protected Double maxSlope;

/**
* A multiplier for how bad walking is, compared to being in transit for equal lengths of time.
* Defaults to 2. Empirically, values between 10 and 20 seem to correspond well to the concept
Expand Down Expand Up @@ -537,6 +544,9 @@ protected RoutingRequest buildRequest() throws ParameterException {
if (maxPreTransitTime != null)
request.setMaxPreTransitTime(maxPreTransitTime);

if (maxSlope != null)
request.setMaxSlope(maxSlope);

if(carParkCarLegWeight != null) {
request.setCarParkCarLegWeight(carParkCarLegWeight);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ private RoutingRequest createRequest(DataFetchingEnvironment environment) {
callWith.argument("wheelchair", request::setWheelchairAccessible);
callWith.argument("numItineraries", request::setNumItineraries);
callWith.argument("maxWalkDistance", request::setMaxWalkDistance);
callWith.argument("maxSlope", request::setMaxSlope);
callWith.argument("maxPreTransitTime", request::setMaxPreTransitTime);
callWith.argument("carParkCarLegWeight", request::setCarParkCarLegWeight);
callWith.argument("itineraryFiltering", request::setItineraryFiltering);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,11 @@ public IndexGraphQLSchema(GraphIndex index) {
.description("The maximum time (in seconds) of pre-transit travel when using drive-to-transit (park and ride or kiss and ride). Default value: 1800.")
.type(Scalars.GraphQLInt)
.build())
.argument(GraphQLArgument.newArgument()
.name("maxSlope")
.description("The maximum slope, up or downhill, that can be used in wheelchair accessible routing. Value is between 0 and 1, and calculated by dividing change of elevation by change of distance. Default value: 0.0833333333333")
.type(Scalars.GraphQLFloat)
.build())
.argument(GraphQLArgument.newArgument()
.name("carParkCarLegWeight")
.description("How expensive it is to drive a car when car&parking, increase this value to make car driving legs shorter. Default value: 1.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import org.opentripplanner.analyst.request.TileRequest;
import org.opentripplanner.api.resource.GraphInspectorTileResource;
import org.opentripplanner.inspector.TileRenderer.TileRenderContext;
import org.opentripplanner.routing.core.RoutingRequest;
import org.opentripplanner.routing.graph.Graph;
import org.opentripplanner.routing.services.GraphService;
import org.slf4j.Logger;
Expand Down Expand Up @@ -35,14 +36,14 @@ public class TileRendererManager {

private Graph graph;

public TileRendererManager(Graph graph) {
public TileRendererManager(Graph graph, RoutingRequest routingRequest) {
this.graph = graph;

// Register layers.
renderers.put("bike-safety", new EdgeVertexTileRenderer(new BikeSafetyEdgeRenderer()));
renderers.put("traversal", new EdgeVertexTileRenderer(
new TraversalPermissionsEdgeRenderer()));
renderers.put("wheelchair", new EdgeVertexTileRenderer(new WheelchairEdgeRenderer()));
renderers.put("wheelchair", new EdgeVertexTileRenderer(new WheelchairEdgeRenderer(routingRequest)));
}

public void registerRenderer(String layer, TileRenderer tileRenderer) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.opentripplanner.inspector;

import org.opentripplanner.inspector.EdgeVertexTileRenderer.EdgeVertexRenderer;
import org.opentripplanner.routing.core.RoutingRequest;
import org.opentripplanner.routing.edgetype.StreetEdge;
import org.opentripplanner.routing.graph.Edge;
import org.opentripplanner.routing.graph.Vertex;
Expand All @@ -16,15 +17,16 @@
public class WheelchairEdgeRenderer implements EdgeVertexRenderer {


private ScalarColorPalette slopePalette = new DefaultScalarColorPalette(0.0, 0.08, 1.0);
private ScalarColorPalette slopePalette;


private static final Color NO_WHEELCHAIR_COLOR = Color.RED;
private static final Color YES_WHEELCHAIR_COLOR = Color.GREEN;
private static final Color NO_WHEELCHAIR_INFORMATION_COLOR = Color.ORANGE;


public WheelchairEdgeRenderer() {
public WheelchairEdgeRenderer(RoutingRequest routingRequest) {
this.slopePalette = new DefaultScalarColorPalette(0.0, routingRequest.maxSlope, 1.0);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1431,6 +1431,12 @@ public void setMaxPreTransitTime(int maxPreTransitTime) {
}
}

public void setMaxSlope(double maxSlope) {
if (maxSlope >= 0 && maxSlope <= 1) {
this.maxSlope = maxSlope;
}
}

public void setModeWeight(TraverseMode traverseMode, Double weight) {
if (weight > 0) {
this.modeWeights.put(traverseMode, weight);
Expand Down

This file was deleted.

4 changes: 2 additions & 2 deletions src/main/java/org/opentripplanner/standalone/Router.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,6 @@ public Router(String id, Graph graph) {
*/
public void startup(JsonNode config) {

this.tileRendererManager = new TileRendererManager(this.graph);

// Analyst Modules FIXME make these optional based on JSON?
{
this.tileCache = new TileCache(this.graph);
Expand All @@ -101,6 +99,8 @@ public void startup(JsonNode config) {
this.defaultRoutingRequest = new RoutingRequest();
}

this.tileRendererManager = new TileRendererManager(this.graph, this.defaultRoutingRequest);

/* Apply single timeout. */
JsonNode timeout = config.get("timeout");
if (timeout != null) {
Expand Down

This file was deleted.

0 comments on commit d60ad21

Please sign in to comment.