Skip to content
GitLab
Explore
Projects
Groups
Snippets
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Eric Duminil
RegionChooser
Commits
179f69ff
Commit
179f69ff
authored
2 years ago
by
Eric Duminil
Browse files
Options
Download
Email Patches
Plain Diff
Getting there
parent
ae1e68cc
master
develop
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/eu/simstadt/regionchooser/RegionChooserCommandLineInterface.java
+24
-21
...tadt/regionchooser/RegionChooserCommandLineInterface.java
with
24 additions
and
21 deletions
+24
-21
src/main/java/eu/simstadt/regionchooser/RegionChooserCommandLineInterface.java
+
24
-
21
View file @
179f69ff
package
eu.simstadt.regionchooser
;
import
java.io.
BufferedWriter
;
import
java.
n
io.
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
;
}
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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
Menu
Explore
Projects
Groups
Snippets