Search in sources :

Example 36 with Bound

use of org.openstreetmap.osmosis.core.domain.v0_6.Bound in project osmosis by openstreetmap.

the class PolygonFilterTest method testProcessBoundContainer2.

/**
 * Test passing a Bound which crosses the antimeredian and intersects the filter area.
 */
@Test
public final void testProcessBoundContainer2() {
    Bound compareBound;
    polyAreaFilter.process(new BoundContainer(crossingIntersectingBound));
    polyAreaFilter.complete();
    compareBound = (Bound) entityInspector.getLastEntityContainer().getEntity();
    assertTrue(Double.compare(compareBound.getRight(), 20) == 0);
    assertTrue(Double.compare(compareBound.getLeft(), -20) == 0);
    assertTrue(Double.compare(compareBound.getTop(), 20) == 0);
    assertTrue(Double.compare(compareBound.getBottom(), -20) == 0);
    assertTrue(compareBound.getOrigin().equals("crossing intersecting"));
}
Also used : BoundContainer(org.openstreetmap.osmosis.core.container.v0_6.BoundContainer) Bound(org.openstreetmap.osmosis.core.domain.v0_6.Bound) Test(org.junit.Test)

Example 37 with Bound

use of org.openstreetmap.osmosis.core.domain.v0_6.Bound 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 38 with Bound

use of org.openstreetmap.osmosis.core.domain.v0_6.Bound in project osmosis by openstreetmap.

the class PolygonFilterTest method testProcessBoundContainer1.

/**
 * Test passing a Bound which intersects the filter area.
 */
@Test
public final void testProcessBoundContainer1() {
    Bound compareBound;
    polyAreaFilter.process(new BoundContainer(intersectingBound));
    polyAreaFilter.complete();
    compareBound = (Bound) entityInspector.getLastEntityContainer().getEntity();
    assertTrue(Double.compare(compareBound.getRight(), 20) == 0);
    assertTrue(Double.compare(compareBound.getLeft(), 0) == 0);
    assertTrue(Double.compare(compareBound.getTop(), 20) == 0);
    assertTrue(Double.compare(compareBound.getBottom(), 0) == 0);
    assertTrue(compareBound.getOrigin().equals("intersecting"));
}
Also used : BoundContainer(org.openstreetmap.osmosis.core.container.v0_6.BoundContainer) Bound(org.openstreetmap.osmosis.core.domain.v0_6.Bound) Test(org.junit.Test)

Example 39 with Bound

use of org.openstreetmap.osmosis.core.domain.v0_6.Bound in project osmosis by openstreetmap.

the class BoundComputer method complete.

@Override
public void complete() {
    objects.complete();
    if (nodesSeen) {
        sink.process(new BoundContainer(new Bound(right, left, top, bottom, this.origin)));
    }
    try (ReleasableIterator<EntityContainer> i = objects.iterate()) {
        while (i.hasNext()) {
            sink.process(i.next());
        }
    }
    sink.complete();
}
Also used : 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)

Example 40 with Bound

use of org.openstreetmap.osmosis.core.domain.v0_6.Bound in project osmosis by openstreetmap.

the class BoundSetterFactory method createTaskManagerImpl.

@Override
protected TaskManager createTaskManagerImpl(TaskConfiguration taskConfig) {
    double left;
    double right;
    double top;
    double bottom;
    int zoom;
    Bound newBound = null;
    String origin = null;
    boolean remove;
    remove = getBooleanArgument(taskConfig, ARG_REMOVE, DEFAULT_REMOVE);
    if (!remove) {
        origin = getStringArgument(taskConfig, ARG_ORIGIN, DEFAULT_ORIGIN);
        left = getDoubleArgument(taskConfig, ARG_LEFT, DEFAULT_LEFT);
        right = getDoubleArgument(taskConfig, ARG_RIGHT, DEFAULT_RIGHT);
        top = getDoubleArgument(taskConfig, ARG_TOP, DEFAULT_TOP);
        bottom = getDoubleArgument(taskConfig, ARG_BOTTOM, DEFAULT_BOTTOM);
        zoom = getIntegerArgument(taskConfig, ARG_ZOOM, DEFAULT_ZOOM);
        if (doesArgumentExist(taskConfig, ARG_X1)) {
            int x1 = getIntegerArgument(taskConfig, ARG_X1);
            left = xToLon(zoom, x1);
            right = xToLon(zoom, getIntegerArgument(taskConfig, ARG_X2, x1) + 1);
        }
        if (doesArgumentExist(taskConfig, ARG_Y1)) {
            int y1 = getIntegerArgument(taskConfig, ARG_Y1);
            top = yToLat(zoom, y1);
            bottom = yToLat(zoom, getIntegerArgument(taskConfig, ARG_Y2, y1) + 1);
        }
        newBound = new Bound(right, left, top, bottom, origin);
    }
    return new SinkSourceManager(taskConfig.getId(), new BoundSetter(newBound), taskConfig.getPipeArgs());
}
Also used : SinkSourceManager(org.openstreetmap.osmosis.core.pipeline.v0_6.SinkSourceManager) Bound(org.openstreetmap.osmosis.core.domain.v0_6.Bound)

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