String filename = OSMImportOp.class.getResource("ways.xml").getFile();
File file = new File(filename);
cli.execute("osm", "import", file.getAbsolutePath());
cli.execute("add");
cli.execute("commit", "-m", "message");
GeoGIG geogig = cli.newGeoGIG();
Optional<RevTree> tree = geogig.command(RevObjectParse.class).setRefSpec("HEAD:node")
.call(RevTree.class);
assertTrue(tree.isPresent());
assertTrue(tree.get().size() > 0);
tree = geogig.command(RevObjectParse.class).setRefSpec("HEAD:way").call(RevTree.class);
assertTrue(tree.isPresent());
assertTrue(tree.get().size() > 0);
// map
String mappingFilename = OSMMap.class.getResource("mapping.json").getFile();
File mappingFile = new File(mappingFilename);
cli.execute("osm", "map", mappingFile.getAbsolutePath());
// check that a feature was correctly mapped
Optional<RevFeature> revFeature = geogig.command(RevObjectParse.class)
.setRefSpec("HEAD:onewaystreets/31045880").call(RevFeature.class);
assertTrue(revFeature.isPresent());
ImmutableList<Optional<Object>> values = revFeature.get().getValues();
String wkt = "LINESTRING (7.1923367 50.7395887, 7.1923127 50.7396946, 7.1923444 50.7397419, 7.1924199 50.7397781)";
assertEquals(wkt, values.get(2).get().toString());
assertEquals("345117525;345117526;1300224327;345117527", values.get(3).get());
assertEquals("yes", values.get(1).get());
// check that a feature was correctly ignored
revFeature = geogig.command(RevObjectParse.class).setRefSpec("HEAD:onewaystreets/31347480")
.call(RevFeature.class);
assertFalse(revFeature.isPresent());
geogig.close();
}