use of de.topobyte.osm4j.core.model.iface.OsmNode in project osm4j-core by topobyte.
the class EntityFinderIgnoreMissing method findNodes.
@Override
public List<OsmNode> findNodes(TLongCollection ids) throws EntityNotFoundException {
List<OsmNode> nodes = new ArrayList<>();
TLongIterator idIterator = ids.iterator();
while (idIterator.hasNext()) {
try {
nodes.add(entityProvider.getNode(idIterator.next()));
} catch (EntityNotFoundException e) {
// ignore silently
}
}
return nodes;
}
use of de.topobyte.osm4j.core.model.iface.OsmNode in project osm4j-core by topobyte.
the class EntityFinderThrowMissing method findNodes.
@Override
public List<OsmNode> findNodes(TLongCollection ids) throws EntityNotFoundException {
List<OsmNode> nodes = new ArrayList<>();
TLongIterator idIterator = ids.iterator();
while (idIterator.hasNext()) {
nodes.add(entityProvider.getNode(idIterator.next()));
}
return nodes;
}
use of de.topobyte.osm4j.core.model.iface.OsmNode in project osm4j-core by topobyte.
the class ImplUtil method clone.
public static Node clone(OsmNode node) {
List<? extends OsmTag> tags = cloneTags(node);
OsmMetadata metadata = cloneMetadata(node);
return new Node(node.getId(), node.getLongitude(), node.getLatitude(), tags, metadata);
}
use of de.topobyte.osm4j.core.model.iface.OsmNode in project osm4j-geometry by topobyte.
the class WayBuilder method buildReturnEmptyIfNodeMissing.
public WayBuilderResult buildReturnEmptyIfNodeMissing(OsmWay way, OsmEntityProvider resolver) {
WayBuilderResult result = new WayBuilderResult();
int numNodes = way.getNumberOfNodes();
if (numNodes == 0) {
return result;
}
if (numNodes == 1) {
if (!includePuntal) {
return result;
} else {
try {
OsmNode node = resolver.getNode(way.getNodeId(0));
result.getCoordinates().add(nodeBuilder.buildCoordinate(node));
} catch (EntityNotFoundException e) {
return result;
}
}
}
CoordinateSequence cs = factory.getCoordinateSequenceFactory().create(numNodes, 2);
for (int i = 0; i < way.getNumberOfNodes(); i++) {
OsmNode node;
try {
node = resolver.getNode(way.getNodeId(i));
} catch (EntityNotFoundException e) {
result.clear();
return result;
}
cs.setOrdinate(i, 0, node.getLongitude());
cs.setOrdinate(i, 1, node.getLatitude());
}
createLine(result, cs, OsmModelUtil.isClosed(way));
return result;
}
use of de.topobyte.osm4j.core.model.iface.OsmNode in project osm4j-geometry by topobyte.
the class WayBuilder method buildOmitVertexIfNodeMissing.
public WayBuilderResult buildOmitVertexIfNodeMissing(OsmWay way, OsmEntityProvider resolver) {
WayBuilderResult result = new WayBuilderResult();
// Test if the way is closed, i.e. first node id == last node id
boolean closed = OsmModelUtil.isClosed(way);
// Remember if the first node is missing, so that we can handle closed
// ways appropriately
boolean firstMissing = false;
List<Coordinate> coords = new ArrayList<>();
for (int i = 0; i < way.getNumberOfNodes(); i++) {
OsmNode node;
try {
node = resolver.getNode(way.getNodeId(i));
} catch (EntityNotFoundException e) {
if (log) {
logMissingNode(way.getNodeId(i));
}
if (i == 0) {
firstMissing = true;
}
continue;
}
coords.add(new Coordinate(node.getLongitude(), node.getLatitude()));
}
if (coords.size() == 0) {
return result;
}
if (coords.size() == 1) {
if (!includePuntal) {
return result;
} else {
result.getCoordinates().add(coords.get(0));
return result;
}
}
// the way by replicating the first found coordinate at the end.
if (closed && firstMissing && coords.size() > 2) {
coords.add(coords.get(0));
}
CoordinateSequence cs = factory.getCoordinateSequenceFactory().create(coords.toArray(new Coordinate[0]));
createLine(result, cs, closed);
return result;
}
Aggregations