Skip to content

Commit fa7e7d9

Browse files
authored
Merge pull request TheTransitClock#101 from vsperez/tc_issue_98
Tc issue 98
2 parents a72b95d + a8e7ebe commit fa7e7d9

File tree

21 files changed

+2420
-99
lines changed

21 files changed

+2420
-99
lines changed

transitclock/pom.xml

Lines changed: 90 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2-
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
32
<modelVersion>4.0.0</modelVersion>
43

54
<groupId>TheTransitClock</groupId>
@@ -46,19 +45,17 @@
4645
<artifactId>esri-geometry-api</artifactId>
4746
<version>1.1</version>
4847
</dependency>
49-
<!-- Needed to fix problem with one-jar not working with AWS SDK. Was getting
48+
<!-- Needed to fix problem with one-jar not working with AWS SDK. Was getting
5049
error message "Fatal: Failed to load the internal config for AWS" -->
51-
52-
5350
<dependency>
5451
<groupId>com.simontuffs</groupId>
5552
<artifactId>one-jar-boot</artifactId>
5653
<version>0.97.3</version>
5754
</dependency>
5855

59-
<!-- Database related, including c3p0 production quality connector. Note:
60-
have found that can have problems if don't use similar versions. Can have
61-
trouble finding the c3p0 connection pooler for example if use old hibernate-core
56+
<!-- Database related, including c3p0 production quality connector. Note:
57+
have found that can have problems if don't use similar versions. Can have
58+
trouble finding the c3p0 connection pooler for example if use old hibernate-core
6259
but new c3p0. -->
6360
<dependency>
6461
<groupId>mysql</groupId>
@@ -87,7 +84,7 @@
8784
<version>4.3.9.Final</version>
8885
</dependency>
8986

90-
<!-- hibernate-core loads in really old version of xml-apis so load in
87+
<!-- hibernate-core loads in really old version of xml-apis so load in
9188
newer version explicitly. Otherwise get problems with the Node class. -->
9289
<dependency>
9390
<groupId>xml-apis</groupId>
@@ -108,9 +105,9 @@
108105
<version>1.1.3</version>
109106
</dependency>
110107
<dependency>
111-
<groupId>org.hsqldb</groupId>
112-
<artifactId>hsqldb</artifactId>
113-
<version>2.2.4</version>
108+
<groupId>org.hsqldb</groupId>
109+
<artifactId>hsqldb</artifactId>
110+
<version>2.2.4</version>
114111
</dependency>
115112

116113
<dependency>
@@ -154,7 +151,7 @@
154151
<version>1.2</version>
155152
</dependency>
156153

157-
<!-- I believe not needed <dependency> <groupId>org.apache.lucene</groupId>
154+
<!-- I believe not needed <dependency> <groupId>org.apache.lucene</groupId>
158155
<artifactId>lucene-core</artifactId> <version>3.6.2</version> </dependency> -->
159156

160157
<!-- For JMS for fancy handling of AVL feeds -->
@@ -176,10 +173,10 @@
176173
<version>1.3.0</version>
177174
</dependency>
178175

179-
<!-- For processing JSON. Needed for Amigocloud and other JSON based AVL
180-
feeds. NOTE: the version 20141113 does not work with Java 1.7, which is what
181-
is still the normal version of Java for AWS, at least as of June 2015. Need
182-
to use old version 20140107 which was compiled with Java 1.7 instead of Java
176+
<!-- For processing JSON. Needed for Amigocloud and other JSON based AVL
177+
feeds. NOTE: the version 20141113 does not work with Java 1.7, which is what
178+
is still the normal version of Java for AWS, at least as of June 2015. Need
179+
to use old version 20140107 which was compiled with Java 1.7 instead of Java
183180
1.8 -->
184181
<dependency>
185182
<groupId>org.json</groupId>
@@ -194,7 +191,7 @@
194191
<version>1.1</version>
195192
</dependency>
196193

197-
<!-- For concurrency annotations like @Immutable and @ThreadSave from the
194+
<!-- For concurrency annotations like @Immutable and @ThreadSave from the
198195
"Concurrency in Practice" book need library -->
199196
<dependency>
200197
<groupId>net.jcip</groupId>
@@ -276,6 +273,15 @@
276273
<version>1.11</version>
277274
</dependency>
278275

276+
<!-- OLS regression algorithm -->
277+
<dependency>
278+
<groupId>com.github.haifengl</groupId>
279+
<artifactId>smile-core</artifactId>
280+
<version>1.5.1</version>
281+
</dependency>
282+
283+
284+
279285
</dependencies>
280286

281287
<build>
@@ -434,74 +440,71 @@
434440
<profiles>
435441

436442

