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());
}
}
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());
}
}
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);
}
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);
}
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());
}
}
Aggregations