Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tc issue 98 #101

Merged
merged 7 commits into from
Sep 7, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
177 changes: 90 additions & 87 deletions transitclock/pom.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<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">
<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">
<modelVersion>4.0.0</modelVersion>

<groupId>TheTransitClock</groupId>
Expand Down Expand Up @@ -46,19 +45,17 @@
<artifactId>esri-geometry-api</artifactId>
<version>1.1</version>
</dependency>
<!-- Needed to fix problem with one-jar not working with AWS SDK. Was getting
<!-- Needed to fix problem with one-jar not working with AWS SDK. Was getting
error message "Fatal: Failed to load the internal config for AWS" -->


<dependency>
<groupId>com.simontuffs</groupId>
<artifactId>one-jar-boot</artifactId>
<version>0.97.3</version>
</dependency>

<!-- Database related, including c3p0 production quality connector. Note:
have found that can have problems if don't use similar versions. Can have
trouble finding the c3p0 connection pooler for example if use old hibernate-core
<!-- Database related, including c3p0 production quality connector. Note:
have found that can have problems if don't use similar versions. Can have
trouble finding the c3p0 connection pooler for example if use old hibernate-core
but new c3p0. -->
<dependency>
<groupId>mysql</groupId>
Expand Down Expand Up @@ -87,7 +84,7 @@
<version>4.3.9.Final</version>
</dependency>

<!-- hibernate-core loads in really old version of xml-apis so load in
<!-- hibernate-core loads in really old version of xml-apis so load in
newer version explicitly. Otherwise get problems with the Node class. -->
<dependency>
<groupId>xml-apis</groupId>
Expand All @@ -108,9 +105,9 @@
<version>1.1.3</version>
</dependency>
<dependency>
<groupId>org.hsqldb</groupId>
<artifactId>hsqldb</artifactId>
<version>2.2.4</version>
<groupId>org.hsqldb</groupId>
<artifactId>hsqldb</artifactId>
<version>2.2.4</version>
</dependency>

<dependency>
Expand Down Expand Up @@ -154,7 +151,7 @@
<version>1.2</version>
</dependency>

<!-- I believe not needed <dependency> <groupId>org.apache.lucene</groupId>
<!-- I believe not needed <dependency> <groupId>org.apache.lucene</groupId>
<artifactId>lucene-core</artifactId> <version>3.6.2</version> </dependency> -->

<!-- For JMS for fancy handling of AVL feeds -->
Expand All @@ -176,10 +173,10 @@
<version>1.3.0</version>
</dependency>

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

<!-- For concurrency annotations like @Immutable and @ThreadSave from the
<!-- For concurrency annotations like @Immutable and @ThreadSave from the
"Concurrency in Practice" book need library -->
<dependency>
<groupId>net.jcip</groupId>
Expand Down Expand Up @@ -276,6 +273,15 @@
<version>1.11</version>
</dependency>

<!-- OLS regression algorithm -->
<dependency>
<groupId>com.github.haifengl</groupId>
<artifactId>smile-core</artifactId>
<version>1.5.1</version>
</dependency>



</dependencies>

<build>
Expand Down Expand Up @@ -434,74 +440,71 @@
<profiles>


