Search in sources :

Example 11 with SinkEntityInspector

use of org.openstreetmap.osmosis.testutil.v0_6.SinkEntityInspector in project osmosis by openstreetmap.

the class MergeBoundTest method testSource0HasBound.

/**
 * Tests whether merge will delete the declared bound if only source 0
 * has a declared bound.
 *
 * @throws Exception if something goes wrong
 */
@Test
public void testSource0HasBound() throws Exception {
    RunnableSource source0 = new BoundSource(new Bound(1, 2, 4, 3, "source0"), true);
    RunnableSource source1 = new BoundSource(new Bound(5, 6, 8, 7, "source1"), false);
    EntityMerger merger = new EntityMerger(ConflictResolutionMethod.LatestSource, 1, BoundRemovedAction.Ignore);
    SinkEntityInspector merged = RunTaskUtilities.run(merger, source0, source1);
    List<EntityContainer> mergedList = createList(merged.getProcessedEntities());
    Assert.assertEquals(2, mergedList.size());
    for (EntityContainer entityContainer : mergedList) {
        Assert.assertEquals(EntityType.Node, entityContainer.getEntity().getType());
    }
}
Also used : Bound(org.openstreetmap.osmosis.core.domain.v0_6.Bound) EntityContainer(org.openstreetmap.osmosis.core.container.v0_6.EntityContainer) SinkEntityInspector(org.openstreetmap.osmosis.testutil.v0_6.SinkEntityInspector) RunnableSource(org.openstreetmap.osmosis.core.task.v0_6.RunnableSource) Test(org.junit.Test)

Example 12 with SinkEntityInspector

use of org.openstreetmap.osmosis.testutil.v0_6.SinkEntityInspector in project osmosis by openstreetmap.

the class MergeBoundTest method testNeitherHasBound.

/**
 * Tests the proper working of the merge task if neither
 * source has a declared bound.
 *
 * @throws Exception if something goes wrong
 */
@Test
public void testNeitherHasBound() throws Exception {
    RunnableSource source0 = new BoundSource(new Bound(1, 2, 4, 3, "source0"), false);
    RunnableSource source1 = new BoundSource(new Bound(5, 6, 8, 7, "source1"), false);
    EntityMerger merger = new EntityMerger(ConflictResolutionMethod.LatestSource, 1, BoundRemovedAction.Ignore);
    SinkEntityInspector merged = RunTaskUtilities.run(merger, source0, source1);
    List<EntityContainer> mergedList = createList(merged.getProcessedEntities());
    Assert.assertEquals(2, mergedList.size());
    for (EntityContainer entityContainer : mergedList) {
        Assert.assertEquals(EntityType.Node, entityContainer.getEntity().getType());
    }
}
Also used : Bound(org.openstreetmap.osmosis.core.domain.v0_6.Bound) EntityContainer(org.openstreetmap.osmosis.core.container.v0_6.EntityContainer) SinkEntityInspector(org.openstreetmap.osmosis.testutil.v0_6.SinkEntityInspector) RunnableSource(org.openstreetmap.osmosis.core.task.v0_6.RunnableSource) Test(org.junit.Test)

Example 13 with SinkEntityInspector

use of org.openstreetmap.osmosis.testutil.v0_6.SinkEntityInspector in project osmosis by openstreetmap.

the class BoundingBoxFilterTest method setUp.

/**
 * Performs pre-test activities.
 */
@Before
public void setUp() {
    OsmUser user;
    List<Tag> tags;
    user = new OsmUser(12, "OsmosisTest");
    // All nodes have an empty tags list.
    tags = new ArrayList<Tag>();
    entityInspector = new SinkEntityInspector();
    // simpleAreaFilter doesn't cross antimeridian; no complete ways or relations
    simpleAreaFilter = new BoundingBoxFilter(IdTrackerType.Dynamic, -20, 20, 20, -20, false, false, false, false);
    simpleAreaFilter.setSink(entityInspector);
    intersectingBound = new Bound(30, 10, 30, 10, "intersecting");
    nonIntersectingBound = new Bound(-30, -50, 10, -10, "nonintersecting");
    inAreaNode = new Node(new CommonEntityData(1234, 0, new Date(), user, 0, tags), 10, 10);
    outOfAreaNode = new Node(new CommonEntityData(1235, 0, new Date(), user, 0, tags), 30, 30);
    edgeNodeEast = new Node(new CommonEntityData(1236, 0, new Date(), user, 0, tags), 10, 20);
    edgeNodeWest = new Node(new CommonEntityData(1237, 0, new Date(), user, 0, tags), 10, -20);
    edgeNodeNorth = new Node(new CommonEntityData(1238, 0, new Date(), user, 0, tags), 20, 10);
    edgeNodeSouth = new Node(new CommonEntityData(1239, 0, new Date(), user, 0, tags), -20, 10);
}
Also used : CommonEntityData(org.openstreetmap.osmosis.core.domain.v0_6.CommonEntityData) OsmUser(org.openstreetmap.osmosis.core.domain.v0_6.OsmUser) Node(org.openstreetmap.osmosis.core.domain.v0_6.Node) Bound(org.openstreetmap.osmosis.core.domain.v0_6.Bound) Tag(org.openstreetmap.osmosis.core.domain.v0_6.Tag) SinkEntityInspector(org.openstreetmap.osmosis.testutil.v0_6.SinkEntityInspector) Date(java.util.Date) Before(org.junit.Before)

