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

Working example

parent 3096e1c7
......@@ -6,11 +6,19 @@
import java.nio.file.Paths;
import java.util.Scanner;
import java.util.concurrent.Callable;
import org.locationtech.jts.geom.Polygon;
import org.locationtech.jts.io.WKTReader;
import org.locationtech.jts.io.WKTWriter;
import org.osgeo.proj4j.CoordinateReferenceSystem;
import picocli.CommandLine;
import picocli.CommandLine.Command;
import picocli.CommandLine.Option;
// Example usage:
// --input /home/ricou/Desktop/CGSC_Repository/Würzburg.proj/LoD2_566_5516_2_BY.gml,/home/ricou/Desktop/CGSC_Repository/Würzburg.proj/LoD2_568_5516_2_BY.gml
// --output /home/ricou/Desktop/output.gml
// --wkt /home/ricou/Desktop/grombuhl.txt
@Command(name = "region_chooser", mixinStandardHelpOptions = true, version = "regionChooser x.x", description = "Extracts a region from one or more citygmls.", sortOptions = false)
class RegionChooserCommandLineInterface implements Callable<Integer>
......@@ -36,6 +44,8 @@ class RegionChooserCommandLineInterface implements Callable<Integer>
@Override
public Integer call() throws Exception {
//TODO: Move as much logic to utils as possible, and test it.
//TODO: Use logger
CoordinateReferenceSystem localCRS;
if (espgId == null) {
......@@ -43,6 +53,7 @@ public Integer call() throws Exception {
} else {
localCRS = RegionChooserUtils.crsFromSrsName("EPSG:" + espgId);
}
System.out.println("Coordinate system is " + localCRS);
String wktPolygon;
......@@ -60,13 +71,20 @@ public Integer call() throws Exception {
}
if (!localCoordinates) {
final WKTReader WKT_READER = new WKTReader();
final WKTWriter WKT_WRITER = new WKTWriter();
// WKT coordinates are in WGS84, so should be first converted to srsName
Polygon wgs84Polygon = (Polygon) WKT_READER.read(wktPolygon);
wktPolygon = WKT_WRITER
.write(RegionChooserUtils.changePolygonCRS(wgs84Polygon, RegionChooserUtils.WGS84, localCRS));
}
System.out.println("WKT Polygon : " + wktPolygon);
StringBuilder sb = RegionExtractor.selectRegionDirectlyFromCityGML(wktPolygon, localCRS.toString(), citygmls);
//TODO: Check how many buildings are written. Warning if 0?
RegionChooserUtils.writeStringBuilderToFile(sb, outputCityGML);
return 0;
......
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