Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Eric Duminil
RegionChooser
Commits
0711c3e9
Commit
0711c3e9
authored
Oct 11, 2022
by
Eric Duminil
Browse files
Try stdout anyway.
Not sure it works.
parent
19ac5537
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/main/java/eu/simstadt/regionchooser/RegionChooserCLI.java
View file @
0711c3e9
package
eu.simstadt.regionchooser
;
import
java.io.BufferedWriter
;
import
java.io.PrintWriter
;
import
java.nio.charset.StandardCharsets
;
import
java.nio.file.Files
;
import
java.nio.file.Path
;
...
...
@@ -102,11 +103,21 @@ public Integer call() throws Exception {
logInfo
(
"WKT Polygon expressed in local coordinates: "
+
wktPolygon
);
try
(
BufferedWriter
gmlWriter
=
Files
.
newBufferedWriter
(
outputCityGML
))
{
int
count
=
RegionExtractor
.
selectRegionDirectlyFromCityGML
(
wktPolygon
,
localCRS
.
toString
(),
gmlWriter
,
citygmls
);
logInfo
(
"Found buildings : "
+
count
);
int
count
;
if
(
outputCityGML
.
toString
().
equals
(
"-"
))
{
logInfo
(
"CityGML written to stdout."
);
PrintWriter
stdOut
=
spec
.
commandLine
().
getOut
();
count
=
RegionExtractor
.
selectRegionDirectlyFromCityGML
(
wktPolygon
,
localCRS
.
toString
(),
stdOut
,
citygmls
);
}
else
{
try
(
BufferedWriter
gmlWriter
=
Files
.
newBufferedWriter
(
outputCityGML
))
{
count
=
RegionExtractor
.
selectRegionDirectlyFromCityGML
(
wktPolygon
,
localCRS
.
toString
(),
gmlWriter
,
citygmls
);
}
}
logInfo
(
"Found buildings : "
+
count
);
return
0
;
}
...
...
src/test/java/eu/simstadt/regionchooser/RegionChooserCLITests.java
View file @
0711c3e9
...
...
@@ -109,6 +109,24 @@ void testExtractRegionWithStandardInput() throws IOException {
assertEquals
(
2
,
countBuildings
(
outGML
));
}
@Test
void
testExtractRegionWithStandardInputAndStandardOutput
()
throws
IOException
{
String
wktPolygon
=
"POLYGON((-73.99325421344473 40.730897087489666, -73.99359753619864 40.7304702545556, -73.99287870418264 40.7300800049056, -73.99244955074026 40.730592207101864, -73.99325421344473 40.730897087489666))"
;
Path
citygml
=
TEST_REPOSITORY
.
resolve
(
"NewYork.proj/ManhattanSmall.gml"
);
InputStream
stdin
=
new
ByteArrayInputStream
(
wktPolygon
.
getBytes
(
StandardCharsets
.
UTF_8
));
System
.
setIn
(
stdin
);
Path
noOutput
=
Paths
.
get
(
"-"
);
Files
.
deleteIfExists
(
noOutput
);
assertFalse
(
Files
.
exists
(
noOutput
));
new
CommandLine
(
new
RegionChooserCLI
()).
execute
(
"--input="
+
citygml
,
"--output=-"
,
"--wkt=-"
);
String
expectedLog
=
"EPSG:32118"
;
assertTrue
(
err
.
toString
().
contains
(
expectedLog
),
err
.
toString
()
+
" should contain "
+
expectedLog
);
String
expectedBuilding
=
"uuid_0547df65-ae80-459e-bb15-c839c1a2e566"
;
assertTrue
(
out
.
toString
().
contains
(
expectedBuilding
),
out
.
toString
()
+
" should contain "
+
expectedBuilding
);
//TODO: Check if footer is here too
assertFalse
(
Files
.
exists
(
noOutput
));
}
@Test
void
testExtractRegionWithMissingInput
()
throws
IOException
{
String
wktPolygon
=
"POLYGON((-73.9959209576448 40.73286384885367, -73.996317924579 40.732359794090684, -73.9947515145143 40.7315061442504, -73.99422580154739 40.73214841515045, -73.9959209576448 40.73286384885367))"
;
...
...
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