Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Eric Duminil
RegionChooser
Commits
3096e1c7
Commit
3096e1c7
authored
Oct 07, 2022
by
Eric Duminil
Browse files
Allow local coordinates
parent
179f69ff
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/main/java/eu/simstadt/regionchooser/RegionChooserCommandLineInterface.java
View file @
3096e1c7
...
...
@@ -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
{
s
rsName
=
"EPSG:"
+
espgId
;
localCRS
=
RegionChooserUtils
.
crsFromS
rsName
(
"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
);
...
...
src/main/java/eu/simstadt/regionchooser/RegionChooserUtils.java
View file @
3096e1c7
...
...
@@ -47,7 +47,7 @@ private RegionChooserUtils() {
* @param srsName
* @return CoordinateReferenceSystem
*/
p
rivate
static
CoordinateReferenceSystem
crsFromSrsName
(
String
srsName
)
{
p
ublic
static
CoordinateReferenceSystem
crsFromSrsName
(
String
srsName
)
{
// EPSG:31467
Pattern
pEPSG
=
Pattern
.
compile
(
"^(EPSG:\\d+)$"
);
Matcher
mEPSG
=
pEPSG
.
matcher
(
srsName
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment