Skip to content

Commit 91ca93d

Browse files
authored
Merge pull request graphhopper#1018 from graphhopper/pt-merge
Public Transit
2 parents cfbf784 + 1b41583 commit 91ca93d

File tree

114 files changed

+6601
-747
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

114 files changed

+6601
-747
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,4 @@ local.properties
4343
/reader-overlay-data/nbproject/
4444
!malta-latest.osm.pbf
4545
/reader-json/nbproject/
46+
/graph-cache

core/pom.xml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,23 @@
7575
<version>2.1</version>
7676
</dependency>
7777

78+
<dependency>
79+
<groupId>com.fasterxml.jackson.core</groupId>
80+
<artifactId>jackson-annotations</artifactId>
81+
<version>${jackson.version}</version>
82+
</dependency>
7883
<dependency>
7984
<groupId>org.json</groupId>
8085
<artifactId>json</artifactId>
8186
<version>${json.org.version}</version>
8287
<scope>test</scope>
8388
</dependency>
89+
<dependency>
90+
<groupId>com.vividsolutions</groupId>
91+
<artifactId>jts</artifactId>
92+
<version>1.13</version>
93+
</dependency>
94+
8495
</dependencies>
8596

8697
<build>

core/src/main/java/com/graphhopper/PathWrapper.java

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import com.graphhopper.util.PointList;
2222
import com.graphhopper.util.shapes.BBox;
2323

24+
import java.math.BigDecimal;
2425
import java.util.ArrayList;
2526
import java.util.Collections;
2627
import java.util.List;
@@ -43,6 +44,10 @@ public class PathWrapper {
4344
private InstructionList instructions;
4445
private PointList waypointList = PointList.EMPTY;
4546
private PointList pointList = PointList.EMPTY;
47+
private int numChanges;
48+
private long firstPtLegDeparture;
49+
private final List<Trip.Leg> legs = new ArrayList<>();
50+
private BigDecimal fare;
4651

4752
/**
4853
* @return the description of this route alternative to make it meaningful for the user e.g. it
@@ -265,4 +270,28 @@ public PathWrapper addErrors(List<Throwable> errors) {
265270
this.errors.addAll(errors);
266271
return this;
267272
}
273+
274+
public void setNumChanges(int numChanges) {
275+
this.numChanges = numChanges;
276+
}
277+
278+
public int getNumChanges() {
279+
return numChanges;
280+
}
281+
282+
public void setFirstPtLegDeparture(long firstPtLegDeparture) {
283+
this.firstPtLegDeparture = firstPtLegDeparture;
284+
}
285+
286+
public List<Trip.Leg> getLegs() {
287+
return legs;
288+
}
289+
290+
public void setFare(BigDecimal fare) {
291+
this.fare = fare;
292+
}
293+
294+
public BigDecimal getFare() {
295+
return fare;
296+
}
268297
}
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
package com.graphhopper;
2+
3+
import com.graphhopper.util.EdgeIteratorState;
4+
import com.graphhopper.util.InstructionList;
5+
import com.vividsolutions.jts.geom.Geometry;
6+
import com.vividsolutions.jts.geom.Point;
7+
8+
import java.util.Date;
9+
import java.util.List;
10+
11+
public class Trip {
12+
public static abstract class Leg {
13+
public final String type;
14+
public final String departureLocation;
15+
public final List<EdgeIteratorState> edges;
16+
public final Geometry geometry;
17+
18+
public final double distance;
19+
20+
public Leg(String type, String departureLocation, List<EdgeIteratorState> edges, Geometry geometry, double distance) {
21+
this.type = type;
22+
this.departureLocation = departureLocation;
23+
this.edges = edges;
24+
this.geometry = geometry;
25+
this.distance = distance;
26+
}
27+
28+
public double getDistance() {
29+
return distance;
30+
}
31+
}
32+
33+
public static class Stop {
34+
public final String stop_id;
35+
public final String name;
36+
public final Point geometry;
37+
38+
public Stop(String stop_id, String name, Point geometry) {
39+
this.stop_id = stop_id;
40+
this.name = name;
41+
this.geometry = geometry;
42+
}
43+
}
44+
public static class WalkLeg extends Leg {
45+
public final InstructionList instructions;
46+
47+
public WalkLeg(String departureLocation, List<EdgeIteratorState> edges, Geometry geometry, double distance, InstructionList instructions) {
48+
super("walk", departureLocation, edges, geometry, distance);
49+
this.instructions = instructions;
50+
}
51+
}
52+
public static class PtLeg extends Leg {
53+
public final String feedId;
54+
public final boolean isInSameVehicleAsPrevious;
55+
public final String trip_headsign;
56+
public final Date departureTime; // TODO: Java 8: Should be LocalDateTime
57+
public final long travelTime;
58+
public final List<Stop> stops;
59+
public final Stop boardStop;
60+
public final String tripId;
61+
public final String routeId;
62+
63+
public PtLeg(String feedId, boolean isInSameVehicleAsPrevious, Stop stop, String tripId, String routeId, List<EdgeIteratorState> edges, Date departureTime, List<Stop> stops, double distance, long travelTime, Geometry geometry) {
64+
super("pt", stop.name, edges, geometry, distance);
65+
this.feedId = feedId;
66+
this.isInSameVehicleAsPrevious = isInSameVehicleAsPrevious;
67+
this.boardStop = stop;
68+
this.tripId = tripId;
69+
this.routeId = routeId;
70+
this.trip_headsign = edges.get(0).getName();
71+
this.departureTime = departureTime;
72+
this.travelTime = travelTime;
73+
this.stops = stops;
74+
}
75+
76+
}
77+
78+
}

0 commit comments

Comments
 (0)