Commit bf8478d7 authored by Eric Duminil's avatar Eric Duminil
Browse files

Changes, for Marieke & CGSC.

parent c88c9734
...@@ -8,7 +8,6 @@ import java.net.http.HttpClient; ...@@ -8,7 +8,6 @@ import java.net.http.HttpClient;
import java.net.http.HttpRequest; import java.net.http.HttpRequest;
import java.net.http.HttpResponse; import java.net.http.HttpResponse;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;
import java.nio.file.Paths; import java.nio.file.Paths;
import java.util.ArrayList; import java.util.ArrayList;
...@@ -122,32 +121,32 @@ public class GreenEnricher ...@@ -122,32 +121,32 @@ public class GreenEnricher
createTransformers(cityModel); createTransformers(cityModel);
OsmData osmData = new OsmData(); // OsmData osmData = new OsmData();
String boundingBoxString = GreenEnricher.extractAndConvertBoundingBox(cityModel, osmData); // String boundingBoxString = GreenEnricher.extractAndConvertBoundingBox(cityModel, osmData);
String boundingBoxBasename = boundingBoxString.replace(",", "__").replace('.', '_'); // String boundingBoxBasename = boundingBoxString.replace(",", "__").replace('.', '_');
Path osmCache = Paths.get("data", "cache", "osm_response_" + boundingBoxBasename + ".xml"); // Path osmCache = Paths.get("data", "cache", "osm_response_" + boundingBoxBasename + ".xml");
if (!Files.exists(osmCache)) { // if (!Files.exists(osmCache)) {
System.out.println("Downloading OSM data for " + boundingBoxString); // System.out.println("Downloading OSM data for " + boundingBoxString);
HttpResponse<String> response = GreenEnricher.getOsmData(boundingBoxString); // HttpResponse<String> response = GreenEnricher.getOsmData(boundingBoxString);
Files.write(osmCache, response.body().getBytes(StandardCharsets.UTF_8)); // Files.write(osmCache, response.body().getBytes(StandardCharsets.UTF_8));
} // }
String osmResponse = Files.readString(osmCache); // String osmResponse = Files.readString(osmCache);
//
System.out.println("Parsing OSM response"); // System.out.println("Parsing OSM response");
parseOsmResponse(osmResponse, osmData); // parseOsmResponse(osmResponse, osmData);
//
System.out.println("Fit data in bounding box"); // System.out.println("Fit data in bounding box");
fitToBoundingBox(osmData); // fitToBoundingBox(osmData);
//
System.out.println("Filter intersecting areas"); // System.out.println("Filter intersecting areas");
List<GreenArea> greenAreas = osmData.getGreenAreas(); // List<GreenArea> greenAreas = osmData.getGreenAreas();
removeDuplicateAreas(greenAreas); // removeDuplicateAreas(greenAreas);
//
convertGreenAreasToCityGML(cityModel, greenAreas); // convertGreenAreasToCityGML(cityModel, greenAreas);
convertWaterAreasToCityGML(cityModel, osmData); // convertWaterAreasToCityGML(cityModel, osmData);
// trees // trees
TreeUtils.insertTrees(cityModel, osmData, baumKatasterPath); TreeUtils.insertTrees(cityModel, null, baumKatasterPath);
clampToGround(cityModel); clampToGround(cityModel);
......
...@@ -7,7 +7,6 @@ import java.util.ArrayList; ...@@ -7,7 +7,6 @@ import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.geotools.data.DataStore; import org.geotools.data.DataStore;
import org.geotools.data.DataStoreFinder; import org.geotools.data.DataStoreFinder;
import org.geotools.data.FeatureSource; import org.geotools.data.FeatureSource;
...@@ -17,7 +16,9 @@ import org.locationtech.jts.geom.Point; ...@@ -17,7 +16,9 @@ import org.locationtech.jts.geom.Point;
import org.opengis.feature.simple.SimpleFeature; import org.opengis.feature.simple.SimpleFeature;
import org.opengis.feature.simple.SimpleFeatureType; import org.opengis.feature.simple.SimpleFeatureType;
public class TreeKatasterData {
public class TreeKatasterData
{
public static final double TRUNK_PERCENTAGE = 0.2; public static final double TRUNK_PERCENTAGE = 0.2;
public static final double CROWN_PERCENTAGE = 1 - TRUNK_PERCENTAGE; public static final double CROWN_PERCENTAGE = 1 - TRUNK_PERCENTAGE;
...@@ -50,7 +51,7 @@ public class TreeKatasterData { ...@@ -50,7 +51,7 @@ public class TreeKatasterData {
if (treeHeightObject == null) { if (treeHeightObject == null) {
continue; continue;
} }
int treeHeight = Integer.parseInt(treeHeightObject.toString()); float treeHeight = Float.parseFloat(treeHeightObject.toString());
double crownHeight = CROWN_PERCENTAGE * treeHeight; double crownHeight = CROWN_PERCENTAGE * treeHeight;
double trunkHeight = TRUNK_PERCENTAGE * treeHeight; double trunkHeight = TRUNK_PERCENTAGE * treeHeight;
tree.setCrownHeight(crownHeight); tree.setCrownHeight(crownHeight);
...@@ -61,14 +62,7 @@ public class TreeKatasterData { ...@@ -61,14 +62,7 @@ public class TreeKatasterData {
continue; continue;
} }
tree.setCrownRadius(Float.parseFloat(crownWidth.toString()) / 2); tree.setCrownRadius(Float.parseFloat(crownWidth.toString()) / 2);
Object trunkCirc = feature.getAttribute("Stammumfan"); int circInCm = 50;
if (trunkCirc == null) {
continue;
}
int circInCm = Integer.parseInt(trunkCirc.toString());
if (circInCm == 0) {
circInCm = 89;
}
tree.setTrunkRadius(circInCm / (2 * Math.PI) / 100); tree.setTrunkRadius(circInCm / (2 * Math.PI) / 100);
result.getTrees().add(tree); result.getTrees().add(tree);
} }
......
...@@ -25,10 +25,10 @@ public class TreeUtils ...@@ -25,10 +25,10 @@ public class TreeUtils
// generateTreesFromKataster(cityModel, katasterData2); // generateTreesFromKataster(cityModel, katasterData2);
// All kataster trees are taken, osm trees are removed // All kataster trees are taken, osm trees are removed
filterDuplicateTreesFromOSM(osmData, katasterData); // filterDuplicateTreesFromOSM(osmData, katasterData);
// filterDuplicateTreesFromOSM(osmData, katasterData2); // filterDuplicateTreesFromOSM(osmData, katasterData2);
generateTreesFromOSM(cityModel, osmData); // generateTreesFromOSM(cityModel, osmData);
} }
......
package de.hft.stuttgart.citygml.green.alkis; package de.hft.stuttgart.citygml.green.alkis;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import de.hft.stuttgart.citygml.green.osm.GreenEnricher; import de.hft.stuttgart.citygml.green.osm.GreenEnricher;
class AlkisGreenEnricherTest class AlkisGreenEnricherTest
{ {
@Test // @Test
void testAlkisGreen() throws Exception { // void testAlkisGreen() throws Exception {
//NOTE: From https://transfer.hft-stuttgart.de/gitlab/circulargreensimcity/circulargreensimcity/-/wikis/Fallstudien/Gromb%C3%BChl // //NOTE: From https://transfer.hft-stuttgart.de/gitlab/circulargreensimcity/circulargreensimcity/-/wikis/Fallstudien/Gromb%C3%BChl
Path outputGML = Paths.get("data/Grombühl_v4_case_study_alkis_test.gml"); // Path outputGML = Paths.get("data/Grombühl_v4_case_study_alkis_test.gml");
Files.deleteIfExists(outputGML); // Files.deleteIfExists(outputGML);
assertFalse(Files.exists(outputGML)); // assertFalse(Files.exists(outputGML));
String[] args = new String[] { "data/Grombühl_v4_case_study.gml", // Input GML // String[] args = new String[] { "data/Grombühl_BA_IST.gml", // Input GML
"data/tn_09663/Nutzung.shp", // ALKIS Data // "data/tn_09663/Nutzung.shp", // ALKIS Data
//NOTE: From https://transfer.hft-stuttgart.de/gitlab/circulargreensimcity/circulargreensimcity/-/issues/26#note_6544 // //NOTE: From https://transfer.hft-stuttgart.de/gitlab/circulargreensimcity/circulargreensimcity/-/issues/26#note_6544
"data/Trees/Trees_realisticScenario_20240201.shp", // Added trees, in Baumkatasterformat, // "data/Trees/Trees_realisticScenario_20240201.shp", // Added trees, in Baumkatasterformat,
"alkis_test" // Output GML suffix // "alkis_test" // Output GML suffix
}; // };
AlkisGreenEnricher.main(args); // AlkisGreenEnricher.main(args);
assertTrue(Files.exists(outputGML)); // assertTrue(Files.exists(outputGML));
} // }
@Test @Test
void testGreen() throws Exception { void testGreen() throws Exception {
Path outputGML = Paths.get("data/Grombühl_v4_case_study_enrich_test.gml"); // Path outputGML = Paths.get("data/Grombühl_BA_IST_.gml");
Files.deleteIfExists(outputGML); // Files.deleteIfExists(outputGML);
assertFalse(Files.exists(outputGML)); // assertFalse(Files.exists(outputGML));
String[] args = new String[] { "data/Grombühl_v4_case_study.gml", // Input GML String[] args = new String[] { "data/Grafenbühl_IST.gml", // Input GML
"data/Trees/Trees_realisticScenario_20240201.shp", // Added trees, in Baumkatasterformat, "data/Baum_Grafenbühl_Ist.shp", // Added trees, in Baumkatasterformat,
"enrich_test" // Output GML suffix // "data/Trees/Trees_realisticScenario_20240201.shp", // Added trees, in Baumkatasterformat,
"plus_trees" // Output GML suffix
}; };
GreenEnricher.main(args); GreenEnricher.main(args);
assertTrue(Files.exists(outputGML)); // args = new String[] { "data/Grombühl_BA_IST_plus_private.gml", // Input GML
// "data/Baum_oeffentlich_Neu_Ist.shp", // Added trees, in Baumkatasterformat,
// // "data/Trees/Trees_realisticScenario_20240201.shp", // Added trees, in Baumkatasterformat,
// "plus_public" // Output GML suffix
// };
// GreenEnricher.main(args);
// assertTrue(Files.exists(outputGML));
} }
} }
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