Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
CityDoctor
CityDoctor2
Commits
e1e08ee0
Commit
e1e08ee0
authored
Dec 10, 2024
by
Riegel
Browse files
Feat: Implement parsing of LibraryObjects in zip-files
parent
a8265bea
Changes
1
Hide whitespace changes
Inline
Side-by-side
CityDoctorParent/CityDoctorModel/src/main/java/de/hft/stuttgart/citydoctor2/datastructure/LibraryObject.java
View file @
e1e08ee0
...
@@ -74,14 +74,7 @@ public class LibraryObject extends Geometry {
...
@@ -74,14 +74,7 @@ public class LibraryObject extends Geometry {
if
(
path
.
toFile
().
exists
())
{
if
(
path
.
toFile
().
exists
())
{
try
{
try
{
CityGmlParser
.
gagLogger
(
true
);
CityGmlParser
.
gagLogger
(
true
);
CityDoctorModel
model
=
CityGmlParser
.
parseCityGmlFile
(
path
.
toString
(),
config
);
geo
=
getProtoGeometry
(
CityGmlParser
.
parseCityGmlFile
(
path
.
toString
(),
config
));
List
<
CityObject
>
objects
=
model
.
createFeatureStream
().
toList
();
if
(
objects
.
isEmpty
())
{
throw
new
InvalidGmlFileException
(
"Referenced library-object's gml file does not contain a CityGML object!"
);
}
else
if
(
objects
.
size
()
>
1
)
{
throw
new
InvalidGmlFileException
(
"Referenced library-object's gml file contains more than one CityGML object!"
);
}
geo
=
objects
.
get
(
0
).
getHighestLodGeometry
();
}
catch
(
CityGmlParseException
e
)
{
}
catch
(
CityGmlParseException
e
)
{
logger
.
error
(
String
.
format
(
logger
.
error
(
String
.
format
(
"Encountered an error while parsing library object %s"
,
path
));
"Encountered an error while parsing library object %s"
,
path
));
...
@@ -89,7 +82,6 @@ public class LibraryObject extends Geometry {
...
@@ -89,7 +82,6 @@ public class LibraryObject extends Geometry {
}
catch
(
InvalidGmlFileException
e
)
{
}
catch
(
InvalidGmlFileException
e
)
{
logger
.
error
(
e
.
getStackTrace
());
logger
.
error
(
e
.
getStackTrace
());
}
finally
{
}
finally
{
// Failsafe to remove gag should parsing fail
CityGmlParser
.
gagLogger
(
false
);
CityGmlParser
.
gagLogger
(
false
);
}
}
}
else
{
}
else
{
...
@@ -99,15 +91,34 @@ public class LibraryObject extends Geometry {
...
@@ -99,15 +91,34 @@ public class LibraryObject extends Geometry {
}
}
private
static
Geometry
parseZipEntry
(
CityGmlZipEntry
entry
,
ParserConfiguration
config
)
{
private
static
Geometry
parseZipEntry
(
CityGmlZipEntry
entry
,
ParserConfiguration
config
)
{
Geometry
geom
=
null
;
Geometry
geo
=
null
;
try
(
CityGmlZipInputStream
cgis
=
new
CityGmlZipInputStream
(
entry
))
{
try
{
InputStream
is
=
cgis
.
getInputStream
();
entry
.
loadEntry
(
config
);
}
catch
(
IOException
e
)
{
geo
=
getProtoGeometry
(
entry
.
getModel
());
throw
new
RuntimeException
(
e
);
}
catch
(
InvalidGmlFileException
e
)
{
}
catch
(
Exception
e
)
{
logger
.
error
(
e
.
getStackTrace
());
throw
new
RuntimeException
(
e
);
}
catch
(
CityGmlParseException
e
)
{
logger
.
error
(
String
.
format
(
"Encountered an error while parsing library object %s"
,
entry
.
getFileName
()));
logger
.
error
(
e
.
getStackTrace
());
}
finally
{
//Gag logger again for next entry
CityGmlParser
.
gagLogger
(
true
);
}
return
geo
;
}
private
static
Geometry
getProtoGeometry
(
CityDoctorModel
model
)
throws
InvalidGmlFileException
,
CityGmlParseException
{
if
(
model
==
null
)
{
throw
new
CityGmlParseException
(
"CityDoctorModel of referenced LibraryObject is null"
);
}
List
<
CityObject
>
objects
=
model
.
createFeatureStream
().
toList
();
if
(
objects
.
isEmpty
())
{
throw
new
InvalidGmlFileException
(
"Referenced library-object's gml file does not contain a CityGML object!"
);
}
else
if
(
objects
.
size
()
>
1
)
{
throw
new
InvalidGmlFileException
(
"Referenced library-object's gml file contains more than one CityGML object!"
);
}
}
return
geom
;
return
objects
.
get
(
0
).
getHighestLodGeometry
()
;
}
}
}
}
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