Search in sources :

Example 6 with Way

use of de.topobyte.osm4j.core.model.impl.Way in project osm4j-geometry by topobyte.

the class RegionBuilder method convert.

private void convert(Collection<ChainOfNodes> rings, Collection<ChainOfNodes> nonRings, OsmEntityProvider resolver, Collection<Coordinate> coordinates, Collection<LineString> lineStrings, Collection<LinearRing> linearRings) throws EntityNotFoundException {
    for (ChainOfNodes ring : rings) {
        Way way = new Way(-1, ring.getNodes());
        WayBuilderResult result = wayBuilder.build(way, resolver);
        add(result, coordinates, lineStrings, linearRings);
    }
    for (ChainOfNodes ring : nonRings) {
        Way way = new Way(-1, ring.getNodes());
        WayBuilderResult result = wayBuilder.build(way, resolver);
        add(result, coordinates, lineStrings, linearRings);
    }
}
Also used : ChainOfNodes(de.topobyte.osm4j.geometry.relation.ChainOfNodes) OsmWay(de.topobyte.osm4j.core.model.iface.OsmWay) Way(de.topobyte.osm4j.core.model.impl.Way)

Example 7 with Way

use of de.topobyte.osm4j.core.model.impl.Way in project osm4j-core by topobyte.

the class ImplUtil method clone.

public static Way clone(OsmWay way) {
    List<? extends OsmTag> tags = cloneTags(way);
    OsmMetadata metadata = cloneMetadata(way);
    TLongList nodes = new TLongArrayList(way.getNumberOfNodes());
    for (int i = 0; i < way.getNumberOfNodes(); i++) {
        nodes.add(way.getNodeId(i));
    }
    return new Way(way.getId(), nodes, tags, metadata);
}
Also used : OsmMetadata(de.topobyte.osm4j.core.model.iface.OsmMetadata) TLongArrayList(com.slimjars.dist.gnu.trove.list.array.TLongArrayList) TLongList(com.slimjars.dist.gnu.trove.list.TLongList) OsmWay(de.topobyte.osm4j.core.model.iface.OsmWay) Way(de.topobyte.osm4j.core.model.impl.Way)

Example 8 with Way

use of de.topobyte.osm4j.core.model.impl.Way in project osm4j-geometry by topobyte.

the class RelationUtil method closeUnclosedRingWithStraightLine.

public static void closeUnclosedRingWithStraightLine(Collection<ChainOfWays> rings) {
    for (ChainOfWays ring : rings) {
        if (!ring.isClosed()) {
            logger.debug("unclosed ring with " + ring.getSegments().size() + " segments");
            List<WaySegment> segments = ring.getSegments();
            WaySegment rs1 = segments.get(0);
            WaySegment rs2 = segments.get(segments.size() - 1);
            long n1 = rs1.getNodeId(0);
            long n2 = rs2.getNodeId(rs2.getNumberOfNodes() - 1);
            TLongArrayList ids = new TLongArrayList();
            ids.add(n1);
            ids.add(n2);
            OsmWay filler = new Way(0L, ids);
            ring.addWay(filler);
        }
    }
}
Also used : OsmWay(de.topobyte.osm4j.core.model.iface.OsmWay) TLongArrayList(com.slimjars.dist.gnu.trove.list.array.TLongArrayList) OsmWay(de.topobyte.osm4j.core.model.iface.OsmWay) Way(de.topobyte.osm4j.core.model.impl.Way)

Aggregations

OsmWay (de.topobyte.osm4j.core.model.iface.OsmWay)8 Way (de.topobyte.osm4j.core.model.impl.Way)8 TLongArrayList (com.slimjars.dist.gnu.trove.list.array.TLongArrayList)7 ArrayList (java.util.ArrayList)5 OsmNode (de.topobyte.osm4j.core.model.iface.OsmNode)4 OsmRelation (de.topobyte.osm4j.core.model.iface.OsmRelation)4 Node (de.topobyte.osm4j.core.model.impl.Node)4 Relation (de.topobyte.osm4j.core.model.impl.Relation)4 OsmHandler (de.topobyte.osm4j.core.access.OsmHandler)2 EntityContainer (de.topobyte.osm4j.core.model.iface.EntityContainer)2 OsmBounds (de.topobyte.osm4j.core.model.iface.OsmBounds)2 OsmMetadata (de.topobyte.osm4j.core.model.iface.OsmMetadata)2 OsmRelationMember (de.topobyte.osm4j.core.model.iface.OsmRelationMember)2 IOException (java.io.IOException)2 List (java.util.List)2 TLongList (com.slimjars.dist.gnu.trove.list.TLongList)1 OsmTag (de.topobyte.osm4j.core.model.iface.OsmTag)1 Tag (de.topobyte.osm4j.core.model.impl.Tag)1 ChainOfNodes (de.topobyte.osm4j.geometry.relation.ChainOfNodes)1 Osmformat (de.topobyte.osm4j.pbf.protobuf.Osmformat)1