Skip to content
Open
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
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ Run map matching system
java -jar [path/to]/sharedstreets-matcher-1.1.jar --input ./event_data --output ./output_tiles --debug ./debug
```

SharedStreets map tiles will be downloaded and cached as the matcher runs. By default tiles will be cached in `/tmp/shst_tiles/` but this path can be overriden by using the `--tmpTilePath /path/to/tmp/tiles/` option. by default tiles will be sourced from the `osm/planet-2018430` build of SharedStreets data, but source and be overridden using the `--tileSource [shst-source-id]` option.
SharedStreets map tiles will be downloaded and cached as the matcher runs. By default tiles will be cached in `/tmp/shst_tiles/` but this path can be overriden by using the `--tmpTilePath /path/to/tmp/tiles/` option. By default tiles will be sourced from the `osm/planet-2018430` build of SharedStreets data, but source and be overridden using the `--tileSource [shst-source-id]` option.
By default tiles will be loaded from server `https://tiles.sharedstreets.io/` but the server can be overridden by using the `--tileServer https://mytileserver.org/` option.
By default tiles detail level will include roads upto road class 6 (Unclassified), but, e.g. to match bike trips, this can be overriden using the `--roadClass 8` option (Note that these tiles currently are not available from the official SharedStreets tiles erver but must be custom built using sharedstreets-builder.

Open debug trace files using [geojson.io](http://geojson.io/). Colored street edges show travel speed, and blue and red tick marks along edges show GPS relationship to matched point along street edge. Red tick marks are "failed matches" due to GPS or map errors (image below shows red ticks caused by missing OSM edges).

Expand Down
11 changes: 8 additions & 3 deletions src/main/java/io/sharedstreets/barefoot/roadmap/RoadMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@
*/
public class RoadMap extends Graph<RoadEdge> implements Serializable {

private final String tileServer;
private final String tileSource;
private final Integer roadClass;

private final String tmpTilePath;

private static final long serialVersionUID = 1L;
Expand All @@ -61,11 +64,13 @@ static Collection<RoadEdge> split(BaseRoad base) {
return roads;
}

public RoadMap(String tmpTilePath, String tileSource) {
public RoadMap(String tmpTilePath, String tileServer, String tileSource, Integer roadClass) {

this.tmpTilePath = tmpTilePath;

this.tileServer = tileServer;
this.tileSource = tileSource;
this.roadClass = roadClass;

index = new Index();
roads = new ArrayList<>();
Expand Down Expand Up @@ -123,7 +128,7 @@ public void loadTile(TileId tileId) throws IOException {
if(loadedTiles.contains(tileId))
return;

SharedStreetsReader sharedStreetsReader = new SharedStreetsReader(this.tmpTilePath, this.tileSource, tileId);
SharedStreetsReader sharedStreetsReader = new SharedStreetsReader(this.tmpTilePath, this.tileServer, this.tileSource, this.roadClass, tileId);

sharedStreetsReader.open();

Expand Down Expand Up @@ -172,7 +177,7 @@ public static RoadMap Load(RoadReader reader) throws SourceException {

logger.info("inserting roads ...");

RoadMap roadmap = new RoadMap(null, null);
RoadMap roadmap = new RoadMap(null, null, null, null);


int geometryCount = 0, counter = 0;
Expand Down
108 changes: 66 additions & 42 deletions src/main/java/io/sharedstreets/matcher/BatchMatcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import com.esri.core.geometry.Point;
import com.esri.core.geometry.Polyline;
import io.sharedstreets.barefoot.road.BaseRoad;
import io.sharedstreets.barefoot.roadmap.Loader;
import io.sharedstreets.barefoot.roadmap.RoadMap;
import io.sharedstreets.matcher.input.Ingest;
import io.sharedstreets.matcher.model.aggregation.*;
Expand Down Expand Up @@ -43,71 +42,88 @@ public static void main(String[] args) throws Exception {

// create the Options
Options options = new Options();
// options.addOption( OptionBuilder.withLongOpt( "map" )
// .withDescription( "path to map tiles" )
// options.addOption( Option.builder().longOpt( "map" )
// .desc( "path to map tiles" )
// .hasArg()
// .withArgName("MAP-DIR")
// .create() );
// .argName("MAP-DIR")
// .build() );

options.addOption( OptionBuilder.withLongOpt( "tracker" )
.withDescription( "tracker.properties files" )
options.addOption( Option.builder().longOpt( "tracker" )
.desc( "tracker.properties files" )
.hasArg()
.withArgName("TRACKER-PATH")
.create() );
.argName("TRACKER-PATH")
.build() );

options.addOption( OptionBuilder.withLongOpt( "input" )
.withDescription( "path to input files" )
options.addOption( Option.builder().longOpt( "input" )
.desc( "path to input files" )
.hasArg()
.withArgName("INPUT-DIR")
.create() );
.argName("INPUT-DIR")
.build() );

options.addOption( OptionBuilder.withLongOpt( "output" )
.withDescription( "path to output" )
options.addOption( Option.builder().longOpt( "output" )
.desc( "path to output" )
.hasArg()
.withArgName("OUTPUT-DIR")
.create() );
.argName("OUTPUT-DIR")
.build() );

options.addOption( OptionBuilder.withLongOpt( "debug" )
.withDescription( "path to debug output" )
options.addOption( Option.builder().longOpt( "debug" )
.desc( "path to debug output" )
.hasArg()
.withArgName("DUBUG-DIR")
.create() );
.argName("DUBUG-DIR")
.build() );

options.addOption( OptionBuilder.withLongOpt( "tileSource" )
.withDescription( "tile source" )
options.addOption( Option.builder().longOpt( "tileServer" )
.desc( "tile server" )
.hasArg()
.withArgName("TILE-SOUCCE")
.create() );
.argName("TILE-SERVER")
.build() );

options.addOption( OptionBuilder.withLongOpt( "tmpTilePath" )
.withDescription( "tmp tile path" )
options.addOption( Option.builder().longOpt( "tileSource" )
.desc( "tile source" )
.hasArg()
.withArgName("TMP-TILE-PATH")
.create() );
.argName("TILE-SOURCE")
.build() );

options.addOption( OptionBuilder.withLongOpt( "dust" )
.withDescription( "path to map dust output" )
options.addOption( Option.builder().longOpt( "roadClass" )
.desc( "road class" )
.hasArg()
.withArgName("DUST-DIR")
.create() );
.type(PatternOptionBuilder.NUMBER_VALUE)
.argName("ROAD-CLASS")
.build() );

options.addOption( OptionBuilder.withLongOpt( "binSize" )
.withDescription( "path to map dust output" )
options.addOption( Option.builder().longOpt( "tmpTilePath" )
.desc( "tmp tile path" )
.hasArg()
.withArgName("DUST-DIR")
.create() );
.argName("TMP-TILE-PATH")
.build() );

options.addOption( OptionBuilder.withLongOpt( "eventType" )
.withDescription( "name for event output" )
options.addOption( Option.builder().longOpt( "dust" )
.desc( "path to map dust output" )
.hasArg()
.withArgName("EVENT-TYPE")
.create() );
.argName("DUST-DIR")
.build() );

options.addOption( Option.builder().longOpt( "binSize" )
.desc( "path to map dust output" )
.hasArg()
.argName("DUST-DIR")
.build() );

options.addOption( Option.builder().longOpt( "eventType" )
.desc( "name for event output" )
.hasArg()
.argName("EVENT-TYPE")
.build() );


options.addOption("f", "fast snap method" );

String tileServer = "https://tiles.sharedstreets.io/";

String tileSource = "osm/planet-180430";

Integer roadClass = 6;

String tmpTilePath = "/tmp/shst_tiles/";

String inputPath = "";
Expand Down Expand Up @@ -149,10 +165,18 @@ public static void main(String[] args) throws Exception {
outputPath = line.getOptionValue( "output" );
}

if( line.hasOption( "tileServer" ) ) {
tileServer = line.getOptionValue( "tileServer" );
}

if( line.hasOption( "tileSource" ) ) {
tileSource = line.getOptionValue( "tileSource" );
}

if( line.hasOption( "roadClass" ) ) {
roadClass = Math.toIntExact((Long) line.getParsedOptionValue("roadClass"));
}

if( line.hasOption( "tmpTilePath" ) ) {
tmpTilePath = line.getOptionValue( "tmpTilePath" );
}
Expand Down Expand Up @@ -196,7 +220,7 @@ public static void main(String[] args) throws Exception {
// as workaround related to Flink serialization of speed matching reducer function

// dynamically load map based on point data
SharedStreetsMatcher.map = new RoadMap(tmpTilePath, tileSource);
SharedStreetsMatcher.map = new RoadMap(tmpTilePath, tileServer, tileSource, roadClass);

// build match engine
SharedStreetsMatcher.matcher = MatcherFactory.createMatcher(trackerPath, SharedStreetsMatcher.map);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,9 @@ public SharedStreetsReader(Path tilePath) {
this.tilePath = tilePath;
}

public SharedStreetsReader(String tmpTilePath, String tileSource, TileId tileId) throws IOException {
public SharedStreetsReader(String tmpTilePath, String tileServer, String tileSource, Integer roadClass, TileId tileId) throws IOException {

String tileFileName = tileId.toString() + ".geometry.6.pbf";
String tileFileName = tileId.toString() + ".geometry."+ roadClass +".pbf";

File tileTempFile = new File(tmpTilePath, tileFileName);

Expand All @@ -121,7 +121,7 @@ public SharedStreetsReader(String tmpTilePath, String tileSource, TileId tileId)

logger.info("loaded tile: {} {}", tileSource, tileFileName);

URL tileUrl = new URL("https://tiles.sharedstreets.io/" + tileSource + "/" + tileFileName);
URL tileUrl = new URL(tileServer + tileSource + "/" + tileFileName);
FileUtils.copyURLToFile(tileUrl, tileTempFile);

}
Expand Down