Search in sources :

Example 31 with Bound

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());
    }
}
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 32 with Bound

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());
    }
}
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 33 with Bound

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();
    }
}
Also used : AllEntityDao(org.openstreetmap.osmosis.apidb.v0_6.impl.AllEntityDao) BoundContainer(org.openstreetmap.osmosis.core.container.v0_6.BoundContainer) Bound(org.openstreetmap.osmosis.core.domain.v0_6.Bound) EntityContainer(org.openstreetmap.osmosis.core.container.v0_6.EntityContainer) EntitySnapshotReader(org.openstreetmap.osmosis.apidb.v0_6.impl.EntitySnapshotReader) SchemaVersionValidator(org.openstreetmap.osmosis.apidb.v0_6.impl.SchemaVersionValidator)

Example 34 with Bound

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));
    }
}
Also used : BoundContainer(org.openstreetmap.osmosis.core.container.v0_6.BoundContainer) Bound(org.openstreetmap.osmosis.core.domain.v0_6.Bound)

Example 35 with Bound

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

Aggregations

Bound (org.openstreetmap.osmosis.core.domain.v0_6.Bound)46 Test (org.junit.Test)25 BoundContainer (org.openstreetmap.osmosis.core.container.v0_6.BoundContainer)22 EntityContainer (org.openstreetmap.osmosis.core.container.v0_6.EntityContainer)19 CommonEntityData (org.openstreetmap.osmosis.core.domain.v0_6.CommonEntityData)14 SinkEntityInspector (org.openstreetmap.osmosis.testutil.v0_6.SinkEntityInspector)14 NodeContainer (org.openstreetmap.osmosis.core.container.v0_6.NodeContainer)13 Date (java.util.Date)11 Node (org.openstreetmap.osmosis.core.domain.v0_6.Node)11 OsmosisRuntimeException (org.openstreetmap.osmosis.core.OsmosisRuntimeException)7 RelationContainer (org.openstreetmap.osmosis.core.container.v0_6.RelationContainer)6 OsmUser (org.openstreetmap.osmosis.core.domain.v0_6.OsmUser)6 WayContainer (org.openstreetmap.osmosis.core.container.v0_6.WayContainer)5 Tag (org.openstreetmap.osmosis.core.domain.v0_6.Tag)5 RunnableSource (org.openstreetmap.osmosis.core.task.v0_6.RunnableSource)5 Osmformat (crosby.binary.Osmformat)4 BoundContainerIterator (org.openstreetmap.osmosis.core.container.v0_6.BoundContainerIterator)4 NodeContainerIterator (org.openstreetmap.osmosis.core.container.v0_6.NodeContainerIterator)4 RelationContainerIterator (org.openstreetmap.osmosis.core.container.v0_6.RelationContainerIterator)4 WayContainerIterator (org.openstreetmap.osmosis.core.container.v0_6.WayContainerIterator)4