use of com.slimjars.dist.gnu.trove.set.hash.TLongHashSet in project osm4j-geometry by topobyte.
the class ChainOfNodes method hasNodeIntersections.
/**
* Return whether this ring has intersections in terms of node ids appearing
* multiple times.
*/
public boolean hasNodeIntersections() {
int size = nodeIds.size();
// Keep a set of already encountered ids
TLongSet before = new TLongHashSet();
// The first id can't be there already because the set is empty
before.add(nodeIds.get(0));
// Check all nodes except the last one which gets special care
for (int i = 1; i < size - 1; i++) {
long id = nodeIds.get(i);
// Is it already on the set -> there is an intersection
if (before.contains(id)) {
return true;
}
// Add to the set of encountered ids
before.add(id);
}
// that is okay
if (isClosed()) {
return false;
}
// with one of the others
return before.contains(nodeIds.get(size - 1));
}
use of com.slimjars.dist.gnu.trove.set.hash.TLongHashSet in project osm4j-core by topobyte.
the class EntityFinderIgnoreMissing method findMemberRelationsRecursively.
private void findMemberRelationsRecursively(Deque<OsmRelation> queue, Set<OsmRelation> outRelations) {
TLongSet ids = new TLongHashSet();
while (!queue.isEmpty()) {
OsmRelation relation = queue.remove();
for (OsmRelationMember member : OsmModelUtil.membersAsList(relation)) {
if (member.getType() != EntityType.Relation) {
continue;
}
long id = member.getId();
if (ids.contains(id)) {
continue;
}
ids.add(id);
try {
OsmRelation child = entityProvider.getRelation(id);
outRelations.add(child);
queue.add(child);
} catch (EntityNotFoundException e) {
// ignore silently
}
}
}
}
use of com.slimjars.dist.gnu.trove.set.hash.TLongHashSet in project osm4j-core by topobyte.
the class EntityFinderLogMissing method findMemberRelationsRecursively.
private void findMemberRelationsRecursively(Deque<OsmRelation> queue, Set<OsmRelation> outRelations) {
TLongSet ids = new TLongHashSet();
while (!queue.isEmpty()) {
OsmRelation relation = queue.remove();
for (OsmRelationMember member : OsmModelUtil.membersAsList(relation)) {
if (member.getType() != EntityType.Relation) {
continue;
}
long id = member.getId();
if (ids.contains(id)) {
continue;
}
ids.add(id);
try {
OsmRelation child = entityProvider.getRelation(id);
outRelations.add(child);
queue.add(child);
} catch (EntityNotFoundException e) {
logRelationNotFound(id);
}
}
}
}
use of com.slimjars.dist.gnu.trove.set.hash.TLongHashSet in project osm4j-core by topobyte.
the class EntityFinderThrowMissing method findMemberRelationsRecursively.
private void findMemberRelationsRecursively(Deque<OsmRelation> queue, Set<OsmRelation> outRelations) throws EntityNotFoundException {
TLongSet ids = new TLongHashSet();
while (!queue.isEmpty()) {
OsmRelation relation = queue.remove();
for (OsmRelationMember member : OsmModelUtil.membersAsList(relation)) {
if (member.getType() != EntityType.Relation) {
continue;
}
long id = member.getId();
if (ids.contains(id)) {
continue;
}
ids.add(id);
OsmRelation child = entityProvider.getRelation(id);
outRelations.add(child);
queue.add(child);
}
}
}
Aggregations