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
6aa2677f
Commit
6aa2677f
authored
Jul 15, 2025
by
Riegel
Browse files
Fix: Parsing of RelativeGeometry
parent
6e94b4c8
Changes
4
Hide whitespace changes
Inline
Side-by-side
CityDoctorParent/CityDoctorModel/src/main/java/de/hft/stuttgart/citydoctor2/datastructure/ImplicitGeometryHolder.java
View file @
6aa2677f
package
de.hft.stuttgart.citydoctor2.datastructure
;
package
de.hft.stuttgart.citydoctor2.datastructure
;
import
java.io.Serial
;
import
java.io.Serial
;
import
java.util.HashSet
;
import
java.util.Set
;
import
java.util.concurrent.ConcurrentHashMap
;
import
de.hft.stuttgart.citydoctor2.check.CheckableVisitor
;
import
de.hft.stuttgart.citydoctor2.check.CheckableVisitor
;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.Logger
;
import
org.citygml4j.core.model.core.ImplicitGeometry
;
import
org.citygml4j.core.model.core.ImplicitGeometry
;
import
de.hft.stuttgart.citydoctor2.math.TransformationMatrix
;
import
de.hft.stuttgart.citydoctor2.math.TransformationMatrix
;
...
@@ -16,9 +21,11 @@ public class ImplicitGeometryHolder extends Geometry {
...
@@ -16,9 +21,11 @@ public class ImplicitGeometryHolder extends Geometry {
@Serial
@Serial
private
static
final
long
serialVersionUID
=
-
8938931081577196349L
;
private
static
final
long
serialVersionUID
=
-
8938931081577196349L
;
private
static
final
Logger
logger
=
LogManager
.
getLogger
(
ImplicitGeometryHolder
.
class
);
private
ImplicitGeometry
cgmlImplicitGeometry
=
null
;
private
ImplicitGeometry
cgmlImplicitGeometry
=
null
;
private
static
ConcurrentHashMap
<
ImplicitGeometryHolder
,
ImplicitGeometry
>
deferredRelGeomObjects
=
new
ConcurrentHashMap
<>();
private
final
PrototypeGeometryType
type
;
private
final
PrototypeGeometryType
type
;
private
final
Geometry
prototypeGeometry
;
private
final
Geometry
prototypeGeometry
;
...
@@ -38,7 +45,40 @@ public class ImplicitGeometryHolder extends Geometry {
...
@@ -38,7 +45,40 @@ public class ImplicitGeometryHolder extends Geometry {
applyTransformation
();
applyTransformation
();
}
}
public
static
ImplicitGeometryHolder
deferRelativeGeomParsing
(
ImplicitGeometry
ig
,
Lod
lod
)
{
ImplicitGeometryHolder
igh
=
new
ImplicitGeometryHolder
(
lod
);
deferredRelGeomObjects
.
put
(
igh
,
ig
);
return
igh
;
}
public
static
void
resolveDeferredObjects
()
{
Set
<
GmlId
>
missingGeoms
=
new
HashSet
<>();
for
(
ImplicitGeometryHolder
key
:
deferredRelGeomObjects
.
keySet
())
{
ImplicitGeometry
ig
=
deferredRelGeomObjects
.
get
(
key
);
String
hrefId
=
ig
.
getRelativeGeometry
().
getHref
();
hrefId
=
hrefId
.
startsWith
(
"#"
)
?
hrefId
.
substring
(
1
)
:
hrefId
;
GmlId
gmlId
=
new
GmlId
(
hrefId
);
RelativeGeometry
relGeom
=
RelativeGeometry
.
of
(
gmlId
);
if
(
relGeom
!=
null
)
{
ImplicitGeometryHolder
igh
=
new
ImplicitGeometryHolder
(
ig
,
relGeom
);
CityObject
parent
=
key
.
getParent
();
parent
.
removeGeometry
(
igh
.
getLod
(),
igh
.
getType
());
parent
.
addGeometry
(
igh
);
}
else
{
missingGeoms
.
add
(
gmlId
);
}
}
if
(!
missingGeoms
.
isEmpty
())
{
logger
.
warn
(
"RelativeGeometries of the following gmlIDs could not be resolved: {}"
,
missingGeoms
);
}
deferredRelGeomObjects
.
clear
();
}
private
ImplicitGeometryHolder
(
Lod
lod
)
{
super
(
null
,
lod
,
null
);
type
=
null
;
prototypeGeometry
=
new
Geometry
(
null
,
lod
,
null
);
}
/**
/**
* Applies the transformation matrix of the implicit geometry to a copy of the reference geometry and copies the resulting
* Applies the transformation matrix of the implicit geometry to a copy of the reference geometry and copies the resulting
* transformed geometry into this object.
* transformed geometry into this object.
...
...
CityDoctorParent/CityDoctorModel/src/main/java/de/hft/stuttgart/citydoctor2/datastructure/RelativeGeometry.java
View file @
6aa2677f
...
@@ -14,19 +14,23 @@ public class RelativeGeometry extends Geometry {
...
@@ -14,19 +14,23 @@ public class RelativeGeometry extends Geometry {
@Serial
@Serial
private
static
final
long
serialVersionUID
=
-
686112245455298977L
;
private
static
final
long
serialVersionUID
=
-
686112245455298977L
;
private
static
Map
<
Geometry
,
RelativeGeometry
>
relativeGeometries
=
new
ConcurrentHashMap
<>();
private
static
final
Map
<
GmlId
,
RelativeGeometry
>
relativeGeometries
=
new
ConcurrentHashMap
<>();
public
static
RelativeGeometry
of
(
Geometry
geom
)
{
public
static
RelativeGeometry
of
(
GmlId
gmlId
,
Geometry
geom
)
{
if
(
relativeGeometries
.
containsKey
(
g
eom
))
{
if
(
relativeGeometries
.
containsKey
(
g
mlId
))
{
return
relativeGeometries
.
get
(
g
eom
);
return
relativeGeometries
.
get
(
g
mlId
);
}
}
RelativeGeometry
relGeo
=
new
RelativeGeometry
(
geom
.
getType
(),
geom
.
getLod
(),
geom
.
getOrientation
());
RelativeGeometry
relGeo
=
new
RelativeGeometry
(
geom
.
getType
(),
geom
.
getLod
(),
geom
.
getOrientation
());
geom
.
getPolygons
().
forEach
(
relGeo:
:
addPolygon
);
geom
.
getPolygons
().
forEach
(
relGeo:
:
addPolygon
);
relGeo
.
updateEdgesAndVertices
();
relGeo
.
updateEdgesAndVertices
();
relativeGeometries
.
put
(
g
eom
,
relGeo
);
relativeGeometries
.
put
(
g
mlId
,
relGeo
);
return
relGeo
;
return
relGeo
;
}
}
public
static
RelativeGeometry
of
(
GmlId
gmlId
)
{
return
relativeGeometries
.
getOrDefault
(
gmlId
,
null
);
}
private
RelativeGeometry
(
GeometryType
type
,
Lod
lod
,
Orientation
orientation
)
{
private
RelativeGeometry
(
GeometryType
type
,
Lod
lod
,
Orientation
orientation
)
{
super
(
type
,
lod
,
orientation
);
super
(
type
,
lod
,
orientation
);
}
}
...
...
CityDoctorParent/CityDoctorModel/src/main/java/de/hft/stuttgart/citydoctor2/mapper/citygml3/Citygml3FeatureMapper.java
View file @
6aa2677f
...
@@ -1035,19 +1035,33 @@ public class Citygml3FeatureMapper extends ObjectWalker {
...
@@ -1035,19 +1035,33 @@ public class Citygml3FeatureMapper extends ObjectWalker {
}
}
}
else
if
(
ig
.
getRelativeGeometry
()
!=
null
)
{
}
else
if
(
ig
.
getRelativeGeometry
()
!=
null
)
{
AbstractGeometry
aGeom
=
ig
.
getRelativeGeometry
().
getObject
();
AbstractGeometry
aGeom
=
ig
.
getRelativeGeometry
().
getObject
();
Geometry
geom
=
null
;
Lod
lod
=
Lod
.
values
()[
lodInt
];
Lod
lod
=
Lod
.
values
()[
lodInt
];
RelativeGeometry
relGeo
=
null
;
if
(
aGeom
!=
null
)
{
if
(
aGeom
instanceof
MultiSurface
ms
)
{
Geometry
geom
=
null
;
geom
=
parseMultiSurface
(
ms
,
lod
);
if
(
aGeom
instanceof
MultiSurface
ms
)
{
}
else
if
(
aGeom
instanceof
Solid
s
)
{
geom
=
parseMultiSurface
(
ms
,
lod
);
geom
=
parseSolid
(
s
,
lod
,
orientation
);
}
else
if
(
aGeom
instanceof
Solid
s
)
{
}
else
if
(
aGeom
instanceof
CompositeSurface
cs
)
{
geom
=
parseSolid
(
s
,
lod
,
orientation
);
geom
=
parseCompositeSurface
(
cs
,
lod
);
}
else
if
(
aGeom
instanceof
CompositeSurface
cs
)
{
}
geom
=
parseCompositeSurface
(
cs
,
lod
);
if
(
geom
!=
null
)
{
}
relGeo
=
RelativeGeometry
.
of
(
geom
);
if
(
geom
!=
null
)
{
igh
=
new
ImplicitGeometryHolder
(
ig
,
relGeo
);
geom
.
setGmlId
(
new
GmlId
(
aGeom
.
getId
()));
RelativeGeometry
relGeo
=
RelativeGeometry
.
of
(
geom
.
getGmlId
(),
geom
);
igh
=
new
ImplicitGeometryHolder
(
ig
,
relGeo
);
}
}
else
if
(
ig
.
getRelativeGeometry
().
getHref
()
!=
null
)
{
String
hrefId
=
ig
.
getRelativeGeometry
().
getHref
();
hrefId
=
hrefId
.
startsWith
(
"#"
)
?
hrefId
.
substring
(
1
)
:
hrefId
;
GmlId
gmlId
=
new
GmlId
(
hrefId
);
RelativeGeometry
relGeo
=
RelativeGeometry
.
of
(
gmlId
);
if
(
relGeo
==
null
)
{
igh
=
ImplicitGeometryHolder
.
deferRelativeGeomParsing
(
ig
,
lod
);
}
else
{
igh
=
new
ImplicitGeometryHolder
(
ig
,
relGeo
);
}
}
else
{
logger
.
warn
(
"Relative geometry of GML-ID {} has neither geometry nor an href"
,
ig
.
getId
());
}
}
}
else
{
}
else
{
...
...
CityDoctorParent/CityDoctorModel/src/main/java/de/hft/stuttgart/citydoctor2/parser/CityGmlParser.java
View file @
6aa2677f
...
@@ -44,6 +44,7 @@ import javax.xml.validation.Schema;
...
@@ -44,6 +44,7 @@ import javax.xml.validation.Schema;
import
javax.xml.validation.SchemaFactory
;
import
javax.xml.validation.SchemaFactory
;
import
javax.xml.validation.Validator
;
import
javax.xml.validation.Validator
;
import
de.hft.stuttgart.citydoctor2.datastructure.ImplicitGeometryHolder
;
import
org.apache.logging.log4j.Level
;
import
org.apache.logging.log4j.Level
;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.Logger
;
import
org.apache.logging.log4j.Logger
;
...
@@ -528,6 +529,8 @@ public class CityGmlParser {
...
@@ -528,6 +529,8 @@ public class CityGmlParser {
logger
.
info
(
Localization
.
getText
(
"CityGmlParser.parsedObjects"
),
logger
.
info
(
Localization
.
getText
(
"CityGmlParser.parsedObjects"
),
mapper
.
getModel
().
getNumberOfFeatures
());
mapper
.
getModel
().
getNumberOfFeatures
());
}
}
// After parsing is complete, try to resolve deferred RelativeGeometries
ImplicitGeometryHolder
.
resolveDeferredObjects
();
mapper
.
setCityGMLVersion
(
version
);
mapper
.
setCityGMLVersion
(
version
);
return
mapper
.
getModel
();
return
mapper
.
getModel
();
}
}
...
...
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