Commit 7f7aa06e authored by Riegel's avatar Riegel
Browse files

Refactored addRing method. Ref #69

parent 27bb39a8
......@@ -30,6 +30,7 @@ import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Stream;
import org.citygml4j.core.model.CityGMLVersion;
......@@ -173,9 +174,9 @@ public class CityDoctorModel {
return;
}
Map<Vertex, Integer> idMap = new LinkedHashMap<>();
int counter = 0;
AtomicInteger counter = new AtomicInteger(0);
for (Polygon poly : highestLod) {
counter = addRing(poly.getExteriorRing(), idMap, counter);
addRing(poly.getExteriorRing(), idMap, counter);
}
try (BufferedWriter writer = Files.newBufferedWriter(folder.toPath().resolve(co.getGmlId() + ".off"))) {
......@@ -209,14 +210,10 @@ public class CityDoctorModel {
});
}
private int addRing(LinearRing ring, Map<Vertex, Integer> idMap, int counter) {
private void addRing(LinearRing ring, Map<Vertex, Integer> idMap, AtomicInteger counter) {
for (Vertex v : ring.getVertices()) {
if (!idMap.containsKey(v)) {
idMap.put(v, counter);
counter++;
}
idMap.computeIfAbsent(v, k -> counter.getAndIncrement());
}
return counter;
}
public Set<CheckError> collectErrors() {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment