Commit 179f69ff authored by Eric Duminil's avatar Eric Duminil
Browse files

Getting there

parent ae1e68cc
package eu.simstadt.regionchooser;
import java.io.BufferedWriter;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.List;
import java.nio.file.Paths;
import java.util.Scanner;
import java.util.concurrent.Callable;
import picocli.CommandLine;
......@@ -16,7 +16,7 @@ class RegionChooserCommandLineInterface implements Callable<Integer>
{
@Option(names = { "-i",
"--input" }, required = true, split = ",", description = "Citygml files to extract from", paramLabel = "input.gml")
List<Path> citygmls;
Path[] citygmls;
@Option(names = { "-o",
"--output" }, required = true, description = "Output file", paramLabel = "output.gml")
......@@ -25,40 +25,43 @@ class RegionChooserCommandLineInterface implements Callable<Integer>
@Option(names = { "-e", "--epsg" }, description = "EPSG id for coordinate reference system", paramLabel = "31467")
Integer espgId;
//TODO: Add possibility to choose wgs84 or local_crs
@Option(names = { "-w",
"--wkt" }, description = "File containing WKT polygon, or - for stdin", paramLabel = "polygon.wkt")
String wktFile = "-";
@Override
public Integer call() throws Exception { // your business logic goes here...
System.out.println("Should extract from :");
for (Path input_citygml : citygmls) {
System.out.println(" " + input_citygml);
}
System.out.print("And write to : ");
System.out.println(outputCityGML);
try (BufferedWriter bf = Files.newBufferedWriter(outputCityGML)) {
bf.write("HELLO THERE!");
}
public Integer call() throws Exception {
String srsName;
if (espgId == null) {
System.out.println("coordinates from " + citygmls.get(0));
srsName = RegionChooserUtils.crsFromCityGMLHeader(citygmls[0]).toString();
} else {
System.out.print("in EPSG:");
System.out.println(espgId + " coordinates.");
srsName = "EPSG:" + espgId;
}
String wktPolygon = "unknown";
if (wktFile.equals("-")) {
if (System.in.available() == 0) {
System.out.println("OH NOEs, NO INPUT!");
throw new IllegalArgumentException("Please provide \"POLYGON((x1 y1, x2 y2, ...))\" to standard input.");
} else {
System.out.println("Here's standard input:");
System.out.println(getInput());
System.out.println("Done");
wktPolygon = getInput();
}
} else {
System.out.println("Try to read from " + wktFile);
wktPolygon = new String(Files.readAllBytes(Paths.get(wktFile)), StandardCharsets.UTF_8);
if (wktPolygon.isEmpty()) {
throw new IllegalArgumentException("Please write \"POLYGON((x1 y1, x2 y2, ...))\" inside " + wktFile);
}
}
System.out.println("WKT Polygon : " + wktPolygon);
StringBuilder sb = RegionExtractor.selectRegionDirectlyFromCityGML(wktPolygon, srsName, citygmls);
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