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; ...@@ -30,6 +30,7 @@ import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Stream; import java.util.stream.Stream;
import org.citygml4j.core.model.CityGMLVersion; import org.citygml4j.core.model.CityGMLVersion;
...@@ -173,9 +174,9 @@ public class CityDoctorModel { ...@@ -173,9 +174,9 @@ public class CityDoctorModel {
return; return;
} }
Map<Vertex, Integer> idMap = new LinkedHashMap<>(); Map<Vertex, Integer> idMap = new LinkedHashMap<>();
int counter = 0; AtomicInteger counter = new AtomicInteger(0);
for (Polygon poly : highestLod) { 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"))) { try (BufferedWriter writer = Files.newBufferedWriter(folder.toPath().resolve(co.getGmlId() + ".off"))) {
...@@ -209,15 +210,11 @@ public class CityDoctorModel { ...@@ -209,15 +210,11 @@ 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()) { for (Vertex v : ring.getVertices()) {
if (!idMap.containsKey(v)) { idMap.computeIfAbsent(v, k -> counter.getAndIncrement());
idMap.put(v, counter);
counter++;
} }
} }
return counter;
}
public Set<CheckError> collectErrors() { public Set<CheckError> collectErrors() {
List<CheckError> errors = new ArrayList<>(); List<CheckError> errors = new ArrayList<>();
......
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