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
cc835fd7
Commit
cc835fd7
authored
2 years ago
by
Eric Duminil
Browse files
Options
Download
Email Patches
Plain Diff
Take size into account for cached hull
parent
92a8de3d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/eu/simstadt/regionchooser/fast_xml_parser/ConvexHullCalculator.java
+10
-3
...t/regionchooser/fast_xml_parser/ConvexHullCalculator.java
with
10 additions
and
3 deletions
+10
-3
src/main/java/eu/simstadt/regionchooser/fast_xml_parser/ConvexHullCalculator.java
+
10
-
3
View file @
cc835fd7
...
@@ -25,6 +25,10 @@
...
@@ -25,6 +25,10 @@
{
{
private
static
final
Logger
LOGGER
=
Logger
.
getLogger
(
ConvexHullCalculator
.
class
.
getName
());
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
* 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
* 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>
...
@@ -92,7 +96,6 @@ public static void extractHullsForEveryCityGML(Path repository, Consumer<String>
try
{
try
{
Path
kmlPath
=
getHullPath
(
repository
,
gmlPath
);
Path
kmlPath
=
getHullPath
(
repository
,
gmlPath
);
if
(
Files
.
exists
(
kmlPath
))
{
if
(
Files
.
exists
(
kmlPath
))
{
//TODO: Check if size is the same as original. Recreate otherwise.
LOGGER
.
fine
(
"Using cache from "
+
repository
.
relativize
(
kmlPath
));
LOGGER
.
fine
(
"Using cache from "
+
repository
.
relativize
(
kmlPath
));
return
new
String
(
Files
.
readAllBytes
(
kmlPath
),
StandardCharsets
.
UTF_8
);
return
new
String
(
Files
.
readAllBytes
(
kmlPath
),
StandardCharsets
.
UTF_8
);
}
else
{
}
else
{
...
@@ -101,8 +104,8 @@ public static void extractHullsForEveryCityGML(Path repository, Consumer<String>
...
@@ -101,8 +104,8 @@ public static void extractHullsForEveryCityGML(Path repository, Consumer<String>
}
}
}
catch
(
IOException
ex
)
{
}
catch
(
IOException
ex
)
{
ex
.
printStackTrace
();
ex
.
printStackTrace
();
return
null
;
}
}
return
null
;
})
})
.
filter
(
Objects:
:
nonNull
)
.
filter
(
Objects:
:
nonNull
)
.
forEach
(
hullKML
->
{
.
forEach
(
hullKML
->
{
...
@@ -190,6 +193,9 @@ public static String calculateConvexHullPlacemark(Path gmlPath, Path kmlPath, bo
...
@@ -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
* 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.
* 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 repository
* @param citygmlPath
* @param citygmlPath
*
*
...
@@ -197,7 +203,8 @@ public static String calculateConvexHullPlacemark(Path gmlPath, Path kmlPath, bo
...
@@ -197,7 +203,8 @@ public static String calculateConvexHullPlacemark(Path gmlPath, Path kmlPath, bo
* @throws IOException
* @throws IOException
*/
*/
private
static
Path
getHullPath
(
Path
repository
,
Path
citygmlPath
)
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
cacheFolder
=
repository
.
resolve
(
".cache/"
);
Path
hullsFolder
=
cacheFolder
.
resolve
(
"hulls/"
);
Path
hullsFolder
=
cacheFolder
.
resolve
(
"hulls/"
);
Files
.
createDirectories
(
hullsFolder
);
Files
.
createDirectories
(
hullsFolder
);
...
...
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