<profile>
<id>PredictionsAccuracyIntegrationTest</id>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>truezip-maven-plugin</artifactId>
<version>1.2</version>
<executions>
<execution>
<id>unzip-database</id>
<goals>
<goal>copy</goal>
</goals>
<phase>test</phase>
<configuration>
<verbose>true</verbose>
<fileset>
<directory>${project.basedir}/src/test/resources/database/transitime_test.zip</directory>
<outputDirectory>${project.basedir}/src/test/resources/database/data</outputDirectory>
</fileset>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.onebusaway.plugins</groupId>
<artifactId>maven-hsqldb-plugin</artifactId>
<!-- version 1.0.1 supports hsqldb 2.3.2 -->
<version>1.0.1</version>
<executions>
<execution>
<id>user-database-start</id>
<phase>test</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<deleteOnEntry>true</deleteOnEntry>
<dbName>${project.basedir}/src/test/resources/database/data/transitime_test</dbName>
<port>9001</port>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.1.1</version>
<executions>
<execution>
<phase>test</phase>
<id>test-case-execution</id>
<goals>
<goal>java</goal>
</goals>
<configuration>
<mainClass>org.transitclock.applications.PredictionsAccuracyIntegrationTest</mainClass>
<commandlineArgs>-c
transitime/src/test/resources/transiTimeConfigIntegrationTest.xml
-gtfsDirectoryName transitime/src/test/resources/wmata_gtfs
-storeNewRevs -maxTravelTimeSegmentLength 1000</commandlineArgs>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>PredictionsAccuracyIntegrationTest</id>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>truezip-maven-plugin</artifactId>
<version>1.2</version>
<executions>
<execution>
<id>unzip-database</id>
<goals>
<goal>copy</goal>
</goals>
<phase>test</phase>
<configuration>
<verbose>true</verbose>
<fileset>
<directory>${project.basedir}/src/test/resources/database/transitime_test.zip</directory>
<outputDirectory>${project.basedir}/src/test/resources/database/data</outputDirectory>
</fileset>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.onebusaway.plugins</groupId>
<artifactId>maven-hsqldb-plugin</artifactId>
<!-- version 1.0.1 supports hsqldb 2.3.2 -->
<version>1.0.1</version>
<executions>
<execution>
<id>user-database-start</id>
<phase>test</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<deleteOnEntry>true</deleteOnEntry>
<dbName>${project.basedir}/src/test/resources/database/data/transitime_test</dbName>
<port>9001</port>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.1.1</version>
<executions>
<execution>
<phase>test</phase>
<id>test-case-execution</id>
<goals>
<goal>java</goal>
</goals>
<configuration>
<mainClass>org.transitclock.applications.PredictionsAccuracyIntegrationTest</mainClass>
<commandlineArgs>-c transitime/src/test/resources/transiTimeConfigIntegrationTest.xml -gtfsDirectoryName transitime/src/test/resources/wmata_gtfs -storeNewRevs -maxTravelTimeSegmentLength 1000</commandlineArgs>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ public class LastArrivalsHeadwayGenerator implements HeadwayGenerator {
public Headway generate(VehicleState vehicleState) {

try {

if(vehicleState.getMatch().getMatchAtPreviousStop()==null)
return null;

String stopId = vehicleState.getMatch().getMatchAtPreviousStop().getAtStop().getStopId();

long date = vehicleState.getMatch().getAvlTime();
Expand Down
21 changes: 19 additions & 2 deletions transitclock/src/main/java/org/transitclock/ipc/data/IpcRoute.java
Original file line number Diff line number Diff line change
Expand Up @@ -217,23 +217,40 @@ private static IpcDirectionsForRoute createStops(Route dbRoute,
// Determine if UI stop. It is a UI stop if the stopId parameter
// specified and the current stop is after the stopId for a UI
// trip pattern.
TripPattern currentTripPattern=null;
boolean isUiStop = true;
if (stopId != null) {
isUiStop = false;
for (TripPattern tripPattern : uiTripPatterns) {
if(tripPattern.getDirectionId().compareTo(currentDirectionId)==0)
currentTripPattern=tripPattern;
if (tripPattern.isStopAtOrAfterStop(stopId, currentStopId)) {
isUiStop = true;
break;
}
}
}

else
{
for (TripPattern tripPattern : uiTripPatterns) {
if(tripPattern.getDirectionId().compareTo(currentDirectionId)==0)
currentTripPattern=tripPattern;
}
}
Double stopPathLength=null;
if(currentTripPattern!=null)
{

StopPath stopPath = currentTripPattern.getStopPath(currentStopId);
if(stopPath!=null)
stopPathLength=stopPath.getLength();
}
// Create the IpcStop and add it to the list of stops for the
// current direction
Stop stop =
Core.getInstance().getDbConfig().getStop(currentStopId);
IpcStop ipcStop =
new IpcStop(stop, isUiStop, currentDirectionId);
new IpcStop(stop, isUiStop, currentDirectionId,stopPathLength);
ipcStopsForDirection.add(ipcStop);
}
ipcDirections.add(new IpcDirection(dbRoute, currentDirectionId,
Expand Down
20 changes: 20 additions & 0 deletions transitclock/src/main/java/org/transitclock/ipc/data/IpcShape.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,25 @@ public class IpcShape implements Serializable {
private String headsign;
private List<Location> locations;
private boolean isUiShape;
private double length;
private String directionId;

public String getDirectionId() {
return directionId;
}

public void setDirectionId(String directionId) {
this.directionId = directionId;
}

public double getLength() {
return length;
}

public void setLength(double length) {
this.length = length;
}

// For determining if segment from previous stop path can be
// combined with segment from new stop path.
private static final double MAX_VERTEX_DISTANCE = 3.0;
Expand All @@ -48,6 +66,8 @@ public class IpcShape implements Serializable {

IpcShape(TripPattern tripPattern, boolean isUiShape) {
this.tripPatternId = tripPattern.getId();
this.length=tripPattern.getLength();
this.directionId=tripPattern.getDirectionId();
this.headsign = tripPattern.getHeadsign();
this.locations = new ArrayList<Location>();
this.isUiShape = isUiShape;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,28 @@ public class IpcStop implements Serializable {
private final Location loc;
private final boolean isUiStop;
private final String directionId;
private Double stopPathLength;

public Double getStopPathLength() {
return stopPathLength;
}

public void setStopPathLength(Double stopPathLength) {
this.stopPathLength = stopPathLength;
}

private static final long serialVersionUID = 8964112532327897125L;

/********************** Member Functions **************************/

public IpcStop(Stop dbStop, boolean aUiStop, String directionId) {
public IpcStop(Stop dbStop, boolean aUiStop, String directionId, Double stopPathLength) {
this.id = dbStop.getId();
this.name = dbStop.getName();
this.code = dbStop.getCode();
this.loc = dbStop.getLoc();
this.isUiStop = aUiStop;
this.directionId = directionId;
this.stopPathLength=stopPathLength;
}

/**
Expand Down
Loading