Skip to content

Commit b1364f4

Browse files
committed
feat: added access/egress option to endpoint
1 parent b5c6c1b commit b1364f4

File tree

1 file changed

+36
-7
lines changed

1 file changed

+36
-7
lines changed

web-bundle/src/main/java/com/graphhopper/resources/PtIsochroneResource.java

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@
1919
package com.graphhopper.resources;
2020

2121
import com.conveyal.gtfs.model.Stop;
22+
import com.graphhopper.GraphHopper;
2223
import com.graphhopper.gtfs.*;
24+
import com.graphhopper.http.DurationParam;
2325
import com.graphhopper.http.GHLocationParam;
2426
import com.graphhopper.http.OffsetDateTimeParam;
2527
import com.graphhopper.isochrone.algorithm.ContourBuilder;
@@ -35,6 +37,7 @@
3537
import com.graphhopper.storage.index.LocationIndex;
3638
import com.graphhopper.util.EdgeIteratorState;
3739
import com.graphhopper.util.JsonFeature;
40+
import com.graphhopper.util.PMap;
3841
import com.graphhopper.util.shapes.BBox;
3942
import org.locationtech.jts.geom.*;
4043
import org.locationtech.jts.triangulate.ConformingDelaunayTriangulator;
@@ -43,6 +46,8 @@
4346
import org.locationtech.jts.triangulate.quadedge.QuadEdge;
4447
import org.locationtech.jts.triangulate.quadedge.QuadEdgeSubdivision;
4548
import org.locationtech.jts.triangulate.quadedge.Vertex;
49+
import org.slf4j.Logger;
50+
import org.slf4j.LoggerFactory;
4651

4752
import javax.inject.Inject;
4853
import javax.validation.constraints.NotNull;
@@ -55,7 +60,7 @@
5560
public class PtIsochroneResource {
5661

5762
private static final double JTS_TOLERANCE = 0.00001;
58-
63+
private static final Logger logger = LoggerFactory.getLogger(GraphHopper.class); // TODO: Remove.
5964
private final GtfsStorage gtfsStorage;
6065
private final EncodingManager encodingManager;
6166
private final BaseGraph baseGraph;
@@ -85,21 +90,45 @@ public Response doGet(
8590
@QueryParam("time_limit") @DefaultValue("600") long seconds,
8691
@QueryParam("reverse_flow") @DefaultValue("false") boolean reverseFlow,
8792
@QueryParam("pt.earliest_departure_time") @NotNull OffsetDateTimeParam departureTimeParam,
93+
@QueryParam("pt.access_profile") @DefaultValue("foot") String accessProfile,
94+
// @QueryParam("pt.beta_access_time") @DefaultValue("PT30M") Double betaAccessTime,
95+
@QueryParam("pt.egress_profile") @DefaultValue("foot") String egressProfile,
96+
// @QueryParam("pt.beta_egress_time") @DefaultValue("false") Double betaEgressTime,
97+
@QueryParam("pt.limit_street_time") @DefaultValue("PT30M") DurationParam limitStreetTimeParam,
8898
@QueryParam("pt.blocked_route_types") @DefaultValue("0") int blockedRouteTypes,
8999
@QueryParam("result") @DefaultValue("multipolygon") String format) {
90100
Instant initialTime = departureTimeParam.get().toInstant();
91101
GHLocation location = sourceParam.get();
92102

103+
// TODO: Remove
104+
logger.warn(accessProfile);
105+
106+
// accessProfile = config.getProfiles().stream().filter(p -> p.getName().equals(request.getAccessProfile())).findFirst().get();
107+
// accessWeighting = weightingFactory.createWeighting(accessProfile, new PMap(), false);
108+
// accessSnapFilter = new DefaultSnapFilter(accessWeighting, encodingManager.getBooleanEncodedValue(Subnetwork.key(accessProfile.getName())));
109+
// egressProfile = config.getProfiles().stream().filter(p -> p.getName().equals(request.getEgressProfile())).findFirst().get();
110+
// egressWeighting = weightingFactory.createWeighting(egressProfile, new PMap(), false);
111+
// egressSnapFilter = new DefaultSnapFilter(egressWeighting, encodingManager.getBooleanEncodedValue(Subnetwork.key(egressProfile.getName())));
112+
113+
// PtLocationSnapper.Result result = new PtLocationSnapper(baseGraph, locationIndex, gtfsStorage).snapAll(Arrays.asList(enter, exit), Arrays.asList(accessSnapFilter, egressSnapFilter));
114+
93115
double targetZ = seconds * 1000;
94116

95117
GeometryFactory geometryFactory = new GeometryFactory();
96-
BooleanEncodedValue accessEnc = encodingManager.getBooleanEncodedValue(VehicleAccess.key("foot"));
97-
DecimalEncodedValue speedEnc = encodingManager.getDecimalEncodedValue(VehicleSpeed.key("foot"));
98-
final Weighting weighting = new FastestWeighting(accessEnc, speedEnc);
99-
DefaultSnapFilter snapFilter = new DefaultSnapFilter(weighting, encodingManager.getBooleanEncodedValue(Subnetwork.key("foot")));
100118

101-
PtLocationSnapper.Result snapResult = new PtLocationSnapper(baseGraph, locationIndex, gtfsStorage).snapAll(Arrays.asList(location), Arrays.asList(snapFilter));
102-
GraphExplorer graphExplorer = new GraphExplorer(snapResult.queryGraph, gtfsStorage.getPtGraph(), weighting, gtfsStorage, RealtimeFeed.empty(), reverseFlow, false, false, 5.0, reverseFlow, blockedRouteTypes);
119+
BooleanEncodedValue accessProfileEnc = encodingManager.getBooleanEncodedValue(VehicleAccess.key(accessProfile));
120+
DecimalEncodedValue accessSpeedEnc = encodingManager.getDecimalEncodedValue(VehicleSpeed.key(accessProfile));
121+
final Weighting accessWeighting = new FastestWeighting(accessProfileEnc, accessSpeedEnc);
122+
DefaultSnapFilter accessSnapFilter = new DefaultSnapFilter(accessWeighting, encodingManager.getBooleanEncodedValue(Subnetwork.key(accessProfile)));
123+
BooleanEncodedValue egressProfileEnc = encodingManager.getBooleanEncodedValue(VehicleAccess.key(egressProfile));
124+
DecimalEncodedValue egressSpeedEnc = encodingManager.getDecimalEncodedValue(VehicleSpeed.key(egressProfile));
125+
final Weighting egressWeighting = new FastestWeighting(egressProfileEnc, egressSpeedEnc);
126+
DefaultSnapFilter egressSnapFilter = new DefaultSnapFilter(egressWeighting, encodingManager.getBooleanEncodedValue(Subnetwork.key(egressProfile)));
127+
128+
PtLocationSnapper.Result snapResult = new PtLocationSnapper(baseGraph, locationIndex, gtfsStorage).snapAll(Arrays.asList(location), Arrays.asList(accessSnapFilter, egressSnapFilter));
129+
130+
// TODO: Should also incorporate egressWeighting in some way.
131+
GraphExplorer graphExplorer = new GraphExplorer(snapResult.queryGraph, gtfsStorage.getPtGraph(), accessWeighting, gtfsStorage, RealtimeFeed.empty(), reverseFlow, false, false, 5.0, reverseFlow, blockedRouteTypes);
103132
MultiCriteriaLabelSetting router = new MultiCriteriaLabelSetting(graphExplorer, reverseFlow, false, false, 0, Collections.emptyList());
104133

105134
Map<Coordinate, Double> z1 = new HashMap<>();

0 commit comments

Comments
 (0)