Skip to content

Commit

Permalink
Merge pull request #7 from sharedstreets/dev
Browse files Browse the repository at this point in the history
update ingester to 1.1
  • Loading branch information
kpwebb authored Aug 3, 2018
2 parents 436e956 + 3f8d9d1 commit 2dbbfb1
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 55 deletions.
2 changes: 1 addition & 1 deletion ingest/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar

group 'io.sharedstreets'
version '1.0'
version '1.1'

apply plugin: 'java'

Expand Down
84 changes: 30 additions & 54 deletions ingest/src/main/java/io/sharedstreets/matcher/ingest/Ingester.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,7 @@ public static void main(String[] args) throws Exception {
.withArgName("OUTPUT-DIR")
.create() );

options.addOption( OptionBuilder.withLongOpt( "tileUrl" )
.withDescription( "url for map tiles " )
.hasArg()
.withArgName("TILE-URL")
.create() );

options.addOption( OptionBuilder.withLongOpt( "tileLevel" )
.withDescription( "" )
.hasArg()
.withArgName("TILE-LEVEL")
.create() );

options.addOption("speeds", "track GPS speed when available");
options.addOption("verbose", "verbose error output" );
Expand All @@ -72,11 +62,9 @@ public static void main(String[] args) throws Exception {

String inputType = "";

String tileLevel = "6";

boolean verbose = false;

String tileUrl = "https://tiles.sharedstreets.io/osm/planet-180312/";

boolean gpsSpeeds = false;

Expand Down Expand Up @@ -105,16 +93,6 @@ public static void main(String[] args) throws Exception {
verbose = true;
}

if( line.hasOption( "tileUrl" ) ) {
// print the value of block-size
tileUrl = line.getOptionValue( "tileUrl" ).trim();;
}

if( line.hasOption( "tileLevel" ) ) {
// print the value of block-size
tileLevel = line.getOptionValue( "tileLevel" ).trim();;
}

if( line.hasOption( "type" ) ) {
// print the value of block-size
inputType = line.getOptionValue( "type" ).trim().toUpperCase();
Expand All @@ -141,8 +119,6 @@ else if(fileParts[fileParts.length-1].toLowerCase().equals("dcfhv"))
}

final String finalInputType = inputType;
final String finalTileUrl = tileUrl;
final String finalTileLevel = tileLevel;
final boolean finalVerbose = verbose;

// let's go...
Expand Down Expand Up @@ -195,39 +171,39 @@ public void flatMap(String value, Collector<InputEvent> out) throws Exception {
});
}

// create list of map tiles for input traces
DataSet<TileId> tileIds = inputEvents.map(new MapFunction<InputEvent, TileId>(){

@Override
public TileId map(InputEvent value) throws Exception {
return TileId.lonLatToTileId(12, value.point.lon, value.point.lat);
}

}).distinct();

// map IDs to tile URLs
DataSet<String> tileUrls = tileIds.map(new MapFunction<TileId, String>() {
@Override
public String map(TileId value) throws Exception {
// TODO allow selection of tile build -- defaulting to current build for moment
return finalTileUrl + value.toString() + ".geometry." + finalTileLevel + ".pbf";
}
});

Path mapTilePath = Paths.get(outputPath, "tile_set.txt").toAbsolutePath();

if(mapTilePath.toFile().exists()) {
System.out.print("File already exists: " + mapTilePath.toString());
return;
}

// write tile URLs to disk (can be read by curl "xargs -n 1 curl -O < tile_set.txt")
tileUrls.writeAsText(mapTilePath.toString()).setParallelism(1);

// // create list of map tiles for input traces
// DataSet<TileId> tileIds = inputEvents.map(new MapFunction<InputEvent, TileId>(){
//
// @Override
// public TileId map(InputEvent value) throws Exception {
// return TileId.lonLatToTileId(12, value.point.lon, value.point.lat);
// }
//
// }).distinct();
//
// // map IDs to tile URLs
// DataSet<String> tileUrls = tileIds.map(new MapFunction<TileId, String>() {
// @Override
// public String map(TileId value) throws Exception {
// // TODO allow selection of tile build -- defaulting to current build for moment
// return finalTileUrl + value.toString() + ".geometry." + finalTileLevel + ".pbf";
// }
// });
//
// Path mapTilePath = Paths.get(outputPath, "tile_set.txt").toAbsolutePath();
//
// if(mapTilePath.toFile().exists()) {
// System.out.print("File already exists: " + mapTilePath.toString());
// return;
// }
//
// // write tile URLs to disk (can be read by curl "xargs -n 1 curl -O < tile_set.txt")
// tileUrls.writeAsText(mapTilePath.toString()).setParallelism(1);
//
Path dataPath = Paths.get(outputPath, "event_data").toAbsolutePath();

if(dataPath.toFile().exists()) {
System.out.print("File already exists: " + mapTilePath.toString());
System.out.print("File already exists: " + outputPath.toString());
return;
}

Expand Down

0 comments on commit 2dbbfb1

Please sign in to comment.