Commit 534d15df authored by Eric Duminil's avatar Eric Duminil
Browse files

Test.

parent bbf99ee0
......@@ -116,16 +116,22 @@ public class GreenEnricher
InterruptedException, ParserConfigurationException, CityGMLWriteException, JAXBException {
System.out.println("Reading CityGML file");
Path inFile = Paths.get(args[0]);
Path baumKatasterPath = Paths.get(args[1]);
String outputSuffix = args[2];
CityModel cityModel = readCityGml(inFile);
createTransformers(cityModel);
OsmData osmData = new OsmData();
String boundingBoxString = extractAndConvertBoundingBox(cityModel, osmData);
// HttpResponse<String> response = getOsmData(boundingBoxString);
// Files.write(Path.of("osm_response.xml"), response.body().getBytes(StandardCharsets.UTF_8));
// String osmResponse = response.body();
String osmResponse = Files.readString(Paths.get("data", "osm_response.xml"));
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)) {
System.out.println("Downloading OSM data for " + boundingBoxString);
HttpResponse<String> response = GreenEnricher.getOsmData(boundingBoxString);
Files.write(osmCache, response.body().getBytes(StandardCharsets.UTF_8));
}
String osmResponse = Files.readString(osmCache);
System.out.println("Parsing OSM response");
parseOsmResponse(osmResponse, osmData);
......@@ -141,13 +147,13 @@ public class GreenEnricher
convertWaterAreasToCityGML(cityModel, osmData);
// trees
TreeUtils.insertTrees(cityModel, osmData);
TreeUtils.insertTrees(cityModel, osmData, baumKatasterPath);
clampToGround(cityModel);
String inputString = inFile.getFileName().toString();
String inputPathWithoutFileEnding = inputString.substring(0, inputString.lastIndexOf('.'));
Path outputPath = Paths.get("data", inputPathWithoutFileEnding + "_with_osm_greens.gml");
Path outputPath = Paths.get("data", inputPathWithoutFileEnding + "_" + outputSuffix + ".gml");
System.out.println("Writing output file.");
writeCityGML(cityModel, outputPath);
System.out.println("Done");
......
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;
......@@ -7,11 +12,15 @@ class AlkisGreenEnricherTest
{
@Test
void testAlkisGreen() throws Exception {
Path outputGML = Paths.get("data/Grombühl_v4_case_study_with_alkis_greens_realistic.gml");
Files.deleteIfExists(outputGML);
assertFalse(Files.exists(outputGML));
String[] args = new String[] { "data/Grombühl_v4_case_study.gml", // Input GML
"data/tn_09663/Nutzung.shp", // ALKIS Data
"data/Trees/Trees_realisticScenario_20240201.shp", // Added trees, in Baumkatasterformat,
"with_alkis_greens_realistic" // Output GML suffix
};
AlkisGreenEnricher.main(args);
assertTrue(Files.exists(outputGML));
}
}
Markdown is supported
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