Search in sources :

Example 26 with Bound

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

the class OsmPbfReader method process.

@Override
public void process(final EntityContainer entityContainer) {
    final Entity rawEntity = entityContainer.getEntity();
    if (shouldProcessEntity(this.loadingOption, rawEntity)) {
        if (rawEntity instanceof Node && this.nodeIdentifiersToInclude.contains(rawEntity.getId())) {
            processNode(rawEntity);
        } else if (rawEntity instanceof Way && this.wayIdentifiersToInclude.contains(rawEntity.getId())) {
            processWay(rawEntity);
        } else if (this.loadingOption.isLoadOsmRelation() && rawEntity instanceof Relation) {
            processRelation(rawEntity);
        } else if (rawEntity instanceof Bound) {
            logger.trace("Encountered PBF Bound {}, skipping over it.", rawEntity.getId());
        }
    } else {
        recordNodeIdentifiersFromFilteredEntity(rawEntity);
        logFilteredStatistics(rawEntity);
        logger.trace("Filtering out OSM {} {} from Raw Atlas", rawEntity.getType(), rawEntity.getId());
    }
}
Also used : AtlasEntity(org.openstreetmap.atlas.geography.atlas.items.AtlasEntity) Entity(org.openstreetmap.osmosis.core.domain.v0_6.Entity) Relation(org.openstreetmap.osmosis.core.domain.v0_6.Relation) WayNode(org.openstreetmap.osmosis.core.domain.v0_6.WayNode) Node(org.openstreetmap.osmosis.core.domain.v0_6.Node) Bound(org.openstreetmap.osmosis.core.domain.v0_6.Bound) Way(org.openstreetmap.osmosis.core.domain.v0_6.Way)

Example 27 with Bound

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

the class OsmosisBinaryParser method parse.

@Override
public void parse(Osmformat.HeaderBlock block) {
    for (String s : block.getRequiredFeaturesList()) {
        if (s.equals("OsmSchema-V0.6")) {
            // We can parse this.
            continue;
        }
        if (s.equals("DenseNodes")) {
            // We can parse this.
            continue;
        }
        throw new OsmosisRuntimeException("File requires unknown feature: " + s);
    }
    if (block.hasBbox()) {
        String source = OsmosisConstants.VERSION;
        if (block.hasSource()) {
            source = block.getSource();
        }
        double multiplier = .000000001;
        double rightf = block.getBbox().getRight() * multiplier;
        double leftf = block.getBbox().getLeft() * multiplier;
        double topf = block.getBbox().getTop() * multiplier;
        double bottomf = block.getBbox().getBottom() * multiplier;
        Bound bounds = new Bound(rightf, leftf, topf, bottomf, source);
        sink.process(new BoundContainer(bounds));
    }
}
Also used : BoundContainer(org.openstreetmap.osmosis.core.container.v0_6.BoundContainer) Bound(org.openstreetmap.osmosis.core.domain.v0_6.Bound) OsmosisRuntimeException(org.openstreetmap.osmosis.core.OsmosisRuntimeException)

Example 28 with Bound

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

the class HeaderBoundReader method apply.

@Override
public BoundContainer apply(Osmformat.HeaderBlock header) {
    Bound bound;
    if (header.hasBbox()) {
        Osmformat.HeaderBBox bbox = header.getBbox();
        bound = new Bound(bbox.getRight() * COORDINATE_SCALING_FACTOR, bbox.getLeft() * COORDINATE_SCALING_FACTOR, bbox.getTop() * COORDINATE_SCALING_FACTOR, bbox.getBottom() * COORDINATE_SCALING_FACTOR, header.getSource());
    } else {
        bound = new Bound(header.getSource());
    }
    return new BoundContainer(bound);
}
Also used : BoundContainer(org.openstreetmap.osmosis.core.container.v0_6.BoundContainer) Bound(org.openstreetmap.osmosis.core.domain.v0_6.Bound) Osmformat(crosby.binary.Osmformat)

Example 29 with Bound

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

the class PbfBlobDecoder method processNodes.

private void processNodes(List<Osmformat.Node> nodes, PbfFieldDecoder fieldDecoder) {
    for (Osmformat.Node node : nodes) {
        org.openstreetmap.osmosis.core.domain.v0_6.Node osmNode;
        CommonEntityData entityData;
        if (node.hasInfo()) {
            entityData = buildCommonEntityData(node.getId(), node.getKeysList(), node.getValsList(), node.getInfo(), fieldDecoder);
        } else {
            entityData = buildCommonEntityData(node.getId(), node.getKeysList(), node.getValsList(), fieldDecoder);
        }
        osmNode = new org.openstreetmap.osmosis.core.domain.v0_6.Node(entityData, fieldDecoder.decodeLatitude(node.getLat()), fieldDecoder.decodeLongitude(node.getLon()));
        // Add the bound object to the results.
        decodedEntities.add(new NodeContainer(osmNode));
    }
}
Also used : CommonEntityData(org.openstreetmap.osmosis.core.domain.v0_6.CommonEntityData) NodeContainer(org.openstreetmap.osmosis.core.container.v0_6.NodeContainer) Osmformat(crosby.binary.Osmformat)

Example 30 with Bound

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

the class BoundSetterTest method removeExistingBoundTest.

/**
 * Tests the bound removal.
 */
@Test
public void removeExistingBoundTest() {
    SinkEntityInspector inspector = new SinkEntityInspector();
    BoundSetter setter = new BoundSetter(null);
    setter.setSink(inspector);
    setter.process(new BoundContainer(new Bound("Test")));
    setter.process(new NodeContainer(new Node(new CommonEntityData(1, 1, new Date(), OsmUser.NONE, 1), 1, 1)));
    setter.complete();
    setter.close();
    EntityContainer ec = inspector.getProcessedEntities().iterator().next();
    Assert.assertEquals(EntityType.Node, ec.getEntity().getType());
}
Also used : CommonEntityData(org.openstreetmap.osmosis.core.domain.v0_6.CommonEntityData) BoundContainer(org.openstreetmap.osmosis.core.container.v0_6.BoundContainer) Node(org.openstreetmap.osmosis.core.domain.v0_6.Node) Bound(org.openstreetmap.osmosis.core.domain.v0_6.Bound) EntityContainer(org.openstreetmap.osmosis.core.container.v0_6.EntityContainer) NodeContainer(org.openstreetmap.osmosis.core.container.v0_6.NodeContainer) SinkEntityInspector(org.openstreetmap.osmosis.testutil.v0_6.SinkEntityInspector) Date(java.util.Date) Test(org.junit.Test)

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