ExpressionFunction exprFunc = new ExpressionFunction( new Fields( "tree_species" ), expression, String.class );
treePipe = new Each( treePipe, new Fields( "scrub_species" ), exprFunc, Fields.ALL );
// join with tree metadata
Pipe metaTreePipe = new Pipe( "meta_tree" );
treePipe = new HashJoin( treePipe, new Fields( "tree_species" ), metaTreePipe, new Fields( "species" ), new InnerJoin() );
treePipe = new Rename( treePipe, new Fields( "blurb" ), new Fields( "tree_name" ) );
regex = "^(\\S+),(\\S+),(\\S+)\\s*$";
int[] gpsGroups = { 1, 2, 3 };
parser = new RegexParser( new Fields( "tree_lat", "tree_lng", "tree_alt" ), regex, gpsGroups );
treePipe = new Each( treePipe, new Fields( "geo" ), parser, Fields.ALL );
// determine a tree geohash
Fields geohashArguments = new Fields( "tree_lat", "tree_lng" );
treePipe = new Each( treePipe, geohashArguments, new GeoHashFunction( new Fields( "tree_geohash" ), 6 ), Fields.ALL );
Fields fieldSelector = new Fields( "tree_name", "priv", "tree_id", "situs", "tree_site", "species", "wikipedia", "calflora", "min_height", "max_height", "tree_lat", "tree_lng", "tree_alt", "tree_geohash" );
treePipe = new Retain( treePipe, fieldSelector );
// parse the "road" output
Pipe roadPipe = new Pipe( "road", tsvCheck );
regex = "^\\s+Sequence\\:.*\\s+Year Constructed\\:\\s+(\\d+)\\s+Traffic Count\\:\\s+(\\d+)\\s+Traffic Index\\:\\s+(\\w.*\\w)\\s+Traffic Class\\:\\s+(\\w.*\\w)\\s+Traffic Date.*\\s+Paving Length\\:\\s+(\\d+)\\s+Paving Width\\:\\s+(\\d+)\\s+Paving Area\\:\\s+(\\d+)\\s+Surface Type\\:\\s+(\\w.*\\w)\\s+Surface Thickness.*\\s+Bike Lane\\:\\s+(\\w+)\\s+Bus Route\\:\\s+(\\w+)\\s+Truck Route\\:\\s+(\\w+)\\s+Remediation.*$";
roadPipe = new Each( roadPipe, new Fields( "misc" ), new RegexFilter( regex ) );
Fields roadFields = new Fields( "year_construct", "traffic_count", "traffic_index", "traffic_class", "paving_length", "paving_width", "paving_area", "surface_type", "bike_lane", "bus_route", "truck_route" );
int[] roadGroups = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 };
parser = new RegexParser( roadFields, regex, roadGroups );
roadPipe = new Each( roadPipe, new Fields( "misc" ), parser, Fields.ALL );
// join with road metadata
Pipe metaRoadPipe = new Pipe( "meta_road" );
roadPipe = new HashJoin( roadPipe, new Fields( "surface_type" ), metaRoadPipe, new Fields( "pavement_type" ), new InnerJoin() );
roadPipe = new Rename( roadPipe, new Fields( "blurb" ), new Fields( "road_name" ) );
// estimate albedo based on the road surface age and pavement type
Fields albedoArguments = new Fields( "year_construct", "albedo_new", "albedo_worn" );
roadPipe = new Each( roadPipe, albedoArguments, new AlbedoFunction( new Fields( "albedo" ), 2002 ), Fields.ALL );