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
Compare Revisions
fa0b90e066cc47db049b54825b516233c40d00ba...13f85aab7d81903e7172567a1f8dd7cb3e629d97
Commits (3)
NOTE
· 92a8de3d
Eric Duminil
authored
Oct 12, 2022
92a8de3d
Take size into account for cached hull
· cc835fd7
Eric Duminil
authored
Oct 12, 2022
cc835fd7
F5 for refresh
· 13f85aab
Eric Duminil
authored
Oct 12, 2022
13f85aab
Hide whitespace changes
Inline
Side-by-side
src/main/java/eu/simstadt/regionchooser/RegionExtractor.java
View file @
13f85aab
...
...
@@ -32,13 +32,13 @@
* same coordinate system as the CityGML), it iterates over each Building and checks if the building is inside the
* geometry. It only works with CityGML files smaller than 2GB. It uses VTD-XML parser instead of a whole
* Simstadt/Citydoctor/Citygml model.
*
*
* @param wktPolygon
* @param srsName
* @param output
* @param citygmlPaths
*
*
*
*
* @writes the extracted Citygml, including header, buildings and footer to output
* @return counts of found building.
* @throws ParseException
...
...
@@ -88,6 +88,7 @@ static int selectRegionDirectlyFromCityGML(String wktPolygon, String srsName, Wr
}
LOGGER
.
info
(
"Buildings found in selected region "
+
foundBuildingsCount
);
//NOTE: This could be a problem if header starts with <core:CityModel> and footer ends with </CityModel>
sb
.
append
(
citygml
.
getFooter
());
return
foundBuildingsCount
;
}
...
...
@@ -99,7 +100,7 @@ static int selectRegionDirectlyFromCityGML(String wktPolygon, String srsName, Wr
* from the extracting polygon. The real envelope might be even smaller, but it could only be known at the end of the
* parsing, after having analyzed every building. The envelope should be written in the header. If present, min and
* max values for Z are kept.
*
*
* @param header
* @param envelope
* @param srsName
...
...
src/main/java/eu/simstadt/regionchooser/fast_xml_parser/ConvexHullCalculator.java
View file @
13f85aab
...
...
@@ -25,6 +25,10 @@
{
private
static
final
Logger
LOGGER
=
Logger
.
getLogger
(
ConvexHullCalculator
.
class
.
getName
());
private
ConvexHullCalculator
()
{
throw
new
IllegalStateException
(
"Utility class"
);
}
/**
* Relatively fast method to extract a convex hull in WGS84 for any Citygml file for which CRS is known and whose
* size is less than 2GB (VTD XML limitation). It iterates over every building, gets the bounding box as 4
...
...
@@ -92,7 +96,6 @@ public static void extractHullsForEveryCityGML(Path repository, Consumer<String>
try
{
Path
kmlPath
=
getHullPath
(
repository
,
gmlPath
);
if
(
Files
.
exists
(
kmlPath
))
{
//TODO: Check if size is the same as original. Recreate otherwise.
LOGGER
.
fine
(
"Using cache from "
+
repository
.
relativize
(
kmlPath
));
return
new
String
(
Files
.
readAllBytes
(
kmlPath
),
StandardCharsets
.
UTF_8
);
}
else
{
...
...
@@ -101,8 +104,8 @@ public static void extractHullsForEveryCityGML(Path repository, Consumer<String>
}
}
catch
(
IOException
ex
)
{
ex
.
printStackTrace
();
return
null
;
}
return
null
;
})
.
filter
(
Objects:
:
nonNull
)
.
forEach
(
hullKML
->
{
...
...
@@ -190,6 +193,9 @@ public static String calculateConvexHullPlacemark(Path gmlPath, Path kmlPath, bo
* folder and hides it. The '.cache' folder isn't specific to the project: every kml cache file is written inside the
* same repository '.cache' folder.
*
* The original CityGML filesize is written in KML basename, in order to update the hull if the CityGML file is
* modified, e.g. LoD2_564_5512_2_BY_11946489.kml
*
* @param repository
* @param citygmlPath
*
...
...
@@ -197,7 +203,8 @@ public static String calculateConvexHullPlacemark(Path gmlPath, Path kmlPath, bo
* @throws IOException
*/
private
static
Path
getHullPath
(
Path
repository
,
Path
citygmlPath
)
throws
IOException
{
String
kmlFilename
=
citygmlPath
.
getFileName
().
toString
().
replaceAll
(
"(?i)\\.gml$"
,
".kml"
);
String
kmlFilename
=
citygmlPath
.
getFileName
().
toString
().
replaceAll
(
"(?i)\\.gml$"
,
"_"
+
Files
.
size
(
citygmlPath
)
+
".kml"
);
Path
cacheFolder
=
repository
.
resolve
(
".cache/"
);
Path
hullsFolder
=
cacheFolder
.
resolve
(
"hulls/"
);
Files
.
createDirectories
(
hullsFolder
);
...
...
src/main/resources/eu/simstadt/regionchooser/website/script/simstadt_openlayers.js
View file @
13f85aab
...
...
@@ -285,12 +285,17 @@ var regionChooser = (function(){
draw
.
setActive
(
false
);
});
// Pressing ESCAPE or DELETE resets the drawing.
// With OpenLayers 3.9, draw_interaction.removeLastPoint(); might be better.
document
.
addEventListener
(
'
keydown
'
,
function
(
e
)
{
if
(
e
.
which
==
27
||
e
.
which
==
46
){
//NOTE: e.key isn't defined in JavaFX Browser
if
(
e
.
which
==
27
||
e
.
which
==
46
){
// ESCAPE or DELETE.
resetDrawing
();
}
if
(
e
.
which
==
116
&&
fromJavaFX
){
// F5 for refresh
dataPanel
.
prepend
(
"
<h2 class='ok'>Refreshing repository...</h2><br/>
\n
"
);
document
.
documentElement
.
className
=
'
wait
'
;
fxapp
.
refreshHulls
();
}
});
function
resetDrawing
(){
...
...