use of de.topobyte.osm4j.core.model.iface.OsmWay 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);
}
use of de.topobyte.osm4j.core.model.iface.OsmWay in project osm4j-core by topobyte.
the class TestWayIterator method test.
@Test
public void test() throws IOException {
InMemoryListDataSet data = ListDataSetLoader.read(createInput().createIterator(true, true), true, true, true);
OsmIteratorInput input = createInput().createIterator(true, true);
WayIterator wayIterator = new WayIterator(input.getIterator());
List<OsmWay> ways = Lists.newArrayList(wayIterator.iterator());
input.close();
assertEquals(data.getWays().size(), ways.size());
for (int i = 0; i < ways.size(); i++) {
OsmWay a = ways.get(i);
OsmWay b = data.getWays().get(i);
assertTrue(EqualityUtil.equals(a, b));
}
}
use of de.topobyte.osm4j.core.model.iface.OsmWay in project osm4j-geometry by topobyte.
the class ChainOfWays method toCoordinateSequence.
private CoordinateSequence toCoordinateSequence(OsmEntityProvider resolver) throws EntityNotFoundException {
CoordinateSequenceFactory csf = factory.getCoordinateSequenceFactory();
int len = getLength();
CoordinateSequence points = csf.create(len, 2);
int n = 0;
for (int i = 0; i < segments.size(); i++) {
WaySegment segment = segments.get(i);
OsmWay way = segment.getWay();
for (int k = 0; k < way.getNumberOfNodes(); k++) {
if (k > 0 || i == 0) {
OsmNode node = resolver.getNode(segment.getNodeId(k));
points.setOrdinate(n, 0, node.getLongitude());
points.setOrdinate(n, 1, node.getLatitude());
n++;
}
}
}
return points;
}
use of de.topobyte.osm4j.core.model.iface.OsmWay in project osm4j-geometry by topobyte.
the class ChainOfWays method toSegmentRing.
public ChainOfNodes toSegmentRing() {
if (segments.isEmpty()) {
return new ChainOfNodes(new TLongArrayList());
}
int len = getLengthNonEmpty();
TLongList ids = new TLongArrayList(len);
for (int i = 0; i < segments.size(); i++) {
WaySegment segment = segments.get(i);
OsmWay way = segment.getWay();
for (int k = 0; k < way.getNumberOfNodes(); k++) {
if (k > 0 || i == 0) {
ids.add(segment.getNodeId(k));
}
}
}
return new ChainOfNodes(ids);
}
use of de.topobyte.osm4j.core.model.iface.OsmWay 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);
}
}
}
Aggregations