Commit 4bb60f60 authored by Eric Duminil's avatar Eric Duminil
Browse files

separating scripts and tests.

parent ade55af9
package de.hft.stuttgart.scripts;
import java.io.File;
import java.io.IOException;
import org.citygml4j.xml.CityGMLContextException;
import org.citygml4j.xml.reader.CityGMLReadException;
import org.citygml4j.xml.writer.CityGMLWriteException;
import org.locationtech.jts.io.ParseException;
import de.hft.stuttgart.citygml.green.osm.GreenEnricher;
import jakarta.xml.bind.JAXBException;
public class PrepareDataForMarieke
{
// Add Trees to GML files inside data/Marieke/...
public static void main(String[] whatever) throws Exception {
processWholeRegion();
processSmallBlocks();
}
private static void processSmallBlocks() throws IOException, CityGMLContextException, CityGMLReadException,
InterruptedException, CityGMLWriteException, JAXBException, ParseException {
File[] folders = {
new File("data/Marieke/75Bäume/"),
new File("data/Marieke/250Bäume/Abstand5m"),
new File("data/Marieke/250Bäume/Abstand15m/49_801844__49_802502__9_948075__9_949534_15m_Block24"),
new File("data/Marieke/250Bäume/Abstand15m/49_802605__49_804087__9_94036__9_948417_15m_Block7-11_14-17"),
new File("data/Marieke/500Bäume/Abstand10m/49_801844__49_802502__9_948075__9_949534_10m_block_24"),
new File("data/Marieke/500Bäume/Abstand10m/49_802605__49_804087__9_94036__9_948417_10m_block_7-11_14-17"),
};
for (File folder : folders) {
System.err.println("### " + folder);
String gml = folder.listFiles((dir, name) -> name.endsWith(".gml"))[0].getName();
File[] shapefiles = folder.listFiles((dir, name) -> name.endsWith(".shp"));
for (File shapefile : shapefiles) {
System.out.println(shapefile);
String extension = shapefile.getName().replaceAll("\\.shp", "");
String[] args = new String[] { folder.toPath().resolve(gml).toString(), // Input GML
shapefile.toString(), // Added trees, in Baumkatasterformat,
extension, // Output GML suffix
};
GreenEnricher.main(args);
}
}
}
private static void processWholeRegion() throws IOException, CityGMLContextException, CityGMLReadException,
InterruptedException, CityGMLWriteException, JAXBException, ParseException {
File folder = new File("data/Marieke/ganzes_gebiet/");
String gml = "Grombühl_BA_IST.gml";
File[] shapefiles = folder.listFiles((dir, name) -> name.endsWith(".shp"));
for (File shapefile : shapefiles) {
System.err.println(">>> " + shapefile);
String extension = shapefile.getName().replaceAll("\\.shp", "");
String[] args = new String[] { folder.toPath().resolve(gml).toString(), // Input GML
shapefile.toString(), // Added trees, in Baumkatasterformat,
extension, // Output GML suffix
};
GreenEnricher.main(args);
}
}
}
package de.hft.stuttgart.citygml.green.alkis; package de.hft.stuttgart.citygml.green.alkis;
import java.io.File; 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 {
// @Test
// void testAlkisGreen() throws Exception {
// //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");
// 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
// //NOTE: From
// https://transfer.hft-stuttgart.de/gitlab/circulargreensimcity/circulargreensimcity/-/issues/26#note_6544
// "data/Trees/Trees_realisticScenario_20240201.shp", // Added trees, in
// Baumkatasterformat,
// "alkis_test", // Output GML suffix
// "POLYGON((9.946874 49.803172, 9.949785 49.803205, 9.952122 49.803312,
// 9.953435 49.803089, 9.956488 49.803150, 9.955465 49.802374, 9.953216
// 49.800916, 9.952371 49.800676, 9.951810 49.800509, 9.949172 49.800829,
// 9.946792 49.800796, 9.946874 49.803172))"
// };
// AlkisGreenEnricher.main(args);
// assertTrue(Files.exists(outputGML));
// }
class AlkisGreenEnricherTest
{
@Test @Test
void testMariekeGanzesGebiet() throws Exception { void testAlkisGreen() throws Exception {
File folder = new File("data/Marieke/ganzes_gebiet/"); //NOTE: From https://transfer.hft-stuttgart.de/gitlab/circulargreensimcity/circulargreensimcity/-/wikis/Fallstudien/Gromb%C3%BChl
String gml = "Grombühl_BA_IST.gml"; Path outputGML = Paths.get("data/Grombühl_v4_case_study_alkis_test.gml");
File[] shapefiles = folder.listFiles((dir, name) -> name.endsWith(".shp")); Files.deleteIfExists(outputGML);
for (File shapefile : shapefiles) { assertFalse(Files.exists(outputGML));
System.out.println(shapefile); String[] args = new String[] { "data/Grombühl_v4_case_study.gml", // Input GML
String extension = shapefile.getName().replaceAll("\\.shp", ""); "data/tn_09663/Nutzung.shp", // ALKIS Data
String[] args = new String[] { folder.toPath().resolve(gml).toString(), // Input GML //NOTE: From https://transfer.hft-stuttgart.de/gitlab/circulargreensimcity/circulargreensimcity/-/issues/26#note_6544
shapefile.toString(), // Added trees, in Baumkatasterformat, "data/Trees/Trees_realisticScenario_20240201.shp", // Added trees, in Baumkatasterformat,
extension, // Output GML suffix "alkis_test", // Output GML suffix
"POLYGON((9.946874 49.803172, 9.949785 49.803205, 9.952122 49.803312, 9.953435 49.803089, 9.956488 49.803150, 9.955465 49.802374, 9.953216 49.800916, 9.952371 49.800676, 9.951810 49.800509, 9.949172 49.800829, 9.946792 49.800796, 9.946874 49.803172))"
}; };
GreenEnricher.main(args); AlkisGreenEnricher.main(args);
} assertTrue(Files.exists(outputGML));
} }
@Test @Test
void testMariekeSpezial() throws Exception { void testGreen() throws Exception {
File[] folders = { Path outputGML = Paths.get("data/Grombühl_v4_case_study_enrich_test.gml");
new File("data/Marieke/75Bäume/"), Files.deleteIfExists(outputGML);
new File("data/Marieke/250Bäume/Abstand5m"), assertFalse(Files.exists(outputGML));
new File("data/Marieke/250Bäume/Abstand15m/49_801844__49_802502__9_948075__9_949534_15m_Block24"), String[] args = new String[] { "data/Grombühl_v4_case_study.gml", // Input GML
new File("data/Marieke/250Bäume/Abstand15m/49_802605__49_804087__9_94036__9_948417_15m_Block7-11_14-17"), "data/Trees/Trees_realisticScenario_20240201.shp", // Added trees, in Baumkatasterformat,
new File("data/Marieke/500Bäume/Abstand10m/49_801844__49_802502__9_948075__9_949534_10m_block_24"), "enrich_test" // Output GML suffix
new File("data/Marieke/500Bäume/Abstand10m/49_802605__49_804087__9_94036__9_948417_10m_block_7-11_14-17"),
};
for (File folder : folders) {
String gml = folder.listFiles((dir, name) -> name.endsWith(".gml"))[0].getName();
File[] shapefiles = folder.listFiles((dir, name) -> name.endsWith(".shp"));
for (File shapefile : shapefiles) {
System.out.println(shapefile);
String extension = shapefile.getName().replaceAll("\\.shp", "");
String[] args = new String[] { folder.toPath().resolve(gml).toString(), // Input GML
shapefile.toString(), // Added trees, in Baumkatasterformat,
extension, // Output GML suffix
}; };
GreenEnricher.main(args); GreenEnricher.main(args);
} assertTrue(Files.exists(outputGML));
}
// assertTrue(Files.exists(outputGML));
} }
} }
\ No newline at end of file
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