Example 14 with SinkEntityInspector

use of org.openstreetmap.osmosis.testutil.v0_6.SinkEntityInspector in project osmosis by openstreetmap.

the class PolygonFilterTest method setUp.

/**
 * Performs pre-test activities.
 */
@Before
public void setUp() {
    OsmUser user;
    List<Tag> tags;
    user = new OsmUser(12, "OsmosisTest");
    // All nodes have an empty tags list.
    tags = new ArrayList<Tag>();
    polygonFile = new File(getClass().getResource("testPolygon.txt").getFile());
    entityInspector = new SinkEntityInspector();
    // polyAreaFilter has a notch out of the Northeast corner.
    polyAreaFilter = new PolygonFilter(IdTrackerType.Dynamic, polygonFile, false, false, false, false);
    polyAreaFilter.setSink(entityInspector);
    intersectingBound = new Bound(30, 0, 30, 0, "intersecting");
    crossingIntersectingBound = new Bound(-10, 10, 30, -30, "crossing intersecting");
    nonIntersectingBound = new Bound(30, 15, 30, 15, "nonintersecting");
    inAreaNode = new Node(new CommonEntityData(1234, 0, new Date(), user, 0, tags), 5, 10);
    outOfAreaNode = new Node(new CommonEntityData(1235, 0, new Date(), user, 0, tags), 15, 15);
    edgeNode = new Node(new CommonEntityData(1236, 0, new Date(), user, 0, tags), 15, 10);
}
Also used : CommonEntityData(org.openstreetmap.osmosis.core.domain.v0_6.CommonEntityData) OsmUser(org.openstreetmap.osmosis.core.domain.v0_6.OsmUser) Node(org.openstreetmap.osmosis.core.domain.v0_6.Node) Bound(org.openstreetmap.osmosis.core.domain.v0_6.Bound) Tag(org.openstreetmap.osmosis.core.domain.v0_6.Tag) SinkEntityInspector(org.openstreetmap.osmosis.testutil.v0_6.SinkEntityInspector) File(java.io.File) Date(java.util.Date) Before(org.junit.Before)

Example 15 with SinkEntityInspector

use of org.openstreetmap.osmosis.testutil.v0_6.SinkEntityInspector in project osmosis by openstreetmap.

the class MergeBoundTest method testBothHaveBounds.

/**
 * Test the proper computation of the union bound iff both sources
 * have bounds.
 *
 * @throws Exception if something goes wrong
 */
@Test
public void testBothHaveBounds() throws Exception {
    Bound bound0 = new Bound(1, 2, 4, 3, "source1");
    RunnableSource source0 = new BoundSource(bound0, true);
    Bound bound1 = new Bound(5, 6, 8, 7, "source2");
    RunnableSource source1 = new BoundSource(bound1, true);
    EntityMerger merger = new EntityMerger(ConflictResolutionMethod.LatestSource, 1, BoundRemovedAction.Ignore);
    SinkEntityInspector merged = RunTaskUtilities.run(merger, source0, source1);
    List<EntityContainer> mergedList = createList(merged.getProcessedEntities());
    Assert.assertEquals(3, mergedList.size());
    Assert.assertEquals(EntityType.Bound, mergedList.get(0).getEntity().getType());
    // Check the bound
    Bound bound01 = (Bound) mergedList.get(0).getEntity();
    Assert.assertEquals(bound0.union(bound1), bound01);
    for (int i = 1; i < mergedList.size(); i++) {
        Assert.assertEquals(EntityType.Node, mergedList.get(i).getEntity().getType());
    }
}
Also used : Bound(org.openstreetmap.osmosis.core.domain.v0_6.Bound) EntityContainer(org.openstreetmap.osmosis.core.container.v0_6.EntityContainer) SinkEntityInspector(org.openstreetmap.osmosis.testutil.v0_6.SinkEntityInspector) RunnableSource(org.openstreetmap.osmosis.core.task.v0_6.RunnableSource) Test(org.junit.Test)

Aggregations

SinkEntityInspector (org.openstreetmap.osmosis.testutil.v0_6.SinkEntityInspector)19 Test (org.junit.Test)17 EntityContainer (org.openstreetmap.osmosis.core.container.v0_6.EntityContainer)14 Bound (org.openstreetmap.osmosis.core.domain.v0_6.Bound)13 Date (java.util.Date)8 CommonEntityData (org.openstreetmap.osmosis.core.domain.v0_6.CommonEntityData)8 Node (org.openstreetmap.osmosis.core.domain.v0_6.Node)8 NodeContainer (org.openstreetmap.osmosis.core.container.v0_6.NodeContainer)6 RunnableSource (org.openstreetmap.osmosis.core.task.v0_6.RunnableSource)6 HashMap (java.util.HashMap)3 HashSet (java.util.HashSet)3 Set (java.util.Set)3 BoundContainer (org.openstreetmap.osmosis.core.container.v0_6.BoundContainer)3 Before (org.junit.Before)2 OsmUser (org.openstreetmap.osmosis.core.domain.v0_6.OsmUser)2 Tag (org.openstreetmap.osmosis.core.domain.v0_6.Tag)2 EmptyReader (org.openstreetmap.osmosis.core.misc.v0_6.EmptyReader)2 File (java.io.File)1