Skip to content

Commit

Permalink
Update TestAtlasHandler to rely on Raw Atlas Flow (#188)
Browse files Browse the repository at this point in the history
* Fixing way section identifier for line with a loop

* Updating test atlas handler to use raw atlas flow when building from pbf
  • Loading branch information
MikeGost authored and matthieun committed Aug 8, 2018
1 parent 4bb7408 commit e20286d
Showing 1 changed file with 23 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,13 @@
import org.openstreetmap.atlas.geography.atlas.items.ItemType;
import org.openstreetmap.atlas.geography.atlas.packed.PackedAtlasBuilder;
import org.openstreetmap.atlas.geography.atlas.pbf.AtlasLoadingOption;
import org.openstreetmap.atlas.geography.atlas.pbf.OsmPbfLoader;
import org.openstreetmap.atlas.geography.atlas.raw.creation.RawAtlasGenerator;
import org.openstreetmap.atlas.geography.atlas.raw.sectioning.WaySectionProcessor;
import org.openstreetmap.atlas.streaming.compression.Decompressor;
import org.openstreetmap.atlas.streaming.resource.ByteArrayResource;
import org.openstreetmap.atlas.streaming.resource.ClassResource;
import org.openstreetmap.atlas.streaming.resource.FileSuffix;
import org.openstreetmap.atlas.streaming.resource.Resource;
import org.openstreetmap.atlas.streaming.resource.StringResource;
import org.openstreetmap.atlas.tags.BuildingPartTag;
import org.openstreetmap.atlas.tags.BuildingTag;
Expand Down Expand Up @@ -178,6 +180,25 @@ private Polygon buildAreaPolygon(final Area area)
return Polygon.SILICON_VALLEY;
}

/**
* Builds an {@link Atlas} from the given pbf resource, using the raw atlas flow. This does NOT
* country-slice the pbf resource since no corresponding boundary file is supplied and the flow
* is not meant to test slicing logic.
*
* @param pbfResource
* The pbf input resource to use
* @return the resulting Atlas
*/
private Atlas buildAtlasFromPbf(final Resource pbfResource)
{
// Create raw Atlas
final RawAtlasGenerator rawAtlasGenerator = new RawAtlasGenerator(pbfResource);
final Atlas rawAtlas = rawAtlasGenerator.build();

// Way-section
return new WaySectionProcessor(rawAtlas, AtlasLoadingOption.withNoFilter()).run();
}

private Location convertLoc(final Loc point)
{
if (point.value().equalsIgnoreCase(Loc.USE_LATLON)
Expand Down Expand Up @@ -388,7 +409,7 @@ private void loadFromJosmOsmResource(final Field field, final CoreTestRule rule,
new OsmFileToPbf().update(resource, pbfFile);
}

field.set(rule, new OsmPbfLoader(pbfFile, AtlasLoadingOption.withNoFilter()).read());
field.set(rule, buildAtlasFromPbf(pbfFile));
}
catch (IllegalArgumentException | IllegalAccessException e)
{
Expand Down

0 comments on commit e20286d

Please sign in to comment.