From 7dda2dcba885dec28cf6d28e908e60a92ac7f423 Mon Sep 17 00:00:00 2001 From: Zsombor Welker Date: Sat, 14 Nov 2015 20:34:01 +0100 Subject: [PATCH 1/2] fixes to work with traffic-engine 0.3 --- pom.xml | 2 +- .../traffic/app/TrafficEngineApp.java | 62 ++++++++++--------- .../traffic/app/data/TrafficPath.java | 4 +- .../traffic/app/data/TrafficPathEdge.java | 4 +- .../traffic/app/data/WeeklyStatsObject.java | 4 +- .../conveyal/traffic/app/engine/Engine.java | 14 ++--- .../conveyal/traffic/app/routing/Routing.java | 6 +- .../traffic/app/tiles/TrafficTileRequest.java | 8 +-- 8 files changed, 55 insertions(+), 49 deletions(-) diff --git a/pom.xml b/pom.xml index 838acdb..4e21b8e 100644 --- a/pom.xml +++ b/pom.xml @@ -125,7 +125,7 @@ 12.2 - com.conveyal + io.opentraffic traffic-engine 0.3 diff --git a/src/main/java/com/conveyal/traffic/app/TrafficEngineApp.java b/src/main/java/com/conveyal/traffic/app/TrafficEngineApp.java index d8e3eb7..f22755b 100644 --- a/src/main/java/com/conveyal/traffic/app/TrafficEngineApp.java +++ b/src/main/java/com/conveyal/traffic/app/TrafficEngineApp.java @@ -1,45 +1,51 @@ package com.conveyal.traffic.app; -import java.awt.Rectangle; -import java.io.FileInputStream; -import java.io.IOException; -import java.nio.ByteBuffer; -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; -import java.time.LocalDateTime; -import java.time.OffsetDateTime; -import java.time.ZoneOffset; -import java.time.temporal.ChronoField; -import java.util.*; -import java.util.logging.Level; -import java.util.logging.Logger; -import java.util.stream.Collectors; - +import com.conveyal.traffic.app.data.StatsObject; import com.conveyal.traffic.app.data.TrafficPath; import com.conveyal.traffic.app.data.WeekObject; import com.conveyal.traffic.app.data.WeeklyStatsObject; import com.conveyal.traffic.app.engine.Engine; -import com.conveyal.traffic.data.SpatialDataItem; -import com.conveyal.traffic.data.stats.SummaryStatistics; -import com.conveyal.traffic.data.stats.SummaryStatisticsComparison; -import com.conveyal.traffic.geom.StreetSegment; -import com.conveyal.traffic.data.stats.SegmentStatistics; +import com.conveyal.traffic.app.routing.Routing; +import com.conveyal.traffic.app.tiles.TrafficTileRequest.DataTile; +import com.conveyal.traffic.app.tiles.TrafficTileRequest.SegmentTile; +import com.fasterxml.jackson.databind.ObjectMapper; import com.vividsolutions.jts.geom.Envelope; +import io.opentraffic.engine.data.SpatialDataItem; +import io.opentraffic.engine.data.pbf.ExchangeFormat; +import io.opentraffic.engine.data.stats.SegmentStatistics; +import io.opentraffic.engine.data.stats.SummaryStatistics; +import io.opentraffic.engine.data.stats.SummaryStatisticsComparison; +import io.opentraffic.engine.geom.GPSPoint; +import io.opentraffic.engine.geom.StreetSegment; import org.mapdb.Fun; import org.opentripplanner.common.model.GenericLocation; import org.opentripplanner.routing.core.RoutingRequest; import org.opentripplanner.routing.core.TraverseMode; import org.opentripplanner.routing.core.TraverseModeSet; -import com.conveyal.traffic.data.pbf.ExchangeFormat; -import com.conveyal.traffic.geom.GPSPoint; -import com.conveyal.traffic.app.data.StatsObject; -import com.conveyal.traffic.app.routing.Routing; -import com.conveyal.traffic.app.tiles.TrafficTileRequest.DataTile; -import com.conveyal.traffic.app.tiles.TrafficTileRequest.SegmentTile; -import com.fasterxml.jackson.databind.ObjectMapper; +import java.awt.*; +import java.io.FileInputStream; +import java.io.IOException; +import java.nio.ByteBuffer; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; +import java.time.LocalDateTime; +import java.time.OffsetDateTime; +import java.time.ZoneOffset; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Properties; +import java.util.Set; +import java.util.logging.Level; +import java.util.logging.Logger; +import java.util.stream.Collectors; -import static spark.Spark.*; +import static spark.Spark.get; +import static spark.Spark.post; +import static spark.Spark.staticFileLocation; public class TrafficEngineApp { diff --git a/src/main/java/com/conveyal/traffic/app/data/TrafficPath.java b/src/main/java/com/conveyal/traffic/app/data/TrafficPath.java index 1fd27a6..5838efc 100644 --- a/src/main/java/com/conveyal/traffic/app/data/TrafficPath.java +++ b/src/main/java/com/conveyal/traffic/app/data/TrafficPath.java @@ -1,7 +1,7 @@ package com.conveyal.traffic.app.data; -import com.conveyal.traffic.data.stats.SummaryStatistics; -import com.conveyal.traffic.geom.StreetSegment; +import io.opentraffic.engine.data.stats.SummaryStatistics; +import io.opentraffic.engine.geom.StreetSegment; import java.util.ArrayList; import java.util.List; diff --git a/src/main/java/com/conveyal/traffic/app/data/TrafficPathEdge.java b/src/main/java/com/conveyal/traffic/app/data/TrafficPathEdge.java index 9fd43d5..4c41aeb 100644 --- a/src/main/java/com/conveyal/traffic/app/data/TrafficPathEdge.java +++ b/src/main/java/com/conveyal/traffic/app/data/TrafficPathEdge.java @@ -1,7 +1,7 @@ package com.conveyal.traffic.app.data; -import com.conveyal.traffic.data.stats.SummaryStatistics; -import com.conveyal.traffic.geom.StreetSegment; +import io.opentraffic.engine.data.stats.SummaryStatistics; +import io.opentraffic.engine.geom.StreetSegment; import org.jcolorbrewer.ColorBrewer; import org.opentripplanner.util.PolylineEncoder; import org.opentripplanner.util.model.EncodedPolylineBean; diff --git a/src/main/java/com/conveyal/traffic/app/data/WeeklyStatsObject.java b/src/main/java/com/conveyal/traffic/app/data/WeeklyStatsObject.java index fb5094d..64f64fd 100644 --- a/src/main/java/com/conveyal/traffic/app/data/WeeklyStatsObject.java +++ b/src/main/java/com/conveyal/traffic/app/data/WeeklyStatsObject.java @@ -1,7 +1,7 @@ package com.conveyal.traffic.app.data; -import com.conveyal.traffic.data.stats.SummaryStatistics; -import com.conveyal.traffic.data.stats.SummaryStatisticsComparison; +import io.opentraffic.engine.data.stats.SummaryStatistics; +import io.opentraffic.engine.data.stats.SummaryStatisticsComparison; public class WeeklyStatsObject { diff --git a/src/main/java/com/conveyal/traffic/app/engine/Engine.java b/src/main/java/com/conveyal/traffic/app/engine/Engine.java index 5663162..4b51ca5 100644 --- a/src/main/java/com/conveyal/traffic/app/engine/Engine.java +++ b/src/main/java/com/conveyal/traffic/app/engine/Engine.java @@ -1,16 +1,16 @@ package com.conveyal.traffic.app.engine; +import com.conveyal.traffic.app.TrafficEngineApp; +import com.vividsolutions.jts.geom.Point; +import io.opentraffic.engine.TrafficEngine; +import io.opentraffic.engine.geom.GPSPoint; +import io.opentraffic.engine.osm.OSMArea; + import java.io.File; -import java.util.*; +import java.util.HashMap; import java.util.logging.Level; import java.util.logging.Logger; -import com.conveyal.traffic.TrafficEngine; -import com.conveyal.traffic.app.TrafficEngineApp; -import com.conveyal.traffic.geom.GPSPoint; -import com.conveyal.traffic.osm.OSMArea; -import com.vividsolutions.jts.geom.Point; - public class Engine { diff --git a/src/main/java/com/conveyal/traffic/app/routing/Routing.java b/src/main/java/com/conveyal/traffic/app/routing/Routing.java index 23df380..bc47e64 100644 --- a/src/main/java/com/conveyal/traffic/app/routing/Routing.java +++ b/src/main/java/com/conveyal/traffic/app/routing/Routing.java @@ -2,9 +2,9 @@ import com.beust.jcommander.internal.Maps; -import com.conveyal.traffic.data.SpatialDataItem; -import com.conveyal.traffic.geom.StreetSegment; -import com.conveyal.traffic.data.stats.SummaryStatistics; +import io.opentraffic.engine.data.SpatialDataItem; +import io.opentraffic.engine.geom.StreetSegment; +import io.opentraffic.engine.data.stats.SummaryStatistics; import com.conveyal.traffic.app.TrafficEngineApp; import com.google.common.collect.Lists; import com.vividsolutions.jts.geom.Envelope; diff --git a/src/main/java/com/conveyal/traffic/app/tiles/TrafficTileRequest.java b/src/main/java/com/conveyal/traffic/app/tiles/TrafficTileRequest.java index a5c7acb..c88825c 100644 --- a/src/main/java/com/conveyal/traffic/app/tiles/TrafficTileRequest.java +++ b/src/main/java/com/conveyal/traffic/app/tiles/TrafficTileRequest.java @@ -1,9 +1,9 @@ package com.conveyal.traffic.app.tiles; -import com.conveyal.traffic.data.SpatialDataItem; -import com.conveyal.traffic.data.stats.SummaryStatisticsComparison; -import com.conveyal.traffic.geom.StreetSegment; -import com.conveyal.traffic.data.stats.SummaryStatistics; +import io.opentraffic.engine.data.SpatialDataItem; +import io.opentraffic.engine.data.stats.SummaryStatisticsComparison; +import io.opentraffic.engine.geom.StreetSegment; +import io.opentraffic.engine.data.stats.SummaryStatistics; import com.conveyal.traffic.app.TrafficEngineApp; import com.google.common.base.Charsets; import com.google.common.hash.HashCode; From 97c937ae7ad1f35d5892bc72018105ec7c15b4cb Mon Sep 17 00:00:00 2001 From: Zsombor Welker Date: Sat, 14 Nov 2015 20:34:19 +0100 Subject: [PATCH 2/2] parse numberOfWorkerCores config correctly --- src/main/java/com/conveyal/traffic/app/engine/Engine.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/conveyal/traffic/app/engine/Engine.java b/src/main/java/com/conveyal/traffic/app/engine/Engine.java index 4b51ca5..d3aadc3 100644 --- a/src/main/java/com/conveyal/traffic/app/engine/Engine.java +++ b/src/main/java/com/conveyal/traffic/app/engine/Engine.java @@ -38,7 +38,7 @@ public Engine() { Integer numberOfWorkerCores; try { - numberOfWorkerCores = Integer.parseInt(TrafficEngineApp.appProps.getProperty("writeStatistics")); + numberOfWorkerCores = Integer.parseInt(TrafficEngineApp.appProps.getProperty("application.numberOfWorkerCores")); } catch(Exception e) { numberOfWorkerCores = Runtime.getRuntime().availableProcessors() / 2; log.log(Level.INFO, "Property numberOfWorkerCores not set, defaulting to " + numberOfWorkerCores + " cores.");