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
Compare Revisions
8f4652a30c792f2cd324bc635839bf96aa75ce34...298f5442583073d63e1c85c77d97cc0280c99879
Source
hft_gitlab/regionchooser
Select target project
298f5442583073d63e1c85c77d97cc0280c99879
Select Git revision
...
Target
hft_gitlab/regionchooser
Select target project
hft_gitlab/regionchooser
8f4652a30c792f2cd324bc635839bf96aa75ce34
Select Git revision
Compare
Swap revisions
Commits (2)
Unused imports.
· 155d5e85
Eric Duminil
authored
2 years ago
155d5e85
Make sure Repository is defined, and it exists, before trying to import anything.
· 298f5442
Eric Duminil
authored
2 years ago
298f5442
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
src/main/java/eu/simstadt/regionchooser/RegionChooserBrowser.java
+12
-5
.../java/eu/simstadt/regionchooser/RegionChooserBrowser.java
src/main/java/eu/simstadt/regionchooser/fast_xml_parser/ConvexHullCalculator.java
+4
-0
...t/regionchooser/fast_xml_parser/ConvexHullCalculator.java
src/test/java/eu/simstadt/regionchooser/fast_xml_parser/CitygmlParserTests.java
+0
-2
...adt/regionchooser/fast_xml_parser/CitygmlParserTests.java
src/test/java/eu/simstadt/regionchooser/fast_xml_parser/ConvexHullCalculatorTests.java
+12
-1
...ionchooser/fast_xml_parser/ConvexHullCalculatorTests.java
with
28 additions
and
8 deletions
+28
-8
src/main/java/eu/simstadt/regionchooser/RegionChooserBrowser.java
View file @
298f5442
...
...
@@ -42,8 +42,8 @@ public class RegionChooserBrowser extends Region
public
JavaScriptFXBridge
()
{
Preferences
userPrefs
=
Preferences
.
userRoot
().
node
(
"/eu/simstadt/desktop"
);
String
repoString
=
userPrefs
.
get
(
PREF_RECENT_REPOSITORY
,
"../TestRepository"
);
repo
=
Paths
.
get
(
repoString
);
String
repoString
=
userPrefs
.
get
(
PREF_RECENT_REPOSITORY
,
null
);
repo
=
repoString
==
null
?
null
:
Paths
.
get
(
repoString
);
}
/**
...
...
@@ -51,6 +51,9 @@ public JavaScriptFXBridge() {
* to the JS app in order to be displayed.
*/
public
void
refreshHulls
()
{
if
(
repo
==
null
||
!
Files
.
exists
(
repo
))
{
selectRepository
();
}
Task
<
Void
>
task
=
new
Task
<
Void
>()
{
@Override
public
Void
call
()
throws
IOException
{
...
...
@@ -62,7 +65,9 @@ public Void call() throws IOException {
task
.
setOnRunning
(
e
->
{
jsApp
.
call
(
"display"
,
"Importing citgyml. Please wait."
);
jsApp
.
call
(
"showRepositoryName"
,
repo
.
getFileName
().
toString
());
if
(
repo
!=
null
)
{
jsApp
.
call
(
"showRepositoryName"
,
repo
.
getFileName
().
toString
());
}
jsApp
.
call
(
"init"
);
});
...
...
@@ -105,13 +110,15 @@ public Integer call() throws IOException, XPathParseException, NavException, Par
public
void
selectRepository
()
{
//TODO: Check if it's really a repository, and not just a project
Preferences
userPrefs
=
Preferences
.
userRoot
().
node
(
"/eu/simstadt/desktop"
);
String
currentRepo
=
userPrefs
.
get
(
PREF_RECENT_REPOSITORY
,
"../TestRepository"
);
DirectoryChooser
fileChooser
=
new
DirectoryChooser
();
Stage
mainStage
=
(
Stage
)
RegionChooserBrowser
.
this
.
getScene
().
getWindow
();
fileChooser
.
setTitle
(
"Select Repository"
);
fileChooser
.
setInitialDirectory
(
new
File
(
currentRepo
));
if
(
repo
!=
null
&&
Files
.
exists
(
repo
))
{
fileChooser
.
setInitialDirectory
(
repo
.
toFile
());
}
File
repoLocation
=
fileChooser
.
showDialog
(
mainStage
);
if
(
repoLocation
!=
null
)
{
...
...
This diff is collapsed.
Click to expand it.
src/main/java/eu/simstadt/regionchooser/fast_xml_parser/ConvexHullCalculator.java
View file @
298f5442
...
...
@@ -89,6 +89,10 @@ public static Geometry calculateFromCityGML(Path citygmlPath) throws XPathParseE
* @throws IOException
*/
public
static
void
extractHullsForEveryCityGML
(
Path
repository
,
Consumer
<
String
>
callback
)
throws
IOException
{
if
(!
Files
.
exists
(
repository
))
{
LOGGER
.
warning
(
repository
+
" does not appear to exist."
);
return
;
}
LOGGER
.
info
(
"Parsing "
+
repository
);
RegionChooserUtils
.
everyCityGML
(
repository
)
.
map
(
gmlPath
->
{
...
...
This diff is collapsed.
Click to expand it.
src/test/java/eu/simstadt/regionchooser/fast_xml_parser/CitygmlParserTests.java
View file @
298f5442
...
...
@@ -7,8 +7,6 @@
import
java.nio.file.Paths
;
import
org.junit.jupiter.api.Test
;
import
com.ximpleware.XPathParseException
;
import
eu.simstadt.regionchooser.fast_xml_parser.BuildingXmlNode
;
import
eu.simstadt.regionchooser.fast_xml_parser.CityGmlIterator
;
public
class
CitygmlParserTests
...
...
This diff is collapsed.
Click to expand it.
src/test/java/eu/simstadt/regionchooser/fast_xml_parser/ConvexHullCalculatorTests.java
View file @
298f5442
package
eu.simstadt.regionchooser.fast_xml_parser
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.
assertEquals
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.
assertFalse
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.
assertTrue
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.
fail
;
import
java.io.File
;
import
java.io.IOException
;
import
java.nio.file.Files
;
...
...
@@ -16,13 +19,13 @@
import
org.locationtech.jts.geom.Point
;
import
com.ximpleware.XPathParseException
;
import
eu.simstadt.regionchooser.RegionChooserUtils
;
import
eu.simstadt.regionchooser.fast_xml_parser.ConvexHullCalculator
;
public
class
ConvexHullCalculatorTests
{
private
static
final
GeometryFactory
gf
=
new
GeometryFactory
();
private
static
final
Path
repository
=
Paths
.
get
(
"src/test/resources/testdata"
);
private
static
final
Path
notExistingRepository
=
Paths
.
get
(
"src/test/resources/surely_not_here"
);
@Test
public
void
testExtractConvexHullFromOneBuilding
()
throws
IOException
,
XPathParseException
{
...
...
@@ -73,4 +76,12 @@ public void testExtractConvexHullFromEveryCitygmlInRepository() throws IOExcepti
assertTrue
(
gmlCount
>=
minHullCount
,
"At least "
+
minHullCount
+
" citygmls should be present in repository"
);
assertTrue
(
hullCount
.
get
()
>=
minHullCount
,
"At least "
+
minHullCount
+
" hulls should have been calculated"
);
}
@Test
public
void
testDontDoMuchWithBrokenRepo
()
throws
IOException
{
ConvexHullCalculator
.
extractHullsForEveryCityGML
(
notExistingRepository
,
kmlHull
->
{
fail
(
"I really shouldn't be called for any gml."
);
});
assertFalse
(
Files
.
exists
(
notExistingRepository
));
}
}
This diff is collapsed.
Click to expand it.
Menu
Explore
Projects
Groups
Snippets