437-
<profile>
438-
<id>PredictionsAccuracyIntegrationTest</id>
439-
<build>
440-
<plugins>
441-
<plugin>
442-
<groupId>org.codehaus.mojo</groupId>
443-
<artifactId>truezip-maven-plugin</artifactId>
444-
<version>1.2</version>
445-
<executions>
446-
<execution>
447-
<id>unzip-database</id>
448-
<goals>
449-
<goal>copy</goal>
450-
</goals>
451-
<phase>test</phase>
452-
<configuration>
453-
<verbose>true</verbose>
454-
<fileset>
455-
<directory>${project.basedir}/src/test/resources/database/transitime_test.zip</directory>
456-
<outputDirectory>${project.basedir}/src/test/resources/database/data</outputDirectory>
457-
</fileset>
458-
</configuration>
459-
</execution>
460-
</executions>
461-
</plugin>
462-
<plugin>
463-
<groupId>org.onebusaway.plugins</groupId>
464-
<artifactId>maven-hsqldb-plugin</artifactId>
465-
<!-- version 1.0.1 supports hsqldb 2.3.2 -->
466-
<version>1.0.1</version>
467-
<executions>
468-
<execution>
469-
<id>user-database-start</id>
470-
<phase>test</phase>
471-
<goals>
472-
<goal>run</goal>
473-
</goals>
474-
<configuration>
475-
<deleteOnEntry>true</deleteOnEntry>
476-
<dbName>${project.basedir}/src/test/resources/database/data/transitime_test</dbName>
477-
<port>9001</port>
478-
</configuration>
479-
</execution>
480-
</executions>
481-
</plugin>
482-
<plugin>
483-
<groupId>org.codehaus.mojo</groupId>
484-
<artifactId>exec-maven-plugin</artifactId>
485-
<version>1.1.1</version>
486-
<executions>
487-
<execution>
488-
<phase>test</phase>
489-
<id>test-case-execution</id>
490-
<goals>
491-
<goal>java</goal>
492-
</goals>
493-
<configuration>
494-
<mainClass>org.transitclock.applications.PredictionsAccuracyIntegrationTest</mainClass>
495-
<commandlineArgs>-c
496-
transitime/src/test/resources/transiTimeConfigIntegrationTest.xml
497-
-gtfsDirectoryName transitime/src/test/resources/wmata_gtfs
498-
-storeNewRevs -maxTravelTimeSegmentLength 1000</commandlineArgs>
499-
</configuration>
500-
</execution>
501-
</executions>
502-
</plugin>
503-
</plugins>
504-
</build>
505-
</profile>
443+
<profile>
444+
<id>PredictionsAccuracyIntegrationTest</id>
445+
<build>
446+
<plugins>
447+
<plugin>
448+
<groupId>org.codehaus.mojo</groupId>
449+
<artifactId>truezip-maven-plugin</artifactId>
450+
<version>1.2</version>
451+
<executions>
452+
<execution>
453+
<id>unzip-database</id>
454+
<goals>
455+
<goal>copy</goal>
456+
</goals>
457+
<phase>test</phase>
458+
<configuration>
459+
<verbose>true</verbose>
460+
<fileset>
461+
<directory>${project.basedir}/src/test/resources/database/transitime_test.zip</directory>
462+
<outputDirectory>${project.basedir}/src/test/resources/database/data</outputDirectory>
463+
</fileset>
464+
</configuration>
465+
</execution>
466+
</executions>
467+
</plugin>
468+
<plugin>
469+
<groupId>org.onebusaway.plugins</groupId>
470+
<artifactId>maven-hsqldb-plugin</artifactId>
471+
<!-- version 1.0.1 supports hsqldb 2.3.2 -->
472+
<version>1.0.1</version>
473+
<executions>
474+
<execution>
475+
<id>user-database-start</id>
476+
<phase>test</phase>
477+
<goals>
478+
<goal>run</goal>
479+
</goals>
480+
<configuration>
481+
<deleteOnEntry>true</deleteOnEntry>
482+
<dbName>${project.basedir}/src/test/resources/database/data/transitime_test</dbName>
483+
<port>9001</port>
484+
</configuration>
485+
</execution>
486+
</executions>
487+
</plugin>
488+
<plugin>
489+
<groupId>org.codehaus.mojo</groupId>
490+
<artifactId>exec-maven-plugin</artifactId>
491+
<version>1.1.1</version>
492+
<executions>
493+
<execution>
494+
<phase>test</phase>
495+
<id>test-case-execution</id>
496+
<goals>
497+
<goal>java</goal>
498+
</goals>
499+
<configuration>
500+
<mainClass>org.transitclock.applications.PredictionsAccuracyIntegrationTest</mainClass>
501+
<commandlineArgs>-c transitime/src/test/resources/transiTimeConfigIntegrationTest.xml -gtfsDirectoryName transitime/src/test/resources/wmata_gtfs -storeNewRevs -maxTravelTimeSegmentLength 1000</commandlineArgs>
502+
</configuration>
503+
</execution>
504+
</executions>
505+
</plugin>
506+
</plugins>
507+
</build>
508+
</profile>
506509
</profiles>
507510
</project>

