Commit 3096e1c7 authored by Eric Duminil's avatar Eric Duminil
Browse files

Allow local coordinates

parent 179f69ff
......@@ -6,6 +6,7 @@
import java.nio.file.Paths;
import java.util.Scanner;
import java.util.concurrent.Callable;
import org.osgeo.proj4j.CoordinateReferenceSystem;
import picocli.CommandLine;
import picocli.CommandLine.Command;
import picocli.CommandLine.Option;
......@@ -25,7 +26,9 @@ 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 = { "-l",
"--local" }, description = "Are WKT coordinates in local CRS?", paramLabel = "local_coordinates?")
boolean localCoordinates;
@Option(names = { "-w",
"--wkt" }, description = "File containing WKT polygon, or - for stdin", paramLabel = "polygon.wkt")
......@@ -33,15 +36,15 @@ class RegionChooserCommandLineInterface implements Callable<Integer>
@Override
public Integer call() throws Exception {
String srsName;
CoordinateReferenceSystem localCRS;
if (espgId == null) {
srsName = RegionChooserUtils.crsFromCityGMLHeader(citygmls[0]).toString();
localCRS = RegionChooserUtils.crsFromCityGMLHeader(citygmls[0]);
} else {
srsName = "EPSG:" + espgId;
localCRS = RegionChooserUtils.crsFromSrsName("EPSG:" + espgId);
}
String wktPolygon = "unknown";
String wktPolygon;
if (wktFile.equals("-")) {
if (System.in.available() == 0) {
......@@ -56,9 +59,13 @@ public Integer call() throws Exception {
}
}
if (!localCoordinates) {
// WKT coordinates are in WGS84, so should be first converted to srsName
}
System.out.println("WKT Polygon : " + wktPolygon);
StringBuilder sb = RegionExtractor.selectRegionDirectlyFromCityGML(wktPolygon, srsName, citygmls);
StringBuilder sb = RegionExtractor.selectRegionDirectlyFromCityGML(wktPolygon, localCRS.toString(), citygmls);
RegionChooserUtils.writeStringBuilderToFile(sb, outputCityGML);
......
......@@ -47,7 +47,7 @@ private RegionChooserUtils() {
* @param srsName
* @return CoordinateReferenceSystem
*/
private static CoordinateReferenceSystem crsFromSrsName(String srsName) {
public static CoordinateReferenceSystem crsFromSrsName(String srsName) {
// EPSG:31467
Pattern pEPSG = Pattern.compile("^(EPSG:\\d+)$");
Matcher mEPSG = pEPSG.matcher(srsName);
......
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