Commit 0b3a4414 authored by Matthias Betz's avatar Matthias Betz
Browse files

fix AlkisGreenEnricher not working with polygon

parent f704c6b4
......@@ -102,7 +102,7 @@ public class AlkisGreenEnricher
GreenEnricher.createTransformers(cityModel);
OsmData osmData = new OsmData();
// String boundingBoxString = GreenEnricher.extractAndConvertBoundingBox(cityModel, osmData);
String boundingBoxString = GreenEnricher.extractAndConvertBoundingBox(cityModel, osmData);
// String boundingBoxBasename = boundingBoxString.replace(",", "__").replace('.', '_');
// Path osmCache = Paths.get("data", "cache", "osm_response_" + boundingBoxBasename + ".xml");
// if (!Files.exists(osmCache)) {
......@@ -144,8 +144,6 @@ public class AlkisGreenEnricher
System.out.println("Writing output file.");
GreenEnricher.writeCityGML(cityModel, outputPath);
System.out.println("Done");
}
private static void parseAlkisData(OsmData osmData, Path alkisDataPath) throws MalformedURLException, IOException {
......
......@@ -50,7 +50,7 @@ public class TreeKatasterData {
if (treeHeightObject == null) {
continue;
}
int treeHeight = Integer.parseInt(treeHeightObject.toString());
double treeHeight = Double.parseDouble(treeHeightObject.toString());
double crownHeight = CROWN_PERCENTAGE * treeHeight;
double trunkHeight = TRUNK_PERCENTAGE * treeHeight;
tree.setCrownHeight(crownHeight);
......@@ -65,8 +65,8 @@ public class TreeKatasterData {
if (trunkCirc == null) {
continue;
}
int circInCm = Integer.parseInt(trunkCirc.toString());
if (circInCm == 0) {
double circInCm = Double.parseDouble(trunkCirc.toString());
if (circInCm <= 0.1) {
circInCm = 89;
}
tree.setTrunkRadius(circInCm / (2 * Math.PI) / 100);
......
......@@ -2,6 +2,7 @@ package de.hft.stuttgart.citygml.green.osm;
import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Iterator;
import java.util.UUID;
import org.citygml4j.core.model.core.AbstractCityObjectProperty;
......@@ -9,6 +10,7 @@ import org.citygml4j.core.model.core.CityModel;
import org.citygml4j.core.model.vegetation.SolitaryVegetationObject;
import org.locationtech.jts.geom.Coordinate;
import org.locationtech.jts.geom.GeometryFactory;
import org.locationtech.jts.geom.Point;
import org.locationtech.jts.geom.Polygon;
import org.xmlobjects.gml.model.basictypes.Code;
import org.xmlobjects.gml.model.geometry.aggregates.MultiSurface;
......@@ -24,6 +26,10 @@ public class TreeUtils {
TreeKatasterData katasterData = TreeKatasterData.parseTreeKatasterData(baumKatasterPath);
generateTreesFromKataster(cityModel, katasterData, osmData, wktPolygon);
// TreeKatasterData added = TreeKatasterData.parseTreeKatasterData(baumKatasterPath);
// filterDuplicateTrees(katasterData, added);
// generateTreesFromKataster(cityModel, added, osmData, wktPolygon);
// TreeKatasterData katasterData2 =
// TreeKatasterData.parseTreeKatasterData(Paths.get("data",
// "Trees_realistic_20240201.shp"));
......@@ -37,6 +43,19 @@ public class TreeUtils {
}
private static void filterDuplicateTrees(TreeKatasterData truth, TreeKatasterData added) {
for (Iterator<Tree> iterator = added.getTrees().iterator(); iterator.hasNext();) {
Tree tp = iterator.next();
// if another tree from kataster is within 1m ignore it
for (Tree tree : truth.getTrees()) {
if (tp.getPoint().distance(tree.getPoint()) < 1) {
iterator.remove();
break;
}
}
}
}
private static void filterDuplicateTreesFromOSM(OsmData osmData, TreeKatasterData katasterData) {
for (Iterator<TreePoint> iterator = osmData.getTreePoints().iterator(); iterator.hasNext();) {
TreePoint tp = iterator.next();
......@@ -80,8 +99,9 @@ public class TreeUtils {
for (Tree tree : katasterData.getTrees()) {
// check if tree is in area
Coordinate coordinate = tree.getPoint().getCoordinate();
if ((wktPolygon != null && !wktPolygon.contains(FACTORY.createPoint(coordinate)))
|| !osmData.getBoundingBox().contains(FACTORY.createPoint(coordinate))) {
Point point = FACTORY.createPoint(coordinate);
if ((wktPolygon != null && !wktPolygon.contains(point))
|| (wktPolygon == null && !osmData.getBoundingBox().contains(point))) {
continue;
}
......
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