transitclock/src/main/java/org/transitclock/core/headwaygenerator/LastArrivalsHeadwayGenerator.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ public class LastArrivalsHeadwayGenerator implements HeadwayGenerator {
3232
public Headway generate(VehicleState vehicleState) {
3333

3434
try {
35+
36+
if(vehicleState.getMatch().getMatchAtPreviousStop()==null)
37+
return null;
38+
3539
String stopId = vehicleState.getMatch().getMatchAtPreviousStop().getAtStop().getStopId();
3640

3741
long date = vehicleState.getMatch().getAvlTime();

transitclock/src/main/java/org/transitclock/ipc/data/IpcRoute.java

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,23 +217,40 @@ private static IpcDirectionsForRoute createStops(Route dbRoute,
217217
// Determine if UI stop. It is a UI stop if the stopId parameter
218218
// specified and the current stop is after the stopId for a UI
219219
// trip pattern.
220+
TripPattern currentTripPattern=null;
220221
boolean isUiStop = true;
221222
if (stopId != null) {
222223
isUiStop = false;
223224
for (TripPattern tripPattern : uiTripPatterns) {
225+
if(tripPattern.getDirectionId().compareTo(currentDirectionId)==0)
226+
currentTripPattern=tripPattern;
224227
if (tripPattern.isStopAtOrAfterStop(stopId, currentStopId)) {
225228
isUiStop = true;
226229
break;
227230
}
228231
}
229232
}
230-
233+
else
234+
{
235+
for (TripPattern tripPattern : uiTripPatterns) {
236+
if(tripPattern.getDirectionId().compareTo(currentDirectionId)==0)
237+
currentTripPattern=tripPattern;
238+
}
239+
}
240+
Double stopPathLength=null;
241+
if(currentTripPattern!=null)
242+
{
243+
244+
StopPath stopPath = currentTripPattern.getStopPath(currentStopId);
245+
if(stopPath!=null)
246+
stopPathLength=stopPath.getLength();
247+
}
231248
// Create the IpcStop and add it to the list of stops for the
232249
// current direction
233250
Stop stop =
234251
Core.getInstance().getDbConfig().getStop(currentStopId);
235252
IpcStop ipcStop =
236-
new IpcStop(stop, isUiStop, currentDirectionId);
253+
new IpcStop(stop, isUiStop, currentDirectionId,stopPathLength);
237254
ipcStopsForDirection.add(ipcStop);
238255
}
239256
ipcDirections.add(new IpcDirection(dbRoute, currentDirectionId,

transitclock/src/main/java/org/transitclock/ipc/data/IpcShape.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,25 @@ public class IpcShape implements Serializable {
3737
private String headsign;
3838
private List<Location> locations;
3939
private boolean isUiShape;
40+
private double length;
41+
private String directionId;
4042

43+
public String getDirectionId() {
44+
return directionId;
45+
}
46+
47+
public void setDirectionId(String directionId) {
48+
this.directionId = directionId;
49+
}
50+
51+
public double getLength() {
52+
return length;
53+
}
54+
55+
public void setLength(double length) {
56+
this.length = length;
57+
}
58+
4159
// For determining if segment from previous stop path can be
4260
// combined with segment from new stop path.
4361
private static final double MAX_VERTEX_DISTANCE = 3.0;
@@ -48,6 +66,8 @@ public class IpcShape implements Serializable {
4866

4967
IpcShape(TripPattern tripPattern, boolean isUiShape) {
5068
this.tripPatternId = tripPattern.getId();
69+
this.length=tripPattern.getLength();
70+
this.directionId=tripPattern.getDirectionId();
5171
this.headsign = tripPattern.getHeadsign();
5272
this.locations = new ArrayList<Location>();
5373
this.isUiShape = isUiShape;

transitclock/src/main/java/org/transitclock/ipc/data/IpcStop.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,18 +38,28 @@ public class IpcStop implements Serializable {
3838
private final Location loc;
3939
private final boolean isUiStop;
4040
private final String directionId;
41+
private Double stopPathLength;
4142

43+
public Double getStopPathLength() {
44+
return stopPathLength;
45+
}
46+
47+
public void setStopPathLength(Double stopPathLength) {
48+
this.stopPathLength = stopPathLength;
49+
}
50+
4251
private static final long serialVersionUID = 8964112532327897125L;
4352

4453
/********************** Member Functions **************************/
4554

46-
public IpcStop(Stop dbStop, boolean aUiStop, String directionId) {
55+
public IpcStop(Stop dbStop, boolean aUiStop, String directionId, Double stopPathLength) {
4756
this.id = dbStop.getId();
4857
this.name = dbStop.getName();
4958
this.code = dbStop.getCode();
5059
this.loc = dbStop.getLoc();
5160
this.isUiStop = aUiStop;
5261
this.directionId = directionId;
62+
this.stopPathLength=stopPathLength;
5363
}
5464

5565
/**

0 commit comments

Comments
 (0)