use of org.openstreetmap.osmosis.core.domain.v0_6.Bound 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.core.domain.v0_6.Bound 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.core.domain.v0_6.Bound in project osmosis by openstreetmap.
the class ApidbReader method runImpl.
/**
* Runs the task implementation. This is called by the run method within a transaction.
*
* @param dbCtx
* Used to access the database.
*/
protected void runImpl(DatabaseContext2 dbCtx) {
try {
AllEntityDao entityDao;
sink.initialize(Collections.<String, Object>emptyMap());
new SchemaVersionValidator(loginCredentials, preferences).validateVersion(ApidbVersionConstants.SCHEMA_MIGRATIONS);
entityDao = new AllEntityDao(dbCtx.getJdbcTemplate());
sink.process(new BoundContainer(new Bound("Osmosis " + OsmosisConstants.VERSION)));
try (ReleasableIterator<EntityContainer> reader = new EntitySnapshotReader(entityDao.getHistory(), snapshotInstant)) {
while (reader.hasNext()) {
sink.process(reader.next());
}
}
sink.complete();
} finally {
sink.close();
}
}
use of org.openstreetmap.osmosis.core.domain.v0_6.Bound in project osmosis by openstreetmap.
the class BoundingBoxFilter method process.
/**
* {@inheritDoc}
*/
@Override
public void process(BoundContainer boundContainer) {
Bound newBound;
/*
* The order of calling intersect is important because the first non-empty origin string
* will be used for the resulting Bound, and we want the origin string from the pipeline
* Bound to be used.
*/
newBound = boundContainer.getEntity().intersect(bound);
// intersect will return null if there is no overlapping area
if (newBound != null) {
// Send on a bound element clipped to the area
super.process(new BoundContainer(newBound));
}
}
use of org.openstreetmap.osmosis.core.domain.v0_6.Bound 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);
}
Aggregations