Search in sources :

Example 1 with Segment

use of org.openstreetmap.atlas.geography.Segment in project atlas-checks by osmlab.

the class DuplicateNodeCheckTest method testCheck.

@Test
public void testCheck() {
    final Rectangle bounds = Rectangle.TEST_RECTANGLE;
    final Set<Location> nodes = new HashSet<>();
    while (nodes.size() < 10) {
        nodes.add(Location.random(bounds));
    }
    final PackedAtlasBuilder builder = new PackedAtlasBuilder();
    int identifier = 0;
    for (final Location node : nodes) {
        // for first node make it a duplicate
        if (identifier == 0) {
            builder.addNode(identifier++, node, RandomTagsSupplier.randomTags(5));
        }
        builder.addNode(identifier++, node, RandomTagsSupplier.randomTags(5));
    }
    final Iterator<Location> locationIterator = nodes.iterator();
    final Location start = locationIterator.next();
    identifier = 0;
    while (locationIterator.hasNext()) {
        if (identifier == 0) {
            builder.addEdge(identifier++, new Segment(start, locationIterator.next()), RandomTagsSupplier.randomTags(5));
        }
        builder.addEdge(identifier++, new Segment(start, locationIterator.next()), RandomTagsSupplier.randomTags(5));
    }
    final Atlas atlas = builder.get();
    final Iterable<CheckFlag> flags = new DuplicateNodeCheck(ConfigurationResolver.emptyConfiguration()).flags(atlas);
    Assert.assertEquals(1, Iterables.size(flags));
}
Also used : Atlas(org.openstreetmap.atlas.geography.atlas.Atlas) PackedAtlasBuilder(org.openstreetmap.atlas.geography.atlas.packed.PackedAtlasBuilder) Rectangle(org.openstreetmap.atlas.geography.Rectangle) CheckFlag(org.openstreetmap.atlas.checks.flag.CheckFlag) Segment(org.openstreetmap.atlas.geography.Segment) Location(org.openstreetmap.atlas.geography.Location) HashSet(java.util.HashSet) Test(org.junit.Test)

Aggregations

HashSet (java.util.HashSet)1 Test (org.junit.Test)1 CheckFlag (org.openstreetmap.atlas.checks.flag.CheckFlag)1 Location (org.openstreetmap.atlas.geography.Location)1 Rectangle (org.openstreetmap.atlas.geography.Rectangle)1 Segment (org.openstreetmap.atlas.geography.Segment)1 Atlas (org.openstreetmap.atlas.geography.atlas.Atlas)1 PackedAtlasBuilder (org.openstreetmap.atlas.geography.atlas.packed.PackedAtlasBuilder)1