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
02de0a22
Commit
02de0a22
authored
Oct 30, 2024
by
Riegel
Browse files
Reformat code
parent
ad3589e8
Pipeline
#10297
passed with stage
in 1 minute and 5 seconds
Changes
61
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
CityDoctorParent/CityDoctorModel/src/main/java/de/hft/stuttgart/citydoctor2/datastructure/ReliefObject.java
View file @
02de0a22
/*-
* Copyright 2022 Beuth Hochschule für Technik Berlin, Hochschule für Technik Stuttgart
*
*
* This file is part of CityDoctor2.
*
* CityDoctor2 is free software: you can redistribute it and/or modify
...
...
@@ -18,142 +18,141 @@
*/
package
de.hft.stuttgart.citydoctor2.datastructure
;
import
java.io.Serial
;
import
java.util.ArrayList
;
import
java.util.List
;
import
org.citygml4j.core.model.relief.ReliefFeature
;
import
org.citygml4j.core.util.geometry.GeometryFactory
;
import
de.hft.stuttgart.citydoctor2.check.Check
;
import
de.hft.stuttgart.citydoctor2.check.CheckError
;
import
de.hft.stuttgart.citydoctor2.check.CheckId
;
import
de.hft.stuttgart.citydoctor2.parser.ParserConfiguration
;
import
de.hft.stuttgart.citydoctor2.utils.CopyHandler
;
import
de.hft.stuttgart.citydoctor2.utils.Copyable
;
import
org.citygml4j.core.model.relief.ReliefFeature
;
import
org.citygml4j.core.util.geometry.GeometryFactory
;
import
java.io.Serial
;
import
java.util.ArrayList
;
import
java.util.List
;
public
class
ReliefObject
extends
CityObject
{
@Serial
private
static
final
long
serialVersionUID
=
-
9162169874426519903L
;
private
final
ReliefFeature
feature
;
private
final
List
<
TinObject
>
components
=
new
ArrayList
<>();
public
ReliefObject
(
ReliefFeature
feature
)
{
this
.
feature
=
feature
;
}
@Override
public
void
accept
(
Check
c
)
{
super
.
accept
(
c
);
if
(
c
.
canExecute
(
this
))
{
c
.
check
(
this
);
}
for
(
TinObject
tin
:
components
)
{
tin
.
accept
(
c
);
}
}
@Override
public
void
collectInstances
(
CopyHandler
handler
)
{
handler
.
addInstance
(
components
);
}
@Override
public
void
fillValues
(
Copyable
original
,
CopyHandler
handler
)
{
super
.
fillValues
(
original
,
handler
);
ReliefObject
originalRelief
=
(
ReliefObject
)
original
;
for
(
TinObject
tin
:
originalRelief
.
components
)
{
components
.
add
(
handler
.
getCopyInstance
(
tin
));
}
}
@Override
public
Copyable
createCopyInstance
()
{
return
new
ReliefObject
(
feature
);
}
@Override
public
void
prepareForChecking
()
{
for
(
TinObject
component
:
components
)
{
component
.
prepareForChecking
();
}
}
@Override
public
void
clearMetaInformation
()
{
for
(
TinObject
component
:
components
)
{
component
.
clearMetaInformation
();
}
}
@Override
public
void
clearAllContainedCheckResults
()
{
for
(
TinObject
component
:
components
)
{
component
.
clearAllContainedCheckResults
();
}
}
@Override
public
void
collectContainedErrors
(
List
<
CheckError
>
errors
)
{
super
.
collectContainedErrors
(
errors
);
for
(
TinObject
tin
:
components
)
{
tin
.
collectContainedErrors
(
errors
);
}
}
@Override
public
boolean
containsAnyError
()
{
boolean
containsError
=
super
.
containsAnyError
();
if
(
containsError
)
{
return
true
;
}
for
(
TinObject
tin
:
components
)
{
if
(
tin
.
containsAnyError
())
{
return
true
;
}
}
return
false
;
}
@Override
public
boolean
containsError
(
CheckId
checkIdentifier
)
{
boolean
hasError
=
super
.
containsError
(
checkIdentifier
);
if
(
hasError
)
{
return
true
;
}
for
(
TinObject
tin
:
components
)
{
if
(
tin
.
containsError
(
checkIdentifier
))
{
return
true
;
}
}
return
false
;
}
@Override
public
void
reCreateGeometries
(
GeometryFactory
factory
,
ParserConfiguration
config
)
{
// no geometries
}
@Override
public
ReliefFeature
getGmlObject
()
{
return
feature
;
}
@Override
public
void
unsetGmlGeometries
()
{
// no geometries
}
@Override
public
FeatureType
getFeatureType
()
{
return
FeatureType
.
LAND
;
}
public
List
<
TinObject
>
getComponents
()
{
return
components
;
}
@Serial
private
static
final
long
serialVersionUID
=
-
9162169874426519903L
;
private
final
ReliefFeature
feature
;
private
final
List
<
TinObject
>
components
=
new
ArrayList
<>();
public
ReliefObject
(
ReliefFeature
feature
)
{
this
.
feature
=
feature
;
}
@Override
public
void
accept
(
Check
c
)
{
super
.
accept
(
c
);
if
(
c
.
canExecute
(
this
))
{
c
.
check
(
this
);
}
for
(
TinObject
tin
:
components
)
{
tin
.
accept
(
c
);
}
}
@Override
public
void
collectInstances
(
CopyHandler
handler
)
{
handler
.
addInstance
(
components
);
}
@Override
public
void
fillValues
(
Copyable
original
,
CopyHandler
handler
)
{
super
.
fillValues
(
original
,
handler
);
ReliefObject
originalRelief
=
(
ReliefObject
)
original
;
for
(
TinObject
tin
:
originalRelief
.
components
)
{
components
.
add
(
handler
.
getCopyInstance
(
tin
));
}
}
@Override
public
Copyable
createCopyInstance
()
{
return
new
ReliefObject
(
feature
);
}
@Override
public
void
prepareForChecking
()
{
for
(
TinObject
component
:
components
)
{
component
.
prepareForChecking
();
}
}
@Override
public
void
clearMetaInformation
()
{
for
(
TinObject
component
:
components
)
{
component
.
clearMetaInformation
();
}
}
@Override
public
void
clearAllContainedCheckResults
()
{
for
(
TinObject
component
:
components
)
{
component
.
clearAllContainedCheckResults
();
}
}
@Override
public
void
collectContainedErrors
(
List
<
CheckError
>
errors
)
{
super
.
collectContainedErrors
(
errors
);
for
(
TinObject
tin
:
components
)
{
tin
.
collectContainedErrors
(
errors
);
}
}
@Override
public
boolean
containsAnyError
()
{
boolean
containsError
=
super
.
containsAnyError
();
if
(
containsError
)
{
return
true
;
}
for
(
TinObject
tin
:
components
)
{
if
(
tin
.
containsAnyError
())
{
return
true
;
}
}
return
false
;
}
@Override
public
boolean
containsError
(
CheckId
checkIdentifier
)
{
boolean
hasError
=
super
.
containsError
(
checkIdentifier
);
if
(
hasError
)
{
return
true
;
}
for
(
TinObject
tin
:
components
)
{
if
(
tin
.
containsError
(
checkIdentifier
))
{
return
true
;
}
}
return
false
;
}
@Override
public
void
reCreateGeometries
(
GeometryFactory
factory
,
ParserConfiguration
config
)
{
// no geometries
}
@Override
public
ReliefFeature
getGmlObject
()
{
return
feature
;
}
@Override
public
void
unsetGmlGeometries
()
{
// no geometries
}
@Override
public
FeatureType
getFeatureType
()
{
return
FeatureType
.
LAND
;
}
public
List
<
TinObject
>
getComponents
()
{
return
components
;
}
}
CityDoctorParent/CityDoctorModel/src/main/java/de/hft/stuttgart/citydoctor2/datastructure/Storey.java
View file @
02de0a22
...
...
@@ -12,7 +12,7 @@ import java.io.Serial;
import
java.util.ArrayList
;
import
java.util.List
;
public
class
Storey
extends
AbstractBuildingSubdivision
{
public
class
Storey
extends
AbstractBuildingSubdivision
{
@Serial
private
static
final
long
serialVersionUID
=
5162814691642668089L
;
...
...
CityDoctorParent/CityDoctorModel/src/main/java/de/hft/stuttgart/citydoctor2/datastructure/SurfaceFeatureType.java
View file @
02de0a22
/*-
* Copyright 2020 Beuth Hochschule für Technik Berlin, Hochschule für Technik Stuttgart
*
*
* This file is part of CityDoctor2.
*
* CityDoctor2 is free software: you can redistribute it and/or modify
...
...
@@ -20,12 +20,11 @@ package de.hft.stuttgart.citydoctor2.datastructure;
/**
* Availabel bridge types in CityGML
*
* @author Matthias Betz
*
* @author Matthias Betz
*/
public
enum
SurfaceFeatureType
{
BUILDING
,
BRIDGE
,
TUNNEL
BUILDING
,
BRIDGE
,
TUNNEL
}
CityDoctorParent/CityDoctorModel/src/main/java/de/hft/stuttgart/citydoctor2/datastructure/TinObject.java
View file @
02de0a22
/*-
* Copyright 2022 Beuth Hochschule für Technik Berlin, Hochschule für Technik Stuttgart
*
*
* This file is part of CityDoctor2.
*
* CityDoctor2 is free software: you can redistribute it and/or modify
...
...
@@ -18,10 +18,9 @@
*/
package
de.hft.stuttgart.citydoctor2.datastructure
;
import
java.io.Serial
;
import
java.util.ArrayList
;
import
java.util.List
;
import
de.hft.stuttgart.citydoctor2.check.Check
;
import
de.hft.stuttgart.citydoctor2.parser.ParserConfiguration
;
import
de.hft.stuttgart.citydoctor2.utils.CityGmlUtils
;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.Logger
;
import
org.citygml4j.core.model.relief.TINRelief
;
...
...
@@ -31,70 +30,70 @@ import org.xmlobjects.gml.model.geometry.primitives.Triangle;
import
org.xmlobjects.gml.model.geometry.primitives.TriangleArrayProperty
;
import
org.xmlobjects.gml.model.geometry.primitives.TriangulatedSurface
;
import
de.hft.stuttgart.citydoctor2.check.Check
;
import
de.hft.stuttgart.citydoctor2.parser.ParserConfiguration
;
import
de.hft.stuttgart.citydoctor2.utils.CityGmlUtils
;
import
java.io.Serial
;
import
java.util.ArrayList
;
import
java.util.List
;
public
class
TinObject
extends
CityObject
{
private
static
final
Logger
logger
=
LogManager
.
getLogger
(
TinObject
.
class
);
private
static
final
Logger
logger
=
LogManager
.
getLogger
(
TinObject
.
class
);
@Serial
private
static
final
long
serialVersionUID
=
1910744427384724422L
;
@Serial
private
static
final
long
serialVersionUID
=
1910744427384724422L
;
private
final
TINRelief
gmlRelief
;
private
final
TINRelief
gmlRelief
;
public
TinObject
(
TINRelief
gmlRelief
)
{
this
.
gmlRelief
=
gmlRelief
;
}
public
TinObject
(
TINRelief
gmlRelief
)
{
this
.
gmlRelief
=
gmlRelief
;
}
@Override
public
void
accept
(
Check
c
)
{
super
.
accept
(
c
);
if
(
c
.
canExecute
(
this
))
{
c
.
check
(
this
);
}
}
@Override
public
void
accept
(
Check
c
)
{
super
.
accept
(
c
);
if
(
c
.
canExecute
(
this
))
{
c
.
check
(
this
);
}
}
@Override
public
TinObject
createCopyInstance
()
{
return
new
TinObject
(
gmlRelief
);
}
@Override
public
TinObject
createCopyInstance
()
{
return
new
TinObject
(
gmlRelief
);
}
@Override
public
void
reCreateGeometries
(
GeometryFactory
factory
,
ParserConfiguration
config
)
{
if
(
getGeometries
().
isEmpty
())
{
return
;
}
if
(
getGeometries
().
size
()
>
1
)
{
logger
.
warn
(
"A TINRelief can only have one geometry but found {}. Using the first geometry found"
,
getGeometries
().
size
());
}
Geometry
geom
=
getGeometries
().
get
(
0
);
List
<
Triangle
>
triangles
=
new
ArrayList
<>();
TriangulatedSurface
surface
=
new
TriangulatedSurface
();
surface
.
setPatches
(
new
TriangleArrayProperty
(
triangles
));
for
(
Polygon
poly
:
geom
.
getPolygons
())
{
LinearRing
ring
=
poly
.
getExteriorRing
();
Triangle
t
=
new
Triangle
();
t
.
setExterior
(
new
AbstractRingProperty
(
CityGmlUtils
.
createGmlRing
(
factory
,
config
,
ring
)));
triangles
.
add
(
t
);
}
}
@Override
public
void
reCreateGeometries
(
GeometryFactory
factory
,
ParserConfiguration
config
)
{
if
(
getGeometries
().
isEmpty
())
{
return
;
}
if
(
getGeometries
().
size
()
>
1
)
{
logger
.
warn
(
"A TINRelief can only have one geometry but found {}. Using the first geometry found"
,
getGeometries
().
size
());
}
Geometry
geom
=
getGeometries
().
get
(
0
);
List
<
Triangle
>
triangles
=
new
ArrayList
<>();
TriangulatedSurface
surface
=
new
TriangulatedSurface
();
surface
.
setPatches
(
new
TriangleArrayProperty
(
triangles
));
for
(
Polygon
poly
:
geom
.
getPolygons
())
{
LinearRing
ring
=
poly
.
getExteriorRing
();
Triangle
t
=
new
Triangle
();
t
.
setExterior
(
new
AbstractRingProperty
(
CityGmlUtils
.
createGmlRing
(
factory
,
config
,
ring
)));
triangles
.
add
(
t
);
}
}
@Override
public
TINRelief
getGmlObject
()
{
return
gmlRelief
;
}
@Override
public
TINRelief
getGmlObject
()
{
return
gmlRelief
;
}
@Override
public
void
unsetGmlGeometries
()
{
gmlRelief
.
setTin
(
null
);
}
@Override
public
void
unsetGmlGeometries
()
{
gmlRelief
.
setTin
(
null
);
}
@Override
public
FeatureType
getFeatureType
()
{
return
FeatureType
.
LAND
;
}
@Override
public
FeatureType
getFeatureType
()
{
return
FeatureType
.
LAND
;
}
}
CityDoctorParent/CityDoctorModel/src/main/java/de/hft/stuttgart/citydoctor2/datastructure/TransportationObject.java
View file @
02de0a22
/*-
* Copyright 2020 Beuth Hochschule für Technik Berlin, Hochschule für Technik Stuttgart
*
*
* This file is part of CityDoctor2.
*
* CityDoctor2 is free software: you can redistribute it and/or modify
...
...
@@ -18,10 +18,13 @@
*/
package
de.hft.stuttgart.citydoctor2.datastructure
;
import
java.io.Serial
;
import
java.util.ArrayList
;
import
java.util.List
;
import
de.hft.stuttgart.citydoctor2.check.Check
;
import
de.hft.stuttgart.citydoctor2.check.CheckError
;
import
de.hft.stuttgart.citydoctor2.check.CheckId
;
import
de.hft.stuttgart.citydoctor2.parser.ParserConfiguration
;
import
de.hft.stuttgart.citydoctor2.utils.CityGmlUtils
;
import
de.hft.stuttgart.citydoctor2.utils.CopyHandler
;
import
de.hft.stuttgart.citydoctor2.utils.Copyable
;
import
org.citygml4j.core.model.core.AbstractCityObject
;
import
org.citygml4j.core.model.core.AbstractSpace
;
import
org.citygml4j.core.model.transportation.AbstractTransportationSpace
;
...
...
@@ -31,302 +34,297 @@ import org.citygml4j.core.util.geometry.GeometryFactory;
import
org.xmlobjects.gml.model.geometry.aggregates.MultiSurface
;
import
org.xmlobjects.gml.model.geometry.aggregates.MultiSurfaceProperty
;
import
de.hft.stuttgart.citydoctor2.check.Check
;
import
de.hft.stuttgart.citydoctor2.check.CheckError
;
import
de.hft.stuttgart.citydoctor2.check.CheckId
;
import
de.hft.stuttgart.citydoctor2.parser.ParserConfiguration
;
import
de.hft.stuttgart.citydoctor2.utils.CityGmlUtils
;
import
de.hft.stuttgart.citydoctor2.utils.CopyHandler
;
import
de.hft.stuttgart.citydoctor2.utils.Copyable
;
import
java.io.Serial
;
import
java.util.ArrayList
;
import
java.util.List
;
/**
* Representation of a transportation object.
*
* @author Matthias Betz
*
* @author Matthias Betz
*/
public
class
TransportationObject
extends
CityObject
{
@Serial
private
static
final
long
serialVersionUID
=
-
2698907271726700390L
;
@Serial
private
static
final
long
serialVersionUID
=
-
2698907271726700390L
;
public
enum
TransportationType
{
ROAD
,
TRACK
,
RAILWAY
,
TRAFFIC_AREA
,
AUXILLIARY_TRAFFIC_AREA
,
TRANSPORTATION_COMPLEX
,
SQUARE
,
AUXILLIARY_TRAFFIC_SPACE
,
TRAFFIC_SPACE
}
private
AbstractCityObject
ato
;
private
final
List
<
TransportationObject
>
composesOf
=
new
ArrayList
<>(
1
);
private
final
TransportationType
type
;
public
enum
TransportationType
{
ROAD
,
TRACK
,
RAILWAY
,
TRAFFIC_AREA
,
AUXILLIARY_TRAFFIC_AREA
,
TRANSPORTATION_COMPLEX
,
SQUARE
,
AUXILLIARY_TRAFFIC_SPACE
,
TRAFFIC_SPACE
}
public
TransportationObject
(
TransportationType
type
)
{
this
.
type
=
type
;
}
private
AbstractCityObject
ato
;
private
final
List
<
TransportationObject
>
composesOf
=
new
ArrayList
<>(
1
);
private
final
TransportationType
type
;
@Override
public
FeatureType
getFeatureType
()
{
return
FeatureType
.
TRANSPORTATION
;
}
public
TransportationObject
(
TransportationType
type
)
{
this
.
type
=
type
;
}
@Override
public
void
reCreateGeometries
(
GeometryFactory
factory
,
ParserConfiguration
config
)
{
for
(
Geometry
geom
:
getGeometries
())
{
if
(
geom
instanceof
ImplicitGeometryHolder
)
{
continue
;
}
if
(
geom
.
getType
()
==
GeometryType
.
MULTI_SURFACE
)
{
MultiSurface
ms
=
CityGmlUtils
.
createMultiSurface
(
geom
,
factory
,
config
);
switch
(
type
)
{
case
ROAD
,
TRACK
,
RAILWAY
,
SQUARE
,
TRANSPORTATION_COMPLEX:
AbstractTransportationSpace
tc
=
(
AbstractTransportationSpace
)
ato
;
setMultiSurfaceAccordingToLod
(
tc
,
ms
,
geom
.
getLod
());
break
;
case
TRAFFIC_AREA:
TrafficArea
ta
=
(
TrafficArea
)
ato
;
setMultiSurfaceAccordingToLod
(
ta
,
ms
,
geom
.
getLod
());
break
;
case
AUXILLIARY_TRAFFIC_AREA:
AuxiliaryTrafficArea
ata
=
(
AuxiliaryTrafficArea
)
ato
;
setMultiSurfaceAccordingToLod
(
ata
,
ms
,
geom
.
getLod
());
break
;
case
AUXILLIARY_TRAFFIC_SPACE
,
TRAFFIC_SPACE:
AbstractSpace
ats
=
(
AbstractSpace
)
ato
;
setMultiSurfaceAccordingToLod
(
ats
,
ms
,
geom
.
getLod
());
break
;
}
}
else
{
throw
new
IllegalStateException
(
"Geometry in TransportationObject cannot be of type "
+
geom
.
getType
()
+
". Only MultiSurface allowed"
);
}
}
for
(
TransportationObject
children
:
composesOf
)
{
children
.
reCreateGeometries
(
factory
,
config
);
}
}
@Override
public
FeatureType
getFeatureType
()
{
return
FeatureType
.
TRANSPORTATION
;
}
private
void
setMultiSurfaceAccordingToLod
(
AbstractSpace
ats
,
MultiSurface
ms
,
Lod
lod
)
{
switch
(
lod
)
{
case
LOD0:
ats
.
setLod0MultiSurface
(
new
MultiSurfaceProperty
(
ms
));
break
;
case
LOD2:
ats
.
setLod2MultiSurface
(
new
MultiSurfaceProperty
(
ms
));
break
;
case
LOD3:
ats
.
setLod3MultiSurface
(
new
MultiSurfaceProperty
(
ms
));
break
;
default
:
throw
new
IllegalStateException
(
"cannot set geometry with LOD for AuxiliaryTrafficSpace: "
+
lod
);
}
}
@Override
public
void
reCreateGeometries
(
GeometryFactory
factory
,
ParserConfiguration
config
)
{
for
(
Geometry
geom
:
getGeometries
())
{
if
(
geom
instanceof
ImplicitGeometryHolder
){
continue
;
}
if
(
geom
.
getType
()
==
GeometryType
.
MULTI_SURFACE
)
{
MultiSurface
ms
=
CityGmlUtils
.
createMultiSurface
(
geom
,
factory
,
config
);
switch
(
type
)
{
case
ROAD
,
TRACK
,
RAILWAY
,
SQUARE
,
TRANSPORTATION_COMPLEX:
AbstractTransportationSpace
tc
=
(
AbstractTransportationSpace
)
ato
;
setMultiSurfaceAccordingToLod
(
tc
,
ms
,
geom
.
getLod
());
break
;
case
TRAFFIC_AREA:
TrafficArea
ta
=
(
TrafficArea
)
ato
;
setMultiSurfaceAccordingToLod
(
ta
,
ms
,
geom
.
getLod
());
break
;
case
AUXILLIARY_TRAFFIC_AREA:
AuxiliaryTrafficArea
ata
=
(
AuxiliaryTrafficArea
)
ato
;
setMultiSurfaceAccordingToLod
(
ata
,
ms
,
geom
.
getLod
());
break
;
case
AUXILLIARY_TRAFFIC_SPACE
,
TRAFFIC_SPACE:
AbstractSpace
ats
=
(
AbstractSpace
)
ato
;
setMultiSurfaceAccordingToLod
(
ats
,
ms
,
geom
.
getLod
());
break
;
}
}
else
{
throw
new
IllegalStateException
(
"Geometry in TransportationObject cannot be of type "
+
geom
.
getType
()
+
". Only MultiSurface allowed"
);
}
}
for
(
TransportationObject
children
:
composesOf
)
{
children
.
reCreateGeometries
(
factory
,
config
);
}
}
private
void
setMultiSurfaceAccordingToLod
(
AbstractTransportationSpace
tc
,
MultiSurface
ms
,
Lod
lod
)
{
switch
(
lod
)
{
case
LOD1:
tc
.
getDeprecatedProperties
().
setLod1MultiSurface
(
new
MultiSurfaceProperty
(
ms
));
break
;
case
LOD2:
tc
.
setLod2MultiSurface
(
new
MultiSurfaceProperty
(
ms
));
break
;
case
LOD3:
tc
.
setLod3MultiSurface
(
new
MultiSurfaceProperty
(
ms
));
break
;
case
LOD4:
tc
.
getDeprecatedProperties
().
setLod4MultiSurface
(
new
MultiSurfaceProperty
(
ms
));
break
;
default
:
throw
new
IllegalStateException
(
"cannot set geometry with LOD for TransportationComplex: "
+
lod
);
}
}
private
void
setMultiSurfaceAccordingToLod
(
AbstractSpace
ats
,
MultiSurface
ms
,
Lod
lod
)
{
switch
(
lod
)
{
case
LOD0:
ats
.
setLod0MultiSurface
(
new
MultiSurfaceProperty
(
ms
));
break
;
case
LOD2:
ats
.
setLod2MultiSurface
(
new
MultiSurfaceProperty
(
ms
));
break
;
case
LOD3:
ats
.
setLod3MultiSurface
(
new
MultiSurfaceProperty
(
ms
));
break
;
default
:
throw
new
IllegalStateException
(
"cannot set geometry with LOD for AuxiliaryTrafficSpace: "
+
lod
);
}
}
private
void
setMultiSurfaceAccordingToLod
(
AuxiliaryTrafficArea
ata
,
MultiSurface
ms
,
Lod
lod
)
{
switch
(
lod
)
{
case
LOD0:
ata
.
setLod0MultiSurface
(
new
MultiSurfaceProperty
(
ms
));
break
;
case
LOD1:
ata
.
setLod1MultiSurface
(
new
MultiSurfaceProperty
(
ms
));
break
;
case
LOD2:
ata
.
setLod2MultiSurface
(
new
MultiSurfaceProperty
(
ms
));
break
;
case
LOD3:
ata
.
setLod3MultiSurface
(
new
MultiSurfaceProperty
(
ms
));
break
;
case
LOD4:
ata
.
getDeprecatedProperties
().
setLod4MultiSurface
(
new
MultiSurfaceProperty
(
ms
));
break
;
default
:
throw
new
IllegalStateException
(
"cannot set geometry with LOD for AuxiliaryTrafficArea: "
+
lod
);
}
}
private
void
setMultiSurfaceAccordingToLod
(
AbstractTransportationSpace
tc
,
MultiSurface
ms
,
Lod
lod
)
{
switch
(
lod
)
{
case
LOD1:
tc
.
getDeprecatedProperties
().
setLod1MultiSurface
(
new
MultiSurfaceProperty
(
ms
));
break
;
case
LOD2:
tc
.
setLod2MultiSurface
(
new
MultiSurfaceProperty
(
ms
));
break
;
case
LOD3:
tc
.
setLod3MultiSurface
(
new
MultiSurfaceProperty
(
ms
));
break
;
case
LOD4:
tc
.
getDeprecatedProperties
().
setLod4MultiSurface
(
new
MultiSurfaceProperty
(
ms
));
break
;
default
:
throw
new
IllegalStateException
(
"cannot set geometry with LOD for TransportationComplex: "
+
lod
);
}
}
private
void
setMultiSurfaceAccordingToLod
(
TrafficArea
ta
,
MultiSurface
ms
,
Lod
lod
)
{
switch
(
lod
)
{
case
LOD2:
ta
.
setLod2MultiSurface
(
new
MultiSurfaceProperty
(
ms
));
break
;
case
LOD3:
ta
.
setLod3MultiSurface
(
new
MultiSurfaceProperty
(
ms
));
break
;
case
LOD4:
ta
.
getDeprecatedProperties
().
setLod4MultiSurface
(
new
MultiSurfaceProperty
(
ms
));
break
;
default
:
throw
new
IllegalStateException
(
"cannot set geometry with LOD for TrafficArea: "
+
lod
);
}
}
private
void
setMultiSurfaceAccordingToLod
(
AuxiliaryTrafficArea
ata
,
MultiSurface
ms
,
Lod
lod
)
{
switch
(
lod
)
{
case
LOD0:
ata
.
setLod0MultiSurface
(
new
MultiSurfaceProperty
(
ms
));
break
;
case
LOD1:
ata
.
setLod1MultiSurface
(
new
MultiSurfaceProperty
(
ms
));
break
;
case
LOD2:
ata
.
setLod2MultiSurface
(
new
MultiSurfaceProperty
(
ms
));
break
;
case
LOD3:
ata
.
setLod3MultiSurface
(
new
MultiSurfaceProperty
(
ms
));
break
;
case
LOD4:
ata
.
getDeprecatedProperties
().
setLod4MultiSurface
(
new
MultiSurfaceProperty
(
ms
));
break
;
default
:
throw
new
IllegalStateException
(
"cannot set geometry with LOD for AuxiliaryTrafficArea: "
+
lod
);
}
}
@Override
public
boolean
containsError
(
CheckId
checkIdentifier
)
{
boolean
hasError
=
super
.
containsError
(
checkIdentifier
);
if
(
hasError
)
{
return
true
;
}
for
(
TransportationObject
to
:
composesOf
)
{
if
(
to
.
containsError
(
checkIdentifier
))
{
return
true
;
}
}
return
false
;
}
private
void
setMultiSurfaceAccordingToLod
(
TrafficArea
ta
,
MultiSurface
ms
,
Lod
lod
)
{
switch
(
lod
)
{
case
LOD2:
ta
.
setLod2MultiSurface
(
new
MultiSurfaceProperty
(
ms
));
break
;
case
LOD3:
ta
.
setLod3MultiSurface
(
new
MultiSurfaceProperty
(
ms
));
break
;
case
LOD4:
ta
.
getDeprecatedProperties
().
setLod4MultiSurface
(
new
MultiSurfaceProperty
(
ms
));
break
;
default
:
throw
new
IllegalStateException
(
"cannot set geometry with LOD for TrafficArea: "
+
lod
);
}
}
@Override
public
void
clearAllContainedCheckResults
()
{
super
.
clearAllContainedCheckResults
();
for
(
TransportationObject
to
:
composesOf
)
{
to
.
clearAllContainedCheckResults
();
}
}
@Override
public
boolean
containsError
(
CheckId
checkIdentifier
)
{
boolean
hasError
=
super
.
containsError
(
checkIdentifier
);
if
(
hasError
)
{
return
true
;
}
for
(
TransportationObject
to
:
composesOf
)
{
if
(
to
.
containsError
(
checkIdentifier
))
{
return
true
;
}
}
return
false
;
}
@Override
public
void
collectContainedErrors
(
List
<
CheckError
>
errors
)
{
super
.
collectContainedErrors
(
errors
);
for
(
TransportationObject
to
:
composesOf
)
{
to
.
collectContainedErrors
(
errors
);
}
}
@Override
public
void
clearAllContainedCheckResults
()
{
super
.
clearAllContainedCheckResults
();
for
(
TransportationObject
to
:
composesOf
)
{
to
.
clearAllContainedCheckResults
();
}
}
@Override
public
boolean
containsAnyError
()
{
boolean
hasError
=
super
.
containsAnyError
();
if
(
hasError
)
{
return
true
;
}
for
(
TransportationObject
to
:
composesOf
)
{
if
(
to
.
containsAnyError
())
{
return
true
;
}
}
return
false
;
}
@Override
public
void
collectContainedErrors
(
List
<
CheckError
>
errors
)
{
super
.
collectContainedErrors
(
errors
);
for
(
TransportationObject
to
:
composesOf
)
{
to
.
collectContainedErrors
(
errors
);
}
}
@Override
public
void
accept
(
Check
c
)
{
super
.
accept
(
c
);
if
(
c
.
canExecute
(
this
))
{
c
.
check
(
this
);
}
for
(
TransportationObject
to
:
composesOf
)
{
to
.
accept
(
c
);
}
}
@Override
public
boolean
containsAnyError
()
{
boolean
hasError
=
super
.
containsAnyError
();
if
(
hasError
)
{
return
true
;
}
for
(
TransportationObject
to
:
composesOf
)
{
if
(
to
.
containsAnyError
())
{
return
true
;
}
}
return
false
;
}
@Override
public
AbstractCityObject
getGmlObject
()
{
return
ato
;
}
@Override
public
void
accept
(
Check
c
)
{
super
.
accept
(
c
);
if
(
c
.
canExecute
(
this
))
{
c
.
check
(
this
);
}
for
(
TransportationObject
to
:
composesOf
)
{
to
.
accept
(
c
);
}
}
@Override
public
void
unsetGmlGeometries
()
{
switch
(
type
)
{
case
ROAD
,
TRACK
,
RAILWAY
,
SQUARE
,
TRANSPORTATION_COMPLEX:
AbstractTransportationSpace
tc
=
(
AbstractTransportationSpace
)
ato
;
tc
.
getDeprecatedProperties
().
setLod1MultiSurface
(
null
);
tc
.
setLod2MultiSurface
(
null
);
tc
.
setLod3MultiSurface
(
null
);
tc
.
getDeprecatedProperties
().
setLod4MultiSurface
(
null
);
break
;
case
TRAFFIC_AREA:
TrafficArea
ta
=
(
TrafficArea
)
ato
;
ta
.
setLod2MultiSurface
(
null
);
ta
.
setLod3MultiSurface
(
null
);
ta
.
getDeprecatedProperties
().
setLod4MultiSurface
(
null
);
break
;
case
AUXILLIARY_TRAFFIC_AREA:
AuxiliaryTrafficArea
ata
=
(
AuxiliaryTrafficArea
)
ato
;
ata
.
setLod0MultiSurface
(
null
);
ata
.
setLod1MultiSurface
(
null
);
ata
.
setLod2MultiSurface
(
null
);
ata
.
setLod3MultiSurface
(
null
);
ata
.
getDeprecatedProperties
().
setLod4MultiSurface
(
null
);
break
;
case
AUXILLIARY_TRAFFIC_SPACE
,
TRAFFIC_SPACE:
AbstractSpace
ats
=
(
AbstractSpace
)
ato
;
ats
.
setLod0MultiSurface
(
null
);
ats
.
setLod2MultiSurface
(
null
);
ats
.
setLod3MultiSurface
(
null
);
break
;
}
}
@Override
public
AbstractCityObject
getGmlObject
()
{
return
ato
;
}
public
void
setGmlObject
(
AbstractCityObject
tc
)
{
ato
=
tc
;
}
@Override
public
void
unsetGmlGeometries
()
{
switch
(
type
)
{
case
ROAD
,
TRACK
,
RAILWAY
,
SQUARE
,
TRANSPORTATION_COMPLEX:
AbstractTransportationSpace
tc
=
(
AbstractTransportationSpace
)
ato
;
tc
.
getDeprecatedProperties
().
setLod1MultiSurface
(
null
);
tc
.
setLod2MultiSurface
(
null
);
tc
.
setLod3MultiSurface
(
null
);
tc
.
getDeprecatedProperties
().
setLod4MultiSurface
(
null
);
break
;
case
TRAFFIC_AREA:
TrafficArea
ta
=
(
TrafficArea
)
ato
;
ta
.
setLod2MultiSurface
(
null
);
ta
.
setLod3MultiSurface
(
null
);
ta
.
getDeprecatedProperties
().
setLod4MultiSurface
(
null
);
break
;
case
AUXILLIARY_TRAFFIC_AREA:
AuxiliaryTrafficArea
ata
=
(
AuxiliaryTrafficArea
)
ato
;
ata
.
setLod0MultiSurface
(
null
);
ata
.
setLod1MultiSurface
(
null
);
ata
.
setLod2MultiSurface
(
null
);
ata
.
setLod3MultiSurface
(
null
);
ata
.
getDeprecatedProperties
().
setLod4MultiSurface
(
null
);
break
;
case
AUXILLIARY_TRAFFIC_SPACE
,
TRAFFIC_SPACE:
AbstractSpace
ats
=
(
AbstractSpace
)
ato
;
ats
.
setLod0MultiSurface
(
null
);
ats
.
setLod2MultiSurface
(
null
);
ats
.
setLod3MultiSurface
(
null
);
break
;
}
}
public
void
addChild
(
TransportationObject
subTrans
)
{
composesOf
.
add
(
subTrans
);
}
public
void
setGmlObject
(
AbstractCityObject
tc
)
{
ato
=
tc
;
}
public
List
<
TransportationObject
>
getChildren
(
)
{
return
composesOf
;
}
public
void
addChild
(
TransportationObject
subTrans
)
{
composesOf
.
add
(
subTrans
)
;
}
public
TransportationType
getTransportationType
(
)
{
return
type
;
}
public
List
<
TransportationObject
>
getChildren
()
{
return
composesOf
;
}
@Override
public
String
toString
()
{
return
"TransportationObject [id="
+
getGmlId
()
+
"]"
;
}
public
TransportationType
getTransportationType
()
{
return
type
;
}
@Override
public
void
prepareForChecking
()
{
super
.
prepareForChecking
();
for
(
TransportationObject
child
:
composesOf
)
{
child
.
prepareForChecking
();
}
}
@Override
public
String
toString
()
{
return
"TransportationObject [id="
+
getGmlId
()
+
"]"
;
}
@Override
public
void
clearMetaInformation
()
{
super
.
clearMetaInformation
();
for
(
TransportationObject
child
:
composesOf
)
{
child
.
clearMetaInformation
();
}
}
@Override
public
void
prepareForChecking
(
)
{
super
.
prepareForChecking
(
);
for
(
TransportationObject
child
:
composesOf
)
{
child
.
prepareForChecking
(
);
}
}
@Override
public
void
collectInstances
(
CopyHandler
handler
)
{
super
.
collectInstances
(
handler
);
for
(
TransportationObject
to
:
composesOf
)
{
handler
.
addInstance
(
to
);
}
}
@Override
public
void
clearMetaInformation
()
{
super
.
clearMetaInformation
();
for
(
TransportationObject
child
:
composesOf
)
{
child
.
clearMetaInformation
();
}
}
@Override
public
void
collectInstances
(
CopyHandler
handler
)
{
super
.
collectInstances
(
handler
);
for
(
TransportationObject
to
:
composesOf
)
{
handler
.
addInstance
(
to
);
}
}
@Override
public
void
fillValues
(
Copyable
original
,
CopyHandler
handler
)
{
super
.
fillValues
(
original
,
handler
);
TransportationObject
originalTo
=
(
TransportationObject
)
original
;
for
(
TransportationObject
to
:
originalTo
.
composesOf
)
{
composesOf
.
add
(
handler
.
getCopyInstance
(
to
));
}
ato
=
originalTo
.
ato
;
}
@Override
public
void
fillValues
(
Copyable
original
,
CopyHandler
handler
)
{
super
.
fillValues
(
original
,
handler
);
TransportationObject
originalTo
=
(
TransportationObject
)
original
;
for
(
TransportationObject
to
:
originalTo
.
composesOf
)
{
composesOf
.
add
(
handler
.
getCopyInstance
(
to
));
}
ato
=
originalTo
.
ato
;
}
@Override
public
Copyable
createCopyInstance
()
{
return
new
TransportationObject
(
type
);
}
@Override
public
Copyable
createCopyInstance
()
{
return
new
TransportationObject
(
type
);
}
}
CityDoctorParent/CityDoctorModel/src/main/java/de/hft/stuttgart/citydoctor2/datastructure/Tunnel.java
View file @
02de0a22
...
...
@@ -15,7 +15,7 @@ import java.io.Serial;
import
java.util.ArrayList
;
import
java.util.List
;
public
class
Tunnel
extends
AbstractTunnel
{
public
class
Tunnel
extends
AbstractTunnel
{
@Serial
private
static
final
long
serialVersionUID
=
5316281216192555555L
;
...
...
CityDoctorParent/CityDoctorModel/src/main/java/de/hft/stuttgart/citydoctor2/datastructure/TunnelFurniture.java
View file @
02de0a22
package
de.hft.stuttgart.citydoctor2.datastructure
;
import
de.hft.stuttgart.citydoctor2.utils.Copyable
;
import
org.citygml4j.core.model.building.BuildingFurniture
;
import
java.io.Serial
;
...
...
@@ -15,7 +14,7 @@ public class TunnelFurniture extends AbstractFurniture {
}
@Override
public
Copyable
createCopyInstance
(){
public
Copyable
createCopyInstance
()
{
return
new
BuildingRoomFurniture
();
}
...
...
CityDoctorParent/CityDoctorModel/src/main/java/de/hft/stuttgart/citydoctor2/datastructure/TunnelHollow.java
View file @
02de0a22
...
...
@@ -8,18 +8,18 @@ import java.io.Serial;
import
java.util.ArrayList
;
import
java.util.List
;
public
class
TunnelHollow
extends
AbstractRoom
{
public
class
TunnelHollow
extends
AbstractRoom
{
@Serial
private
static
final
long
serialVersionUID
=
-
276088332165299253L
;
private
final
List
<
TunnelFurnitureProperty
>
furnitureRefs
=
new
ArrayList
<>(
2
);
private
CityObject
parent
;
public
void
setGmlObject
(
org
.
citygml4j
.
core
.
model
.
tunnel
.
HollowSpace
gmlHollowSpace
){
public
void
setGmlObject
(
org
.
citygml4j
.
core
.
model
.
tunnel
.
HollowSpace
gmlHollowSpace
)
{
super
.
cgmlRoom
=
gmlHollowSpace
;
}
public
void
setParent
(
CityObject
parent
){
public
void
setParent
(
CityObject
parent
)
{
this
.
parent
=
parent
;
}
...
...
@@ -36,7 +36,7 @@ public class TunnelHollow extends AbstractRoom{
}
@Override
public
void
fillValues
(
Copyable
original
,
CopyHandler
handler
){
public
void
fillValues
(
Copyable
original
,
CopyHandler
handler
)
{
super
.
fillValues
(
original
,
handler
);
TunnelHollow
oHollow
=
(
TunnelHollow
)
original
;
...
...
@@ -44,7 +44,7 @@ public class TunnelHollow extends AbstractRoom{
}
@Override
public
void
collectInstances
(
CopyHandler
handler
){
public
void
collectInstances
(
CopyHandler
handler
)
{
super
.
collectInstances
(
handler
);
handler
.
addInstance
(
parent
);
}
...
...
CityDoctorParent/CityDoctorModel/src/main/java/de/hft/stuttgart/citydoctor2/datastructure/TunnelPart.java
View file @
02de0a22
...
...
@@ -50,5 +50,6 @@ public class TunnelPart extends AbstractTunnel {
return
new
TunnelPart
();
}
private
TunnelPart
(){}
private
TunnelPart
()
{
}
}
CityDoctorParent/CityDoctorModel/src/main/java/de/hft/stuttgart/citydoctor2/datastructure/Vegetation.java
View file @
02de0a22
/*-
* Copyright 2020 Beuth Hochschule für Technik Berlin, Hochschule für Technik Stuttgart
*
*
* This file is part of CityDoctor2.
*
* CityDoctor2 is free software: you can redistribute it and/or modify
...
...
@@ -18,9 +18,10 @@
*/
package
de.hft.stuttgart.citydoctor2.datastructure
;
import
java.io.Serial
;
import
java.util.Collections
;
import
de.hft.stuttgart.citydoctor2.check.Check
;
import
de.hft.stuttgart.citydoctor2.parser.ParserConfiguration
;
import
de.hft.stuttgart.citydoctor2.utils.CityGmlUtils
;
import
de.hft.stuttgart.citydoctor2.utils.Copyable
;
import
org.citygml4j.core.model.core.AbstractCityObject
;
import
org.citygml4j.core.model.vegetation.AbstractVegetationObject
;
import
org.citygml4j.core.model.vegetation.PlantCover
;
...
...
@@ -33,188 +34,185 @@ import org.xmlobjects.gml.model.geometry.aggregates.MultiSurfaceProperty;
import
org.xmlobjects.gml.model.geometry.primitives.Solid
;
import
org.xmlobjects.gml.model.geometry.primitives.SolidProperty
;
import
de.hft.stuttgart.citydoctor2.check.Check
;
import
de.hft.stuttgart.citydoctor2.parser.ParserConfiguration
;
import
de.hft.stuttgart.citydoctor2.utils.CityGmlUtils
;
import
de.hft.stuttgart.citydoctor2.utils.Copyable
;
import
java.io.Serial
;
import
java.util.Collections
;
/**
* Representation of CityGML vegetation objects
*
* @author Matthias Betz
*
* @author Matthias Betz
*/
public
class
Vegetation
extends
CityObject
{
@Serial
private
static
final
long
serialVersionUID
=
-
5136358065541704146L
;
public
enum
VegetationType
{
SOLITARY_VEGETATION_OBJECT
,
PLANT_COVER
}
private
AbstractVegetationObject
citygmlVegetation
;
private
final
VegetationType
type
;
public
Vegetation
(
VegetationType
type
)
{
this
.
type
=
type
;
}
@Override
public
FeatureType
getFeatureType
()
{
return
FeatureType
.
VEGETATION
;
}
@Override
public
void
reCreateGeometries
(
GeometryFactory
factory
,
ParserConfiguration
config
)
{
for
(
Geometry
geom
:
getGeometries
())
{
if
(
geom
instanceof
ImplicitGeometryHolder
){
continue
;
}
if
(
geom
.
getType
()
==
GeometryType
.
MULTI_SURFACE
)
{
MultiSurface
ms
=
CityGmlUtils
.
createMultiSurface
(
geom
,
factory
,
config
);
if
(
type
==
VegetationType
.
SOLITARY_VEGETATION_OBJECT
)
{
SolitaryVegetationObject
svo
=
(
SolitaryVegetationObject
)
citygmlVegetation
;
setMultiSurfaceAccordingToLod
(
svo
,
ms
,
geom
.
getLod
());
}
else
{
PlantCover
pc
=
(
PlantCover
)
citygmlVegetation
;
setMultiSurfaceAccordingToLod
(
pc
,
ms
,
geom
.
getLod
());
}
}
else
{
Solid
solid
=
CityGmlUtils
.
createSolid
(
geom
,
factory
,
config
);
if
(
type
==
VegetationType
.
SOLITARY_VEGETATION_OBJECT
)
{
SolitaryVegetationObject
svo
=
(
SolitaryVegetationObject
)
citygmlVegetation
;
setSolidAccordingToLod
(
svo
,
solid
,
geom
.
getLod
());
}
else
{
PlantCover
pc
=
(
PlantCover
)
citygmlVegetation
;
setSolidAccordingToLod
(
pc
,
solid
,
geom
.
getLod
());
}
}
}
}
private
void
setSolidAccordingToLod
(
PlantCover
pc
,
Solid
solid
,
Lod
lod
)
{
switch
(
lod
)
{
case
LOD1:
pc
.
getDeprecatedProperties
().
setLod1MultiSolid
(
new
MultiSolidProperty
(
new
MultiSolid
(
Collections
.
singletonList
(
new
SolidProperty
(
solid
)))));
break
;
case
LOD2:
pc
.
getDeprecatedProperties
().
setLod2MultiSolid
(
new
MultiSolidProperty
(
new
MultiSolid
(
Collections
.
singletonList
(
new
SolidProperty
(
solid
)))));
break
;
case
LOD3:
pc
.
getDeprecatedProperties
().
setLod3MultiSolid
(
new
MultiSolidProperty
(
new
MultiSolid
(
Collections
.
singletonList
(
new
SolidProperty
(
solid
)))));
break
;
case
LOD4:
pc
.
getDeprecatedProperties
().
setLod4MultiSolid
(
new
MultiSolidProperty
(
new
MultiSolid
(
Collections
.
singletonList
(
new
SolidProperty
(
solid
)))));
break
;
default
:
throw
new
IllegalStateException
(
"Cannot set Solid with lod to PlantCover:"
+
lod
);
}
}
private
void
setSolidAccordingToLod
(
SolitaryVegetationObject
svo
,
Solid
solid
,
Lod
lod
)
{
switch
(
lod
)
{
case
LOD1:
svo
.
getDeprecatedProperties
().
setLod1Geometry
(
new
SolidProperty
(
solid
));
break
;
case
LOD2:
svo
.
getDeprecatedProperties
().
setLod2Geometry
(
new
SolidProperty
(
solid
));
break
;
case
LOD3:
svo
.
getDeprecatedProperties
().
setLod3Geometry
(
new
SolidProperty
(
solid
));
break
;
case
LOD4:
svo
.
getDeprecatedProperties
().
setLod4Geometry
(
new
SolidProperty
(
solid
));
break
;
default
:
throw
new
IllegalStateException
(
"Cannot set Solid with lod to SolitaryVegetationObject:"
+
lod
);
}
}
private
void
setMultiSurfaceAccordingToLod
(
PlantCover
pc
,
MultiSurface
ms
,
Lod
lod
)
{
switch
(
lod
)
{
case
LOD1:
pc
.
getDeprecatedProperties
().
setLod1MultiSurface
(
new
MultiSurfaceProperty
(
ms
));
break
;
case
LOD2:
pc
.
setLod2MultiSurface
(
new
MultiSurfaceProperty
(
ms
));
break
;
case
LOD3:
pc
.
setLod3MultiSurface
(
new
MultiSurfaceProperty
(
ms
));
break
;
case
LOD4:
pc
.
getDeprecatedProperties
().
setLod4MultiSurface
(
new
MultiSurfaceProperty
(
ms
));
break
;
default
:
throw
new
IllegalStateException
(
"Cannot set MultiSurface with lod to PlantCover:"
+
lod
);
}
}
private
void
setMultiSurfaceAccordingToLod
(
SolitaryVegetationObject
svo
,
MultiSurface
ms
,
Lod
lod
)
{
switch
(
lod
)
{
case
LOD1:
svo
.
getDeprecatedProperties
().
setLod1Geometry
(
new
MultiSurfaceProperty
(
ms
));
break
;
case
LOD2:
svo
.
getDeprecatedProperties
().
setLod2Geometry
(
new
MultiSurfaceProperty
(
ms
));
break
;
case
LOD3:
svo
.
getDeprecatedProperties
().
setLod3Geometry
(
new
MultiSurfaceProperty
(
ms
));
break
;
case
LOD4:
svo
.
getDeprecatedProperties
().
setLod4Geometry
(
new
MultiSurfaceProperty
(
ms
));
break
;
default
:
throw
new
IllegalStateException
(
"Cannot set MultiSurface with lod to SolitaryVegetationObject:"
+
lod
);
}
}
@Override
public
void
accept
(
Check
c
)
{
super
.
accept
(
c
);
if
(
c
.
canExecute
(
this
))
{
c
.
check
(
this
);
}
}
@Override
public
AbstractCityObject
getGmlObject
()
{
return
citygmlVegetation
;
}
@Override
public
void
unsetGmlGeometries
()
{
if
(
type
==
VegetationType
.
SOLITARY_VEGETATION_OBJECT
)
{
SolitaryVegetationObject
svo
=
(
SolitaryVegetationObject
)
citygmlVegetation
;
svo
.
getDeprecatedProperties
().
setLod1Geometry
(
null
);
svo
.
getDeprecatedProperties
().
setLod2Geometry
(
null
);
svo
.
getDeprecatedProperties
().
setLod3Geometry
(
null
);
svo
.
getDeprecatedProperties
().
setLod4Geometry
(
null
);
}
else
{
PlantCover
pc
=
(
PlantCover
)
citygmlVegetation
;
pc
.
getDeprecatedProperties
().
setLod1MultiSurface
(
null
);
pc
.
setLod2MultiSurface
(
null
);
pc
.
setLod3MultiSurface
(
null
);
pc
.
getDeprecatedProperties
().
setLod4MultiSurface
(
null
);
}
}
public
void
setGmlObject
(
AbstractVegetationObject
avo
)
{
citygmlVegetation
=
avo
;
}
public
VegetationType
getVegetationType
()
{
return
type
;
}
@Override
public
String
toString
()
{
return
"Vegetation [id="
+
getGmlId
()
+
"]"
;
}
@Override
public
Copyable
createCopyInstance
()
{
return
new
Vegetation
(
type
);
}
@Serial
private
static
final
long
serialVersionUID
=
-
5136358065541704146L
;
public
enum
VegetationType
{
SOLITARY_VEGETATION_OBJECT
,
PLANT_COVER
}
private
AbstractVegetationObject
citygmlVegetation
;
private
final
VegetationType
type
;
public
Vegetation
(
VegetationType
type
)
{
this
.
type
=
type
;
}
@Override
public
FeatureType
getFeatureType
()
{
return
FeatureType
.
VEGETATION
;
}
@Override
public
void
reCreateGeometries
(
GeometryFactory
factory
,
ParserConfiguration
config
)
{
for
(
Geometry
geom
:
getGeometries
())
{
if
(
geom
instanceof
ImplicitGeometryHolder
)
{
continue
;
}
if
(
geom
.
getType
()
==
GeometryType
.
MULTI_SURFACE
)
{
MultiSurface
ms
=
CityGmlUtils
.
createMultiSurface
(
geom
,
factory
,
config
);
if
(
type
==
VegetationType
.
SOLITARY_VEGETATION_OBJECT
)
{
SolitaryVegetationObject
svo
=
(
SolitaryVegetationObject
)
citygmlVegetation
;
setMultiSurfaceAccordingToLod
(
svo
,
ms
,
geom
.
getLod
());
}
else
{
PlantCover
pc
=
(
PlantCover
)
citygmlVegetation
;
setMultiSurfaceAccordingToLod
(
pc
,
ms
,
geom
.
getLod
());
}
}
else
{
Solid
solid
=
CityGmlUtils
.
createSolid
(
geom
,
factory
,
config
);
if
(
type
==
VegetationType
.
SOLITARY_VEGETATION_OBJECT
)
{
SolitaryVegetationObject
svo
=
(
SolitaryVegetationObject
)
citygmlVegetation
;
setSolidAccordingToLod
(
svo
,
solid
,
geom
.
getLod
());
}
else
{
PlantCover
pc
=
(
PlantCover
)
citygmlVegetation
;
setSolidAccordingToLod
(
pc
,
solid
,
geom
.
getLod
());
}
}
}
}
private
void
setSolidAccordingToLod
(
PlantCover
pc
,
Solid
solid
,
Lod
lod
)
{
switch
(
lod
)
{
case
LOD1:
pc
.
getDeprecatedProperties
().
setLod1MultiSolid
(
new
MultiSolidProperty
(
new
MultiSolid
(
Collections
.
singletonList
(
new
SolidProperty
(
solid
)))));
break
;
case
LOD2:
pc
.
getDeprecatedProperties
().
setLod2MultiSolid
(
new
MultiSolidProperty
(
new
MultiSolid
(
Collections
.
singletonList
(
new
SolidProperty
(
solid
)))));
break
;
case
LOD3:
pc
.
getDeprecatedProperties
().
setLod3MultiSolid
(
new
MultiSolidProperty
(
new
MultiSolid
(
Collections
.
singletonList
(
new
SolidProperty
(
solid
)))));
break
;
case
LOD4:
pc
.
getDeprecatedProperties
().
setLod4MultiSolid
(
new
MultiSolidProperty
(
new
MultiSolid
(
Collections
.
singletonList
(
new
SolidProperty
(
solid
)))));
break
;
default
:
throw
new
IllegalStateException
(
"Cannot set Solid with lod to PlantCover:"
+
lod
);
}
}
private
void
setSolidAccordingToLod
(
SolitaryVegetationObject
svo
,
Solid
solid
,
Lod
lod
)
{
switch
(
lod
)
{
case
LOD1:
svo
.
getDeprecatedProperties
().
setLod1Geometry
(
new
SolidProperty
(
solid
));
break
;
case
LOD2:
svo
.
getDeprecatedProperties
().
setLod2Geometry
(
new
SolidProperty
(
solid
));
break
;
case
LOD3:
svo
.
getDeprecatedProperties
().
setLod3Geometry
(
new
SolidProperty
(
solid
));
break
;
case
LOD4:
svo
.
getDeprecatedProperties
().
setLod4Geometry
(
new
SolidProperty
(
solid
));
break
;
default
:
throw
new
IllegalStateException
(
"Cannot set Solid with lod to SolitaryVegetationObject:"
+
lod
);
}
}
private
void
setMultiSurfaceAccordingToLod
(
PlantCover
pc
,
MultiSurface
ms
,
Lod
lod
)
{
switch
(
lod
)
{
case
LOD1:
pc
.
getDeprecatedProperties
().
setLod1MultiSurface
(
new
MultiSurfaceProperty
(
ms
));
break
;
case
LOD2:
pc
.
setLod2MultiSurface
(
new
MultiSurfaceProperty
(
ms
));
break
;
case
LOD3:
pc
.
setLod3MultiSurface
(
new
MultiSurfaceProperty
(
ms
));
break
;
case
LOD4:
pc
.
getDeprecatedProperties
().
setLod4MultiSurface
(
new
MultiSurfaceProperty
(
ms
));
break
;
default
:
throw
new
IllegalStateException
(
"Cannot set MultiSurface with lod to PlantCover:"
+
lod
);
}
}
private
void
setMultiSurfaceAccordingToLod
(
SolitaryVegetationObject
svo
,
MultiSurface
ms
,
Lod
lod
)
{
switch
(
lod
)
{
case
LOD1:
svo
.
getDeprecatedProperties
().
setLod1Geometry
(
new
MultiSurfaceProperty
(
ms
));
break
;
case
LOD2:
svo
.
getDeprecatedProperties
().
setLod2Geometry
(
new
MultiSurfaceProperty
(
ms
));
break
;
case
LOD3:
svo
.
getDeprecatedProperties
().
setLod3Geometry
(
new
MultiSurfaceProperty
(
ms
));
break
;
case
LOD4:
svo
.
getDeprecatedProperties
().
setLod4Geometry
(
new
MultiSurfaceProperty
(
ms
));
break
;
default
:
throw
new
IllegalStateException
(
"Cannot set MultiSurface with lod to SolitaryVegetationObject:"
+
lod
);
}
}
@Override
public
void
accept
(
Check
c
)
{
super
.
accept
(
c
);
if
(
c
.
canExecute
(
this
))
{
c
.
check
(
this
);
}
}
@Override
public
AbstractCityObject
getGmlObject
()
{
return
citygmlVegetation
;
}
@Override
public
void
unsetGmlGeometries
()
{
if
(
type
==
VegetationType
.
SOLITARY_VEGETATION_OBJECT
)
{
SolitaryVegetationObject
svo
=
(
SolitaryVegetationObject
)
citygmlVegetation
;
svo
.
getDeprecatedProperties
().
setLod1Geometry
(
null
);
svo
.
getDeprecatedProperties
().
setLod2Geometry
(
null
);
svo
.
getDeprecatedProperties
().
setLod3Geometry
(
null
);
svo
.
getDeprecatedProperties
().
setLod4Geometry
(
null
);
}
else
{
PlantCover
pc
=
(
PlantCover
)
citygmlVegetation
;
pc
.
getDeprecatedProperties
().
setLod1MultiSurface
(
null
);
pc
.
setLod2MultiSurface
(
null
);
pc
.
setLod3MultiSurface
(
null
);
pc
.
getDeprecatedProperties
().
setLod4MultiSurface
(
null
);
}
}
public
void
setGmlObject
(
AbstractVegetationObject
avo
)
{
citygmlVegetation
=
avo
;
}
public
VegetationType
getVegetationType
()
{
return
type
;
}
@Override
public
String
toString
()
{
return
"Vegetation [id="
+
getGmlId
()
+
"]"
;
}
@Override
public
Copyable
createCopyInstance
()
{
return
new
Vegetation
(
type
);
}
}
CityDoctorParent/CityDoctorModel/src/main/java/de/hft/stuttgart/citydoctor2/datastructure/Vertex.java
View file @
02de0a22
/*-
* Copyright 2020 Beuth Hochschule für Technik Berlin, Hochschule für Technik Stuttgart
*
*
* This file is part of CityDoctor2.
*
* CityDoctor2 is free software: you can redistribute it and/or modify
...
...
@@ -18,155 +18,154 @@
*/
package
de.hft.stuttgart.citydoctor2.datastructure
;
import
de.hft.stuttgart.citydoctor2.math.Vector3d
;
import
de.hft.stuttgart.citydoctor2.utils.CopyHandler
;
import
de.hft.stuttgart.citydoctor2.utils.Copyable
;
import
de.hft.stuttgart.citydoctor2.utils.SerializablePair
;
import
java.io.Serial
;
import
java.util.ArrayList
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.Set
;
import
de.hft.stuttgart.citydoctor2.math.Vector3d
;
import
de.hft.stuttgart.citydoctor2.utils.CopyHandler
;
import
de.hft.stuttgart.citydoctor2.utils.Copyable
;
import
de.hft.stuttgart.citydoctor2.utils.SerializablePair
;
/**
* Contains the vertex information of a point in a linear ring
*
* @author Matthias Betz
*
* @author Matthias Betz
*/
public
class
Vertex
extends
Vector3d
implements
Copyable
{
@Serial
private
static
final
long
serialVersionUID
=
-
5525361920397934892L
;
private
List
<
SerializablePair
<
Geometry
,
HashSet
<
LinearRing
>>>
adjacentRings
=
new
ArrayList
<>(
2
);
public
Vertex
(
double
x
,
double
y
,
double
z
)
{
super
(
x
,
y
,
z
);
}
public
Vertex
(
Vector3d
vec
)
{
super
(
vec
);
}
private
Set
<
LinearRing
>
getAdjacentRingsWithoutNeighbor
(
Geometry
geom
)
{
for
(
SerializablePair
<
Geometry
,
HashSet
<
LinearRing
>>
adjacency
:
adjacentRings
)
{
if
(
adjacency
.
getValue0
()
==
geom
)
{
return
adjacency
.
getValue1
();
}
}
throw
new
IllegalStateException
(
"Requested adjacent rings with Geometry not containing this vertex"
);
}
public
Set
<
LinearRing
>
getAdjacentRings
(
Geometry
geom
)
{
return
getAdjacentRingsWithoutNeighbor
(
geom
);
}
void
addAdjacentRing
(
LinearRing
ring
,
Geometry
geom
)
{
findAdjacentRingsForGeometry
(
geom
).
add
(
ring
);
}
private
Set
<
LinearRing
>
findAdjacentRingsForGeometry
(
Geometry
geom
)
{
HashSet
<
LinearRing
>
adjacendRingsSet
=
null
;
for
(
SerializablePair
<
Geometry
,
HashSet
<
LinearRing
>>
adjacency
:
adjacentRings
)
{
if
(
adjacency
.
getValue0
()
==
geom
)
{
adjacendRingsSet
=
adjacency
.
getValue1
();
}
}
if
(
adjacendRingsSet
==
null
)
{
adjacendRingsSet
=
new
HashSet
<>(
4
);
adjacentRings
.
add
(
new
SerializablePair
<>(
geom
,
adjacendRingsSet
));
}
return
adjacendRingsSet
;
}
private
Set
<
Polygon
>
getAdjacentPolygonsWithoutNeighbor
(
Geometry
geom
)
{
for
(
SerializablePair
<
Geometry
,
HashSet
<
LinearRing
>>
adjacency
:
adjacentRings
)
{
if
(
adjacency
.
getValue0
()
==
geom
)
{
Set
<
Polygon
>
polygons
=
new
HashSet
<>();
for
(
LinearRing
lr
:
adjacency
.
getValue1
())
{
polygons
.
add
(
lr
.
getParent
());
}
return
polygons
;
}
}
throw
new
IllegalStateException
(
"Requested adjacent polygons with Geometry not containing this vertex"
);
}
public
Set
<
Polygon
>
getAdjacentPolygons
(
Geometry
geom
)
{
return
getAdjacentPolygonsWithoutNeighbor
(
geom
);
}
@Override
public
int
hashCode
()
{
final
int
prime
=
31
;
int
result
=
super
.
hashCode
();
return
prime
*
result
;
}
@Override
public
boolean
equals
(
Object
obj
)
{
if
(
this
==
obj
)
{
return
true
;
}
if
(!
super
.
equals
(
obj
))
{
return
false
;
}
return
getClass
()
==
obj
.
getClass
();
}
@Override
public
String
toString
()
{
return
"Vertex [x="
+
getX
()
+
", y="
+
getY
()
+
", z="
+
getZ
()
+
"]"
;
}
public
void
clearAdjacentRings
(
Geometry
geometry
)
{
if
(
adjacentRings
==
null
)
{
return
;
}
findAdjacentRingsForGeometry
(
geometry
).
clear
();
}
void
removeAdjacency
(
LinearRing
lr
,
Geometry
geom
)
{
findAdjacentRingsForGeometry
(
geom
).
remove
(
lr
);
}
/**
* Remove all adjacent rings from this vertex, ignoring geometry association
*/
void
clearAdjacentRings
()
{
adjacentRings
=
new
ArrayList
<>(
2
);
}
@Override
public
void
collectInstances
(
CopyHandler
handler
)
{
for
(
SerializablePair
<
Geometry
,
HashSet
<
LinearRing
>>
pair
:
adjacentRings
)
{
handler
.
addInstance
(
pair
.
getValue0
());
for
(
LinearRing
lr
:
pair
.
getValue1
())
{
handler
.
addInstance
(
lr
);
}
}
}
@Override
public
Copyable
createCopyInstance
()
{
return
new
Vertex
(
this
);
}
@Override
public
void
fillValues
(
Copyable
original
,
CopyHandler
handler
)
{
Vertex
originalVertex
=
(
Vertex
)
original
;
// vertex point data already filled
for
(
SerializablePair
<
Geometry
,
HashSet
<
LinearRing
>>
pair
:
originalVertex
.
adjacentRings
)
{
Geometry
geomCopy
=
handler
.
getCopyInstance
(
pair
.
getValue0
());
HashSet
<
LinearRing
>
set
=
new
HashSet
<>();
for
(
LinearRing
originalRing
:
pair
.
getValue1
())
{
set
.
add
(
handler
.
getCopyInstance
(
originalRing
));
}
SerializablePair
<
Geometry
,
HashSet
<
LinearRing
>>
copyPair
=
new
SerializablePair
<>(
geomCopy
,
set
);
adjacentRings
.
add
(
copyPair
);
}
}
@Serial
private
static
final
long
serialVersionUID
=
-
5525361920397934892L
;
private
List
<
SerializablePair
<
Geometry
,
HashSet
<
LinearRing
>>>
adjacentRings
=
new
ArrayList
<>(
2
);
public
Vertex
(
double
x
,
double
y
,
double
z
)
{
super
(
x
,
y
,
z
);
}
public
Vertex
(
Vector3d
vec
)
{
super
(
vec
);
}
private
Set
<
LinearRing
>
getAdjacentRingsWithoutNeighbor
(
Geometry
geom
)
{
for
(
SerializablePair
<
Geometry
,
HashSet
<
LinearRing
>>
adjacency
:
adjacentRings
)
{
if
(
adjacency
.
getValue0
()
==
geom
)
{
return
adjacency
.
getValue1
();
}
}
throw
new
IllegalStateException
(
"Requested adjacent rings with Geometry not containing this vertex"
);
}
public
Set
<
LinearRing
>
getAdjacentRings
(
Geometry
geom
)
{
return
getAdjacentRingsWithoutNeighbor
(
geom
);
}
void
addAdjacentRing
(
LinearRing
ring
,
Geometry
geom
)
{
findAdjacentRingsForGeometry
(
geom
).
add
(
ring
);
}
private
Set
<
LinearRing
>
findAdjacentRingsForGeometry
(
Geometry
geom
)
{
HashSet
<
LinearRing
>
adjacendRingsSet
=
null
;
for
(
SerializablePair
<
Geometry
,
HashSet
<
LinearRing
>>
adjacency
:
adjacentRings
)
{
if
(
adjacency
.
getValue0
()
==
geom
)
{
adjacendRingsSet
=
adjacency
.
getValue1
();
}
}
if
(
adjacendRingsSet
==
null
)
{
adjacendRingsSet
=
new
HashSet
<>(
4
);
adjacentRings
.
add
(
new
SerializablePair
<>(
geom
,
adjacendRingsSet
));
}
return
adjacendRingsSet
;
}
private
Set
<
Polygon
>
getAdjacentPolygonsWithoutNeighbor
(
Geometry
geom
)
{
for
(
SerializablePair
<
Geometry
,
HashSet
<
LinearRing
>>
adjacency
:
adjacentRings
)
{
if
(
adjacency
.
getValue0
()
==
geom
)
{
Set
<
Polygon
>
polygons
=
new
HashSet
<>();
for
(
LinearRing
lr
:
adjacency
.
getValue1
())
{
polygons
.
add
(
lr
.
getParent
());
}
return
polygons
;
}
}
throw
new
IllegalStateException
(
"Requested adjacent polygons with Geometry not containing this vertex"
);
}
public
Set
<
Polygon
>
getAdjacentPolygons
(
Geometry
geom
)
{
return
getAdjacentPolygonsWithoutNeighbor
(
geom
);
}
@Override
public
int
hashCode
()
{
final
int
prime
=
31
;
int
result
=
super
.
hashCode
();
return
prime
*
result
;
}
@Override
public
boolean
equals
(
Object
obj
)
{
if
(
this
==
obj
)
{
return
true
;
}
if
(!
super
.
equals
(
obj
))
{
return
false
;
}
return
getClass
()
==
obj
.
getClass
();
}
@Override
public
String
toString
()
{
return
"Vertex [x="
+
getX
()
+
", y="
+
getY
()
+
", z="
+
getZ
()
+
"]"
;
}
public
void
clearAdjacentRings
(
Geometry
geometry
)
{
if
(
adjacentRings
==
null
)
{
return
;
}
findAdjacentRingsForGeometry
(
geometry
).
clear
();
}
void
removeAdjacency
(
LinearRing
lr
,
Geometry
geom
)
{
findAdjacentRingsForGeometry
(
geom
).
remove
(
lr
);
}
/**
* Remove all adjacent rings from this vertex, ignoring geometry association
*/
void
clearAdjacentRings
()
{
adjacentRings
=
new
ArrayList
<>(
2
);
}
@Override
public
void
collectInstances
(
CopyHandler
handler
)
{
for
(
SerializablePair
<
Geometry
,
HashSet
<
LinearRing
>>
pair
:
adjacentRings
)
{
handler
.
addInstance
(
pair
.
getValue0
());
for
(
LinearRing
lr
:
pair
.
getValue1
())
{
handler
.
addInstance
(
lr
);
}
}
}
@Override
public
Copyable
createCopyInstance
()
{
return
new
Vertex
(
this
);
}
@Override
public
void
fillValues
(
Copyable
original
,
CopyHandler
handler
)
{
Vertex
originalVertex
=
(
Vertex
)
original
;
// vertex point data already filled
for
(
SerializablePair
<
Geometry
,
HashSet
<
LinearRing
>>
pair
:
originalVertex
.
adjacentRings
)
{
Geometry
geomCopy
=
handler
.
getCopyInstance
(
pair
.
getValue0
());
HashSet
<
LinearRing
>
set
=
new
HashSet
<>();
for
(
LinearRing
originalRing
:
pair
.
getValue1
())
{
set
.
add
(
handler
.
getCopyInstance
(
originalRing
));
}
SerializablePair
<
Geometry
,
HashSet
<
LinearRing
>>
copyPair
=
new
SerializablePair
<>(
geomCopy
,
set
);
adjacentRings
.
add
(
copyPair
);
}
}
}
CityDoctorParent/CityDoctorModel/src/main/java/de/hft/stuttgart/citydoctor2/datastructure/WaterObject.java
View file @
02de0a22
/*-
* Copyright 2020 Beuth Hochschule für Technik Berlin, Hochschule für Technik Stuttgart
*
*
* This file is part of CityDoctor2.
*
* CityDoctor2 is free software: you can redistribute it and/or modify
...
...
@@ -18,155 +18,153 @@
*/
package
de.hft.stuttgart.citydoctor2.datastructure
;
import
java.io.Serial
;
import
java.util.ArrayList
;
import
java.util.List
;
import
de.hft.stuttgart.citydoctor2.check.Check
;
import
de.hft.stuttgart.citydoctor2.parser.ParserConfiguration
;
import
de.hft.stuttgart.citydoctor2.utils.CityGmlUtils
;
import
de.hft.stuttgart.citydoctor2.utils.CopyHandler
;
import
de.hft.stuttgart.citydoctor2.utils.Copyable
;
import
org.citygml4j.core.model.core.AbstractCityObject
;
import
org.citygml4j.core.model.waterbody.WaterBody
;
import
org.citygml4j.core.util.geometry.GeometryFactory
;
import
org.xmlobjects.gml.model.geometry.aggregates.MultiSurface
;
import
org.xmlobjects.gml.model.geometry.aggregates.MultiSurfaceProperty
;
import
de.hft.stuttgart.citydoctor2.check.Check
;
import
de.hft.stuttgart.citydoctor2.parser.ParserConfiguration
;
import
de.hft.stuttgart.citydoctor2.utils.CityGmlUtils
;
import
de.hft.stuttgart.citydoctor2.utils.CopyHandler
;
import
de.hft.stuttgart.citydoctor2.utils.Copyable
;
import
java.io.Serial
;
import
java.util.ArrayList
;
import
java.util.List
;
/**
* Represents cityGML water body objects.
*
* @author Matthias Betz
*
* @author Matthias Betz
*/
public
class
WaterObject
extends
CityObject
{
@Serial
private
static
final
long
serialVersionUID
=
-
3821060595086337424L
;
private
WaterBody
gmlWater
;
private
final
List
<
BoundarySurface
>
boundarySurfaceList
=
new
ArrayList
<>();
@Override
public
void
reCreateGeometries
(
GeometryFactory
factory
,
ParserConfiguration
config
)
{
for
(
Geometry
geom
:
getGeometries
())
{
if
(
geom
.
getType
()
==
GeometryType
.
MULTI_SURFACE
)
{
MultiSurface
ms
=
CityGmlUtils
.
createMultiSurface
(
geom
,
factory
,
config
);
if
(
geom
.
getLod
()
==
Lod
.
LOD0
)
{
gmlWater
.
setLod0MultiSurface
(
new
MultiSurfaceProperty
(
ms
));
}
else
if
(
geom
.
getLod
()
==
Lod
.
LOD1
)
{
gmlWater
.
getDeprecatedProperties
().
setLod1MultiSurface
(
new
MultiSurfaceProperty
(
ms
));
}
else
{
throw
new
IllegalStateException
(
"Cannot add MultiSurface geometry with lod to WaterBody:"
+
geom
.
getLod
());
}
}
else
{
throw
new
IllegalStateException
(
"Cannot add Solid geometry to WaterBody"
);
}
}
}
/**
* Getter for all boundary surfaces contained in this building.
*
* @return the boundary surfaces
*/
public
List
<
BoundarySurface
>
getBoundarySurfaces
()
{
return
boundarySurfaceList
;
}
public
void
addBoundarySurface
(
BoundarySurface
bs
)
{
boundarySurfaceList
.
add
(
bs
);
bs
.
setParent
(
this
);
}
@Override
public
FeatureType
getFeatureType
()
{
return
FeatureType
.
WATER
;
}
@Override
public
void
accept
(
Check
c
)
{
super
.
accept
(
c
);
if
(
c
.
canExecute
(
this
))
{
c
.
check
(
this
);
}
for
(
BoundarySurface
bs
:
boundarySurfaceList
)
{
bs
.
accept
(
c
);
}
}
@Override
public
AbstractCityObject
getGmlObject
()
{
return
gmlWater
;
}
@Override
public
void
unsetGmlGeometries
()
{
gmlWater
.
setLod0MultiSurface
(
null
);
gmlWater
.
getDeprecatedProperties
().
setLod1MultiSurface
(
null
);
}
public
void
setGmlObject
(
WaterBody
waterBody
)
{
gmlWater
=
waterBody
;
}
@Override
public
String
toString
()
{
return
"WaterObject [id="
+
getGmlId
()
+
"]"
;
}
@Override
public
WaterObject
createCopyInstance
()
{
return
new
WaterObject
();
}
@Override
public
void
fillValues
(
Copyable
original
,
CopyHandler
handler
)
{
WaterObject
wo
=
(
WaterObject
)
original
;
WaterObject
originalWaterObject
=
(
WaterObject
)
original
;
for
(
BoundarySurface
originalBs
:
originalWaterObject
.
boundarySurfaceList
)
{
boundarySurfaceList
.
add
(
handler
.
getCopyInstance
(
originalBs
));
}
gmlWater
=
wo
.
gmlWater
;
}
@Override
public
boolean
containsAnyError
()
{
boolean
hasError
=
super
.
containsAnyError
();
if
(
hasError
)
{
return
true
;
}
for
(
BoundarySurface
bs
:
boundarySurfaceList
)
{
if
(
bs
.
containsAnyError
())
{
return
true
;
}
}
return
false
;
}
@Override
public
void
collectInstances
(
CopyHandler
handler
)
{
super
.
collectInstances
(
handler
);
handler
.
addInstance
(
boundarySurfaceList
);
}
@Override
public
void
clearMetaInformation
()
{
super
.
clearMetaInformation
();
for
(
BoundarySurface
bs
:
boundarySurfaceList
)
{
bs
.
clearMetaInformation
();
}
}
@Override
public
void
prepareForChecking
()
{
super
.
prepareForChecking
();
for
(
BoundarySurface
bs
:
boundarySurfaceList
)
{
bs
.
prepareForChecking
();
}
}
@Serial
private
static
final
long
serialVersionUID
=
-
3821060595086337424L
;
private
WaterBody
gmlWater
;
private
final
List
<
BoundarySurface
>
boundarySurfaceList
=
new
ArrayList
<>();
@Override
public
void
reCreateGeometries
(
GeometryFactory
factory
,
ParserConfiguration
config
)
{
for
(
Geometry
geom
:
getGeometries
())
{
if
(
geom
.
getType
()
==
GeometryType
.
MULTI_SURFACE
)
{
MultiSurface
ms
=
CityGmlUtils
.
createMultiSurface
(
geom
,
factory
,
config
);
if
(
geom
.
getLod
()
==
Lod
.
LOD0
)
{
gmlWater
.
setLod0MultiSurface
(
new
MultiSurfaceProperty
(
ms
));
}
else
if
(
geom
.
getLod
()
==
Lod
.
LOD1
)
{
gmlWater
.
getDeprecatedProperties
().
setLod1MultiSurface
(
new
MultiSurfaceProperty
(
ms
));
}
else
{
throw
new
IllegalStateException
(
"Cannot add MultiSurface geometry with lod to WaterBody:"
+
geom
.
getLod
());
}
}
else
{
throw
new
IllegalStateException
(
"Cannot add Solid geometry to WaterBody"
);
}
}
}
/**
* Getter for all boundary surfaces contained in this building.
*
* @return the boundary surfaces
*/
public
List
<
BoundarySurface
>
getBoundarySurfaces
()
{
return
boundarySurfaceList
;
}
public
void
addBoundarySurface
(
BoundarySurface
bs
)
{
boundarySurfaceList
.
add
(
bs
);
bs
.
setParent
(
this
);
}
@Override
public
FeatureType
getFeatureType
()
{
return
FeatureType
.
WATER
;
}
@Override
public
void
accept
(
Check
c
)
{
super
.
accept
(
c
);
if
(
c
.
canExecute
(
this
))
{
c
.
check
(
this
);
}
for
(
BoundarySurface
bs
:
boundarySurfaceList
)
{
bs
.
accept
(
c
);
}
}
@Override
public
AbstractCityObject
getGmlObject
()
{
return
gmlWater
;
}
@Override
public
void
unsetGmlGeometries
()
{
gmlWater
.
setLod0MultiSurface
(
null
);
gmlWater
.
getDeprecatedProperties
().
setLod1MultiSurface
(
null
);
}
public
void
setGmlObject
(
WaterBody
waterBody
)
{
gmlWater
=
waterBody
;
}
@Override
public
String
toString
()
{
return
"WaterObject [id="
+
getGmlId
()
+
"]"
;
}
@Override
public
WaterObject
createCopyInstance
()
{
return
new
WaterObject
();
}
@Override
public
void
fillValues
(
Copyable
original
,
CopyHandler
handler
)
{
WaterObject
wo
=
(
WaterObject
)
original
;
WaterObject
originalWaterObject
=
(
WaterObject
)
original
;
for
(
BoundarySurface
originalBs
:
originalWaterObject
.
boundarySurfaceList
)
{
boundarySurfaceList
.
add
(
handler
.
getCopyInstance
(
originalBs
));
}
gmlWater
=
wo
.
gmlWater
;
}
@Override
public
boolean
containsAnyError
()
{
boolean
hasError
=
super
.
containsAnyError
();
if
(
hasError
)
{
return
true
;
}
for
(
BoundarySurface
bs
:
boundarySurfaceList
)
{
if
(
bs
.
containsAnyError
())
{
return
true
;
}
}
return
false
;
}
@Override
public
void
collectInstances
(
CopyHandler
handler
)
{
super
.
collectInstances
(
handler
);
handler
.
addInstance
(
boundarySurfaceList
);
}
@Override
public
void
clearMetaInformation
()
{
super
.
clearMetaInformation
();
for
(
BoundarySurface
bs
:
boundarySurfaceList
)
{
bs
.
clearMetaInformation
();
}
}
@Override
public
void
prepareForChecking
()
{
super
.
prepareForChecking
();
for
(
BoundarySurface
bs
:
boundarySurfaceList
)
{
bs
.
prepareForChecking
();
}
}
}
CityDoctorParent/CityDoctorModel/src/main/java/de/hft/stuttgart/citydoctor2/mapper/citygml3/Citygml3FeatureMapper.java
View file @
02de0a22
...
...
@@ -18,51 +18,37 @@
*/
package
de.hft.stuttgart.citydoctor2.mapper.citygml3
;
import
java.nio.file.Path
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
de.hft.stuttgart.citydoctor2.datastructure.*
;
import
de.hft.stuttgart.citydoctor2.datastructure.AbstractBuilding
;
import
de.hft.stuttgart.citydoctor2.datastructure.AbstractTunnel
;
import
de.hft.stuttgart.citydoctor2.datastructure.BridgeConstructiveElement
;
import
de.hft.stuttgart.citydoctor2.datastructure.*
;
import
de.hft.stuttgart.citydoctor2.datastructure.Building
;
import
de.hft.stuttgart.citydoctor2.datastructure.BuildingPart
;
import
de.hft.stuttgart.citydoctor2.datastructure.BuildingRoom
;
import
de.hft.stuttgart.citydoctor2.datastructure.LinearRing
;
import
de.hft.stuttgart.citydoctor2.datastructure.Polygon
;
import
de.hft.stuttgart.citydoctor2.datastructure.BridgeObject.BridgeType
;
import
de.hft.stuttgart.citydoctor2.datastructure.TunnelFurniture
;
import
de.hft.stuttgart.citydoctor2.datastructure.TunnelPart
;
import
de.hft.stuttgart.citydoctor2.datastructure.TransportationObject.TransportationType
;
import
de.hft.stuttgart.citydoctor2.datastructure.Vegetation.VegetationType
;
import
de.hft.stuttgart.citydoctor2.math.graph.KDTree
;
import
de.hft.stuttgart.citydoctor2.parser.ParserConfiguration
;
import
de.hft.stuttgart.citydoctor2.utils.Localization
;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.Logger
;
import
org.citygml4j.core.model.CityGMLVersion
;
import
org.citygml4j.core.model.bridge.AbstractBridge
;
import
org.citygml4j.core.model.bridge.Bridge
;
import
org.citygml4j.core.model.bridge.BridgeConstructiveElementProperty
;
import
org.citygml4j.core.model.bridge.BridgeInstallation
;
import
org.citygml4j.core.model.bridge.BridgeInstallationProperty
;
import
org.citygml4j.core.model.bridge.BridgePart
;
import
org.citygml4j.core.model.bridge.BridgePartProperty
;
import
org.citygml4j.core.model.building.*
;
import
org.citygml4j.core.model.building.BuildingFurniture
;
import
org.citygml4j.core.model.bridge.*
;
import
org.citygml4j.core.model.building.BuildingUnit
;
import
org.citygml4j.core.model.building.Storey
;
import
org.citygml4j.core.model.building.*
;
import
org.citygml4j.core.model.construction.AbstractConstruction
;
import
org.citygml4j.core.model.core.*
;
import
org.citygml4j.core.model.deprecated.transportation.TransportationComplex
;
import
org.citygml4j.core.model.landuse.LandUse
;
import
org.citygml4j.core.model.transportation.AbstractTransportationSpace
;
import
org.citygml4j.core.model.transportation.AuxiliaryTrafficArea
;
import
org.citygml4j.core.model.transportation.AuxiliaryTrafficSpace
;
import
org.citygml4j.core.model.transportation.AuxiliaryTrafficSpaceProperty
;
import
org.citygml4j.core.model.transportation.Railway
;
import
org.citygml4j.core.model.transportation.Road
;
import
org.citygml4j.core.model.transportation.Square
;
import
org.citygml4j.core.model.transportation.Track
;
import
org.citygml4j.core.model.transportation.TrafficArea
;
import
org.citygml4j.core.model.transportation.TrafficSpace
;
import
org.citygml4j.core.model.transportation.TrafficSpaceProperty
;
import
org.citygml4j.core.model.tunnel.*
;
import
org.citygml4j.core.model.transportation.*
;
import
org.citygml4j.core.model.tunnel.Tunnel
;
import
org.citygml4j.core.model.tunnel.*
;
import
org.citygml4j.core.model.vegetation.AbstractVegetationObject
;
import
org.citygml4j.core.model.vegetation.PlantCover
;
import
org.citygml4j.core.model.vegetation.SolitaryVegetationObject
;
...
...
@@ -75,1165 +61,1154 @@ import org.xmlobjects.gml.model.geometry.GeometryProperty;
import
org.xmlobjects.gml.model.geometry.aggregates.MultiSurface
;
import
org.xmlobjects.gml.model.geometry.aggregates.MultiSurfaceProperty
;
import
org.xmlobjects.gml.model.geometry.complexes.CompositeSurface
;
import
org.xmlobjects.gml.model.geometry.primitives.AbstractSolid
;
import
org.xmlobjects.gml.model.geometry.primitives.AbstractSurface
;
import
org.xmlobjects.gml.model.geometry.primitives.Shell
;
import
org.xmlobjects.gml.model.geometry.primitives.ShellProperty
;
import
org.xmlobjects.gml.model.geometry.primitives.Solid
;
import
org.xmlobjects.gml.model.geometry.primitives.SolidProperty
;
import
org.xmlobjects.gml.model.geometry.primitives.SurfaceProperty
;
import
org.xmlobjects.gml.model.geometry.primitives.*
;
import
de.hft.stuttgart.citydoctor2.datastructure.BridgeObject.BridgeType
;
import
de.hft.stuttgart.citydoctor2.datastructure.TransportationObject.TransportationType
;
import
de.hft.stuttgart.citydoctor2.datastructure.Vegetation.VegetationType
;
import
de.hft.stuttgart.citydoctor2.math.graph.KDTree
;
import
de.hft.stuttgart.citydoctor2.parser.ParserConfiguration
;
import
de.hft.stuttgart.citydoctor2.utils.Localization
;
import
java.nio.file.Path
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
public
class
Citygml3FeatureMapper
extends
ObjectWalker
{
private
static
final
Logger
logger
=
LogManager
.
getLogger
(
Citygml3FeatureMapper
.
class
);
private
final
CityDoctorModel
model
;
private
Map
<
String
,
ConcretePolygon
>
polygonMap
=
new
HashMap
<>();
private
List
<
ResolvableReference
>
references
=
new
ArrayList
<>();
private
Map
<
Vertex
,
Vertex
>
vertexMap
=
new
HashMap
<>();
private
final
ParserConfiguration
config
;
private
final
Path
directory
;
private
final
double
neighborDistance
;
public
Citygml3FeatureMapper
(
ParserConfiguration
config
,
Path
path
)
{
this
.
config
=
config
;
this
.
directory
=
path
.
getParent
();
model
=
new
CityDoctorModel
(
config
,
path
.
toFile
());
neighborDistance
=
1.8d
/
Math
.
pow
(
10
,
config
.
getNumberOfRoundingPlaces
());
}
@Override
public
void
visit
(
AbstractSpace
space
)
{
// if we are here, an AbstractSpace thing was read that is not handled in the
// other methods
}
@Override
public
void
visit
(
org
.
citygml4j
.
core
.
model
.
cityfurniture
.
CityFurniture
gmlCityFurniture
)
{
CityFurniture
cf
=
new
CityFurniture
();
cf
.
setGmlObject
(
gmlCityFurniture
);
mapAbstractOccupiedSpace
(
gmlCityFurniture
,
cf
);
resolveAndClearReferences
();
cf
.
unsetGmlGeometries
();
updateEdgesAndVertices
(
cf
);
model
.
addCityFurniture
(
cf
);
}
@Override
public
void
visit
(
org
.
citygml4j
.
core
.
model
.
generics
.
GenericOccupiedSpace
gos
){
GenericCityObject
gco
=
new
GenericCityObject
();
gco
.
setGmlObject
(
gos
);
mapAbstractOccupiedSpace
(
gos
,
gco
);
resolveAndClearReferences
();
gco
.
unsetGmlGeometries
();
updateEdgesAndVertices
(
gco
);
model
.
addGenericCityObject
(
gco
);
}
@Override
public
void
visit
(
org
.
citygml4j
.
core
.
model
.
building
.
Building
gmlBuilding
)
{
Building
cdBuilding
=
new
Building
();
readAbstractBuilding
(
gmlBuilding
,
cdBuilding
);
for
(
BuildingPartProperty
bpProp
:
gmlBuilding
.
getBuildingParts
())
{
if
(!
bpProp
.
isSetObject
())
{
continue
;
}
BuildingPart
part
=
new
BuildingPart
(
cdBuilding
);
readAbstractBuilding
(
bpProp
.
getObject
(),
part
);
}
model
.
addBuilding
(
cdBuilding
);
}
@Override
public
void
visit
(
WaterBody
waterBody
)
{
WaterObject
wo
=
new
WaterObject
();
wo
.
setGmlObject
(
waterBody
);
mapAbstractOccupiedSpace
(
waterBody
,
wo
);
parseAndAddMultiSurface
(
waterBody
.
getDeprecatedProperties
().
getLod1MultiSurface
(),
Lod
.
LOD1
,
wo
);
parseAndAddSolid
(
waterBody
.
getDeprecatedProperties
().
getLod4Solid
(),
Lod
.
LOD4
,
wo
);
SurfaceMapper
surfaceMapper
=
new
SurfaceMapper
(
polygonMap
,
references
,
vertexMap
,
config
);
for
(
AbstractSpaceBoundaryProperty
surfaceProp
:
waterBody
.
getBoundaries
())
{
if
(!
surfaceProp
.
isSetObject
())
{
continue
;
}
AbstractSpaceBoundary
surface
=
surfaceProp
.
getObject
();
surface
.
accept
(
surfaceMapper
);
}
for
(
BoundarySurface
bs
:
surfaceMapper
.
getSurfaces
())
{
wo
.
addBoundarySurface
(
bs
);
}
resolveAndClearReferences
();
wo
.
unsetGmlGeometries
();
updateEdgesAndVertices
(
wo
);
for
(
BoundarySurface
bs
:
surfaceMapper
.
getSurfaces
())
{
updateEdgesAndVertices
(
bs
);
}
model
.
addWater
(
wo
);
}
@Override
public
void
visit
(
LandUse
landUse
)
{
LandObject
lo
=
new
LandObject
(
landUse
);
mapAbstractThematicSurface
(
landUse
,
lo
);
finishCityObjectConstruction
(
lo
);
model
.
addLand
(
lo
);
}
@Override
public
void
visit
(
PlantCover
plantCover
)
{
Vegetation
veg
=
new
Vegetation
(
VegetationType
.
PLANT_COVER
);
veg
.
setGmlObject
(
plantCover
);
mapAbstractVegetationObject
(
plantCover
,
veg
);
parseAndAddMultiSurface
(
plantCover
.
getDeprecatedProperties
().
getLod1MultiSurface
(),
Lod
.
LOD1
,
veg
);
parseAndAddMultiSurface
(
plantCover
.
getDeprecatedProperties
().
getLod4MultiSurface
(),
Lod
.
LOD4
,
veg
);
finishCityObjectConstruction
(
veg
);
model
.
addVegetation
(
veg
);
}
@Override
public
void
visit
(
SolitaryVegetationObject
solitaryVegetationObject
)
{
Vegetation
veg
=
new
Vegetation
(
VegetationType
.
SOLITARY_VEGETATION_OBJECT
);
veg
.
setGmlObject
(
solitaryVegetationObject
);
mapAbstractVegetationObject
(
solitaryVegetationObject
,
veg
);
parseAndAddAbstractGeometry
(
solitaryVegetationObject
.
getDeprecatedProperties
().
getLod1Geometry
(),
Lod
.
LOD1
,
veg
);
parseAndAddAbstractGeometry
(
solitaryVegetationObject
.
getDeprecatedProperties
().
getLod2Geometry
(),
Lod
.
LOD2
,
veg
);
parseAndAddAbstractGeometry
(
solitaryVegetationObject
.
getDeprecatedProperties
().
getLod3Geometry
(),
Lod
.
LOD3
,
veg
);
parseAndAddAbstractGeometry
(
solitaryVegetationObject
.
getDeprecatedProperties
().
getLod4Geometry
(),
Lod
.
LOD4
,
veg
);
finishCityObjectConstruction
(
veg
);
model
.
addVegetation
(
veg
);
}
private
void
mapAbstractVegetationObject
(
AbstractVegetationObject
avo
,
Vegetation
veg
)
{
mapAbstractOccupiedSpace
(
avo
,
veg
);
}
private
void
mapAbstractOccupiedSpace
(
AbstractOccupiedSpace
aos
,
CityObject
co
)
{
mapAbstractPhysicalSpace
(
aos
,
co
);
parseImplicitGeometry
(
aos
,
co
);
}
private
void
mapAbstractPhysicalSpace
(
AbstractPhysicalSpace
aps
,
CityObject
co
)
{
mapAbstractSpace
(
aps
,
co
);
}
private
void
mapAbstractSpace
(
AbstractSpace
as
,
CityObject
co
)
{
mapAbstractFeature
(
as
,
co
);
parseAndAddMultiSurface
(
as
.
getLod0MultiSurface
(),
Lod
.
LOD0
,
co
);
parseAndAddMultiSurface
(
as
.
getLod2MultiSurface
(),
Lod
.
LOD2
,
co
);
parseAndAddMultiSurface
(
as
.
getLod3MultiSurface
(),
Lod
.
LOD3
,
co
);
parseAndAddSolid
(
as
.
getLod1Solid
(),
Lod
.
LOD1
,
co
);
parseAndAddSolid
(
as
.
getLod2Solid
(),
Lod
.
LOD2
,
co
);
parseAndAddSolid
(
as
.
getLod3Solid
(),
Lod
.
LOD3
,
co
);
}
@Override
public
void
visit
(
Bridge
bridge
)
{
BridgeObject
bo
=
new
BridgeObject
(
BridgeType
.
BRIDGE
,
bridge
);
for
(
BridgePartProperty
bPartProperty
:
bridge
.
getBridgeParts
())
{
if
(!
bPartProperty
.
isSetObject
())
{
continue
;
}
BridgePart
gmlBridgePart
=
bPartProperty
.
getObject
();
BridgeObject
bPart
=
new
BridgeObject
(
BridgeType
.
BRIDGE_PART
,
gmlBridgePart
);
mapAbstractBridge
(
gmlBridgePart
,
bPart
);
bo
.
addBridgePart
(
bPart
);
}
mapAbstractBridge
(
bridge
,
bo
);
resolveAndClearReferences
();
updateEdgesAndVertices
(
bo
);
for
(
BridgeObject
part
:
bo
.
getParts
())
{
updateEdgesAndVertices
(
part
);
}
for
(
BridgeConstructiveElement
ele
:
bo
.
getConstructiveElements
())
{
updateEdgesAndVertices
(
ele
);
for
(
BoundarySurface
bs
:
ele
.
getBoundarySurfaces
())
{
updateEdgesAndVertices
(
bs
);
}
}
for
(
Installation
bi
:
bo
.
getBridgeInstallations
())
{
updateEdgesAndVertices
(
bi
);
for
(
BoundarySurface
bs
:
bi
.
getBoundarySurfaces
())
{
updateEdgesAndVertices
(
bs
);
}
}
model
.
addBridge
(
bo
);
}
private
void
mapAbstractBridge
(
AbstractBridge
ab
,
BridgeObject
bo
)
{
mapAbstractConstruction
(
ab
,
bo
);
for
(
BridgeConstructiveElementProperty
eleProp
:
ab
.
getBridgeConstructiveElements
())
{
if
(!
eleProp
.
isSetObject
())
{
continue
;
}
org
.
citygml4j
.
core
.
model
.
bridge
.
BridgeConstructiveElement
constructiveElement
=
eleProp
.
getObject
();
BridgeConstructiveElement
cdEle
=
new
BridgeConstructiveElement
(
constructiveElement
);
mapConstructiveElement
(
constructiveElement
,
cdEle
);
bo
.
addConstructiveElement
(
cdEle
);
}
List
<
BridgeInstallationProperty
>
bridgeInstallations
=
ab
.
getBridgeInstallations
();
for
(
BridgeInstallationProperty
installationProp
:
bridgeInstallations
)
{
var
gmlBi
=
installationProp
.
getObject
();
if
(
gmlBi
==
null
)
{
// ignore empty properties
continue
;
}
Installation
bi
=
mapBridgeInstallation
(
gmlBi
);
bo
.
addBridgeInstallation
(
bi
);
}
SurfaceMapper
surfaceMapper
=
new
SurfaceMapper
(
polygonMap
,
references
,
vertexMap
,
config
);
for
(
AbstractSpaceBoundaryProperty
surfaceProp
:
ab
.
getBoundaries
())
{
if
(!
surfaceProp
.
isSetObject
())
{
continue
;
}
AbstractSpaceBoundary
surface
=
surfaceProp
.
getObject
();
surface
.
accept
(
surfaceMapper
);
}
updatePartOfSurface
(
bo
,
surfaceMapper
);
for
(
BoundarySurface
bs
:
bo
.
getBoundarySurfaces
())
{
updateEdgesAndVertices
(
bs
);
}
bo
.
unsetGmlGeometries
();
}
private
Installation
mapBridgeInstallation
(
BridgeInstallation
gmlBi
)
{
Installation
bi
=
new
Installation
();
bi
.
setGmlObject
(
gmlBi
);
mapAbstractOccupiedSpace
(
gmlBi
,
bi
);
GeometryProperty
<?>
lod2Prop
=
gmlBi
.
getDeprecatedProperties
().
getLod2Geometry
();
parseAndAddAbstractGeometry
(
lod2Prop
,
Lod
.
LOD2
,
bi
);
GeometryProperty
<?>
lod3Prop
=
gmlBi
.
getDeprecatedProperties
().
getLod3Geometry
();
parseAndAddAbstractGeometry
(
lod3Prop
,
Lod
.
LOD3
,
bi
);
GeometryProperty
<?>
lod4Prop
=
gmlBi
.
getDeprecatedProperties
().
getLod4Geometry
();
parseAndAddAbstractGeometry
(
lod4Prop
,
Lod
.
LOD4
,
bi
);
bi
.
unsetGmlGeometries
();
SurfaceMapper
surfaceMapper
=
new
SurfaceMapper
(
polygonMap
,
references
,
vertexMap
,
config
);
for
(
AbstractSpaceBoundaryProperty
surfaceProp
:
gmlBi
.
getBoundaries
())
{
if
(!
surfaceProp
.
isSetObject
())
{
continue
;
}
AbstractSpaceBoundary
surface
=
surfaceProp
.
getObject
();
surface
.
accept
(
surfaceMapper
);
}
for
(
BoundarySurface
bs
:
surfaceMapper
.
getSurfaces
())
{
bi
.
addBoundarySurface
(
bs
);
for
(
Geometry
geom
:
bs
.
getGeometries
())
{
for
(
Polygon
p
:
geom
.
getPolygons
())
{
p
.
setPartOfSurface
(
bs
);
p
.
setPartOfInstallation
(
bi
);
}
}
}
for
(
Geometry
geom
:
bi
.
getGeometries
())
{
for
(
Polygon
p
:
geom
.
getPolygons
())
{
p
.
setPartOfInstallation
(
bi
);
}
}
return
bi
;
}
@Override
public
void
visit
(
Tunnel
tunnel
){
de
.
hft
.
stuttgart
.
citydoctor2
.
datastructure
.
Tunnel
tu
=
new
de
.
hft
.
stuttgart
.
citydoctor2
.
datastructure
.
Tunnel
();
for
(
TunnelPartProperty
tPartProperty
:
tunnel
.
getTunnelParts
())
{
if
(!
tPartProperty
.
isSetObject
())
{
continue
;
}
org
.
citygml4j
.
core
.
model
.
tunnel
.
TunnelPart
gmlTunnelPart
=
tPartProperty
.
getObject
();
TunnelPart
tPart
=
new
TunnelPart
(
tu
);
readAbstractTunnel
(
gmlTunnelPart
,
tPart
);
tu
.
addTunnelPart
(
tPart
);
}
readAbstractTunnel
(
tunnel
,
tu
);
resolveAndClearReferences
();
updateEdgesAndVertices
(
tu
);
for
(
TunnelPart
part
:
tu
.
getTunnelParts
())
{
updateEdgesAndVertices
(
part
);
}
model
.
addTunnel
(
tu
);
}
private
void
readAbstractTunnel
(
org
.
citygml4j
.
core
.
model
.
tunnel
.
AbstractTunnel
gmlTunnel
,
AbstractTunnel
cdTunnel
)
{
mapAbstractOccupiedSpace
(
gmlTunnel
,
cdTunnel
);
cdTunnel
.
setGmlObject
(
gmlTunnel
);
// parse deprecated geometries
parseAndAddMultiSurface
(
gmlTunnel
.
getDeprecatedProperties
().
getLod1MultiSurface
(),
Lod
.
LOD1
,
cdTunnel
);
parseAndAddMultiSurface
(
gmlTunnel
.
getDeprecatedProperties
().
getLod4MultiSurface
(),
Lod
.
LOD4
,
cdTunnel
);
parseAndAddSolid
(
gmlTunnel
.
getDeprecatedProperties
().
getLod4Solid
(),
Lod
.
LOD4
,
cdTunnel
);
for
(
TunnelInstallationProperty
tiProp
:
gmlTunnel
.
getTunnelInstallations
())
{
var
gmlTi
=
tiProp
.
getObject
();
if
(
gmlTi
==
null
)
{
// ignore empty properties
continue
;
}
Installation
ti
=
mapTunnelInstallation
(
gmlTi
);
cdTunnel
.
addTunnelInstallation
(
ti
);
}
for
(
HollowSpaceProperty
thProp
:
gmlTunnel
.
getHollowSpaces
())
{
var
gmlTh
=
thProp
.
getObject
();
if
(
gmlTh
==
null
)
{
continue
;
}
TunnelHollow
br
=
mapTunnelHollow
(
gmlTh
);
cdTunnel
.
addTunnelHollow
(
br
);
}
SurfaceMapper
surfaceMapper
=
new
SurfaceMapper
(
polygonMap
,
references
,
vertexMap
,
config
);
for
(
AbstractSpaceBoundaryProperty
surfaceProp
:
gmlTunnel
.
getBoundaries
())
{
if
(!
surfaceProp
.
isSetObject
())
{
continue
;
}
AbstractSpaceBoundary
surface
=
surfaceProp
.
getObject
();
surface
.
accept
(
surfaceMapper
);
}
cdTunnel
.
unsetGmlGeometries
();
resolveAndClearReferences
();
updateEdgesAndVertices
(
cdTunnel
);
for
(
BoundarySurface
bs
:
surfaceMapper
.
getSurfaces
())
{
updateEdgesAndVertices
(
bs
);
for
(
Opening
o
:
bs
.
getOpenings
())
{
updateEdgesAndVertices
(
o
);
}
}
for
(
Installation
ti
:
cdTunnel
.
getTunnelInstallations
())
{
updateEdgesAndVertices
(
ti
);
for
(
BoundarySurface
bs
:
ti
.
getBoundarySurfaces
())
{
updateEdgesAndVertices
(
bs
);
for
(
Opening
o
:
bs
.
getOpenings
())
{
updateEdgesAndVertices
(
o
);
}
}
}
for
(
TunnelFurnitureProperty
tfProp
:
gmlTunnel
.
getTunnelFurniture
()){
var
gmlTf
=
tfProp
.
getObject
();
if
(
gmlTf
==
null
)
{
continue
;
}
TunnelFurniture
tf
=
mapTunnelFurniture
(
gmlTf
);
cdTunnel
.
addTunnelFurniture
(
tf
);
}
}
private
Installation
mapTunnelInstallation
(
TunnelInstallation
gmlTi
){
Installation
ti
=
new
Installation
();
ti
.
setGmlObject
(
gmlTi
);
mapAbstractOccupiedSpace
(
gmlTi
,
ti
);
GeometryProperty
<?>
lod2Prop
=
gmlTi
.
getDeprecatedProperties
().
getLod2Geometry
();
parseAndAddAbstractGeometry
(
lod2Prop
,
Lod
.
LOD2
,
ti
);
GeometryProperty
<?>
lod3Prop
=
gmlTi
.
getDeprecatedProperties
().
getLod3Geometry
();
parseAndAddAbstractGeometry
(
lod3Prop
,
Lod
.
LOD3
,
ti
);
GeometryProperty
<?>
lod4Prop
=
gmlTi
.
getDeprecatedProperties
().
getLod4Geometry
();
parseAndAddAbstractGeometry
(
lod4Prop
,
Lod
.
LOD4
,
ti
);
ti
.
unsetGmlGeometries
();
SurfaceMapper
surfaceMapper
=
new
SurfaceMapper
(
polygonMap
,
references
,
vertexMap
,
config
);
for
(
AbstractSpaceBoundaryProperty
surfaceProp
:
gmlTi
.
getBoundaries
())
{
if
(!
surfaceProp
.
isSetObject
())
{
continue
;
}
AbstractSpaceBoundary
surface
=
surfaceProp
.
getObject
();
surface
.
accept
(
surfaceMapper
);
}
for
(
BoundarySurface
bs
:
surfaceMapper
.
getSurfaces
())
{
ti
.
addBoundarySurface
(
bs
);
for
(
Geometry
geom
:
bs
.
getGeometries
())
{
for
(
Polygon
p
:
geom
.
getPolygons
())
{
p
.
setPartOfSurface
(
bs
);
p
.
setPartOfInstallation
(
ti
);
}
}
}
for
(
Geometry
geom
:
ti
.
getGeometries
())
{
for
(
Polygon
p
:
geom
.
getPolygons
())
{
p
.
setPartOfInstallation
(
ti
);
}
}
return
ti
;
}
private
TunnelHollow
mapTunnelHollow
(
HollowSpace
gmlHo
){
TunnelHollow
tHollow
=
new
TunnelHollow
();
tHollow
.
setGmlObject
(
gmlHo
);
mapAbstractUnoccupiedSpace
(
gmlHo
,
tHollow
);
SurfaceMapper
surfaceMapper
=
new
SurfaceMapper
(
polygonMap
,
references
,
vertexMap
,
config
);
for
(
AbstractSpaceBoundaryProperty
surfaceProp
:
gmlHo
.
getBoundaries
())
{
if
(!
surfaceProp
.
isSetObject
())
{
continue
;
}
AbstractSpaceBoundary
surface
=
surfaceProp
.
getObject
();
surface
.
accept
(
surfaceMapper
);
}
for
(
BoundarySurface
bs
:
surfaceMapper
.
getSurfaces
())
{
tHollow
.
addBoundarySurface
(
bs
);
for
(
Geometry
geom
:
bs
.
getGeometries
())
{
for
(
Polygon
p
:
geom
.
getPolygons
())
{
p
.
setPartOfSurface
(
bs
);
}
}
}
for
(
TunnelInstallationProperty
tiProp
:
gmlHo
.
getTunnelInstallations
())
{
var
gmlTi
=
tiProp
.
getObject
();
if
(
gmlTi
==
null
)
{
// ignore empty properties
continue
;
}
Installation
bi
=
mapTunnelInstallation
(
gmlTi
);
tHollow
.
addRoomInstallation
(
bi
);
}
for
(
TunnelFurnitureProperty
tfProp
:
gmlHo
.
getTunnelFurniture
()){
var
gmlHref
=
tfProp
.
getHref
();
if
(
gmlHref
==
null
)
{
continue
;
}
tHollow
.
addFurnitureRef
(
tfProp
);
}
return
tHollow
;
}
private
TunnelFurniture
mapTunnelFurniture
(
org
.
citygml4j
.
core
.
model
.
tunnel
.
TunnelFurniture
gmlTf
){
TunnelFurniture
tf
=
new
TunnelFurniture
();
tf
.
setGmlObject
(
gmlTf
);
mapAbstractOccupiedSpace
(
gmlTf
,
tf
);
tf
.
unsetGmlGeometries
();
SurfaceMapper
surfaceMapper
=
new
SurfaceMapper
(
polygonMap
,
references
,
vertexMap
,
config
);
for
(
AbstractSpaceBoundaryProperty
surfaceProp
:
gmlTf
.
getBoundaries
())
{
if
(!
surfaceProp
.
isSetObject
())
{
continue
;
}
AbstractSpaceBoundary
surface
=
surfaceProp
.
getObject
();
surface
.
accept
(
surfaceMapper
);
}
for
(
BoundarySurface
bs
:
surfaceMapper
.
getSurfaces
())
{
tf
.
addBoundarySurface
(
bs
);
for
(
Geometry
geom
:
bs
.
getGeometries
())
{
for
(
Polygon
p
:
geom
.
getPolygons
())
{
p
.
setPartOfSurface
(
bs
);
}
}
}
return
tf
;
}
private
void
updatePartOfSurface
(
BridgeObject
bo
,
SurfaceMapper
surfaceMapper
)
{
for
(
BoundarySurface
bs
:
surfaceMapper
.
getSurfaces
())
{
bo
.
addBoundarySurface
(
bs
);
for
(
Geometry
geom
:
bs
.
getGeometries
())
{
for
(
Polygon
p
:
geom
.
getPolygons
())
{
p
.
setPartOfSurface
(
bs
);
}
}
}
}
private
void
mapConstructiveElement
(
org
.
citygml4j
.
core
.
model
.
bridge
.
BridgeConstructiveElement
ele
,
BridgeConstructiveElement
bce
)
{
mapAbstractConstructiveElement
(
ele
,
bce
);
SurfaceMapper
surfaceMapper
=
new
SurfaceMapper
(
polygonMap
,
references
,
vertexMap
,
config
);
for
(
AbstractSpaceBoundaryProperty
surfaceProp
:
ele
.
getBoundaries
())
{
if
(!
surfaceProp
.
isSetObject
())
{
continue
;
}
AbstractSpaceBoundary
surface
=
surfaceProp
.
getObject
();
surface
.
accept
(
surfaceMapper
);
}
for
(
BoundarySurface
bs
:
surfaceMapper
.
getSurfaces
())
{
bce
.
addBoundarySurface
(
bs
);
}
}
private
void
mapAbstractConstructiveElement
(
org
.
citygml4j
.
core
.
model
.
bridge
.
BridgeConstructiveElement
ele
,
BridgeConstructiveElement
bce
)
{
mapAbstractOccupiedSpace
(
ele
,
bce
);
}
private
void
mapAbstractConstruction
(
AbstractConstruction
ac
,
BridgeObject
bo
)
{
mapAbstractOccupiedSpace
(
ac
,
bo
);
}
@Override
public
void
visit
(
AuxiliaryTrafficArea
ata
)
{
TransportationObject
to
=
new
TransportationObject
(
TransportationType
.
AUXILLIARY_TRAFFIC_AREA
);
mapAbstractThematicSurface
(
ata
,
to
);
finishTransportationMapping
(
to
);
}
@Override
public
void
visit
(
TrafficArea
ta
)
{
TransportationObject
to
=
new
TransportationObject
(
TransportationType
.
TRAFFIC_AREA
);
mapAbstractThematicSurface
(
ta
,
to
);
finishTransportationMapping
(
to
);
}
@Override
public
void
visit
(
Road
road
)
{
TransportationObject
to
=
new
TransportationObject
(
TransportationType
.
ROAD
);
mapAbstractTransportationSpace
(
road
,
to
);
finishTransportationMapping
(
to
);
}
private
void
mapAbstractThematicSurface
(
AbstractThematicSurface
ats
,
CityObject
co
)
{
mapAbstractSpaceBoundary
(
ats
,
co
);
parseAndAddMultiSurface
(
ats
.
getLod0MultiSurface
(),
Lod
.
LOD0
,
co
);
parseAndAddMultiSurface
(
ats
.
getLod1MultiSurface
(),
Lod
.
LOD1
,
co
);
parseAndAddMultiSurface
(
ats
.
getLod2MultiSurface
(),
Lod
.
LOD2
,
co
);
parseAndAddMultiSurface
(
ats
.
getLod3MultiSurface
(),
Lod
.
LOD3
,
co
);
parseAndAddMultiSurface
(
ats
.
getDeprecatedProperties
().
getLod4MultiSurface
(),
Lod
.
LOD4
,
co
);
}
private
void
mapAbstractSpaceBoundary
(
AbstractSpaceBoundary
asb
,
CityObject
co
)
{
mapAbstractCityObject
(
asb
,
co
);
}
private
void
mapAbstractCityObject
(
AbstractCityObject
aco
,
CityObject
to
)
{
mapAbstractFeatureWithLifespan
(
aco
,
to
);
}
private
void
mapAbstractFeatureWithLifespan
(
AbstractFeatureWithLifespan
afwl
,
CityObject
to
)
{
mapAbstractFeature
(
afwl
,
to
);
}
private
void
mapAbstractFeature
(
AbstractFeature
af
,
CityObject
to
)
{
mapAbstractGML
(
af
,
to
);
}
private
void
mapAbstractGML
(
AbstractGML
ag
,
CityObject
to
)
{
parseId
(
ag
,
to
);
}
@Override
public
void
visit
(
Railway
railway
)
{
TransportationObject
to
=
new
TransportationObject
(
TransportationType
.
RAILWAY
);
mapAbstractTransportationSpace
(
railway
,
to
);
finishTransportationMapping
(
to
);
}
@Override
public
void
visit
(
Square
square
)
{
TransportationObject
to
=
new
TransportationObject
(
TransportationType
.
SQUARE
);
mapAbstractTransportationSpace
(
square
,
to
);
finishTransportationMapping
(
to
);
}
@Override
public
void
visit
(
Track
track
)
{
TransportationObject
to
=
new
TransportationObject
(
TransportationType
.
TRACK
);
mapAbstractTransportationSpace
(
track
,
to
);
finishTransportationMapping
(
to
);
}
@Override
public
void
visit
(
TransportationComplex
transportationComplex
)
{
TransportationObject
to
=
new
TransportationObject
(
TransportationType
.
TRANSPORTATION_COMPLEX
);
mapAbstractTransportationSpace
(
transportationComplex
,
to
);
finishTransportationMapping
(
to
);
}
private
void
finishTransportationMapping
(
TransportationObject
to
)
{
finishCityObjectConstruction
(
to
);
model
.
addTransportation
(
to
);
}
private
void
finishCityObjectConstruction
(
CityObject
co
)
{
co
.
unsetGmlGeometries
();
resolveAndClearReferences
();
updateEdgesAndVertices
(
co
);
}
private
void
mapAbstractTransportationSpace
(
AbstractTransportationSpace
ats
,
TransportationObject
to
)
{
to
.
setGmlObject
(
ats
);
parseAbstractTransportationSpaceGeometries
(
ats
,
to
);
for
(
TrafficSpaceProperty
tsp
:
ats
.
getTrafficSpaces
())
{
if
(
tsp
.
isSetObject
())
{
TransportationObject
trafficSpace
=
new
TransportationObject
(
TransportationType
.
TRAFFIC_SPACE
);
mapTrafficSpace
(
tsp
.
getObject
(),
trafficSpace
);
finishTransportationMapping
(
trafficSpace
);
to
.
getChildren
().
add
(
trafficSpace
);
}
}
for
(
AuxiliaryTrafficSpaceProperty
auxTrafficProp
:
ats
.
getAuxiliaryTrafficSpaces
())
{
if
(
auxTrafficProp
.
isSetObject
())
{
TransportationObject
trafficSpace
=
parseAuxiliaryTrafficSpace
(
auxTrafficProp
.
getObject
());
finishTransportationMapping
(
trafficSpace
);
to
.
addChild
(
trafficSpace
);
}
}
}
private
void
mapTrafficSpace
(
TrafficSpace
ts
,
TransportationObject
to
)
{
mapAbstractUnoccupiedSpace
(
ts
,
to
);
}
private
void
mapAbstractUnoccupiedSpace
(
AbstractUnoccupiedSpace
aus
,
CityObject
co
)
{
mapAbstractPhysicalSpace
(
aus
,
co
);
}
private
TransportationObject
parseAuxiliaryTrafficSpace
(
AuxiliaryTrafficSpace
ats
)
{
TransportationObject
to
=
new
TransportationObject
(
TransportationType
.
AUXILLIARY_TRAFFIC_SPACE
);
parseAbstractSpaceGeometries
(
ats
,
to
);
finishCityObjectConstruction
(
to
);
return
to
;
}
private
void
parseAbstractTransportationSpaceGeometries
(
AbstractTransportationSpace
space
,
CityObject
co
)
{
parseAndAddMultiSurface
(
space
.
getDeprecatedProperties
().
getLod1MultiSurface
(),
Lod
.
LOD1
,
co
);
parseAndAddMultiSurface
(
space
.
getDeprecatedProperties
().
getLod4MultiSurface
(),
Lod
.
LOD4
,
co
);
}
private
void
parseAbstractSpaceGeometries
(
AbstractSpace
as
,
CityObject
co
)
{
parseAndAddMultiSurface
(
as
.
getLod0MultiSurface
(),
Lod
.
LOD0
,
co
);
parseAndAddMultiSurface
(
as
.
getLod2MultiSurface
(),
Lod
.
LOD2
,
co
);
parseAndAddMultiSurface
(
as
.
getLod3MultiSurface
(),
Lod
.
LOD3
,
co
);
parseAndAddSolid
(
as
.
getLod1Solid
(),
Lod
.
LOD1
,
co
);
parseAndAddSolid
(
as
.
getLod2Solid
(),
Lod
.
LOD2
,
co
);
parseAndAddSolid
(
as
.
getLod3Solid
(),
Lod
.
LOD3
,
co
);
}
private
void
parseAndAddMultiSurface
(
MultiSurfaceProperty
msp
,
Lod
lod
,
CityObject
co
)
{
if
(
msp
==
null
||
msp
.
getObject
()
==
null
)
{
return
;
}
Geometry
geom
=
parseMultiSurface
(
msp
.
getObject
(),
lod
);
co
.
addGeometry
(
geom
);
}
private
void
parseAndAddSolid
(
SolidProperty
sp
,
Lod
lod
,
CityObject
co
)
{
if
(
sp
==
null
||
sp
.
getObject
()
==
null
)
{
return
;
}
Geometry
geom
=
parseSolid
(
sp
.
getObject
(),
lod
);
if
(
geom
!=
null
)
{
co
.
addGeometry
(
geom
);
}
}
private
void
parseAndAddCompositeSurface
(
MultiSurfaceProperty
ms
,
Lod
lod
,
CityObject
co
){
if
(
ms
==
null
||
ms
.
getObject
()
==
null
)
{
return
;
}
List
<
SurfaceProperty
>
surfaces
=
ms
.
getObject
().
getSurfaceMember
();
for
(
SurfaceProperty
surface
:
surfaces
)
{
if
(
surface
.
getObject
()
instanceof
CompositeSurface
cs
)
{
Geometry
geom
=
parseCompositeSurface
(
cs
,
lod
);
if
(
geom
!=
null
)
{
co
.
addGeometry
(
geom
);
}
}
}
}
private
void
parseImplicitGeometry
(
AbstractOccupiedSpace
aos
,
CityObject
co
){
for
(
int
i
=
1
;
i
<=
3
;
i
++){
if
(
aos
.
getImplicitRepresentation
(
i
)
==
null
){
continue
;
}
if
(
aos
.
getImplicitRepresentation
(
i
).
getObject
()
!=
null
){
ImplicitGeometry
impGeom
=
aos
.
getImplicitRepresentation
(
i
).
getObject
();
ImplicitGeometryHolder
igh
=
resolveImplicitGeometry
(
impGeom
,
i
);
if
(
igh
!=
null
){
co
.
addGeometry
(
igh
);
}
}
else
if
(
aos
.
getImplicitRepresentation
(
i
).
getHref
()
!=
null
){
// TODO: HREF handling of implicit geometries
}
}
}
private
ImplicitGeometryHolder
resolveImplicitGeometry
(
ImplicitGeometry
ig
,
int
lodInt
)
{
ImplicitGeometryHolder
igh
=
null
;
if
(
ig
.
getLibraryObject
()
!=
null
){
Path
libraryObjectPath
=
directory
.
resolve
(
ig
.
getLibraryObject
());
LibraryObject
libObj
=
LibraryObject
.
of
(
libraryObjectPath
,
config
);
if
(
libObj
!=
null
){
igh
=
new
ImplicitGeometryHolder
(
ig
,
libObj
);
}
}
else
if
(
ig
.
getRelativeGeometry
()
!=
null
){
AbstractGeometry
aGeom
=
ig
.
getRelativeGeometry
().
getObject
();
Geometry
geom
=
null
;
Lod
lod
=
Lod
.
values
()[
lodInt
];
RelativeGeometry
relGeo
=
null
;
if
(
aGeom
instanceof
MultiSurface
ms
){
geom
=
parseMultiSurface
(
ms
,
lod
);
}
else
if
(
aGeom
instanceof
Solid
s
){
geom
=
parseSolid
(
s
,
lod
);
}
else
if
(
aGeom
instanceof
CompositeSurface
cs
){
geom
=
parseCompositeSurface
(
cs
,
lod
);
}
if
(
geom
!=
null
){
relGeo
=
RelativeGeometry
.
of
(
geom
);
igh
=
new
ImplicitGeometryHolder
(
ig
,
relGeo
);
}
}
else
{
logger
.
error
(
String
.
format
(
"Implicit geometry of GML-ID %s has no referenced geometry."
,
ig
.
getId
()));
}
return
igh
;
}
private
void
resolveAndClearReferences
()
{
for
(
ResolvableReference
ref
:
references
)
{
String
href
=
ref
.
href
();
if
(
href
.
startsWith
(
"#"
))
{
href
=
href
.
substring
(
1
);
}
Geometry
geom
=
ref
.
geometry
();
ConcretePolygon
concPoly
=
polygonMap
.
get
(
href
);
if
(
concPoly
==
null
)
{
if
(
logger
.
isWarnEnabled
())
{
logger
.
warn
(
Localization
.
getText
(
"FeatureMapper.polygonUnreferenced"
),
href
);
}
continue
;
}
if
(
concPoly
instanceof
CompositePolygon
comp
)
{
resolveCompositePolygon
(
comp
).
forEach
(
geom:
:
addPolygon
);
}
else
{
//
LinkedPolygon
lPoly
=
new
LinkedPolygon
(
concPoly
,
geom
);
if
(
geom
.
getParent
()
instanceof
BoundarySurface
bs
)
{
lPoly
.
setPartOfSurface
(
bs
);
if
(
bs
.
getParent
()
instanceof
Installation
bi
)
{
lPoly
.
setPartOfInstallation
(
bi
);
}
}
geom
.
addPolygon
(
lPoly
);
}
}
// clear storage for polygons and vertices
// probably faster than .clear() ?
references
=
new
ArrayList
<>();
vertexMap
=
new
HashMap
<>();
polygonMap
=
new
HashMap
<>();
}
private
List
<
ConcretePolygon
>
resolveCompositePolygon
(
CompositePolygon
comp
)
{
List
<
ConcretePolygon
>
polygons
=
new
ArrayList
<>();
for
(
ConcretePolygon
conc:
comp
.
getCompositeMembers
()){
if
(
conc
instanceof
CompositePolygon
recComp
){
polygons
.
addAll
(
resolveCompositePolygon
(
recComp
));
}
else
{
polygons
.
add
(
conc
);
}
}
return
polygons
;
}
private
void
readAbstractBuilding
(
org
.
citygml4j
.
core
.
model
.
building
.
AbstractBuilding
gmlAb
,
AbstractBuilding
cdBuilding
)
{
mapAbstractOccupiedSpace
(
gmlAb
,
cdBuilding
);
cdBuilding
.
setGmlObject
(
gmlAb
);
// parse deprecated geometries
parseAndAddMultiSurface
(
gmlAb
.
getDeprecatedProperties
().
getLod1MultiSurface
(),
Lod
.
LOD1
,
cdBuilding
);
parseAndAddMultiSurface
(
gmlAb
.
getDeprecatedProperties
().
getLod4MultiSurface
(),
Lod
.
LOD4
,
cdBuilding
);
parseAndAddSolid
(
gmlAb
.
getDeprecatedProperties
().
getLod4Solid
(),
Lod
.
LOD4
,
cdBuilding
);
for
(
BuildingInstallationProperty
biProp
:
gmlAb
.
getBuildingInstallations
())
{
var
gmlBi
=
biProp
.
getObject
();
if
(
gmlBi
==
null
)
{
// ignore empty properties
continue
;
}
Installation
bi
=
mapBuildingInstallation
(
gmlBi
);
cdBuilding
.
addBuildingInstallation
(
bi
);
}
for
(
BuildingRoomProperty
brProp
:
gmlAb
.
getBuildingRooms
())
{
var
gmlBr
=
brProp
.
getObject
();
if
(
gmlBr
==
null
)
{
continue
;
}
BuildingRoom
br
=
mapBuildingRoom
(
gmlBr
);
cdBuilding
.
addBuildingRoom
(
br
);
}
for
(
AbstractBuildingSubdivisionProperty
abs
:
gmlAb
.
getBuildingSubdivisions
())
{
var
gmlABS
=
abs
.
getObject
();
if
(
gmlABS
==
null
)
{
continue
;
}
if
(
gmlABS
instanceof
Storey
gmlStorey
)
{
de
.
hft
.
stuttgart
.
citydoctor2
.
datastructure
.
Storey
storey
=
mapBuildingStorey
(
gmlStorey
);
cdBuilding
.
addStorey
(
storey
);
}
else
if
(
gmlABS
instanceof
BuildingUnit
gmlBU
){
de
.
hft
.
stuttgart
.
citydoctor2
.
datastructure
.
BuildingUnit
bu
=
mapBuildingUnit
(
gmlBU
);
cdBuilding
.
addBuildingUnit
(
bu
);
}
}
SurfaceMapper
surfaceMapper
=
new
SurfaceMapper
(
polygonMap
,
references
,
vertexMap
,
config
);
for
(
AbstractSpaceBoundaryProperty
surfaceProp
:
gmlAb
.
getBoundaries
())
{
if
(!
surfaceProp
.
isSetObject
())
{
continue
;
}
AbstractSpaceBoundary
surface
=
surfaceProp
.
getObject
();
surface
.
accept
(
surfaceMapper
);
}
updatePartOfSurface
(
cdBuilding
,
surfaceMapper
);
cdBuilding
.
unsetGmlGeometries
();
resolveAndClearReferences
();
updateEdgesAndVertices
(
cdBuilding
);
for
(
BoundarySurface
bs
:
surfaceMapper
.
getSurfaces
())
{
updateEdgesAndVertices
(
bs
);
for
(
Opening
o
:
bs
.
getOpenings
())
{
updateEdgesAndVertices
(
o
);
}
}
for
(
Installation
bi
:
cdBuilding
.
getBuildingInstallations
())
{
updateEdgesAndVertices
(
bi
);
for
(
BoundarySurface
bs
:
bi
.
getBoundarySurfaces
())
{
updateEdgesAndVertices
(
bs
);
for
(
Opening
o
:
bs
.
getOpenings
())
{
updateEdgesAndVertices
(
o
);
}
}
}
for
(
BuildingFurnitureProperty
bfProp
:
gmlAb
.
getBuildingFurniture
()){
var
gmlBf
=
bfProp
.
getObject
();
if
(
gmlBf
==
null
)
{
continue
;
}
BuildingRoomFurniture
bf
=
mapBuildingFurniture
(
gmlBf
);
cdBuilding
.
addBuildingRoomFurniture
(
bf
);
}
}
private
BuildingRoom
mapBuildingRoom
(
org
.
citygml4j
.
core
.
model
.
building
.
BuildingRoom
gmlBr
)
{
BuildingRoom
br
=
new
BuildingRoom
();
br
.
setGmlObject
(
gmlBr
);
mapAbstractUnoccupiedSpace
(
gmlBr
,
br
);
SurfaceMapper
surfaceMapper
=
new
SurfaceMapper
(
polygonMap
,
references
,
vertexMap
,
config
);
for
(
AbstractSpaceBoundaryProperty
surfaceProp
:
gmlBr
.
getBoundaries
())
{
if
(!
surfaceProp
.
isSetObject
())
{
continue
;
}
AbstractSpaceBoundary
surface
=
surfaceProp
.
getObject
();
surface
.
accept
(
surfaceMapper
);
}
for
(
BoundarySurface
bs
:
surfaceMapper
.
getSurfaces
())
{
br
.
addBoundarySurface
(
bs
);
for
(
Geometry
geom
:
bs
.
getGeometries
())
{
for
(
Polygon
p
:
geom
.
getPolygons
())
{
p
.
setPartOfSurface
(
bs
);
}
}
}
for
(
BuildingInstallationProperty
biProp
:
gmlBr
.
getBuildingInstallations
())
{
var
gmlBi
=
biProp
.
getObject
();
if
(
gmlBi
==
null
)
{
// ignore empty properties
continue
;
}
Installation
bi
=
mapBuildingInstallation
(
gmlBi
);
br
.
addRoomInstallation
(
bi
);
}
for
(
BuildingFurnitureProperty
bfProp
:
gmlBr
.
getBuildingFurniture
()){
var
gmlHref
=
bfProp
.
getHref
();
if
(
gmlHref
==
null
)
{
continue
;
}
br
.
addFurnitureRef
(
bfProp
);
}
return
br
;
}
private
BuildingRoomFurniture
mapBuildingFurniture
(
BuildingFurniture
gmlAF
){
BuildingRoomFurniture
bf
=
new
BuildingRoomFurniture
();
bf
.
setGmlObject
(
gmlAF
);
mapAbstractOccupiedSpace
(
gmlAF
,
bf
);
bf
.
unsetGmlGeometries
();
SurfaceMapper
surfaceMapper
=
new
SurfaceMapper
(
polygonMap
,
references
,
vertexMap
,
config
);
for
(
AbstractSpaceBoundaryProperty
surfaceProp
:
gmlAF
.
getBoundaries
())
{
if
(!
surfaceProp
.
isSetObject
())
{
continue
;
}
AbstractSpaceBoundary
surface
=
surfaceProp
.
getObject
();
surface
.
accept
(
surfaceMapper
);
}
for
(
BoundarySurface
bs
:
surfaceMapper
.
getSurfaces
())
{
bf
.
addBoundarySurface
(
bs
);
for
(
Geometry
geom
:
bs
.
getGeometries
())
{
for
(
Polygon
p
:
geom
.
getPolygons
())
{
p
.
setPartOfSurface
(
bs
);
}
}
}
return
bf
;
}
private
de
.
hft
.
stuttgart
.
citydoctor2
.
datastructure
.
Storey
mapBuildingStorey
(
Storey
gmlStorey
){
de
.
hft
.
stuttgart
.
citydoctor2
.
datastructure
.
Storey
storey
=
new
de
.
hft
.
stuttgart
.
citydoctor2
.
datastructure
.
Storey
();
storey
.
setGmlObject
(
gmlStorey
);
mapAbstractSpace
(
gmlStorey
,
storey
);
storey
.
unsetGmlGeometries
();
SurfaceMapper
surfaceMapper
=
new
SurfaceMapper
(
polygonMap
,
references
,
vertexMap
,
config
);
for
(
AbstractSpaceBoundaryProperty
surfaceProp
:
gmlStorey
.
getBoundaries
())
{
if
(!
surfaceProp
.
isSetObject
())
{
continue
;
}
AbstractSpaceBoundary
surface
=
surfaceProp
.
getObject
();
surface
.
accept
(
surfaceMapper
);
}
for
(
BoundarySurface
bs
:
surfaceMapper
.
getSurfaces
())
{
storey
.
addBoundarySurface
(
bs
);
for
(
Geometry
geom
:
bs
.
getGeometries
())
{
for
(
Polygon
p
:
geom
.
getPolygons
())
{
p
.
setPartOfSurface
(
bs
);
}
}
}
return
storey
;
}
private
de
.
hft
.
stuttgart
.
citydoctor2
.
datastructure
.
BuildingUnit
mapBuildingUnit
(
BuildingUnit
gmlBU
){
de
.
hft
.
stuttgart
.
citydoctor2
.
datastructure
.
BuildingUnit
bu
=
new
de
.
hft
.
stuttgart
.
citydoctor2
.
datastructure
.
BuildingUnit
();
bu
.
setGmlObject
(
gmlBU
);
mapAbstractSpace
(
gmlBU
,
bu
);
bu
.
unsetGmlGeometries
();
SurfaceMapper
surfaceMapper
=
new
SurfaceMapper
(
polygonMap
,
references
,
vertexMap
,
config
);
for
(
AbstractSpaceBoundaryProperty
surfaceProp
:
gmlBU
.
getBoundaries
())
{
if
(!
surfaceProp
.
isSetObject
())
{
continue
;
}
AbstractSpaceBoundary
surface
=
surfaceProp
.
getObject
();
surface
.
accept
(
surfaceMapper
);
}
for
(
BoundarySurface
bs
:
surfaceMapper
.
getSurfaces
())
{
bu
.
addBoundarySurface
(
bs
);
for
(
Geometry
geom
:
bs
.
getGeometries
())
{
for
(
Polygon
p
:
geom
.
getPolygons
())
{
p
.
setPartOfSurface
(
bs
);
}
}
}
return
bu
;
}
private
void
updatePartOfSurface
(
AbstractBuilding
cdBuilding
,
SurfaceMapper
surfaceMapper
)
{
for
(
BoundarySurface
bs
:
surfaceMapper
.
getSurfaces
())
{
cdBuilding
.
addBoundarySurface
(
bs
);
for
(
Geometry
geom
:
bs
.
getGeometries
())
{
for
(
Polygon
p
:
geom
.
getPolygons
())
{
p
.
setPartOfSurface
(
bs
);
}
}
}
}
public
static
void
parseId
(
AbstractGML
gml
,
GmlElement
gmlElement
)
{
String
id
=
gml
.
getId
();
if
(
id
!=
null
)
{
gmlElement
.
setGmlId
(
new
GmlId
(
id
));
}
}
private
Installation
mapBuildingInstallation
(
org
.
citygml4j
.
core
.
model
.
building
.
BuildingInstallation
gmlBi
)
{
Installation
bi
=
new
Installation
();
bi
.
setGmlObject
(
gmlBi
);
mapAbstractOccupiedSpace
(
gmlBi
,
bi
);
GeometryProperty
<?>
lod2Prop
=
gmlBi
.
getDeprecatedProperties
().
getLod2Geometry
();
parseAndAddAbstractGeometry
(
lod2Prop
,
Lod
.
LOD2
,
bi
);
GeometryProperty
<?>
lod3Prop
=
gmlBi
.
getDeprecatedProperties
().
getLod3Geometry
();
parseAndAddAbstractGeometry
(
lod3Prop
,
Lod
.
LOD3
,
bi
);
GeometryProperty
<?>
lod4Prop
=
gmlBi
.
getDeprecatedProperties
().
getLod4Geometry
();
parseAndAddAbstractGeometry
(
lod4Prop
,
Lod
.
LOD4
,
bi
);
bi
.
unsetGmlGeometries
();
SurfaceMapper
surfaceMapper
=
new
SurfaceMapper
(
polygonMap
,
references
,
vertexMap
,
config
);
for
(
AbstractSpaceBoundaryProperty
surfaceProp
:
gmlBi
.
getBoundaries
())
{
if
(!
surfaceProp
.
isSetObject
())
{
continue
;
}
AbstractSpaceBoundary
surface
=
surfaceProp
.
getObject
();
surface
.
accept
(
surfaceMapper
);
}
for
(
BoundarySurface
bs
:
surfaceMapper
.
getSurfaces
())
{
bi
.
addBoundarySurface
(
bs
);
for
(
Geometry
geom
:
bs
.
getGeometries
())
{
for
(
Polygon
p
:
geom
.
getPolygons
())
{
p
.
setPartOfSurface
(
bs
);
p
.
setPartOfInstallation
(
bi
);
}
}
}
for
(
Geometry
geom
:
bi
.
getGeometries
())
{
for
(
Polygon
p
:
geom
.
getPolygons
())
{
p
.
setPartOfInstallation
(
bi
);
}
}
return
bi
;
}
private
void
parseAndAddAbstractGeometry
(
GeometryProperty
<?>
geomProp
,
Lod
lod
,
CityObject
co
)
{
if
(
geomProp
==
null
||
geomProp
.
getObject
()
==
null
)
{
return
;
}
AbstractGeometry
abstractGeometry
=
geomProp
.
getObject
();
if
(
abstractGeometry
instanceof
MultiSurface
ms
)
{
Geometry
geom
=
parseMultiSurface
(
ms
,
lod
);
co
.
addGeometry
(
geom
);
}
else
if
(
abstractGeometry
instanceof
Solid
solid
)
{
Geometry
geom
=
parseSolid
(
solid
,
lod
);
if
(
geom
!=
null
)
{
co
.
addGeometry
(
geom
);
}
}
else
{
logger
.
warn
(
"Cannot handle geometry type {}, ignoring"
,
abstractGeometry
.
getClass
().
getSimpleName
());
}
}
private
Geometry
parseSolid
(
AbstractSolid
abstractSolid
,
Lod
lod
)
{
if
(
abstractSolid
instanceof
Solid
s
)
{
return
handleSolidGeometry
(
s
,
lod
);
}
else
{
logger
.
warn
(
"Cannot handle solid class {}, can only process pure solids"
,
abstractSolid
.
getClass
().
getSimpleName
());
return
null
;
}
}
private
Geometry
handleSolidGeometry
(
Solid
solid
,
Lod
lod
)
{
ShellProperty
exteriorProperty
=
solid
.
getExterior
();
if
(
exteriorProperty
==
null
||
exteriorProperty
.
getObject
()
==
null
)
{
logger
.
warn
(
"Found solid {} without exterior hull, ignoring"
,
solid
.
getId
());
return
null
;
}
Geometry
geom
=
new
Geometry
(
GeometryType
.
SOLID
,
lod
);
Shell
exterior
=
solid
.
getExterior
().
getObject
();
Citygml3GeometryMapper
geometryMapper
=
new
Citygml3GeometryMapper
(
config
,
vertexMap
);
readSurfaceMember
(
geom
,
geometryMapper
,
exterior
.
getSurfaceMembers
());
return
geom
;
}
private
Geometry
parseMultiSurface
(
MultiSurface
ms
,
Lod
lod
)
{
Geometry
geom
=
new
Geometry
(
GeometryType
.
MULTI_SURFACE
,
lod
);
Citygml3GeometryMapper
geometryMapper
=
new
Citygml3GeometryMapper
(
config
,
vertexMap
);
readSurfaceMember
(
geom
,
geometryMapper
,
ms
.
getSurfaceMember
());
return
geom
;
}
private
void
readSurfaceMember
(
Geometry
geom
,
Citygml3GeometryMapper
geometryMapper
,
List
<
SurfaceProperty
>
surfaceMember
)
{
for
(
SurfaceProperty
prop
:
surfaceMember
)
{
if
(
prop
.
getHref
()
!=
null
)
{
references
.
add
(
new
ResolvableReference
(
prop
.
getHref
(),
geom
));
continue
;
}
if
(
prop
.
getObject
()
!=
null
)
{
AbstractSurface
as
=
prop
.
getObject
();
as
.
accept
(
geometryMapper
);
}
}
List
<
ConcretePolygon
>
polygons
=
geometryMapper
.
getPolygons
();
for
(
ConcretePolygon
concretePoly
:
polygons
)
{
geom
.
addPolygon
(
concretePoly
);
if
(
concretePoly
.
hasExistingGmlId
())
{
polygonMap
.
put
(
concretePoly
.
getGmlId
().
getGmlString
(),
concretePoly
);
}
}
}
private
Geometry
parseCompositeSurface
(
CompositeSurface
cs
,
Lod
lod
)
{
Geometry
geom
=
new
Geometry
(
GeometryType
.
COMPOSITE_SURFACE
,
lod
);
Citygml3GeometryMapper
geometryMapper
=
new
Citygml3GeometryMapper
(
config
,
vertexMap
);
readSurfaceMember
(
geom
,
geometryMapper
,
cs
.
getSurfaceMembers
());
return
geom
;
}
private
void
updateEdgesAndVertices
(
CityObject
co
)
{
// searching for neighboring vertices, replacing them with one single vertex to
// avoid later problems with edges and manifold problems
for
(
Geometry
geom
:
co
.
getGeometries
())
{
KDTree
tree
=
new
KDTree
();
for
(
Polygon
poly
:
geom
.
getPolygons
())
{
if
(
poly
instanceof
CompositePolygon
){
continue
;
}
LinearRing
lr
=
poly
.
getExteriorRing
();
updateRing
(
tree
,
lr
);
for
(
LinearRing
innerRing
:
poly
.
getInnerRings
())
{
updateRing
(
tree
,
innerRing
);
}
}
if
(!
config
.
useLowMemoryConsumption
())
{
// no low memory consumption mode meaning create all meta information in
// geometry
geom
.
updateEdgesAndVertices
();
}
}
}
private
void
updateRing
(
KDTree
tree
,
LinearRing
lr
)
{
for
(
int
i
=
0
;
i
<
lr
.
getVertices
().
size
();
i
++)
{
Vertex
v
=
lr
.
getVertices
().
get
(
i
);
List
<
Vertex
>
nodesInRange
=
tree
.
getNodesInRange
(
v
,
neighborDistance
);
if
(
nodesInRange
.
isEmpty
())
{
tree
.
add
(
v
);
}
else
{
// replace other vertex with any neighboring one
Vertex
original
=
nodesInRange
.
get
(
0
);
lr
.
setVertex
(
i
,
original
);
}
}
}
public
void
setCityModel
(
CityModel
cModel
)
{
model
.
setCityModel
(
cModel
);
}
public
CityDoctorModel
getModel
()
{
return
model
;
}
public
void
setCityGMLVersion
(
CityGMLVersion
cityGMLVersion
)
{
model
.
setParsedCityGMLVersion
(
cityGMLVersion
);
}
private
static
final
Logger
logger
=
LogManager
.
getLogger
(
Citygml3FeatureMapper
.
class
);
private
final
CityDoctorModel
model
;
private
final
ParserConfiguration
config
;
private
final
Path
directory
;
private
final
double
neighborDistance
;
private
Map
<
String
,
ConcretePolygon
>
polygonMap
=
new
HashMap
<>();
private
List
<
ResolvableReference
>
references
=
new
ArrayList
<>();
private
Map
<
Vertex
,
Vertex
>
vertexMap
=
new
HashMap
<>();
public
Citygml3FeatureMapper
(
ParserConfiguration
config
,
Path
path
)
{
this
.
config
=
config
;
this
.
directory
=
path
.
getParent
();
model
=
new
CityDoctorModel
(
config
,
path
.
toFile
());
neighborDistance
=
1.8d
/
Math
.
pow
(
10
,
config
.
getNumberOfRoundingPlaces
());
}
public
static
void
parseId
(
AbstractGML
gml
,
GmlElement
gmlElement
)
{
String
id
=
gml
.
getId
();
if
(
id
!=
null
)
{
gmlElement
.
setGmlId
(
new
GmlId
(
id
));
}
}
@Override
public
void
visit
(
AbstractSpace
space
)
{
// if we are here, an AbstractSpace thing was read that is not handled in the
// other methods
}
@Override
public
void
visit
(
org
.
citygml4j
.
core
.
model
.
cityfurniture
.
CityFurniture
gmlCityFurniture
)
{
CityFurniture
cf
=
new
CityFurniture
();
cf
.
setGmlObject
(
gmlCityFurniture
);
mapAbstractOccupiedSpace
(
gmlCityFurniture
,
cf
);
resolveAndClearReferences
();
cf
.
unsetGmlGeometries
();
updateEdgesAndVertices
(
cf
);
model
.
addCityFurniture
(
cf
);
}
@Override
public
void
visit
(
org
.
citygml4j
.
core
.
model
.
generics
.
GenericOccupiedSpace
gos
)
{
GenericCityObject
gco
=
new
GenericCityObject
();
gco
.
setGmlObject
(
gos
);
mapAbstractOccupiedSpace
(
gos
,
gco
);
resolveAndClearReferences
();
gco
.
unsetGmlGeometries
();
updateEdgesAndVertices
(
gco
);
model
.
addGenericCityObject
(
gco
);
}
@Override
public
void
visit
(
org
.
citygml4j
.
core
.
model
.
building
.
Building
gmlBuilding
)
{
Building
cdBuilding
=
new
Building
();
readAbstractBuilding
(
gmlBuilding
,
cdBuilding
);
for
(
BuildingPartProperty
bpProp
:
gmlBuilding
.
getBuildingParts
())
{
if
(!
bpProp
.
isSetObject
())
{
continue
;
}
BuildingPart
part
=
new
BuildingPart
(
cdBuilding
);
readAbstractBuilding
(
bpProp
.
getObject
(),
part
);
}
model
.
addBuilding
(
cdBuilding
);
}
@Override
public
void
visit
(
WaterBody
waterBody
)
{
WaterObject
wo
=
new
WaterObject
();
wo
.
setGmlObject
(
waterBody
);
mapAbstractOccupiedSpace
(
waterBody
,
wo
);
parseAndAddMultiSurface
(
waterBody
.
getDeprecatedProperties
().
getLod1MultiSurface
(),
Lod
.
LOD1
,
wo
);
parseAndAddSolid
(
waterBody
.
getDeprecatedProperties
().
getLod4Solid
(),
Lod
.
LOD4
,
wo
);
SurfaceMapper
surfaceMapper
=
new
SurfaceMapper
(
polygonMap
,
references
,
vertexMap
,
config
);
for
(
AbstractSpaceBoundaryProperty
surfaceProp
:
waterBody
.
getBoundaries
())
{
if
(!
surfaceProp
.
isSetObject
())
{
continue
;
}
AbstractSpaceBoundary
surface
=
surfaceProp
.
getObject
();
surface
.
accept
(
surfaceMapper
);
}
for
(
BoundarySurface
bs
:
surfaceMapper
.
getSurfaces
())
{
wo
.
addBoundarySurface
(
bs
);
}
resolveAndClearReferences
();
wo
.
unsetGmlGeometries
();
updateEdgesAndVertices
(
wo
);
for
(
BoundarySurface
bs
:
surfaceMapper
.
getSurfaces
())
{
updateEdgesAndVertices
(
bs
);
}
model
.
addWater
(
wo
);
}
@Override
public
void
visit
(
LandUse
landUse
)
{
LandObject
lo
=
new
LandObject
(
landUse
);
mapAbstractThematicSurface
(
landUse
,
lo
);
finishCityObjectConstruction
(
lo
);
model
.
addLand
(
lo
);
}
@Override
public
void
visit
(
PlantCover
plantCover
)
{
Vegetation
veg
=
new
Vegetation
(
VegetationType
.
PLANT_COVER
);
veg
.
setGmlObject
(
plantCover
);
mapAbstractVegetationObject
(
plantCover
,
veg
);
parseAndAddMultiSurface
(
plantCover
.
getDeprecatedProperties
().
getLod1MultiSurface
(),
Lod
.
LOD1
,
veg
);
parseAndAddMultiSurface
(
plantCover
.
getDeprecatedProperties
().
getLod4MultiSurface
(),
Lod
.
LOD4
,
veg
);
finishCityObjectConstruction
(
veg
);
model
.
addVegetation
(
veg
);
}
@Override
public
void
visit
(
SolitaryVegetationObject
solitaryVegetationObject
)
{
Vegetation
veg
=
new
Vegetation
(
VegetationType
.
SOLITARY_VEGETATION_OBJECT
);
veg
.
setGmlObject
(
solitaryVegetationObject
);
mapAbstractVegetationObject
(
solitaryVegetationObject
,
veg
);
parseAndAddAbstractGeometry
(
solitaryVegetationObject
.
getDeprecatedProperties
().
getLod1Geometry
(),
Lod
.
LOD1
,
veg
);
parseAndAddAbstractGeometry
(
solitaryVegetationObject
.
getDeprecatedProperties
().
getLod2Geometry
(),
Lod
.
LOD2
,
veg
);
parseAndAddAbstractGeometry
(
solitaryVegetationObject
.
getDeprecatedProperties
().
getLod3Geometry
(),
Lod
.
LOD3
,
veg
);
parseAndAddAbstractGeometry
(
solitaryVegetationObject
.
getDeprecatedProperties
().
getLod4Geometry
(),
Lod
.
LOD4
,
veg
);
finishCityObjectConstruction
(
veg
);
model
.
addVegetation
(
veg
);
}
private
void
mapAbstractVegetationObject
(
AbstractVegetationObject
avo
,
Vegetation
veg
)
{
mapAbstractOccupiedSpace
(
avo
,
veg
);
}
private
void
mapAbstractOccupiedSpace
(
AbstractOccupiedSpace
aos
,
CityObject
co
)
{
mapAbstractPhysicalSpace
(
aos
,
co
);
parseImplicitGeometry
(
aos
,
co
);
}
private
void
mapAbstractPhysicalSpace
(
AbstractPhysicalSpace
aps
,
CityObject
co
)
{
mapAbstractSpace
(
aps
,
co
);
}
private
void
mapAbstractSpace
(
AbstractSpace
as
,
CityObject
co
)
{
mapAbstractFeature
(
as
,
co
);
parseAndAddMultiSurface
(
as
.
getLod0MultiSurface
(),
Lod
.
LOD0
,
co
);
parseAndAddMultiSurface
(
as
.
getLod2MultiSurface
(),
Lod
.
LOD2
,
co
);
parseAndAddMultiSurface
(
as
.
getLod3MultiSurface
(),
Lod
.
LOD3
,
co
);
parseAndAddSolid
(
as
.
getLod1Solid
(),
Lod
.
LOD1
,
co
);
parseAndAddSolid
(
as
.
getLod2Solid
(),
Lod
.
LOD2
,
co
);
parseAndAddSolid
(
as
.
getLod3Solid
(),
Lod
.
LOD3
,
co
);
}
@Override
public
void
visit
(
Bridge
bridge
)
{
BridgeObject
bo
=
new
BridgeObject
(
BridgeType
.
BRIDGE
,
bridge
);
for
(
BridgePartProperty
bPartProperty
:
bridge
.
getBridgeParts
())
{
if
(!
bPartProperty
.
isSetObject
())
{
continue
;
}
BridgePart
gmlBridgePart
=
bPartProperty
.
getObject
();
BridgeObject
bPart
=
new
BridgeObject
(
BridgeType
.
BRIDGE_PART
,
gmlBridgePart
);
mapAbstractBridge
(
gmlBridgePart
,
bPart
);
bo
.
addBridgePart
(
bPart
);
}
mapAbstractBridge
(
bridge
,
bo
);
resolveAndClearReferences
();
updateEdgesAndVertices
(
bo
);
for
(
BridgeObject
part
:
bo
.
getParts
())
{
updateEdgesAndVertices
(
part
);
}
for
(
BridgeConstructiveElement
ele
:
bo
.
getConstructiveElements
())
{
updateEdgesAndVertices
(
ele
);
for
(
BoundarySurface
bs
:
ele
.
getBoundarySurfaces
())
{
updateEdgesAndVertices
(
bs
);
}
}
for
(
Installation
bi
:
bo
.
getBridgeInstallations
())
{
updateEdgesAndVertices
(
bi
);
for
(
BoundarySurface
bs
:
bi
.
getBoundarySurfaces
())
{
updateEdgesAndVertices
(
bs
);
}
}
model
.
addBridge
(
bo
);
}
private
void
mapAbstractBridge
(
AbstractBridge
ab
,
BridgeObject
bo
)
{
mapAbstractConstruction
(
ab
,
bo
);
for
(
BridgeConstructiveElementProperty
eleProp
:
ab
.
getBridgeConstructiveElements
())
{
if
(!
eleProp
.
isSetObject
())
{
continue
;
}
org
.
citygml4j
.
core
.
model
.
bridge
.
BridgeConstructiveElement
constructiveElement
=
eleProp
.
getObject
();
BridgeConstructiveElement
cdEle
=
new
BridgeConstructiveElement
(
constructiveElement
);
mapConstructiveElement
(
constructiveElement
,
cdEle
);
bo
.
addConstructiveElement
(
cdEle
);
}
List
<
BridgeInstallationProperty
>
bridgeInstallations
=
ab
.
getBridgeInstallations
();
for
(
BridgeInstallationProperty
installationProp
:
bridgeInstallations
)
{
var
gmlBi
=
installationProp
.
getObject
();
if
(
gmlBi
==
null
)
{
// ignore empty properties
continue
;
}
Installation
bi
=
mapBridgeInstallation
(
gmlBi
);
bo
.
addBridgeInstallation
(
bi
);
}
SurfaceMapper
surfaceMapper
=
new
SurfaceMapper
(
polygonMap
,
references
,
vertexMap
,
config
);
for
(
AbstractSpaceBoundaryProperty
surfaceProp
:
ab
.
getBoundaries
())
{
if
(!
surfaceProp
.
isSetObject
())
{
continue
;
}
AbstractSpaceBoundary
surface
=
surfaceProp
.
getObject
();
surface
.
accept
(
surfaceMapper
);
}
updatePartOfSurface
(
bo
,
surfaceMapper
);
for
(
BoundarySurface
bs
:
bo
.
getBoundarySurfaces
())
{
updateEdgesAndVertices
(
bs
);
}
bo
.
unsetGmlGeometries
();
}
private
Installation
mapBridgeInstallation
(
BridgeInstallation
gmlBi
)
{
Installation
bi
=
new
Installation
();
bi
.
setGmlObject
(
gmlBi
);
mapAbstractOccupiedSpace
(
gmlBi
,
bi
);
GeometryProperty
<?>
lod2Prop
=
gmlBi
.
getDeprecatedProperties
().
getLod2Geometry
();
parseAndAddAbstractGeometry
(
lod2Prop
,
Lod
.
LOD2
,
bi
);
GeometryProperty
<?>
lod3Prop
=
gmlBi
.
getDeprecatedProperties
().
getLod3Geometry
();
parseAndAddAbstractGeometry
(
lod3Prop
,
Lod
.
LOD3
,
bi
);
GeometryProperty
<?>
lod4Prop
=
gmlBi
.
getDeprecatedProperties
().
getLod4Geometry
();
parseAndAddAbstractGeometry
(
lod4Prop
,
Lod
.
LOD4
,
bi
);
bi
.
unsetGmlGeometries
();
SurfaceMapper
surfaceMapper
=
new
SurfaceMapper
(
polygonMap
,
references
,
vertexMap
,
config
);
for
(
AbstractSpaceBoundaryProperty
surfaceProp
:
gmlBi
.
getBoundaries
())
{
if
(!
surfaceProp
.
isSetObject
())
{
continue
;
}
AbstractSpaceBoundary
surface
=
surfaceProp
.
getObject
();
surface
.
accept
(
surfaceMapper
);
}
for
(
BoundarySurface
bs
:
surfaceMapper
.
getSurfaces
())
{
bi
.
addBoundarySurface
(
bs
);
for
(
Geometry
geom
:
bs
.
getGeometries
())
{
for
(
Polygon
p
:
geom
.
getPolygons
())
{
p
.
setPartOfSurface
(
bs
);
p
.
setPartOfInstallation
(
bi
);
}
}
}
for
(
Geometry
geom
:
bi
.
getGeometries
())
{
for
(
Polygon
p
:
geom
.
getPolygons
())
{
p
.
setPartOfInstallation
(
bi
);
}
}
return
bi
;
}
@Override
public
void
visit
(
Tunnel
tunnel
)
{
de
.
hft
.
stuttgart
.
citydoctor2
.
datastructure
.
Tunnel
tu
=
new
de
.
hft
.
stuttgart
.
citydoctor2
.
datastructure
.
Tunnel
();
for
(
TunnelPartProperty
tPartProperty
:
tunnel
.
getTunnelParts
())
{
if
(!
tPartProperty
.
isSetObject
())
{
continue
;
}
org
.
citygml4j
.
core
.
model
.
tunnel
.
TunnelPart
gmlTunnelPart
=
tPartProperty
.
getObject
();
TunnelPart
tPart
=
new
TunnelPart
(
tu
);
readAbstractTunnel
(
gmlTunnelPart
,
tPart
);
tu
.
addTunnelPart
(
tPart
);
}
readAbstractTunnel
(
tunnel
,
tu
);
resolveAndClearReferences
();
updateEdgesAndVertices
(
tu
);
for
(
TunnelPart
part
:
tu
.
getTunnelParts
())
{
updateEdgesAndVertices
(
part
);
}
model
.
addTunnel
(
tu
);
}
private
void
readAbstractTunnel
(
org
.
citygml4j
.
core
.
model
.
tunnel
.
AbstractTunnel
gmlTunnel
,
AbstractTunnel
cdTunnel
)
{
mapAbstractOccupiedSpace
(
gmlTunnel
,
cdTunnel
);
cdTunnel
.
setGmlObject
(
gmlTunnel
);
// parse deprecated geometries
parseAndAddMultiSurface
(
gmlTunnel
.
getDeprecatedProperties
().
getLod1MultiSurface
(),
Lod
.
LOD1
,
cdTunnel
);
parseAndAddMultiSurface
(
gmlTunnel
.
getDeprecatedProperties
().
getLod4MultiSurface
(),
Lod
.
LOD4
,
cdTunnel
);
parseAndAddSolid
(
gmlTunnel
.
getDeprecatedProperties
().
getLod4Solid
(),
Lod
.
LOD4
,
cdTunnel
);
for
(
TunnelInstallationProperty
tiProp
:
gmlTunnel
.
getTunnelInstallations
())
{
var
gmlTi
=
tiProp
.
getObject
();
if
(
gmlTi
==
null
)
{
// ignore empty properties
continue
;
}
Installation
ti
=
mapTunnelInstallation
(
gmlTi
);
cdTunnel
.
addTunnelInstallation
(
ti
);
}
for
(
HollowSpaceProperty
thProp
:
gmlTunnel
.
getHollowSpaces
())
{
var
gmlTh
=
thProp
.
getObject
();
if
(
gmlTh
==
null
)
{
continue
;
}
TunnelHollow
br
=
mapTunnelHollow
(
gmlTh
);
cdTunnel
.
addTunnelHollow
(
br
);
}
SurfaceMapper
surfaceMapper
=
new
SurfaceMapper
(
polygonMap
,
references
,
vertexMap
,
config
);
for
(
AbstractSpaceBoundaryProperty
surfaceProp
:
gmlTunnel
.
getBoundaries
())
{
if
(!
surfaceProp
.
isSetObject
())
{
continue
;
}
AbstractSpaceBoundary
surface
=
surfaceProp
.
getObject
();
surface
.
accept
(
surfaceMapper
);
}
cdTunnel
.
unsetGmlGeometries
();
resolveAndClearReferences
();
updateEdgesAndVertices
(
cdTunnel
);
for
(
BoundarySurface
bs
:
surfaceMapper
.
getSurfaces
())
{
updateEdgesAndVertices
(
bs
);
for
(
Opening
o
:
bs
.
getOpenings
())
{
updateEdgesAndVertices
(
o
);
}
}
for
(
Installation
ti
:
cdTunnel
.
getTunnelInstallations
())
{
updateEdgesAndVertices
(
ti
);
for
(
BoundarySurface
bs
:
ti
.
getBoundarySurfaces
())
{
updateEdgesAndVertices
(
bs
);
for
(
Opening
o
:
bs
.
getOpenings
())
{
updateEdgesAndVertices
(
o
);
}
}
}
for
(
TunnelFurnitureProperty
tfProp
:
gmlTunnel
.
getTunnelFurniture
())
{
var
gmlTf
=
tfProp
.
getObject
();
if
(
gmlTf
==
null
)
{
continue
;
}
TunnelFurniture
tf
=
mapTunnelFurniture
(
gmlTf
);
cdTunnel
.
addTunnelFurniture
(
tf
);
}
}
private
Installation
mapTunnelInstallation
(
TunnelInstallation
gmlTi
)
{
Installation
ti
=
new
Installation
();
ti
.
setGmlObject
(
gmlTi
);
mapAbstractOccupiedSpace
(
gmlTi
,
ti
);
GeometryProperty
<?>
lod2Prop
=
gmlTi
.
getDeprecatedProperties
().
getLod2Geometry
();
parseAndAddAbstractGeometry
(
lod2Prop
,
Lod
.
LOD2
,
ti
);
GeometryProperty
<?>
lod3Prop
=
gmlTi
.
getDeprecatedProperties
().
getLod3Geometry
();
parseAndAddAbstractGeometry
(
lod3Prop
,
Lod
.
LOD3
,
ti
);
GeometryProperty
<?>
lod4Prop
=
gmlTi
.
getDeprecatedProperties
().
getLod4Geometry
();
parseAndAddAbstractGeometry
(
lod4Prop
,
Lod
.
LOD4
,
ti
);
ti
.
unsetGmlGeometries
();
SurfaceMapper
surfaceMapper
=
new
SurfaceMapper
(
polygonMap
,
references
,
vertexMap
,
config
);
for
(
AbstractSpaceBoundaryProperty
surfaceProp
:
gmlTi
.
getBoundaries
())
{
if
(!
surfaceProp
.
isSetObject
())
{
continue
;
}
AbstractSpaceBoundary
surface
=
surfaceProp
.
getObject
();
surface
.
accept
(
surfaceMapper
);
}
for
(
BoundarySurface
bs
:
surfaceMapper
.
getSurfaces
())
{
ti
.
addBoundarySurface
(
bs
);
for
(
Geometry
geom
:
bs
.
getGeometries
())
{
for
(
Polygon
p
:
geom
.
getPolygons
())
{
p
.
setPartOfSurface
(
bs
);
p
.
setPartOfInstallation
(
ti
);
}
}
}
for
(
Geometry
geom
:
ti
.
getGeometries
())
{
for
(
Polygon
p
:
geom
.
getPolygons
())
{
p
.
setPartOfInstallation
(
ti
);
}
}
return
ti
;
}
private
TunnelHollow
mapTunnelHollow
(
HollowSpace
gmlHo
)
{
TunnelHollow
tHollow
=
new
TunnelHollow
();
tHollow
.
setGmlObject
(
gmlHo
);
mapAbstractUnoccupiedSpace
(
gmlHo
,
tHollow
);
SurfaceMapper
surfaceMapper
=
new
SurfaceMapper
(
polygonMap
,
references
,
vertexMap
,
config
);
for
(
AbstractSpaceBoundaryProperty
surfaceProp
:
gmlHo
.
getBoundaries
())
{
if
(!
surfaceProp
.
isSetObject
())
{
continue
;
}
AbstractSpaceBoundary
surface
=
surfaceProp
.
getObject
();
surface
.
accept
(
surfaceMapper
);
}
for
(
BoundarySurface
bs
:
surfaceMapper
.
getSurfaces
())
{
tHollow
.
addBoundarySurface
(
bs
);
for
(
Geometry
geom
:
bs
.
getGeometries
())
{
for
(
Polygon
p
:
geom
.
getPolygons
())
{
p
.
setPartOfSurface
(
bs
);
}
}
}
for
(
TunnelInstallationProperty
tiProp
:
gmlHo
.
getTunnelInstallations
())
{
var
gmlTi
=
tiProp
.
getObject
();
if
(
gmlTi
==
null
)
{
// ignore empty properties
continue
;
}
Installation
bi
=
mapTunnelInstallation
(
gmlTi
);
tHollow
.
addRoomInstallation
(
bi
);
}
for
(
TunnelFurnitureProperty
tfProp
:
gmlHo
.
getTunnelFurniture
())
{
var
gmlHref
=
tfProp
.
getHref
();
if
(
gmlHref
==
null
)
{
continue
;
}
tHollow
.
addFurnitureRef
(
tfProp
);
}
return
tHollow
;
}
private
TunnelFurniture
mapTunnelFurniture
(
org
.
citygml4j
.
core
.
model
.
tunnel
.
TunnelFurniture
gmlTf
)
{
TunnelFurniture
tf
=
new
TunnelFurniture
();
tf
.
setGmlObject
(
gmlTf
);
mapAbstractOccupiedSpace
(
gmlTf
,
tf
);
tf
.
unsetGmlGeometries
();
SurfaceMapper
surfaceMapper
=
new
SurfaceMapper
(
polygonMap
,
references
,
vertexMap
,
config
);
for
(
AbstractSpaceBoundaryProperty
surfaceProp
:
gmlTf
.
getBoundaries
())
{
if
(!
surfaceProp
.
isSetObject
())
{
continue
;
}
AbstractSpaceBoundary
surface
=
surfaceProp
.
getObject
();
surface
.
accept
(
surfaceMapper
);
}
for
(
BoundarySurface
bs
:
surfaceMapper
.
getSurfaces
())
{
tf
.
addBoundarySurface
(
bs
);
for
(
Geometry
geom
:
bs
.
getGeometries
())
{
for
(
Polygon
p
:
geom
.
getPolygons
())
{
p
.
setPartOfSurface
(
bs
);
}
}
}
return
tf
;
}
private
void
updatePartOfSurface
(
BridgeObject
bo
,
SurfaceMapper
surfaceMapper
)
{
for
(
BoundarySurface
bs
:
surfaceMapper
.
getSurfaces
())
{
bo
.
addBoundarySurface
(
bs
);
for
(
Geometry
geom
:
bs
.
getGeometries
())
{
for
(
Polygon
p
:
geom
.
getPolygons
())
{
p
.
setPartOfSurface
(
bs
);
}
}
}
}
private
void
mapConstructiveElement
(
org
.
citygml4j
.
core
.
model
.
bridge
.
BridgeConstructiveElement
ele
,
BridgeConstructiveElement
bce
)
{
mapAbstractConstructiveElement
(
ele
,
bce
);
SurfaceMapper
surfaceMapper
=
new
SurfaceMapper
(
polygonMap
,
references
,
vertexMap
,
config
);
for
(
AbstractSpaceBoundaryProperty
surfaceProp
:
ele
.
getBoundaries
())
{
if
(!
surfaceProp
.
isSetObject
())
{
continue
;
}
AbstractSpaceBoundary
surface
=
surfaceProp
.
getObject
();
surface
.
accept
(
surfaceMapper
);
}
for
(
BoundarySurface
bs
:
surfaceMapper
.
getSurfaces
())
{
bce
.
addBoundarySurface
(
bs
);
}
}
private
void
mapAbstractConstructiveElement
(
org
.
citygml4j
.
core
.
model
.
bridge
.
BridgeConstructiveElement
ele
,
BridgeConstructiveElement
bce
)
{
mapAbstractOccupiedSpace
(
ele
,
bce
);
}
private
void
mapAbstractConstruction
(
AbstractConstruction
ac
,
BridgeObject
bo
)
{
mapAbstractOccupiedSpace
(
ac
,
bo
);
}
@Override
public
void
visit
(
AuxiliaryTrafficArea
ata
)
{
TransportationObject
to
=
new
TransportationObject
(
TransportationType
.
AUXILLIARY_TRAFFIC_AREA
);
mapAbstractThematicSurface
(
ata
,
to
);
finishTransportationMapping
(
to
);
}
@Override
public
void
visit
(
TrafficArea
ta
)
{
TransportationObject
to
=
new
TransportationObject
(
TransportationType
.
TRAFFIC_AREA
);
mapAbstractThematicSurface
(
ta
,
to
);
finishTransportationMapping
(
to
);
}
@Override
public
void
visit
(
Road
road
)
{
TransportationObject
to
=
new
TransportationObject
(
TransportationType
.
ROAD
);
mapAbstractTransportationSpace
(
road
,
to
);
finishTransportationMapping
(
to
);
}
private
void
mapAbstractThematicSurface
(
AbstractThematicSurface
ats
,
CityObject
co
)
{
mapAbstractSpaceBoundary
(
ats
,
co
);
parseAndAddMultiSurface
(
ats
.
getLod0MultiSurface
(),
Lod
.
LOD0
,
co
);
parseAndAddMultiSurface
(
ats
.
getLod1MultiSurface
(),
Lod
.
LOD1
,
co
);
parseAndAddMultiSurface
(
ats
.
getLod2MultiSurface
(),
Lod
.
LOD2
,
co
);
parseAndAddMultiSurface
(
ats
.
getLod3MultiSurface
(),
Lod
.
LOD3
,
co
);
parseAndAddMultiSurface
(
ats
.
getDeprecatedProperties
().
getLod4MultiSurface
(),
Lod
.
LOD4
,
co
);
}
private
void
mapAbstractSpaceBoundary
(
AbstractSpaceBoundary
asb
,
CityObject
co
)
{
mapAbstractCityObject
(
asb
,
co
);
}
private
void
mapAbstractCityObject
(
AbstractCityObject
aco
,
CityObject
to
)
{
mapAbstractFeatureWithLifespan
(
aco
,
to
);
}
private
void
mapAbstractFeatureWithLifespan
(
AbstractFeatureWithLifespan
afwl
,
CityObject
to
)
{
mapAbstractFeature
(
afwl
,
to
);
}
private
void
mapAbstractFeature
(
AbstractFeature
af
,
CityObject
to
)
{
mapAbstractGML
(
af
,
to
);
}
private
void
mapAbstractGML
(
AbstractGML
ag
,
CityObject
to
)
{
parseId
(
ag
,
to
);
}
@Override
public
void
visit
(
Railway
railway
)
{
TransportationObject
to
=
new
TransportationObject
(
TransportationType
.
RAILWAY
);
mapAbstractTransportationSpace
(
railway
,
to
);
finishTransportationMapping
(
to
);
}
@Override
public
void
visit
(
Square
square
)
{
TransportationObject
to
=
new
TransportationObject
(
TransportationType
.
SQUARE
);
mapAbstractTransportationSpace
(
square
,
to
);
finishTransportationMapping
(
to
);
}
@Override
public
void
visit
(
Track
track
)
{
TransportationObject
to
=
new
TransportationObject
(
TransportationType
.
TRACK
);
mapAbstractTransportationSpace
(
track
,
to
);
finishTransportationMapping
(
to
);
}
@Override
public
void
visit
(
TransportationComplex
transportationComplex
)
{
TransportationObject
to
=
new
TransportationObject
(
TransportationType
.
TRANSPORTATION_COMPLEX
);
mapAbstractTransportationSpace
(
transportationComplex
,
to
);
finishTransportationMapping
(
to
);
}
private
void
finishTransportationMapping
(
TransportationObject
to
)
{
finishCityObjectConstruction
(
to
);
model
.
addTransportation
(
to
);
}
private
void
finishCityObjectConstruction
(
CityObject
co
)
{
co
.
unsetGmlGeometries
();
resolveAndClearReferences
();
updateEdgesAndVertices
(
co
);
}
private
void
mapAbstractTransportationSpace
(
AbstractTransportationSpace
ats
,
TransportationObject
to
)
{
to
.
setGmlObject
(
ats
);
parseAbstractTransportationSpaceGeometries
(
ats
,
to
);
for
(
TrafficSpaceProperty
tsp
:
ats
.
getTrafficSpaces
())
{
if
(
tsp
.
isSetObject
())
{
TransportationObject
trafficSpace
=
new
TransportationObject
(
TransportationType
.
TRAFFIC_SPACE
);
mapTrafficSpace
(
tsp
.
getObject
(),
trafficSpace
);
finishTransportationMapping
(
trafficSpace
);
to
.
getChildren
().
add
(
trafficSpace
);
}
}
for
(
AuxiliaryTrafficSpaceProperty
auxTrafficProp
:
ats
.
getAuxiliaryTrafficSpaces
())
{
if
(
auxTrafficProp
.
isSetObject
())
{
TransportationObject
trafficSpace
=
parseAuxiliaryTrafficSpace
(
auxTrafficProp
.
getObject
());
finishTransportationMapping
(
trafficSpace
);
to
.
addChild
(
trafficSpace
);
}
}
}
private
void
mapTrafficSpace
(
TrafficSpace
ts
,
TransportationObject
to
)
{
mapAbstractUnoccupiedSpace
(
ts
,
to
);
}
private
void
mapAbstractUnoccupiedSpace
(
AbstractUnoccupiedSpace
aus
,
CityObject
co
)
{
mapAbstractPhysicalSpace
(
aus
,
co
);
}
private
TransportationObject
parseAuxiliaryTrafficSpace
(
AuxiliaryTrafficSpace
ats
)
{
TransportationObject
to
=
new
TransportationObject
(
TransportationType
.
AUXILLIARY_TRAFFIC_SPACE
);
parseAbstractSpaceGeometries
(
ats
,
to
);
finishCityObjectConstruction
(
to
);
return
to
;
}
private
void
parseAbstractTransportationSpaceGeometries
(
AbstractTransportationSpace
space
,
CityObject
co
)
{
parseAndAddMultiSurface
(
space
.
getDeprecatedProperties
().
getLod1MultiSurface
(),
Lod
.
LOD1
,
co
);
parseAndAddMultiSurface
(
space
.
getDeprecatedProperties
().
getLod4MultiSurface
(),
Lod
.
LOD4
,
co
);
}
private
void
parseAbstractSpaceGeometries
(
AbstractSpace
as
,
CityObject
co
)
{
parseAndAddMultiSurface
(
as
.
getLod0MultiSurface
(),
Lod
.
LOD0
,
co
);
parseAndAddMultiSurface
(
as
.
getLod2MultiSurface
(),
Lod
.
LOD2
,
co
);
parseAndAddMultiSurface
(
as
.
getLod3MultiSurface
(),
Lod
.
LOD3
,
co
);
parseAndAddSolid
(
as
.
getLod1Solid
(),
Lod
.
LOD1
,
co
);
parseAndAddSolid
(
as
.
getLod2Solid
(),
Lod
.
LOD2
,
co
);
parseAndAddSolid
(
as
.
getLod3Solid
(),
Lod
.
LOD3
,
co
);
}
private
void
parseAndAddMultiSurface
(
MultiSurfaceProperty
msp
,
Lod
lod
,
CityObject
co
)
{
if
(
msp
==
null
||
msp
.
getObject
()
==
null
)
{
return
;
}
Geometry
geom
=
parseMultiSurface
(
msp
.
getObject
(),
lod
);
co
.
addGeometry
(
geom
);
}
private
void
parseAndAddSolid
(
SolidProperty
sp
,
Lod
lod
,
CityObject
co
)
{
if
(
sp
==
null
||
sp
.
getObject
()
==
null
)
{
return
;
}
Geometry
geom
=
parseSolid
(
sp
.
getObject
(),
lod
);
if
(
geom
!=
null
)
{
co
.
addGeometry
(
geom
);
}
}
private
void
parseAndAddCompositeSurface
(
MultiSurfaceProperty
ms
,
Lod
lod
,
CityObject
co
)
{
if
(
ms
==
null
||
ms
.
getObject
()
==
null
)
{
return
;
}
List
<
SurfaceProperty
>
surfaces
=
ms
.
getObject
().
getSurfaceMember
();
for
(
SurfaceProperty
surface
:
surfaces
)
{
if
(
surface
.
getObject
()
instanceof
CompositeSurface
cs
)
{
Geometry
geom
=
parseCompositeSurface
(
cs
,
lod
);
if
(
geom
!=
null
)
{
co
.
addGeometry
(
geom
);
}
}
}
}
private
void
parseImplicitGeometry
(
AbstractOccupiedSpace
aos
,
CityObject
co
)
{
for
(
int
i
=
1
;
i
<=
3
;
i
++)
{
if
(
aos
.
getImplicitRepresentation
(
i
)
==
null
)
{
continue
;
}
if
(
aos
.
getImplicitRepresentation
(
i
).
getObject
()
!=
null
)
{
ImplicitGeometry
impGeom
=
aos
.
getImplicitRepresentation
(
i
).
getObject
();
ImplicitGeometryHolder
igh
=
resolveImplicitGeometry
(
impGeom
,
i
);
if
(
igh
!=
null
)
{
co
.
addGeometry
(
igh
);
}
}
else
if
(
aos
.
getImplicitRepresentation
(
i
).
getHref
()
!=
null
)
{
// Hrefs of ImplicitGeometries point to its RelativeGeometry.
// Can be ignored for CD since the Href is only used for repeating the RelativeGeometry at different LODs
}
}
}
private
ImplicitGeometryHolder
resolveImplicitGeometry
(
ImplicitGeometry
ig
,
int
lodInt
)
{
ImplicitGeometryHolder
igh
=
null
;
if
(
ig
.
getLibraryObject
()
!=
null
)
{
Path
libraryObjectPath
=
directory
.
resolve
(
ig
.
getLibraryObject
());
LibraryObject
libObj
=
LibraryObject
.
of
(
libraryObjectPath
,
config
);
if
(
libObj
!=
null
)
{
igh
=
new
ImplicitGeometryHolder
(
ig
,
libObj
);
}
}
else
if
(
ig
.
getRelativeGeometry
()
!=
null
)
{
AbstractGeometry
aGeom
=
ig
.
getRelativeGeometry
().
getObject
();
Geometry
geom
=
null
;
Lod
lod
=
Lod
.
values
()[
lodInt
];
RelativeGeometry
relGeo
=
null
;
if
(
aGeom
instanceof
MultiSurface
ms
)
{
geom
=
parseMultiSurface
(
ms
,
lod
);
}
else
if
(
aGeom
instanceof
Solid
s
)
{
geom
=
parseSolid
(
s
,
lod
);
}
else
if
(
aGeom
instanceof
CompositeSurface
cs
)
{
geom
=
parseCompositeSurface
(
cs
,
lod
);
}
if
(
geom
!=
null
)
{
relGeo
=
RelativeGeometry
.
of
(
geom
);
igh
=
new
ImplicitGeometryHolder
(
ig
,
relGeo
);
}
}
else
{
logger
.
error
(
String
.
format
(
"Implicit geometry of GML-ID %s has no referenced geometry."
,
ig
.
getId
()));
}
return
igh
;
}
private
void
resolveAndClearReferences
()
{
for
(
ResolvableReference
ref
:
references
)
{
String
href
=
ref
.
href
();
if
(
href
.
startsWith
(
"#"
))
{
href
=
href
.
substring
(
1
);
}
Geometry
geom
=
ref
.
geometry
();
ConcretePolygon
concPoly
=
polygonMap
.
get
(
href
);
if
(
concPoly
==
null
)
{
if
(
logger
.
isWarnEnabled
())
{
logger
.
warn
(
Localization
.
getText
(
"FeatureMapper.polygonUnreferenced"
),
href
);
}
continue
;
}
if
(
concPoly
instanceof
CompositePolygon
comp
)
{
resolveCompositePolygon
(
comp
).
forEach
(
geom:
:
addPolygon
);
}
else
{
//
LinkedPolygon
lPoly
=
new
LinkedPolygon
(
concPoly
,
geom
);
if
(
geom
.
getParent
()
instanceof
BoundarySurface
bs
)
{
lPoly
.
setPartOfSurface
(
bs
);
if
(
bs
.
getParent
()
instanceof
Installation
bi
)
{
lPoly
.
setPartOfInstallation
(
bi
);
}
}
geom
.
addPolygon
(
lPoly
);
}
}
// clear storage for polygons and vertices
// probably faster than .clear() ?
references
=
new
ArrayList
<>();
vertexMap
=
new
HashMap
<>();
polygonMap
=
new
HashMap
<>();
}
private
List
<
ConcretePolygon
>
resolveCompositePolygon
(
CompositePolygon
comp
)
{
List
<
ConcretePolygon
>
polygons
=
new
ArrayList
<>();
for
(
ConcretePolygon
conc
:
comp
.
getCompositeMembers
())
{
if
(
conc
instanceof
CompositePolygon
recComp
)
{
polygons
.
addAll
(
resolveCompositePolygon
(
recComp
));
}
else
{
polygons
.
add
(
conc
);
}
}
return
polygons
;
}
private
void
readAbstractBuilding
(
org
.
citygml4j
.
core
.
model
.
building
.
AbstractBuilding
gmlAb
,
AbstractBuilding
cdBuilding
)
{
mapAbstractOccupiedSpace
(
gmlAb
,
cdBuilding
);
cdBuilding
.
setGmlObject
(
gmlAb
);
// parse deprecated geometries
parseAndAddMultiSurface
(
gmlAb
.
getDeprecatedProperties
().
getLod1MultiSurface
(),
Lod
.
LOD1
,
cdBuilding
);
parseAndAddMultiSurface
(
gmlAb
.
getDeprecatedProperties
().
getLod4MultiSurface
(),
Lod
.
LOD4
,
cdBuilding
);
parseAndAddSolid
(
gmlAb
.
getDeprecatedProperties
().
getLod4Solid
(),
Lod
.
LOD4
,
cdBuilding
);
for
(
BuildingInstallationProperty
biProp
:
gmlAb
.
getBuildingInstallations
())
{
var
gmlBi
=
biProp
.
getObject
();
if
(
gmlBi
==
null
)
{
// ignore empty properties
continue
;
}
Installation
bi
=
mapBuildingInstallation
(
gmlBi
);
cdBuilding
.
addBuildingInstallation
(
bi
);
}
for
(
BuildingRoomProperty
brProp
:
gmlAb
.
getBuildingRooms
())
{
var
gmlBr
=
brProp
.
getObject
();
if
(
gmlBr
==
null
)
{
continue
;
}
BuildingRoom
br
=
mapBuildingRoom
(
gmlBr
);
cdBuilding
.
addBuildingRoom
(
br
);
}
for
(
AbstractBuildingSubdivisionProperty
abs
:
gmlAb
.
getBuildingSubdivisions
())
{
var
gmlABS
=
abs
.
getObject
();
if
(
gmlABS
==
null
)
{
continue
;
}
if
(
gmlABS
instanceof
Storey
gmlStorey
)
{
de
.
hft
.
stuttgart
.
citydoctor2
.
datastructure
.
Storey
storey
=
mapBuildingStorey
(
gmlStorey
);
cdBuilding
.
addStorey
(
storey
);
}
else
if
(
gmlABS
instanceof
BuildingUnit
gmlBU
)
{
de
.
hft
.
stuttgart
.
citydoctor2
.
datastructure
.
BuildingUnit
bu
=
mapBuildingUnit
(
gmlBU
);
cdBuilding
.
addBuildingUnit
(
bu
);
}
}
SurfaceMapper
surfaceMapper
=
new
SurfaceMapper
(
polygonMap
,
references
,
vertexMap
,
config
);
for
(
AbstractSpaceBoundaryProperty
surfaceProp
:
gmlAb
.
getBoundaries
())
{
if
(!
surfaceProp
.
isSetObject
())
{
continue
;
}
AbstractSpaceBoundary
surface
=
surfaceProp
.
getObject
();
surface
.
accept
(
surfaceMapper
);
}
updatePartOfSurface
(
cdBuilding
,
surfaceMapper
);
cdBuilding
.
unsetGmlGeometries
();
resolveAndClearReferences
();
updateEdgesAndVertices
(
cdBuilding
);
for
(
BoundarySurface
bs
:
surfaceMapper
.
getSurfaces
())
{
updateEdgesAndVertices
(
bs
);
for
(
Opening
o
:
bs
.
getOpenings
())
{
updateEdgesAndVertices
(
o
);
}
}
for
(
Installation
bi
:
cdBuilding
.
getBuildingInstallations
())
{
updateEdgesAndVertices
(
bi
);
for
(
BoundarySurface
bs
:
bi
.
getBoundarySurfaces
())
{
updateEdgesAndVertices
(
bs
);
for
(
Opening
o
:
bs
.
getOpenings
())
{
updateEdgesAndVertices
(
o
);
}
}
}
for
(
BuildingFurnitureProperty
bfProp
:
gmlAb
.
getBuildingFurniture
())
{
var
gmlBf
=
bfProp
.
getObject
();
if
(
gmlBf
==
null
)
{
continue
;
}
BuildingRoomFurniture
bf
=
mapBuildingFurniture
(
gmlBf
);
cdBuilding
.
addBuildingRoomFurniture
(
bf
);
}
}
private
BuildingRoom
mapBuildingRoom
(
org
.
citygml4j
.
core
.
model
.
building
.
BuildingRoom
gmlBr
)
{
BuildingRoom
br
=
new
BuildingRoom
();
br
.
setGmlObject
(
gmlBr
);
mapAbstractUnoccupiedSpace
(
gmlBr
,
br
);
SurfaceMapper
surfaceMapper
=
new
SurfaceMapper
(
polygonMap
,
references
,
vertexMap
,
config
);
for
(
AbstractSpaceBoundaryProperty
surfaceProp
:
gmlBr
.
getBoundaries
())
{
if
(!
surfaceProp
.
isSetObject
())
{
continue
;
}
AbstractSpaceBoundary
surface
=
surfaceProp
.
getObject
();
surface
.
accept
(
surfaceMapper
);
}
for
(
BoundarySurface
bs
:
surfaceMapper
.
getSurfaces
())
{
br
.
addBoundarySurface
(
bs
);
for
(
Geometry
geom
:
bs
.
getGeometries
())
{
for
(
Polygon
p
:
geom
.
getPolygons
())
{
p
.
setPartOfSurface
(
bs
);
}
}
}
for
(
BuildingInstallationProperty
biProp
:
gmlBr
.
getBuildingInstallations
())
{
var
gmlBi
=
biProp
.
getObject
();
if
(
gmlBi
==
null
)
{
// ignore empty properties
continue
;
}
Installation
bi
=
mapBuildingInstallation
(
gmlBi
);
br
.
addRoomInstallation
(
bi
);
}
for
(
BuildingFurnitureProperty
bfProp
:
gmlBr
.
getBuildingFurniture
())
{
var
gmlHref
=
bfProp
.
getHref
();
if
(
gmlHref
==
null
)
{
continue
;
}
br
.
addFurnitureRef
(
bfProp
);
}
return
br
;
}
private
BuildingRoomFurniture
mapBuildingFurniture
(
BuildingFurniture
gmlAF
)
{
BuildingRoomFurniture
bf
=
new
BuildingRoomFurniture
();
bf
.
setGmlObject
(
gmlAF
);
mapAbstractOccupiedSpace
(
gmlAF
,
bf
);
bf
.
unsetGmlGeometries
();
SurfaceMapper
surfaceMapper
=
new
SurfaceMapper
(
polygonMap
,
references
,
vertexMap
,
config
);
for
(
AbstractSpaceBoundaryProperty
surfaceProp
:
gmlAF
.
getBoundaries
())
{
if
(!
surfaceProp
.
isSetObject
())
{
continue
;
}
AbstractSpaceBoundary
surface
=
surfaceProp
.
getObject
();
surface
.
accept
(
surfaceMapper
);
}
for
(
BoundarySurface
bs
:
surfaceMapper
.
getSurfaces
())
{
bf
.
addBoundarySurface
(
bs
);
for
(
Geometry
geom
:
bs
.
getGeometries
())
{
for
(
Polygon
p
:
geom
.
getPolygons
())
{
p
.
setPartOfSurface
(
bs
);
}
}
}
return
bf
;
}
private
de
.
hft
.
stuttgart
.
citydoctor2
.
datastructure
.
Storey
mapBuildingStorey
(
Storey
gmlStorey
)
{
de
.
hft
.
stuttgart
.
citydoctor2
.
datastructure
.
Storey
storey
=
new
de
.
hft
.
stuttgart
.
citydoctor2
.
datastructure
.
Storey
();
storey
.
setGmlObject
(
gmlStorey
);
mapAbstractSpace
(
gmlStorey
,
storey
);
storey
.
unsetGmlGeometries
();
SurfaceMapper
surfaceMapper
=
new
SurfaceMapper
(
polygonMap
,
references
,
vertexMap
,
config
);
for
(
AbstractSpaceBoundaryProperty
surfaceProp
:
gmlStorey
.
getBoundaries
())
{
if
(!
surfaceProp
.
isSetObject
())
{
continue
;
}
AbstractSpaceBoundary
surface
=
surfaceProp
.
getObject
();
surface
.
accept
(
surfaceMapper
);
}
for
(
BoundarySurface
bs
:
surfaceMapper
.
getSurfaces
())
{
storey
.
addBoundarySurface
(
bs
);
for
(
Geometry
geom
:
bs
.
getGeometries
())
{
for
(
Polygon
p
:
geom
.
getPolygons
())
{
p
.
setPartOfSurface
(
bs
);
}
}
}
return
storey
;
}
private
de
.
hft
.
stuttgart
.
citydoctor2
.
datastructure
.
BuildingUnit
mapBuildingUnit
(
BuildingUnit
gmlBU
)
{
de
.
hft
.
stuttgart
.
citydoctor2
.
datastructure
.
BuildingUnit
bu
=
new
de
.
hft
.
stuttgart
.
citydoctor2
.
datastructure
.
BuildingUnit
();
bu
.
setGmlObject
(
gmlBU
);
mapAbstractSpace
(
gmlBU
,
bu
);
bu
.
unsetGmlGeometries
();
SurfaceMapper
surfaceMapper
=
new
SurfaceMapper
(
polygonMap
,
references
,
vertexMap
,
config
);
for
(
AbstractSpaceBoundaryProperty
surfaceProp
:
gmlBU
.
getBoundaries
())
{
if
(!
surfaceProp
.
isSetObject
())
{
continue
;
}
AbstractSpaceBoundary
surface
=
surfaceProp
.
getObject
();
surface
.
accept
(
surfaceMapper
);
}
for
(
BoundarySurface
bs
:
surfaceMapper
.
getSurfaces
())
{
bu
.
addBoundarySurface
(
bs
);
for
(
Geometry
geom
:
bs
.
getGeometries
())
{
for
(
Polygon
p
:
geom
.
getPolygons
())
{
p
.
setPartOfSurface
(
bs
);
}
}
}
return
bu
;
}
private
void
updatePartOfSurface
(
AbstractBuilding
cdBuilding
,
SurfaceMapper
surfaceMapper
)
{
for
(
BoundarySurface
bs
:
surfaceMapper
.
getSurfaces
())
{
cdBuilding
.
addBoundarySurface
(
bs
);
for
(
Geometry
geom
:
bs
.
getGeometries
())
{
for
(
Polygon
p
:
geom
.
getPolygons
())
{
p
.
setPartOfSurface
(
bs
);
}
}
}
}
private
Installation
mapBuildingInstallation
(
org
.
citygml4j
.
core
.
model
.
building
.
BuildingInstallation
gmlBi
)
{
Installation
bi
=
new
Installation
();
bi
.
setGmlObject
(
gmlBi
);
mapAbstractOccupiedSpace
(
gmlBi
,
bi
);
GeometryProperty
<?>
lod2Prop
=
gmlBi
.
getDeprecatedProperties
().
getLod2Geometry
();
parseAndAddAbstractGeometry
(
lod2Prop
,
Lod
.
LOD2
,
bi
);
GeometryProperty
<?>
lod3Prop
=
gmlBi
.
getDeprecatedProperties
().
getLod3Geometry
();
parseAndAddAbstractGeometry
(
lod3Prop
,
Lod
.
LOD3
,
bi
);
GeometryProperty
<?>
lod4Prop
=
gmlBi
.
getDeprecatedProperties
().
getLod4Geometry
();
parseAndAddAbstractGeometry
(
lod4Prop
,
Lod
.
LOD4
,
bi
);
bi
.
unsetGmlGeometries
();
SurfaceMapper
surfaceMapper
=
new
SurfaceMapper
(
polygonMap
,
references
,
vertexMap
,
config
);
for
(
AbstractSpaceBoundaryProperty
surfaceProp
:
gmlBi
.
getBoundaries
())
{
if
(!
surfaceProp
.
isSetObject
())
{
continue
;
}
AbstractSpaceBoundary
surface
=
surfaceProp
.
getObject
();
surface
.
accept
(
surfaceMapper
);
}
for
(
BoundarySurface
bs
:
surfaceMapper
.
getSurfaces
())
{
bi
.
addBoundarySurface
(
bs
);
for
(
Geometry
geom
:
bs
.
getGeometries
())
{
for
(
Polygon
p
:
geom
.
getPolygons
())
{
p
.
setPartOfSurface
(
bs
);
p
.
setPartOfInstallation
(
bi
);
}
}
}
for
(
Geometry
geom
:
bi
.
getGeometries
())
{
for
(
Polygon
p
:
geom
.
getPolygons
())
{
p
.
setPartOfInstallation
(
bi
);
}
}
return
bi
;
}
private
void
parseAndAddAbstractGeometry
(
GeometryProperty
<?>
geomProp
,
Lod
lod
,
CityObject
co
)
{
if
(
geomProp
==
null
||
geomProp
.
getObject
()
==
null
)
{
return
;
}
AbstractGeometry
abstractGeometry
=
geomProp
.
getObject
();
if
(
abstractGeometry
instanceof
MultiSurface
ms
)
{
Geometry
geom
=
parseMultiSurface
(
ms
,
lod
);
co
.
addGeometry
(
geom
);
}
else
if
(
abstractGeometry
instanceof
Solid
solid
)
{
Geometry
geom
=
parseSolid
(
solid
,
lod
);
if
(
geom
!=
null
)
{
co
.
addGeometry
(
geom
);
}
}
else
{
logger
.
warn
(
"Cannot handle geometry type {}, ignoring"
,
abstractGeometry
.
getClass
().
getSimpleName
());
}
}
private
Geometry
parseSolid
(
AbstractSolid
abstractSolid
,
Lod
lod
)
{
if
(
abstractSolid
instanceof
Solid
s
)
{
return
handleSolidGeometry
(
s
,
lod
);
}
else
{
logger
.
warn
(
"Cannot handle solid class {}, can only process pure solids"
,
abstractSolid
.
getClass
().
getSimpleName
());
return
null
;
}
}
private
Geometry
handleSolidGeometry
(
Solid
solid
,
Lod
lod
)
{
ShellProperty
exteriorProperty
=
solid
.
getExterior
();
if
(
exteriorProperty
==
null
||
exteriorProperty
.
getObject
()
==
null
)
{
logger
.
warn
(
"Found solid {} without exterior hull, ignoring"
,
solid
.
getId
());
return
null
;
}
Geometry
geom
=
new
Geometry
(
GeometryType
.
SOLID
,
lod
);
Shell
exterior
=
solid
.
getExterior
().
getObject
();
Citygml3GeometryMapper
geometryMapper
=
new
Citygml3GeometryMapper
(
config
,
vertexMap
);
readSurfaceMember
(
geom
,
geometryMapper
,
exterior
.
getSurfaceMembers
());
return
geom
;
}
private
Geometry
parseMultiSurface
(
MultiSurface
ms
,
Lod
lod
)
{
Geometry
geom
=
new
Geometry
(
GeometryType
.
MULTI_SURFACE
,
lod
);
Citygml3GeometryMapper
geometryMapper
=
new
Citygml3GeometryMapper
(
config
,
vertexMap
);
readSurfaceMember
(
geom
,
geometryMapper
,
ms
.
getSurfaceMember
());
return
geom
;
}
private
void
readSurfaceMember
(
Geometry
geom
,
Citygml3GeometryMapper
geometryMapper
,
List
<
SurfaceProperty
>
surfaceMember
)
{
for
(
SurfaceProperty
prop
:
surfaceMember
)
{
if
(
prop
.
getHref
()
!=
null
)
{
references
.
add
(
new
ResolvableReference
(
prop
.
getHref
(),
geom
));
continue
;
}
if
(
prop
.
getObject
()
!=
null
)
{
AbstractSurface
as
=
prop
.
getObject
();
as
.
accept
(
geometryMapper
);
}
}
List
<
ConcretePolygon
>
polygons
=
geometryMapper
.
getPolygons
();
for
(
ConcretePolygon
concretePoly
:
polygons
)
{
geom
.
addPolygon
(
concretePoly
);
if
(
concretePoly
.
hasExistingGmlId
())
{
polygonMap
.
put
(
concretePoly
.
getGmlId
().
getGmlString
(),
concretePoly
);
}
}
}
private
Geometry
parseCompositeSurface
(
CompositeSurface
cs
,
Lod
lod
)
{
Geometry
geom
=
new
Geometry
(
GeometryType
.
COMPOSITE_SURFACE
,
lod
);
Citygml3GeometryMapper
geometryMapper
=
new
Citygml3GeometryMapper
(
config
,
vertexMap
);
readSurfaceMember
(
geom
,
geometryMapper
,
cs
.
getSurfaceMembers
());
return
geom
;
}
private
void
updateEdgesAndVertices
(
CityObject
co
)
{
// searching for neighboring vertices, replacing them with one single vertex to
// avoid later problems with edges and manifold problems
for
(
Geometry
geom
:
co
.
getGeometries
())
{
KDTree
tree
=
new
KDTree
();
for
(
Polygon
poly
:
geom
.
getPolygons
())
{
if
(
poly
instanceof
CompositePolygon
)
{
continue
;
}
LinearRing
lr
=
poly
.
getExteriorRing
();
updateRing
(
tree
,
lr
);
for
(
LinearRing
innerRing
:
poly
.
getInnerRings
())
{
updateRing
(
tree
,
innerRing
);
}
}
if
(!
config
.
useLowMemoryConsumption
())
{
// no low memory consumption mode meaning create all meta information in
// geometry
geom
.
updateEdgesAndVertices
();
}
}
}
private
void
updateRing
(
KDTree
tree
,
LinearRing
lr
)
{
for
(
int
i
=
0
;
i
<
lr
.
getVertices
().
size
();
i
++)
{
Vertex
v
=
lr
.
getVertices
().
get
(
i
);
List
<
Vertex
>
nodesInRange
=
tree
.
getNodesInRange
(
v
,
neighborDistance
);
if
(
nodesInRange
.
isEmpty
())
{
tree
.
add
(
v
);
}
else
{
// replace other vertex with any neighboring one
Vertex
original
=
nodesInRange
.
get
(
0
);
lr
.
setVertex
(
i
,
original
);
}
}
}
public
void
setCityModel
(
CityModel
cModel
)
{
model
.
setCityModel
(
cModel
);
}
public
CityDoctorModel
getModel
()
{
return
model
;
}
public
void
setCityGMLVersion
(
CityGMLVersion
cityGMLVersion
)
{
model
.
setParsedCityGMLVersion
(
cityGMLVersion
);
}
}
CityDoctorParent/CityDoctorModel/src/main/java/de/hft/stuttgart/citydoctor2/mapper/citygml3/Citygml3GeometryMapper.java
View file @
02de0a22
/*-
* Copyright 2020 Beuth Hochschule für Technik Berlin, Hochschule für Technik Stuttgart
*
*
* This file is part of CityDoctor2.
*
* CityDoctor2 is free software: you can redistribute it and/or modify
...
...
@@ -18,188 +18,187 @@
*/
package
de.hft.stuttgart.citydoctor2.mapper.citygml3
;
import
java.math.BigDecimal
;
import
java.math.RoundingMode
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
import
de.hft.stuttgart.citydoctor2.datastructure.*
;
import
de.hft.stuttgart.citydoctor2.datastructure.LinearRing
;
import
de.hft.stuttgart.citydoctor2.datastructure.*
;
import
de.hft.stuttgart.citydoctor2.datastructure.LinearRing.LinearRingType
;
import
de.hft.stuttgart.citydoctor2.parser.ParserConfiguration
;
import
de.hft.stuttgart.citydoctor2.utils.Localization
;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.Logger
;
import
org.locationtech.proj4j.BasicCoordinateTransform
;
import
org.locationtech.proj4j.ProjCoordinate
;
import
org.xmlobjects.gml.model.geometry.complexes.CompositeSurface
;
import
org.xmlobjects.gml.model.geometry.primitives.*
;
import
org.xmlobjects.gml.model.geometry.primitives.Polygon
;
import
org.xmlobjects.gml.model.geometry.primitives.*
;
import
org.xmlobjects.gml.visitor.GeometryWalker
;
import
de.hft.stuttgart.citydoctor2.datastructure.LinearRing.LinearRingType
;
import
de.hft.stuttgart.citydoctor2.parser.ParserConfiguration
;
import
de.hft.stuttgart.citydoctor2.utils.Localization
;
import
java.math.BigDecimal
;
import
java.math.RoundingMode
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
public
class
Citygml3GeometryMapper
extends
GeometryWalker
{
private
static
final
Logger
logger
=
LogManager
.
getLogger
(
Citygml3GeometryMapper
.
class
);
private
final
List
<
ConcretePolygon
>
polygons
=
new
ArrayList
<>();
private
LinearRing
currentRing
=
null
;
private
final
ParserConfiguration
config
;
private
final
ProjCoordinate
p1
=
new
ProjCoordinate
();
private
final
ProjCoordinate
p2
=
new
ProjCoordinate
();
private
final
Map
<
Vertex
,
Vertex
>
vertexMap
;
public
Citygml3GeometryMapper
(
ParserConfiguration
config
,
Map
<
Vertex
,
Vertex
>
vertices
)
{
this
.
config
=
config
;
this
.
vertexMap
=
vertices
;
}
@Override
public
void
visit
(
Polygon
polygon
)
{
parsePolygon
(
polygon
.
getId
(),
polygon
.
getExterior
(),
polygon
.
getInterior
());
if
(
polygon
.
getExterior
()
==
null
)
{
logger
.
warn
(
String
.
format
(
"No exterior: %s"
,
polygon
.
getId
()));
}
}
private
void
parsePolygon
(
String
id
,
AbstractRingProperty
exterior
,
List
<
AbstractRingProperty
>
interior
)
{
if
(
exterior
==
null
||
exterior
.
getObject
()
==
null
)
{
if
(
logger
.
isWarnEnabled
())
{
logger
.
warn
(
Localization
.
getText
(
"GeometryMapper.emptyPolygon"
));
}
return
;
}
ConcretePolygon
cdPoly
=
new
ConcretePolygon
();
polygons
.
add
(
cdPoly
);
if
(
id
!=
null
)
{
cdPoly
.
setGmlId
(
new
GmlId
(
id
));
}
currentRing
=
new
LinearRing
(
LinearRingType
.
EXTERIOR
);
exterior
.
getObject
().
accept
(
this
);
cdPoly
.
setExteriorRing
(
currentRing
);
for
(
AbstractRingProperty
interiorGmlRing
:
interior
)
{
AbstractRing
gmlRing
=
interiorGmlRing
.
getObject
();
if
(
gmlRing
==
null
)
{
continue
;
}
currentRing
=
new
LinearRing
(
LinearRingType
.
INTERIOR
);
gmlRing
.
accept
(
this
);
cdPoly
.
addInteriorRing
(
currentRing
);
}
}
@Override
public
void
visit
(
CompositeSurface
cs
){
if
(
cs
.
getSurfaceMembers
()
!=
null
&&
cs
.
getSurfaceMembers
().
isEmpty
())
{
logger
.
warn
(
"CompositeSurface %s is empty"
,
cs
.
getId
());
return
;
}
List
<
SurfaceProperty
>
surfaceMember
=
cs
.
getSurfaceMembers
();
Citygml3GeometryMapper
recursiveMapper
=
new
Citygml3GeometryMapper
(
config
,
vertexMap
);
CompositePolygon
comp
=
new
CompositePolygon
();
if
(
cs
.
getId
()
==
null
){
comp
.
setGmlId
(
GmlId
.
generateId
());
}
else
{
comp
.
setGmlId
(
new
GmlId
(
cs
.
getId
()));
}
for
(
SurfaceProperty
prop
:
surfaceMember
)
{
if
(
prop
.
getObject
()
!=
null
)
{
AbstractSurface
as
=
prop
.
getObject
();
as
.
accept
(
recursiveMapper
);
}
}
List
<
ConcretePolygon
>
compPolys
=
recursiveMapper
.
getPolygons
();
compPolys
.
forEach
(
comp:
:
addCompositeMember
);
polygons
.
add
(
comp
);
polygons
.
addAll
(
compPolys
);
}
@Override
public
void
visit
(
org
.
xmlobjects
.
gml
.
model
.
geometry
.
primitives
.
LinearRing
gmlRing
)
{
if
(
gmlRing
.
getSrsDimension
()
!=
null
&&
gmlRing
.
getSrsDimension
()
!=
3
)
{
logger
.
warn
(
"Cannot handle geometry with srsDimension not 3"
);
return
;
}
if
(
gmlRing
.
getId
()
!=
null
)
{
currentRing
.
setGmlId
(
new
GmlId
(
gmlRing
.
getId
()));
}
List
<
Double
>
coordinates
=
gmlRing
.
toCoordinateList3D
();
handleCoordinateList
(
coordinates
);
}
@Override
public
void
visit
(
Ring
ring
)
{
if
(
ring
.
getSrsDimension
()
!=
null
&&
ring
.
getSrsDimension
()
!=
3
)
{
logger
.
warn
(
"Cannot handle geometry with srsDimension not 3"
);
return
;
}
if
(
ring
.
getId
()
!=
null
)
{
currentRing
.
setGmlId
(
new
GmlId
(
ring
.
getId
()));
}
List
<
Double
>
coordinates
=
ring
.
toCoordinateList3D
();
handleCoordinateList
(
coordinates
);
}
private
void
handleCoordinateList
(
List
<
Double
>
coordinates
)
{
if
(
coordinates
.
size
()
%
3
!=
0
)
{
String
id
;
if
(
currentRing
.
hasExistingGmlId
())
{
id
=
currentRing
.
getGmlId
().
getGmlString
();
}
else
{
id
=
""
;
}
logger
.
warn
(
"The number of coordinates for linear ring {} do not result in fully 3D points"
,
id
);
}
for
(
int
i
=
0
;
i
<
coordinates
.
size
();
i
=
i
+
3
)
{
double
x
=
coordinates
.
get
(
i
);
double
y
=
coordinates
.
get
(
i
+
1
);
double
z
=
coordinates
.
get
(
i
+
2
);
createVertex
(
x
,
y
,
z
);
}
}
private
void
createVertex
(
double
x
,
double
y
,
double
z
)
{
// transform into utm, if available
BasicCoordinateTransform
trans
=
config
.
getTargetTransform
();
if
(
trans
!=
null
)
{
p1
.
setValue
(
x
,
y
);
trans
.
transform
(
p1
,
p2
);
x
=
p2
.
x
;
y
=
p2
.
y
;
z
=
z
/
config
.
getFromMeters
();
}
x
=
round
(
x
,
config
.
getNumberOfRoundingPlaces
());
y
=
round
(
y
,
config
.
getNumberOfRoundingPlaces
());
z
=
round
(
z
,
config
.
getNumberOfRoundingPlaces
());
Vertex
v
=
new
Vertex
(
x
,
y
,
z
);
Vertex
duplicate
=
vertexMap
.
get
(
v
);
if
(
duplicate
==
null
)
{
vertexMap
.
put
(
v
,
v
);
}
else
{
v
=
duplicate
;
}
currentRing
.
addVertex
(
v
);
}
private
double
round
(
double
value
,
int
places
)
{
if
(
places
<
0
)
{
throw
new
IllegalArgumentException
();
}
BigDecimal
bd
=
BigDecimal
.
valueOf
(
value
);
bd
=
bd
.
setScale
(
places
,
RoundingMode
.
HALF_UP
);
return
bd
.
doubleValue
();
}
public
List
<
ConcretePolygon
>
getPolygons
()
{
return
polygons
;
}
private
static
final
Logger
logger
=
LogManager
.
getLogger
(
Citygml3GeometryMapper
.
class
);
private
final
List
<
ConcretePolygon
>
polygons
=
new
ArrayList
<>();
private
LinearRing
currentRing
=
null
;
private
final
ParserConfiguration
config
;
private
final
ProjCoordinate
p1
=
new
ProjCoordinate
();
private
final
ProjCoordinate
p2
=
new
ProjCoordinate
();
private
final
Map
<
Vertex
,
Vertex
>
vertexMap
;
public
Citygml3GeometryMapper
(
ParserConfiguration
config
,
Map
<
Vertex
,
Vertex
>
vertices
)
{
this
.
config
=
config
;
this
.
vertexMap
=
vertices
;
}
@Override
public
void
visit
(
Polygon
polygon
)
{
parsePolygon
(
polygon
.
getId
(),
polygon
.
getExterior
(),
polygon
.
getInterior
());
if
(
polygon
.
getExterior
()
==
null
)
{
logger
.
warn
(
String
.
format
(
"No exterior: %s"
,
polygon
.
getId
()));
}
}
private
void
parsePolygon
(
String
id
,
AbstractRingProperty
exterior
,
List
<
AbstractRingProperty
>
interior
)
{
if
(
exterior
==
null
||
exterior
.
getObject
()
==
null
)
{
if
(
logger
.
isWarnEnabled
())
{
logger
.
warn
(
Localization
.
getText
(
"GeometryMapper.emptyPolygon"
));
}
return
;
}
ConcretePolygon
cdPoly
=
new
ConcretePolygon
();
polygons
.
add
(
cdPoly
);
if
(
id
!=
null
)
{
cdPoly
.
setGmlId
(
new
GmlId
(
id
));
}
currentRing
=
new
LinearRing
(
LinearRingType
.
EXTERIOR
);
exterior
.
getObject
().
accept
(
this
);
cdPoly
.
setExteriorRing
(
currentRing
);
for
(
AbstractRingProperty
interiorGmlRing
:
interior
)
{
AbstractRing
gmlRing
=
interiorGmlRing
.
getObject
();
if
(
gmlRing
==
null
)
{
continue
;
}
currentRing
=
new
LinearRing
(
LinearRingType
.
INTERIOR
);
gmlRing
.
accept
(
this
);
cdPoly
.
addInteriorRing
(
currentRing
);
}
}
@Override
public
void
visit
(
CompositeSurface
cs
)
{
if
(
cs
.
getSurfaceMembers
()
!=
null
&&
cs
.
getSurfaceMembers
().
isEmpty
())
{
logger
.
warn
(
"CompositeSurface %s is empty"
,
cs
.
getId
());
return
;
}
List
<
SurfaceProperty
>
surfaceMember
=
cs
.
getSurfaceMembers
();
Citygml3GeometryMapper
recursiveMapper
=
new
Citygml3GeometryMapper
(
config
,
vertexMap
);
CompositePolygon
comp
=
new
CompositePolygon
();
if
(
cs
.
getId
()
==
null
)
{
comp
.
setGmlId
(
GmlId
.
generateId
());
}
else
{
comp
.
setGmlId
(
new
GmlId
(
cs
.
getId
()));
}
for
(
SurfaceProperty
prop
:
surfaceMember
)
{
if
(
prop
.
getObject
()
!=
null
)
{
AbstractSurface
as
=
prop
.
getObject
();
as
.
accept
(
recursiveMapper
);
}
}
List
<
ConcretePolygon
>
compPolys
=
recursiveMapper
.
getPolygons
();
compPolys
.
forEach
(
comp:
:
addCompositeMember
);
polygons
.
add
(
comp
);
polygons
.
addAll
(
compPolys
);
}
@Override
public
void
visit
(
org
.
xmlobjects
.
gml
.
model
.
geometry
.
primitives
.
LinearRing
gmlRing
)
{
if
(
gmlRing
.
getSrsDimension
()
!=
null
&&
gmlRing
.
getSrsDimension
()
!=
3
)
{
logger
.
warn
(
"Cannot handle geometry with srsDimension not 3"
);
return
;
}
if
(
gmlRing
.
getId
()
!=
null
)
{
currentRing
.
setGmlId
(
new
GmlId
(
gmlRing
.
getId
()));
}
List
<
Double
>
coordinates
=
gmlRing
.
toCoordinateList3D
();
handleCoordinateList
(
coordinates
);
}
@Override
public
void
visit
(
Ring
ring
)
{
if
(
ring
.
getSrsDimension
()
!=
null
&&
ring
.
getSrsDimension
()
!=
3
)
{
logger
.
warn
(
"Cannot handle geometry with srsDimension not 3"
);
return
;
}
if
(
ring
.
getId
()
!=
null
)
{
currentRing
.
setGmlId
(
new
GmlId
(
ring
.
getId
()));
}
List
<
Double
>
coordinates
=
ring
.
toCoordinateList3D
();
handleCoordinateList
(
coordinates
);
}
private
void
handleCoordinateList
(
List
<
Double
>
coordinates
)
{
if
(
coordinates
.
size
()
%
3
!=
0
)
{
String
id
;
if
(
currentRing
.
hasExistingGmlId
())
{
id
=
currentRing
.
getGmlId
().
getGmlString
();
}
else
{
id
=
""
;
}
logger
.
warn
(
"The number of coordinates for linear ring {} do not result in fully 3D points"
,
id
);
}
for
(
int
i
=
0
;
i
<
coordinates
.
size
();
i
=
i
+
3
)
{
double
x
=
coordinates
.
get
(
i
);
double
y
=
coordinates
.
get
(
i
+
1
);
double
z
=
coordinates
.
get
(
i
+
2
);
createVertex
(
x
,
y
,
z
);
}
}
private
void
createVertex
(
double
x
,
double
y
,
double
z
)
{
// transform into utm, if available
BasicCoordinateTransform
trans
=
config
.
getTargetTransform
();
if
(
trans
!=
null
)
{
p1
.
setValue
(
x
,
y
);
trans
.
transform
(
p1
,
p2
);
x
=
p2
.
x
;
y
=
p2
.
y
;
z
=
z
/
config
.
getFromMeters
();
}
x
=
round
(
x
,
config
.
getNumberOfRoundingPlaces
());
y
=
round
(
y
,
config
.
getNumberOfRoundingPlaces
());
z
=
round
(
z
,
config
.
getNumberOfRoundingPlaces
());
Vertex
v
=
new
Vertex
(
x
,
y
,
z
);
Vertex
duplicate
=
vertexMap
.
get
(
v
);
if
(
duplicate
==
null
)
{
vertexMap
.
put
(
v
,
v
);
}
else
{
v
=
duplicate
;
}
currentRing
.
addVertex
(
v
);
}
private
double
round
(
double
value
,
int
places
)
{
if
(
places
<
0
)
{
throw
new
IllegalArgumentException
();
}
BigDecimal
bd
=
BigDecimal
.
valueOf
(
value
);
bd
=
bd
.
setScale
(
places
,
RoundingMode
.
HALF_UP
);
return
bd
.
doubleValue
();
}
public
List
<
ConcretePolygon
>
getPolygons
()
{
return
polygons
;
}
}
CityDoctorParent/CityDoctorModel/src/main/java/de/hft/stuttgart/citydoctor2/mapper/citygml3/SurfaceMapper.java
View file @
02de0a22
/*-
* Copyright 2022 Beuth Hochschule für Technik Berlin, Hochschule für Technik Stuttgart
*
*
* This file is part of CityDoctor2.
*
* CityDoctor2 is free software: you can redistribute it and/or modify
...
...
@@ -18,206 +18,192 @@
*/
package
de.hft.stuttgart.citydoctor2.mapper.citygml3
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
import
de.hft.stuttgart.citydoctor2.datastructure.*
;
import
org.citygml4j.core.model.construction.AbstractConstructionSurface
;
import
org.citygml4j.core.model.construction.AbstractFillingSurface
;
import
org.citygml4j.core.model.construction.AbstractFillingSurfaceProperty
;
import
org.citygml4j.core.model.construction.CeilingSurface
;
import
org.citygml4j.core.model.construction.DoorSurface
;
import
org.citygml4j.core.model.construction.FloorSurface
;
import
org.citygml4j.core.model.construction.GroundSurface
;
import
org.citygml4j.core.model.construction.InteriorWallSurface
;
import
org.citygml4j.core.model.construction.OuterCeilingSurface
;
import
org.citygml4j.core.model.construction.OuterFloorSurface
;
import
org.citygml4j.core.model.construction.RoofSurface
;
import
org.citygml4j.core.model.construction.WallSurface
;
import
org.citygml4j.core.model.construction.WindowSurface
;
import
de.hft.stuttgart.citydoctor2.parser.ParserConfiguration
;
import
org.citygml4j.core.model.construction.*
;
import
org.citygml4j.core.model.core.AbstractThematicSurface
;
import
org.citygml4j.core.model.core.ClosureSurface
;
import
org.citygml4j.core.visitor.ObjectWalker
;
import
org.xmlobjects.gml.model.geometry.aggregates.MultiSurface
;
import
org.xmlobjects.gml.model.geometry.aggregates.MultiSurfaceProperty
;
import
org.xmlobjects.gml.model.geometry.complexes.CompositeSurface
;
import
org.xmlobjects.gml.model.geometry.primitives.AbstractSurface
;
import
org.xmlobjects.gml.model.geometry.primitives.SurfaceProperty
;
import
de.hft.stuttgart.citydoctor2.parser.ParserConfiguration
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
public
class
SurfaceMapper
extends
ObjectWalker
{
private
final
List
<
BoundarySurface
>
surfaces
=
new
ArrayList
<>();
private
final
Map
<
String
,
ConcretePolygon
>
polygonMap
;
private
final
List
<
ResolvableReference
>
references
;
private
final
Map
<
Vertex
,
Vertex
>
vertexMap
;
private
final
ParserConfiguration
config
;
public
SurfaceMapper
(
Map
<
String
,
ConcretePolygon
>
polygonMap
,
List
<
ResolvableReference
>
references
,
Map
<
Vertex
,
Vertex
>
vertexMap
,
ParserConfiguration
config
)
{
this
.
polygonMap
=
polygonMap
;
this
.
references
=
references
;
this
.
vertexMap
=
vertexMap
;
this
.
config
=
config
;
}
@Override
public
void
visit
(
WallSurface
wallSurface
)
{
BoundarySurface
surface
=
new
BoundarySurface
(
SurfaceFeatureType
.
BUILDING
,
BoundarySurfaceType
.
WALL
,
wallSurface
);
handleConstructionSurface
(
wallSurface
,
surface
);
surfaces
.
add
(
surface
);
}
private
void
handleConstructionSurface
(
AbstractConstructionSurface
gmlSurface
,
BoundarySurface
cdSurface
)
{
for
(
AbstractFillingSurfaceProperty
fillingProp
:
gmlSurface
.
getFillingSurfaces
())
{
if
(
fillingProp
.
isSetObject
())
{
readAbstractFillingSurface
(
fillingProp
.
getObject
(),
cdSurface
);
}
}
handleThematicSurface
(
gmlSurface
,
cdSurface
);
cdSurface
.
unsetGmlGeometries
();
}
private
void
readAbstractFillingSurface
(
AbstractFillingSurface
afs
,
BoundarySurface
cdSurface
)
{
Opening
o
;
if
(
afs
instanceof
DoorSurface
ds
)
{
o
=
new
Opening
(
OpeningType
.
DOOR
,
SurfaceFeatureType
.
BUILDING
,
cdSurface
,
ds
);
}
else
if
(
afs
instanceof
WindowSurface
ws
){
o
=
new
Opening
(
OpeningType
.
WINDOW
,
SurfaceFeatureType
.
BUILDING
,
cdSurface
,
ws
);
}
else
{
o
=
new
Opening
(
OpeningType
.
UNKNOWN
,
SurfaceFeatureType
.
BUILDING
,
cdSurface
,
afs
);
}
cdSurface
.
addOpening
(
o
);
parseAndAddMultiSurface
(
afs
.
getLod0MultiSurface
(),
Lod
.
LOD0
,
o
);
parseAndAddMultiSurface
(
afs
.
getLod1MultiSurface
(),
Lod
.
LOD1
,
o
);
parseAndAddMultiSurface
(
afs
.
getLod2MultiSurface
(),
Lod
.
LOD2
,
o
);
parseAndAddMultiSurface
(
afs
.
getLod3MultiSurface
(),
Lod
.
LOD3
,
o
);
parseAndAddMultiSurface
(
afs
.
getDeprecatedProperties
().
getLod4MultiSurface
(),
Lod
.
LOD4
,
o
);
o
.
unsetGmlGeometries
();
}
private
void
handleThematicSurface
(
AbstractThematicSurface
gmlSurface
,
CityObject
cdSurface
)
{
Citygml3FeatureMapper
.
parseId
(
gmlSurface
,
cdSurface
);
parseAndAddMultiSurface
(
gmlSurface
.
getLod0MultiSurface
(),
Lod
.
LOD0
,
cdSurface
);
parseAndAddMultiSurface
(
gmlSurface
.
getLod1MultiSurface
(),
Lod
.
LOD1
,
cdSurface
);
parseAndAddMultiSurface
(
gmlSurface
.
getLod2MultiSurface
(),
Lod
.
LOD2
,
cdSurface
);
parseAndAddMultiSurface
(
gmlSurface
.
getLod3MultiSurface
(),
Lod
.
LOD3
,
cdSurface
);
parseAndAddMultiSurface
(
gmlSurface
.
getDeprecatedProperties
().
getLod4MultiSurface
(),
Lod
.
LOD4
,
cdSurface
);
}
private
void
parseAndAddMultiSurface
(
MultiSurfaceProperty
msp
,
Lod
lod
,
CityObject
cdSurface
)
{
if
(
msp
==
null
||
msp
.
getObject
()
==
null
)
{
return
;
}
Geometry
geom
=
parseMultiSurface
(
msp
.
getObject
(),
lod
);
cdSurface
.
addGeometry
(
geom
);
}
private
Geometry
parseMultiSurface
(
MultiSurface
ms
,
Lod
lod
)
{
Geometry
geom
=
new
Geometry
(
GeometryType
.
MULTI_SURFACE
,
lod
);
Citygml3GeometryMapper
geometryMapper
=
new
Citygml3GeometryMapper
(
config
,
vertexMap
);
readSurfaceMember
(
geom
,
geometryMapper
,
ms
.
getSurfaceMember
());
return
geom
;
}
private
void
readSurfaceMember
(
Geometry
geom
,
Citygml3GeometryMapper
geometryMapper
,
List
<
SurfaceProperty
>
surfaceMember
)
{
for
(
SurfaceProperty
prop
:
surfaceMember
)
{
if
(
prop
.
getHref
()
!=
null
)
{
references
.
add
(
new
ResolvableReference
(
prop
.
getHref
(),
geom
));
continue
;
}
if
(
prop
.
getObject
()
!=
null
)
{
AbstractSurface
as
=
prop
.
getObject
();
as
.
accept
(
geometryMapper
);
}
}
List
<
ConcretePolygon
>
polygons
=
geometryMapper
.
getPolygons
();
for
(
ConcretePolygon
concretePoly
:
polygons
)
{
if
(
concretePoly
instanceof
CompositePolygon
comp
)
{
references
.
add
(
new
ResolvableReference
(
comp
.
getGmlId
().
toString
(),
geom
));
polygonMap
.
put
(
comp
.
getGmlId
().
toString
(),
comp
);
}
else
{
geom
.
addPolygon
(
concretePoly
);
if
(
concretePoly
.
hasExistingGmlId
())
{
polygonMap
.
put
(
concretePoly
.
getGmlId
().
getGmlString
(),
concretePoly
);
}
}
}
}
@Override
public
void
visit
(
FloorSurface
floorSurface
)
{
BoundarySurface
surface
=
new
BoundarySurface
(
SurfaceFeatureType
.
BUILDING
,
BoundarySurfaceType
.
FLOOR
,
floorSurface
);
handleConstructionSurface
(
floorSurface
,
surface
);
surfaces
.
add
(
surface
);
}
@Override
public
void
visit
(
CeilingSurface
ceilingSurface
)
{
BoundarySurface
surface
=
new
BoundarySurface
(
SurfaceFeatureType
.
BUILDING
,
BoundarySurfaceType
.
CEILING
,
ceilingSurface
);
handleConstructionSurface
(
ceilingSurface
,
surface
);
surfaces
.
add
(
surface
);
}
@Override
public
void
visit
(
GroundSurface
groundSurface
)
{
BoundarySurface
surface
=
new
BoundarySurface
(
SurfaceFeatureType
.
BUILDING
,
BoundarySurfaceType
.
GROUND
,
groundSurface
);
handleConstructionSurface
(
groundSurface
,
surface
);
surfaces
.
add
(
surface
);
}
@Override
public
void
visit
(
InteriorWallSurface
interiorWallSurface
)
{
BoundarySurface
surface
=
new
BoundarySurface
(
SurfaceFeatureType
.
BUILDING
,
BoundarySurfaceType
.
INTERIOR_WALL
,
interiorWallSurface
);
handleConstructionSurface
(
interiorWallSurface
,
surface
);
surfaces
.
add
(
surface
);
}
@Override
public
void
visit
(
OuterCeilingSurface
outerCeilingSurface
)
{
BoundarySurface
surface
=
new
BoundarySurface
(
SurfaceFeatureType
.
BUILDING
,
BoundarySurfaceType
.
OUTER_CEILING
,
outerCeilingSurface
);
handleConstructionSurface
(
outerCeilingSurface
,
surface
);
surfaces
.
add
(
surface
);
}
@Override
public
void
visit
(
OuterFloorSurface
outerFloorSurface
)
{
BoundarySurface
surface
=
new
BoundarySurface
(
SurfaceFeatureType
.
BUILDING
,
BoundarySurfaceType
.
OUTER_FLOOR
,
outerFloorSurface
);
handleConstructionSurface
(
outerFloorSurface
,
surface
);
surfaces
.
add
(
surface
);
}
@Override
public
void
visit
(
RoofSurface
roofSurface
)
{
BoundarySurface
surface
=
new
BoundarySurface
(
SurfaceFeatureType
.
BUILDING
,
BoundarySurfaceType
.
ROOF
,
roofSurface
);
handleConstructionSurface
(
roofSurface
,
surface
);
surfaces
.
add
(
surface
);
}
@Override
public
void
visit
(
ClosureSurface
closureSurface
)
{
BoundarySurface
surface
=
new
BoundarySurface
(
SurfaceFeatureType
.
BUILDING
,
BoundarySurfaceType
.
CLOSURE
,
closureSurface
);
handleThematicSurface
(
closureSurface
,
surface
);
surfaces
.
add
(
surface
);
}
public
List
<
BoundarySurface
>
getSurfaces
()
{
return
surfaces
;
}
private
final
List
<
BoundarySurface
>
surfaces
=
new
ArrayList
<>();
private
final
Map
<
String
,
ConcretePolygon
>
polygonMap
;
private
final
List
<
ResolvableReference
>
references
;
private
final
Map
<
Vertex
,
Vertex
>
vertexMap
;
private
final
ParserConfiguration
config
;
public
SurfaceMapper
(
Map
<
String
,
ConcretePolygon
>
polygonMap
,
List
<
ResolvableReference
>
references
,
Map
<
Vertex
,
Vertex
>
vertexMap
,
ParserConfiguration
config
)
{
this
.
polygonMap
=
polygonMap
;
this
.
references
=
references
;
this
.
vertexMap
=
vertexMap
;
this
.
config
=
config
;
}
@Override
public
void
visit
(
WallSurface
wallSurface
)
{
BoundarySurface
surface
=
new
BoundarySurface
(
SurfaceFeatureType
.
BUILDING
,
BoundarySurfaceType
.
WALL
,
wallSurface
);
handleConstructionSurface
(
wallSurface
,
surface
);
surfaces
.
add
(
surface
);
}
private
void
handleConstructionSurface
(
AbstractConstructionSurface
gmlSurface
,
BoundarySurface
cdSurface
)
{
for
(
AbstractFillingSurfaceProperty
fillingProp
:
gmlSurface
.
getFillingSurfaces
())
{
if
(
fillingProp
.
isSetObject
())
{
readAbstractFillingSurface
(
fillingProp
.
getObject
(),
cdSurface
);
}
}
handleThematicSurface
(
gmlSurface
,
cdSurface
);
cdSurface
.
unsetGmlGeometries
();
}
private
void
readAbstractFillingSurface
(
AbstractFillingSurface
afs
,
BoundarySurface
cdSurface
)
{
Opening
o
;
if
(
afs
instanceof
DoorSurface
ds
)
{
o
=
new
Opening
(
OpeningType
.
DOOR
,
SurfaceFeatureType
.
BUILDING
,
cdSurface
,
ds
);
}
else
if
(
afs
instanceof
WindowSurface
ws
)
{
o
=
new
Opening
(
OpeningType
.
WINDOW
,
SurfaceFeatureType
.
BUILDING
,
cdSurface
,
ws
);
}
else
{
o
=
new
Opening
(
OpeningType
.
UNKNOWN
,
SurfaceFeatureType
.
BUILDING
,
cdSurface
,
afs
);
}
cdSurface
.
addOpening
(
o
);
parseAndAddMultiSurface
(
afs
.
getLod0MultiSurface
(),
Lod
.
LOD0
,
o
);
parseAndAddMultiSurface
(
afs
.
getLod1MultiSurface
(),
Lod
.
LOD1
,
o
);
parseAndAddMultiSurface
(
afs
.
getLod2MultiSurface
(),
Lod
.
LOD2
,
o
);
parseAndAddMultiSurface
(
afs
.
getLod3MultiSurface
(),
Lod
.
LOD3
,
o
);
parseAndAddMultiSurface
(
afs
.
getDeprecatedProperties
().
getLod4MultiSurface
(),
Lod
.
LOD4
,
o
);
o
.
unsetGmlGeometries
();
}
private
void
handleThematicSurface
(
AbstractThematicSurface
gmlSurface
,
CityObject
cdSurface
)
{
Citygml3FeatureMapper
.
parseId
(
gmlSurface
,
cdSurface
);
parseAndAddMultiSurface
(
gmlSurface
.
getLod0MultiSurface
(),
Lod
.
LOD0
,
cdSurface
);
parseAndAddMultiSurface
(
gmlSurface
.
getLod1MultiSurface
(),
Lod
.
LOD1
,
cdSurface
);
parseAndAddMultiSurface
(
gmlSurface
.
getLod2MultiSurface
(),
Lod
.
LOD2
,
cdSurface
);
parseAndAddMultiSurface
(
gmlSurface
.
getLod3MultiSurface
(),
Lod
.
LOD3
,
cdSurface
);
parseAndAddMultiSurface
(
gmlSurface
.
getDeprecatedProperties
().
getLod4MultiSurface
(),
Lod
.
LOD4
,
cdSurface
);
}
private
void
parseAndAddMultiSurface
(
MultiSurfaceProperty
msp
,
Lod
lod
,
CityObject
cdSurface
)
{
if
(
msp
==
null
||
msp
.
getObject
()
==
null
)
{
return
;
}
Geometry
geom
=
parseMultiSurface
(
msp
.
getObject
(),
lod
);
cdSurface
.
addGeometry
(
geom
);
}
private
Geometry
parseMultiSurface
(
MultiSurface
ms
,
Lod
lod
)
{
Geometry
geom
=
new
Geometry
(
GeometryType
.
MULTI_SURFACE
,
lod
);
Citygml3GeometryMapper
geometryMapper
=
new
Citygml3GeometryMapper
(
config
,
vertexMap
);
readSurfaceMember
(
geom
,
geometryMapper
,
ms
.
getSurfaceMember
());
return
geom
;
}
private
void
readSurfaceMember
(
Geometry
geom
,
Citygml3GeometryMapper
geometryMapper
,
List
<
SurfaceProperty
>
surfaceMember
)
{
for
(
SurfaceProperty
prop
:
surfaceMember
)
{
if
(
prop
.
getHref
()
!=
null
)
{
references
.
add
(
new
ResolvableReference
(
prop
.
getHref
(),
geom
));
continue
;
}
if
(
prop
.
getObject
()
!=
null
)
{
AbstractSurface
as
=
prop
.
getObject
();
as
.
accept
(
geometryMapper
);
}
}
List
<
ConcretePolygon
>
polygons
=
geometryMapper
.
getPolygons
();
for
(
ConcretePolygon
concretePoly
:
polygons
)
{
if
(
concretePoly
instanceof
CompositePolygon
comp
)
{
references
.
add
(
new
ResolvableReference
(
comp
.
getGmlId
().
toString
(),
geom
));
polygonMap
.
put
(
comp
.
getGmlId
().
toString
(),
comp
);
}
else
{
geom
.
addPolygon
(
concretePoly
);
if
(
concretePoly
.
hasExistingGmlId
())
{
polygonMap
.
put
(
concretePoly
.
getGmlId
().
getGmlString
(),
concretePoly
);
}
}
}
}
@Override
public
void
visit
(
FloorSurface
floorSurface
)
{
BoundarySurface
surface
=
new
BoundarySurface
(
SurfaceFeatureType
.
BUILDING
,
BoundarySurfaceType
.
FLOOR
,
floorSurface
);
handleConstructionSurface
(
floorSurface
,
surface
);
surfaces
.
add
(
surface
);
}
@Override
public
void
visit
(
CeilingSurface
ceilingSurface
)
{
BoundarySurface
surface
=
new
BoundarySurface
(
SurfaceFeatureType
.
BUILDING
,
BoundarySurfaceType
.
CEILING
,
ceilingSurface
);
handleConstructionSurface
(
ceilingSurface
,
surface
);
surfaces
.
add
(
surface
);
}
@Override
public
void
visit
(
GroundSurface
groundSurface
)
{
BoundarySurface
surface
=
new
BoundarySurface
(
SurfaceFeatureType
.
BUILDING
,
BoundarySurfaceType
.
GROUND
,
groundSurface
);
handleConstructionSurface
(
groundSurface
,
surface
);
surfaces
.
add
(
surface
);
}
@Override
public
void
visit
(
InteriorWallSurface
interiorWallSurface
)
{
BoundarySurface
surface
=
new
BoundarySurface
(
SurfaceFeatureType
.
BUILDING
,
BoundarySurfaceType
.
INTERIOR_WALL
,
interiorWallSurface
);
handleConstructionSurface
(
interiorWallSurface
,
surface
);
surfaces
.
add
(
surface
);
}
@Override
public
void
visit
(
OuterCeilingSurface
outerCeilingSurface
)
{
BoundarySurface
surface
=
new
BoundarySurface
(
SurfaceFeatureType
.
BUILDING
,
BoundarySurfaceType
.
OUTER_CEILING
,
outerCeilingSurface
);
handleConstructionSurface
(
outerCeilingSurface
,
surface
);
surfaces
.
add
(
surface
);
}
@Override
public
void
visit
(
OuterFloorSurface
outerFloorSurface
)
{
BoundarySurface
surface
=
new
BoundarySurface
(
SurfaceFeatureType
.
BUILDING
,
BoundarySurfaceType
.
OUTER_FLOOR
,
outerFloorSurface
);
handleConstructionSurface
(
outerFloorSurface
,
surface
);
surfaces
.
add
(
surface
);
}
@Override
public
void
visit
(
RoofSurface
roofSurface
)
{
BoundarySurface
surface
=
new
BoundarySurface
(
SurfaceFeatureType
.
BUILDING
,
BoundarySurfaceType
.
ROOF
,
roofSurface
);
handleConstructionSurface
(
roofSurface
,
surface
);
surfaces
.
add
(
surface
);
}
@Override
public
void
visit
(
ClosureSurface
closureSurface
)
{
BoundarySurface
surface
=
new
BoundarySurface
(
SurfaceFeatureType
.
BUILDING
,
BoundarySurfaceType
.
CLOSURE
,
closureSurface
);
handleThematicSurface
(
closureSurface
,
surface
);
surfaces
.
add
(
surface
);
}
public
List
<
BoundarySurface
>
getSurfaces
()
{
return
surfaces
;
}
}
CityDoctorParent/CityDoctorModel/src/main/java/de/hft/stuttgart/citydoctor2/utils/CityGmlUtils.java
View file @
02de0a22
/*-
* Copyright 2020 Beuth Hochschule für Technik Berlin, Hochschule für Technik Stuttgart
*
*
* This file is part of CityDoctor2.
*
* CityDoctor2 is free software: you can redistribute it and/or modify
...
...
@@ -18,209 +18,205 @@
*/
package
de.hft.stuttgart.citydoctor2.utils
;
import
java.util.ArrayList
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.Set
;
import
de.hft.stuttgart.citydoctor2.datastructure.LinearRing
;
import
de.hft.stuttgart.citydoctor2.datastructure.Polygon
;
import
de.hft.stuttgart.citydoctor2.datastructure.*
;
import
de.hft.stuttgart.citydoctor2.parser.ParserConfiguration
;
import
org.citygml4j.core.util.geometry.GeometryFactory
;
import
org.locationtech.proj4j.BasicCoordinateTransform
;
import
org.locationtech.proj4j.ProjCoordinate
;
import
org.xmlobjects.gml.model.geometry.aggregates.MultiSurface
;
import
org.xmlobjects.gml.model.geometry.complexes.CompositeSurface
;
import
org.xmlobjects.gml.model.geometry.primitives.AbstractRingProperty
;
import
org.xmlobjects.gml.model.geometry.primitives.Shell
;
import
org.xmlobjects.gml.model.geometry.primitives.ShellProperty
;
import
org.xmlobjects.gml.model.geometry.primitives.Solid
;
import
org.xmlobjects.gml.model.geometry.primitives.SurfaceProperty
;
import
org.xmlobjects.gml.model.geometry.primitives.*
;
import
de.hft.stuttgart.citydoctor2.parser.ParserConfiguration
;
import
java.util.ArrayList
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.Set
;
/**
* Utility class dedicated to create CityGML4j datastructures.
*
* @author Matthias Betz
*
* @author Matthias Betz
*/
public
final
class
CityGmlUtils
{
private
CityGmlUtils
()
{
// util class
}
public
static
org
.
xmlobjects
.
gml
.
model
.
geometry
.
primitives
.
Polygon
createGmlPolygon
(
GeometryFactory
factory
,
Polygon
cdPoly
,
ParserConfiguration
config
)
{
if
(
cdPoly
.
getExteriorRing
()
==
null
)
{
return
null
;
}
org
.
xmlobjects
.
gml
.
model
.
geometry
.
primitives
.
Polygon
gmlPoly
=
new
org
.
xmlobjects
.
gml
.
model
.
geometry
.
primitives
.
Polygon
();
// exterior ring
LinearRing
extLr
=
cdPoly
.
getExteriorRing
();
if
(
extLr
.
getVertices
().
size
()
<
3
)
{
// this ring does not have enough points in it
// this leads to errors when exporting therefore ignore it
return
null
;
}
org
.
xmlobjects
.
gml
.
model
.
geometry
.
primitives
.
LinearRing
gmlLr
=
createGmlRing
(
factory
,
config
,
extLr
);
gmlPoly
.
setExterior
(
new
AbstractRingProperty
(
gmlLr
));
// interior rings
for
(
LinearRing
lr
:
cdPoly
.
getInnerRings
())
{
gmlLr
=
createGmlRing
(
factory
,
config
,
lr
);
if
(
lr
.
getVertices
().
size
()
<
3
)
{
// this ring does not have enough points in it
// this leads to errors when exporting therefore ignore it
return
null
;
}
gmlPoly
.
getInterior
().
add
(
new
AbstractRingProperty
(
gmlLr
));
}
gmlPoly
.
setId
(
cdPoly
.
getGmlId
().
getGmlString
());
return
gmlPoly
;
}
public
static
CompositeSurface
createGmlComposite
(
GeometryFactory
factory
,
CompositePolygon
cdPoly
,
ParserConfiguration
config
)
{
List
<
ConcretePolygon
>
cdMembers
=
cdPoly
.
getCompositeMembers
();
List
<
SurfaceProperty
>
surfaces
=
new
ArrayList
<>();
for
(
ConcretePolygon
cd
:
cdMembers
)
{
surfaces
.
add
(
resolveCompositeMember
(
factory
,
cd
,
config
));
}
if
(
surfaces
.
isEmpty
()){
return
null
;
}
return
new
CompositeSurface
(
surfaces
);
}
private
static
SurfaceProperty
resolveCompositeMember
(
GeometryFactory
factory
,
ConcretePolygon
cdPoly
,
ParserConfiguration
config
){
if
(
cdPoly
instanceof
CompositePolygon
comp
)
{
return
new
SurfaceProperty
(
createGmlComposite
(
factory
,
comp
,
config
));
}
else
{
return
new
SurfaceProperty
(
createGmlPolygon
(
factory
,
cdPoly
,
config
));
}
}
public
static
org
.
xmlobjects
.
gml
.
model
.
geometry
.
primitives
.
LinearRing
createGmlRing
(
GeometryFactory
factory
,
ParserConfiguration
config
,
LinearRing
lr
)
{
ProjCoordinate
p1
=
new
ProjCoordinate
();
ProjCoordinate
p2
=
new
ProjCoordinate
();
List
<
Double
>
ringValues
=
new
ArrayList
<>();
BasicCoordinateTransform
trans
=
config
.
getOriginalTransform
();
for
(
Vertex
v
:
lr
.
getVertices
())
{
double
x
=
v
.
getX
();
double
y
=
v
.
getY
();
double
z
=
v
.
getZ
();
if
(
trans
!=
null
)
{
p1
.
x
=
x
;
p1
.
y
=
y
;
trans
.
transform
(
p1
,
p2
);
x
=
p2
.
x
;
y
=
p2
.
y
;
z
=
z
*
config
.
getFromMeters
();
}
ringValues
.
add
(
x
);
ringValues
.
add
(
y
);
ringValues
.
add
(
z
);
}
org
.
xmlobjects
.
gml
.
model
.
geometry
.
primitives
.
LinearRing
gmlLr
=
factory
.
createLinearRing
(
ringValues
,
3
);
gmlLr
.
setId
(
lr
.
getGmlId
().
getGmlString
());
return
gmlLr
;
}
public
static
Solid
createSolid
(
Geometry
geom
,
GeometryFactory
factory
,
ParserConfiguration
config
)
{
if
(
geom
.
getType
()
!=
GeometryType
.
SOLID
)
{
throw
new
IllegalArgumentException
(
"Only solids are allowed"
);
}
CompositeSurface
comp
=
new
CompositeSurface
();
List
<
SurfaceProperty
>
surfaceMember
=
comp
.
getSurfaceMembers
();
for
(
Polygon
cdPoly
:
geom
.
getPolygons
())
{
if
(!
cdPoly
.
isLink
())
{
org
.
xmlobjects
.
gml
.
model
.
geometry
.
primitives
.
Polygon
gmlPoly
=
createGmlPolygon
(
factory
,
cdPoly
,
config
);
if
(
gmlPoly
!=
null
)
{
surfaceMember
.
add
(
new
SurfaceProperty
(
gmlPoly
));
}
}
else
{
// add reference to polygon
surfaceMember
.
add
(
new
SurfaceProperty
(
"#"
+
cdPoly
.
getGmlId
().
getGmlString
()));
}
}
if
(
surfaceMember
.
isEmpty
())
{
return
null
;
}
Solid
solid
=
new
Solid
();
Shell
shell
=
new
Shell
(
surfaceMember
);
solid
.
setExterior
(
new
ShellProperty
(
shell
));
solid
.
setId
(
geom
.
getGmlId
().
getGmlString
());
return
solid
;
}
public
static
MultiSurface
createMultiSurface
(
Geometry
geom
,
GeometryFactory
factory
,
ParserConfiguration
config
)
{
if
(
geom
.
getType
()
!=
GeometryType
.
MULTI_SURFACE
&&
geom
.
getType
()
!=
GeometryType
.
COMPOSITE_SURFACE
)
{
throw
new
IllegalArgumentException
(
"This can only handle MultiSurfaces"
);
}
List
<
SurfaceProperty
>
surfaces
=
new
ArrayList
<>();
Set
<
CompositePolygon
>
compositePolygons
=
new
HashSet
<>();
for
(
Polygon
cdPoly
:
geom
.
getPolygons
())
{
if
(
cdPoly
instanceof
ConcretePolygon
conc
&&
conc
.
isCompositeMember
())
{
compositePolygons
.
add
(
conc
.
getPartOfComposite
());
}
else
if
(
cdPoly
instanceof
CompositePolygon
composite
)
{
compositePolygons
.
add
(
composite
);
}
else
if
(!
cdPoly
.
isLink
())
{
// is not part of a boundary surface
org
.
xmlobjects
.
gml
.
model
.
geometry
.
primitives
.
Polygon
gmlPoly
=
createGmlPolygon
(
factory
,
cdPoly
,
config
);
if
(
gmlPoly
!=
null
)
{
surfaces
.
add
(
new
SurfaceProperty
(
gmlPoly
));
}
}
else
{
// add reference to polygon
surfaces
.
add
(
new
SurfaceProperty
(
"#"
+
cdPoly
.
getGmlId
().
getGmlString
()));
}
}
for
(
CompositePolygon
cdPoly
:
compositePolygons
)
{
surfaces
.
add
(
new
SurfaceProperty
(
createGmlComposite
(
factory
,
cdPoly
,
config
)));
}
if
(
surfaces
.
isEmpty
())
{
return
null
;
}
MultiSurface
ms
=
new
MultiSurface
(
surfaces
);
ms
.
setId
(
geom
.
getGmlId
().
getGmlString
());
return
ms
;
}
public
static
MultiSurface
createMultiSurface
(
List
<
Polygon
>
polygons
,
GeometryFactory
factory
,
ParserConfiguration
config
)
{
List
<
SurfaceProperty
>
surfaces
=
new
ArrayList
<>();
for
(
Polygon
cdPoly
:
polygons
)
{
org
.
xmlobjects
.
gml
.
model
.
geometry
.
primitives
.
Polygon
gmlPoly
=
createGmlPolygon
(
factory
,
cdPoly
,
config
);
if
(
gmlPoly
!=
null
)
{
surfaces
.
add
(
new
SurfaceProperty
(
gmlPoly
));
}
}
if
(
surfaces
.
isEmpty
())
{
return
null
;
}
return
new
MultiSurface
(
surfaces
);
}
public
static
CompositeSurface
createCompositeSurface
(
Geometry
geom
,
GeometryFactory
factory
,
ParserConfiguration
config
)
{
List
<
SurfaceProperty
>
surfaces
=
new
ArrayList
<>();
for
(
Polygon
cdPoly
:
geom
.
getPolygons
())
{
org
.
xmlobjects
.
gml
.
model
.
geometry
.
primitives
.
Polygon
gmlPoly
=
createGmlPolygon
(
factory
,
cdPoly
,
config
);
if
(
gmlPoly
!=
null
)
{
surfaces
.
add
(
new
SurfaceProperty
(
gmlPoly
));
}
}
if
(
surfaces
.
isEmpty
())
{
return
null
;
}
return
new
CompositeSurface
(
surfaces
);
}
private
CityGmlUtils
()
{
// util class
}
public
static
org
.
xmlobjects
.
gml
.
model
.
geometry
.
primitives
.
Polygon
createGmlPolygon
(
GeometryFactory
factory
,
Polygon
cdPoly
,
ParserConfiguration
config
)
{
if
(
cdPoly
.
getExteriorRing
()
==
null
)
{
return
null
;
}
org
.
xmlobjects
.
gml
.
model
.
geometry
.
primitives
.
Polygon
gmlPoly
=
new
org
.
xmlobjects
.
gml
.
model
.
geometry
.
primitives
.
Polygon
();
// exterior ring
LinearRing
extLr
=
cdPoly
.
getExteriorRing
();
if
(
extLr
.
getVertices
().
size
()
<
3
)
{
// this ring does not have enough points in it
// this leads to errors when exporting therefore ignore it
return
null
;
}
org
.
xmlobjects
.
gml
.
model
.
geometry
.
primitives
.
LinearRing
gmlLr
=
createGmlRing
(
factory
,
config
,
extLr
);
gmlPoly
.
setExterior
(
new
AbstractRingProperty
(
gmlLr
));
// interior rings
for
(
LinearRing
lr
:
cdPoly
.
getInnerRings
())
{
gmlLr
=
createGmlRing
(
factory
,
config
,
lr
);
if
(
lr
.
getVertices
().
size
()
<
3
)
{
// this ring does not have enough points in it
// this leads to errors when exporting therefore ignore it
return
null
;
}
gmlPoly
.
getInterior
().
add
(
new
AbstractRingProperty
(
gmlLr
));
}
gmlPoly
.
setId
(
cdPoly
.
getGmlId
().
getGmlString
());
return
gmlPoly
;
}
public
static
CompositeSurface
createGmlComposite
(
GeometryFactory
factory
,
CompositePolygon
cdPoly
,
ParserConfiguration
config
)
{
List
<
ConcretePolygon
>
cdMembers
=
cdPoly
.
getCompositeMembers
();
List
<
SurfaceProperty
>
surfaces
=
new
ArrayList
<>();
for
(
ConcretePolygon
cd
:
cdMembers
)
{
surfaces
.
add
(
resolveCompositeMember
(
factory
,
cd
,
config
));
}
if
(
surfaces
.
isEmpty
())
{
return
null
;
}
return
new
CompositeSurface
(
surfaces
);
}
private
static
SurfaceProperty
resolveCompositeMember
(
GeometryFactory
factory
,
ConcretePolygon
cdPoly
,
ParserConfiguration
config
)
{
if
(
cdPoly
instanceof
CompositePolygon
comp
)
{
return
new
SurfaceProperty
(
createGmlComposite
(
factory
,
comp
,
config
));
}
else
{
return
new
SurfaceProperty
(
createGmlPolygon
(
factory
,
cdPoly
,
config
));
}
}
public
static
org
.
xmlobjects
.
gml
.
model
.
geometry
.
primitives
.
LinearRing
createGmlRing
(
GeometryFactory
factory
,
ParserConfiguration
config
,
LinearRing
lr
)
{
ProjCoordinate
p1
=
new
ProjCoordinate
();
ProjCoordinate
p2
=
new
ProjCoordinate
();
List
<
Double
>
ringValues
=
new
ArrayList
<>();
BasicCoordinateTransform
trans
=
config
.
getOriginalTransform
();
for
(
Vertex
v
:
lr
.
getVertices
())
{
double
x
=
v
.
getX
();
double
y
=
v
.
getY
();
double
z
=
v
.
getZ
();
if
(
trans
!=
null
)
{
p1
.
x
=
x
;
p1
.
y
=
y
;
trans
.
transform
(
p1
,
p2
);
x
=
p2
.
x
;
y
=
p2
.
y
;
z
=
z
*
config
.
getFromMeters
();
}
ringValues
.
add
(
x
);
ringValues
.
add
(
y
);
ringValues
.
add
(
z
);
}
org
.
xmlobjects
.
gml
.
model
.
geometry
.
primitives
.
LinearRing
gmlLr
=
factory
.
createLinearRing
(
ringValues
,
3
);
gmlLr
.
setId
(
lr
.
getGmlId
().
getGmlString
());
return
gmlLr
;
}
public
static
Solid
createSolid
(
Geometry
geom
,
GeometryFactory
factory
,
ParserConfiguration
config
)
{
if
(
geom
.
getType
()
!=
GeometryType
.
SOLID
)
{
throw
new
IllegalArgumentException
(
"Only solids are allowed"
);
}
CompositeSurface
comp
=
new
CompositeSurface
();
List
<
SurfaceProperty
>
surfaceMember
=
comp
.
getSurfaceMembers
();
for
(
Polygon
cdPoly
:
geom
.
getPolygons
())
{
if
(!
cdPoly
.
isLink
())
{
org
.
xmlobjects
.
gml
.
model
.
geometry
.
primitives
.
Polygon
gmlPoly
=
createGmlPolygon
(
factory
,
cdPoly
,
config
);
if
(
gmlPoly
!=
null
)
{
surfaceMember
.
add
(
new
SurfaceProperty
(
gmlPoly
));
}
}
else
{
// add reference to polygon
surfaceMember
.
add
(
new
SurfaceProperty
(
"#"
+
cdPoly
.
getGmlId
().
getGmlString
()));
}
}
if
(
surfaceMember
.
isEmpty
())
{
return
null
;
}
Solid
solid
=
new
Solid
();
Shell
shell
=
new
Shell
(
surfaceMember
);
solid
.
setExterior
(
new
ShellProperty
(
shell
));
solid
.
setId
(
geom
.
getGmlId
().
getGmlString
());
return
solid
;
}
public
static
MultiSurface
createMultiSurface
(
Geometry
geom
,
GeometryFactory
factory
,
ParserConfiguration
config
)
{
if
(
geom
.
getType
()
!=
GeometryType
.
MULTI_SURFACE
&&
geom
.
getType
()
!=
GeometryType
.
COMPOSITE_SURFACE
)
{
throw
new
IllegalArgumentException
(
"This can only handle MultiSurfaces"
);
}
List
<
SurfaceProperty
>
surfaces
=
new
ArrayList
<>();
Set
<
CompositePolygon
>
compositePolygons
=
new
HashSet
<>();
for
(
Polygon
cdPoly
:
geom
.
getPolygons
())
{
if
(
cdPoly
instanceof
ConcretePolygon
conc
&&
conc
.
isCompositeMember
())
{
compositePolygons
.
add
(
conc
.
getPartOfComposite
());
}
else
if
(
cdPoly
instanceof
CompositePolygon
composite
)
{
compositePolygons
.
add
(
composite
);
}
else
if
(!
cdPoly
.
isLink
())
{
// is not part of a boundary surface
org
.
xmlobjects
.
gml
.
model
.
geometry
.
primitives
.
Polygon
gmlPoly
=
createGmlPolygon
(
factory
,
cdPoly
,
config
);
if
(
gmlPoly
!=
null
)
{
surfaces
.
add
(
new
SurfaceProperty
(
gmlPoly
));
}
}
else
{
// add reference to polygon
surfaces
.
add
(
new
SurfaceProperty
(
"#"
+
cdPoly
.
getGmlId
().
getGmlString
()));
}
}
for
(
CompositePolygon
cdPoly
:
compositePolygons
)
{
surfaces
.
add
(
new
SurfaceProperty
(
createGmlComposite
(
factory
,
cdPoly
,
config
)));
}
if
(
surfaces
.
isEmpty
())
{
return
null
;
}
MultiSurface
ms
=
new
MultiSurface
(
surfaces
);
ms
.
setId
(
geom
.
getGmlId
().
getGmlString
());
return
ms
;
}
public
static
MultiSurface
createMultiSurface
(
List
<
Polygon
>
polygons
,
GeometryFactory
factory
,
ParserConfiguration
config
)
{
List
<
SurfaceProperty
>
surfaces
=
new
ArrayList
<>();
for
(
Polygon
cdPoly
:
polygons
)
{
org
.
xmlobjects
.
gml
.
model
.
geometry
.
primitives
.
Polygon
gmlPoly
=
createGmlPolygon
(
factory
,
cdPoly
,
config
);
if
(
gmlPoly
!=
null
)
{
surfaces
.
add
(
new
SurfaceProperty
(
gmlPoly
));
}
}
if
(
surfaces
.
isEmpty
())
{
return
null
;
}
return
new
MultiSurface
(
surfaces
);
}
public
static
CompositeSurface
createCompositeSurface
(
Geometry
geom
,
GeometryFactory
factory
,
ParserConfiguration
config
)
{
List
<
SurfaceProperty
>
surfaces
=
new
ArrayList
<>();
for
(
Polygon
cdPoly
:
geom
.
getPolygons
())
{
org
.
xmlobjects
.
gml
.
model
.
geometry
.
primitives
.
Polygon
gmlPoly
=
createGmlPolygon
(
factory
,
cdPoly
,
config
);
if
(
gmlPoly
!=
null
)
{
surfaces
.
add
(
new
SurfaceProperty
(
gmlPoly
));
}
}
if
(
surfaces
.
isEmpty
())
{
return
null
;
}
return
new
CompositeSurface
(
surfaces
);
}
}
CityDoctorParent/Extensions/CityDoctorGUI/src/main/java/de/hft/stuttgart/citydoctor2/gui/CityDoctorController.java
View file @
02de0a22
package
de.hft.stuttgart.citydoctor2.gui
;
import
java.io.File
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Optional
;
import
java.util.Set
;
import
java.util.StringJoiner
;
import
java.util.concurrent.atomic.AtomicInteger
;
import
java.util.function.Function
;
import
de.hft.stuttgart.citydoctor2.datastructure.*
;
import
de.hft.stuttgart.citydoctor2.gui.tree.*
;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.Logger
;
import
org.citygml4j.core.model.core.CityModel
;
import
org.xml.sax.SAXParseException
;
import
de.hft.stuttgart.citydoctor2.check.CheckError
;
import
de.hft.stuttgart.citydoctor2.check.Checker
;
import
de.hft.stuttgart.citydoctor2.check.ErrorId
;
import
de.hft.stuttgart.citydoctor2.check.ValidationConfiguration
;
import
de.hft.stuttgart.citydoctor2.check.error.SchematronError
;
import
de.hft.stuttgart.citydoctor2.datastructure.*
;
import
de.hft.stuttgart.citydoctor2.exceptions.CityDoctorWriteException
;
import
de.hft.stuttgart.citydoctor2.gui.table.ErrorStat
;
import
de.hft.stuttgart.citydoctor2.gui.tree.*
;
import
de.hft.stuttgart.citydoctor2.mapper.citygml3.GMLValidationHandler
;
import
de.hft.stuttgart.citydoctor2.parser.CityGmlParseException
;
import
de.hft.stuttgart.citydoctor2.parser.CityGmlParser
;
import
de.hft.stuttgart.citydoctor2.parser.InvalidGmlFileException
;
import
de.hft.stuttgart.citydoctor2.parser.ParserConfiguration
;
import
de.hft.stuttgart.citydoctor2.parser.ProgressListener
;
import
de.hft.stuttgart.citydoctor2.parser.*
;
import
de.hft.stuttgart.citydoctor2.utils.Localization
;
import
javafx.application.Platform
;
import
javafx.scene.chart.XYChart.Data
;
...
...
@@ -42,6 +21,15 @@ import javafx.scene.control.TreeItem;
import
javafx.scene.control.TreeView
;
import
javafx.stage.FileChooser
;
import
javafx.stage.FileChooser.ExtensionFilter
;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.Logger
;
import
org.citygml4j.core.model.core.CityModel
;
import
org.xml.sax.SAXParseException
;
import
java.io.File
;
import
java.util.*
;
import
java.util.concurrent.atomic.AtomicInteger
;
import
java.util.function.Function
;
public
class
CityDoctorController
{
...
...
@@ -150,7 +138,7 @@ public class CityDoctorController {
}
}
private
void
setupFeatureTabs
(){
private
void
setupFeatureTabs
()
{
mainWindow
.
setDisableOfFeatureTab
(
FeatureType
.
BUILDING
,
model
.
getBuildings
().
isEmpty
());
mainWindow
.
setDisableOfFeatureTab
(
FeatureType
.
VEGETATION
,
model
.
getVegetation
().
isEmpty
());
mainWindow
.
setDisableOfFeatureTab
(
FeatureType
.
TRANSPORTATION
,
model
.
getTransportation
().
isEmpty
());
...
...
@@ -298,7 +286,7 @@ public class CityDoctorController {
addMoreButtonIfNecessary
(
trans
,
transView
,
transRoot
,
transportationChunkNr
);
}
private
void
buildTunnel
(
List
<
Tunnel
>
tunnels
){
private
void
buildTunnel
(
List
<
Tunnel
>
tunnels
)
{
if
(
tunnels
.
isEmpty
())
{
return
;
}
...
...
@@ -575,7 +563,7 @@ public class CityDoctorController {
}
private
void
createBuildingStoreyNodes
(
Building
ab
,
TreeItem
<
Renderable
>
root
){
private
void
createBuildingStoreyNodes
(
Building
ab
,
TreeItem
<
Renderable
>
root
)
{
List
<
Storey
>
storeys
=
ab
.
getBuildingStoreys
();
if
(
storeys
.
isEmpty
())
{
return
;
...
...
@@ -1087,7 +1075,7 @@ public class CityDoctorController {
transportationChunkNr
);
}
public
void
fillTreeViewWithErrorTunnel
(){
public
void
fillTreeViewWithErrorTunnel
()
{
if
(
model
==
null
)
{
return
;
}
...
...
@@ -1264,7 +1252,7 @@ public class CityDoctorController {
return
currentConfig
;
}
public
void
setOriginBB
(
BoundingBox
origin
){
public
void
setOriginBB
(
BoundingBox
origin
)
{
this
.
originBB
=
origin
;
}
...
...
CityDoctorParent/Extensions/CityDoctorGUI/src/main/java/de/hft/stuttgart/citydoctor2/gui/MainToolBar.java
View file @
02de0a22
package
de.hft.stuttgart.citydoctor2.gui
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.Logger
;
import
de.hft.stuttgart.citydoctor2.gui.tree.Renderable
;
import
de.hft.stuttgart.citydoctor2.utils.Localization
;
import
javafx.fxml.FXML
;
import
javafx.fxml.FXMLLoader
;
import
javafx.scene.control.Button
;
import
javafx.scene.control.Tab
;
import
javafx.scene.control.TabPane
;
import
javafx.scene.control.ToggleButton
;
import
javafx.scene.control.Tooltip
;
import
javafx.scene.control.TreeView
;
import
javafx.scene.control.*
;
import
javafx.scene.image.Image
;
import
javafx.scene.image.ImageView
;
import
javafx.scene.layout.HBox
;
import
javafx.stage.Stage
;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.Logger
;
import
java.io.IOException
;
import
java.io.InputStream
;
public
class
MainToolBar
{
private
static
final
Logger
logger
=
LogManager
.
getLogger
(
MainToolBar
.
class
);
private
static
final
Logger
logger
=
LogManager
.
getLogger
(
MainToolBar
.
class
);
@FXML
private
Button
saveBtn
;
@FXML
private
Button
saveBtn
;
@FXML
private
ImageView
saveView
;
@FXML
private
ImageView
saveView
;
@FXML
private
Button
openBtn
;
@FXML
private
Button
openBtn
;
@FXML
private
ImageView
openImageView
;
@FXML
private
ImageView
openImageView
;
@FXML
private
Button
checkBtn
;
@FXML
private
Button
checkBtn
;
@FXML
private
ImageView
checkImageView
;
@FXML
private
ImageView
checkImageView
;
@FXML
private
Button
showWorldBtn
;
@FXML
private
Button
showWorldBtn
;
@FXML
private
ImageView
showWorldImageView
;
@FXML
private
ImageView
showWorldImageView
;
@FXML
private
ToggleButton
hideRoofBtn
;
@FXML
private
ToggleButton
hideRoofBtn
;
@FXML
private
ImageView
hideRoofView
;
@FXML
private
ImageView
hideRoofView
;
@FXML
private
Button
resetCameraBtn
;
@FXML
private
Button
resetCameraBtn
;
@FXML
private
ImageView
resetCameraView
;
@FXML
private
ImageView
resetCameraView
;
@FXML
private
Button
schematronBtn
;
@FXML
private
Button
schematronBtn
;
@FXML
private
ImageView
schematronImgView
;
@FXML
private
ImageView
schematronImgView
;
@FXML
private
ToggleButton
lod1Btn
;
@FXML
private
ToggleButton
lod1Btn
;
@FXML
private
ImageView
lod1View
;
@FXML
private
ImageView
lod1View
;
@FXML
private
ToggleButton
lod2Btn
;
@FXML
private
ToggleButton
lod2Btn
;
@FXML
private
ImageView
lod2View
;
@FXML
private
ImageView
lod2View
;
@FXML
private
ToggleButton
lod3Btn
;
@FXML
private
ToggleButton
lod3Btn
;
@FXML
private
ImageView
lod3View
;
@FXML
private
ImageView
lod3View
;
@FXML
private
ToggleButton
lod4Btn
;
@FXML
private
ToggleButton
lod4Btn
;
@FXML
private
ImageView
lod4View
;
@FXML
private
ImageView
lod4View
;
@FXML
private
Button
aboutBtn
;
@FXML
private
ImageView
aboutImgView
;
@FXML
private
ToggleButton
gridButton
;
@FXML
private
ToggleButton
cullingButton
;
@FXML
private
ImageView
cullingImageView
;
@FXML
private
ImageView
gridImageView
;
@FXML
private
Button
reportBtn
;
@FXML
private
ImageView
reportImageView
;
private
OpenFileDialog
fileDialog
;
private
CheckDialog
checkDialog
;
private
WriteReportDialog
writeDialog
;
private
AboutDialog
aboutDialog
;
private
CityDoctorController
controller
;
private
TabPane
featurePane
;
private
Stage
stage
;
private
Renderer
renderer
;
private
MainWindow
mainWindow
;
private
HBox
toolBar
;
public
MainToolBar
(
Stage
stage
,
CityDoctorController
controller
,
TabPane
featurePane
,
Renderer
renderer
,
MainWindow
mainWindow
)
throws
IOException
{
this
.
controller
=
controller
;
this
.
featurePane
=
featurePane
;
this
.
renderer
=
renderer
;
this
.
stage
=
stage
;
this
.
mainWindow
=
mainWindow
;
FXMLLoader
loader
=
new
FXMLLoader
(
MainToolBar
.
class
.
getResource
(
"MainToolBar.fxml"
));
loader
.
setController
(
this
);
toolBar
=
loader
.
load
();
fileDialog
=
new
OpenFileDialog
(
stage
,
controller
);
}
public
void
initialize
()
{
openBtn
.
setOnAction
(
ae
->
fileDialog
.
show
());
setupSaveBtn
();
setupCheckButton
();
setupLodButtons
();
setupAboutButton
();
setupReportButton
();
setupResetCameraButton
();
setupHideRoofButton
();
loadImages
();
gridButton
.
setOnAction
(
ae
->
renderer
.
showWireFrame
(
gridButton
.
isSelected
()));
gridButton
.
setTooltip
(
new
Tooltip
(
Localization
.
getText
(
"MainToolBar.wireframe"
)));
cullingButton
.
setOnAction
(
ae
->
renderer
.
enableCulling
(
cullingButton
.
isSelected
()));
cullingButton
.
setTooltip
(
new
Tooltip
(
Localization
.
getText
(
"MainToolBar.culling"
)));
showWorldBtn
.
setOnAction
(
ar
->
{
Tab
selectedItem
=
featurePane
.
getSelectionModel
().
getSelectedItem
();
if
(
selectedItem
.
getContent
()
instanceof
TreeView
)
{
@SuppressWarnings
(
"unchecked"
)
TreeView
<
Renderable
>
content
=
(
TreeView
<
Renderable
>)
selectedItem
.
getContent
();
content
.
getSelectionModel
().
clearSelection
();
}
controller
.
showWorld
();
});
showWorldBtn
.
setTooltip
(
new
Tooltip
(
Localization
.
getText
(
"MainToolBar.showWorld"
)));
}
private
void
loadImages
()
{
try
{
try
(
InputStream
inStream
=
MainWindow
.
class
.
getResourceAsStream
(
"icons/openFolderIcon.png"
))
{
Image
img
=
new
Image
(
inStream
);
openImageView
.
setImage
(
img
);
}
try
(
InputStream
inStream
=
MainWindow
.
class
.
getResourceAsStream
(
"icons/check32x32.png"
))
{
Image
img
=
new
Image
(
inStream
);
checkImageView
.
setImage
(
img
);
}
try
(
InputStream
inStream
=
MainWindow
.
class
.
getResourceAsStream
(
"icons/wireframe32x32.png"
))
{
Image
img
=
new
Image
(
inStream
);
gridImageView
.
setImage
(
img
);
}
try
(
InputStream
inStream
=
MainWindow
.
class
.
getResourceAsStream
(
"icons/Culling.png"
))
{
Image
img
=
new
Image
(
inStream
);
cullingImageView
.
setImage
(
img
);
}
try
(
InputStream
inStream
=
MainWindow
.
class
.
getResourceAsStream
(
"icons/error_stat32x32.png"
))
{
Image
img
=
new
Image
(
inStream
);
reportImageView
.
setImage
(
img
);
}
try
(
InputStream
inStream
=
MainWindow
.
class
.
getResourceAsStream
(
"icons/scene.png"
))
{
Image
img
=
new
Image
(
inStream
);
showWorldImageView
.
setImage
(
img
);
}
try
(
InputStream
inStream
=
MainWindow
.
class
.
getResourceAsStream
(
"icons/lod1_32x32.png"
))
{
Image
img
=
new
Image
(
inStream
);
lod1View
.
setImage
(
img
);
}
try
(
InputStream
inStream
=
MainWindow
.
class
.
getResourceAsStream
(
"icons/lod2_32x32.png"
))
{
Image
img
=
new
Image
(
inStream
);
lod2View
.
setImage
(
img
);
}
try
(
InputStream
inStream
=
MainWindow
.
class
.
getResourceAsStream
(
"icons/lod3_32x32.png"
))
{
Image
img
=
new
Image
(
inStream
);
lod3View
.
setImage
(
img
);
}
try
(
InputStream
inStream
=
MainWindow
.
class
.
getResourceAsStream
(
"icons/lod4_32x32.png"
))
{
Image
img
=
new
Image
(
inStream
);
lod4View
.
setImage
(
img
);
}
try
(
InputStream
inStream
=
MainWindow
.
class
.
getResourceAsStream
(
"icons/about.png"
))
{
Image
img
=
new
Image
(
inStream
);
aboutImgView
.
setImage
(
img
);
}
try
(
InputStream
inStream
=
MainWindow
.
class
.
getResourceAsStream
(
"icons/save.png"
))
{
Image
img
=
new
Image
(
inStream
);
saveView
.
setImage
(
img
);
}
try
(
InputStream
inStream
=
MainWindow
.
class
.
getResourceAsStream
(
"icons/reset_camera.png"
))
{
Image
img
=
new
Image
(
inStream
);
resetCameraView
.
setImage
(
img
);
}
try
(
InputStream
inStream
=
MainWindow
.
class
.
getResourceAsStream
(
"icons/hide_roof.png"
))
{
Image
img
=
new
Image
(
inStream
);
hideRoofView
.
setImage
(
img
);
}
}
catch
(
IOException
e
)
{
// ignore close exception
}
}
private
void
setupReportButton
()
{
reportBtn
.
setDisable
(
true
);
reportBtn
.
setTooltip
(
new
Tooltip
(
Localization
.
getText
(
"MainToolBar.writeReports"
)));
reportBtn
.
setOnAction
(
ae
->
{
if
(
writeDialog
==
null
)
{
try
{
writeDialog
=
new
WriteReportDialog
(
stage
,
controller
,
mainWindow
);
}
catch
(
IOException
e
)
{
logger
.
catching
(
e
);
mainWindow
.
showExceptionDialog
(
e
);
}
}
if
(
writeDialog
!=
null
)
{
// writeDialog can be null if creation of said dialog fails
writeDialog
.
show
();
}
});
}
private
void
setupAboutButton
()
{
aboutBtn
.
setOnAction
(
ae
->
{
if
(
aboutDialog
==
null
)
{
try
{
aboutDialog
=
new
AboutDialog
(
stage
);
aboutDialog
.
show
();
}
catch
(
IOException
e
)
{
logger
.
error
(
"Could not load about dialog."
,
e
);
}
}
else
{
aboutDialog
.
show
();
}
});
}
private
void
setupLodButtons
()
{
lod1Btn
.
setOnAction
(
ae
->
{
if
(
lod1Btn
.
isSelected
())
{
renderer
.
enableLod1
();
}
else
{
renderer
.
disableLod1
();
}
});
lod2Btn
.
setOnAction
(
ae
->
{
if
(
lod2Btn
.
isSelected
())
{
renderer
.
enableLod2
();
}
else
{
renderer
.
disableLod2
();
}
});
lod3Btn
.
setOnAction
(
ae
->
{
if
(
lod3Btn
.
isSelected
())
{
renderer
.
enableLod3
();
}
else
{
renderer
.
disableLod3
();
}
});
lod4Btn
.
setOnAction
(
ae
->
{
if
(
lod4Btn
.
isSelected
())
{
renderer
.
enableLod4
();
}
else
{
renderer
.
disableLod4
();
}
});
}
private
void
setupSaveBtn
()
{
saveBtn
.
setOnAction
(
ae
->
controller
.
askAndSave
());
}
private
void
setupCheckButton
()
{
checkBtn
.
setDisable
(
true
);
checkBtn
.
setTooltip
(
new
Tooltip
(
Localization
.
getText
(
"MainToolBar.executeChecks"
)));
checkBtn
.
setOnAction
(
ae
->
{
if
(
checkDialog
==
null
)
{
try
{
checkDialog
=
new
CheckDialog
(
mainWindow
,
stage
,
controller
);
}
catch
(
IOException
e
)
{
mainWindow
.
showExceptionDialog
(
e
);
logger
.
catching
(
e
);
}
}
checkDialog
.
show
();
});
}
private
void
setupResetCameraButton
(){
resetCameraBtn
.
setDisable
(
true
);
resetCameraBtn
.
setTooltip
(
new
Tooltip
(
Localization
.
getText
(
"MainToolBar.resetCamera"
)));
resetCameraBtn
.
setOnAction
(
ae
->
mainWindow
.
resetCamera
());
}
private
void
setupHideRoofButton
()
{
hideRoofBtn
.
setDisable
(
true
);
hideRoofBtn
.
setSelected
(
false
);
hideRoofBtn
.
setTooltip
(
new
Tooltip
(
Localization
.
getText
(
"MainToolBar.hideRoof"
)));
hideRoofBtn
.
setOnAction
(
ae
->
{
if
(
hideRoofBtn
.
isSelected
())
{
renderer
.
hideRoofs
();
}
else
{
renderer
.
showRoofs
();
}});
}
public
Button
getCheckButton
()
{
return
checkBtn
;
}
public
ToggleButton
getGridButton
()
{
return
gridButton
;
}
public
ToggleButton
getCullingButton
()
{
return
cullingButton
;
}
public
Button
getSaveButton
()
{
return
saveBtn
;
}
public
Button
getWriteReportButton
()
{
return
reportBtn
;
}
public
ToggleButton
getLod1Btn
()
{
return
lod1Btn
;
}
public
ToggleButton
getLod2Btn
()
{
return
lod2Btn
;
}
public
ToggleButton
getLod3Btn
()
{
return
lod3Btn
;
}
public
ToggleButton
getLod4Btn
()
{
return
lod4Btn
;
}
public
ToggleButton
getHideRoofBtn
(){
return
hideRoofBtn
;
}
public
Button
getWorldBtn
()
{
return
showWorldBtn
;
}
public
Button
getSaveBtn
()
{
return
saveBtn
;
}
public
Button
getResetCameraBtn
(){
return
resetCameraBtn
;
}
public
HBox
getToolBar
()
{
return
toolBar
;
}
public
Button
getOpenBtn
()
{
return
openBtn
;
}
@FXML
private
Button
aboutBtn
;
@FXML
private
ImageView
aboutImgView
;
@FXML
private
ToggleButton
gridButton
;
@FXML
private
ToggleButton
cullingButton
;
@FXML
private
ImageView
cullingImageView
;
@FXML
private
ImageView
gridImageView
;
@FXML
private
Button
reportBtn
;
@FXML
private
ImageView
reportImageView
;
private
OpenFileDialog
fileDialog
;
private
CheckDialog
checkDialog
;
private
WriteReportDialog
writeDialog
;
private
AboutDialog
aboutDialog
;
private
CityDoctorController
controller
;
private
TabPane
featurePane
;
private
Stage
stage
;
private
Renderer
renderer
;
private
MainWindow
mainWindow
;
private
HBox
toolBar
;
public
MainToolBar
(
Stage
stage
,
CityDoctorController
controller
,
TabPane
featurePane
,
Renderer
renderer
,
MainWindow
mainWindow
)
throws
IOException
{
this
.
controller
=
controller
;
this
.
featurePane
=
featurePane
;
this
.
renderer
=
renderer
;
this
.
stage
=
stage
;
this
.
mainWindow
=
mainWindow
;
FXMLLoader
loader
=
new
FXMLLoader
(
MainToolBar
.
class
.
getResource
(
"MainToolBar.fxml"
));
loader
.
setController
(
this
);
toolBar
=
loader
.
load
();
fileDialog
=
new
OpenFileDialog
(
stage
,
controller
);
}
public
void
initialize
()
{
openBtn
.
setOnAction
(
ae
->
fileDialog
.
show
());
setupSaveBtn
();
setupCheckButton
();
setupLodButtons
();
setupAboutButton
();
setupReportButton
();
setupResetCameraButton
();
setupHideRoofButton
();
loadImages
();
gridButton
.
setOnAction
(
ae
->
renderer
.
showWireFrame
(
gridButton
.
isSelected
()));
gridButton
.
setTooltip
(
new
Tooltip
(
Localization
.
getText
(
"MainToolBar.wireframe"
)));
cullingButton
.
setOnAction
(
ae
->
renderer
.
enableCulling
(
cullingButton
.
isSelected
()));
cullingButton
.
setTooltip
(
new
Tooltip
(
Localization
.
getText
(
"MainToolBar.culling"
)));
showWorldBtn
.
setOnAction
(
ar
->
{
Tab
selectedItem
=
featurePane
.
getSelectionModel
().
getSelectedItem
();
if
(
selectedItem
.
getContent
()
instanceof
TreeView
)
{
@SuppressWarnings
(
"unchecked"
)
TreeView
<
Renderable
>
content
=
(
TreeView
<
Renderable
>)
selectedItem
.
getContent
();
content
.
getSelectionModel
().
clearSelection
();
}
controller
.
showWorld
();
});
showWorldBtn
.
setTooltip
(
new
Tooltip
(
Localization
.
getText
(
"MainToolBar.showWorld"
)));
}
private
void
loadImages
()
{
try
{
try
(
InputStream
inStream
=
MainWindow
.
class
.
getResourceAsStream
(
"icons/openFolderIcon.png"
))
{
Image
img
=
new
Image
(
inStream
);
openImageView
.
setImage
(
img
);
}
try
(
InputStream
inStream
=
MainWindow
.
class
.
getResourceAsStream
(
"icons/check32x32.png"
))
{
Image
img
=
new
Image
(
inStream
);
checkImageView
.
setImage
(
img
);
}
try
(
InputStream
inStream
=
MainWindow
.
class
.
getResourceAsStream
(
"icons/wireframe32x32.png"
))
{
Image
img
=
new
Image
(
inStream
);
gridImageView
.
setImage
(
img
);
}
try
(
InputStream
inStream
=
MainWindow
.
class
.
getResourceAsStream
(
"icons/Culling.png"
))
{
Image
img
=
new
Image
(
inStream
);
cullingImageView
.
setImage
(
img
);
}
try
(
InputStream
inStream
=
MainWindow
.
class
.
getResourceAsStream
(
"icons/error_stat32x32.png"
))
{
Image
img
=
new
Image
(
inStream
);
reportImageView
.
setImage
(
img
);
}
try
(
InputStream
inStream
=
MainWindow
.
class
.
getResourceAsStream
(
"icons/scene.png"
))
{
Image
img
=
new
Image
(
inStream
);
showWorldImageView
.
setImage
(
img
);
}
try
(
InputStream
inStream
=
MainWindow
.
class
.
getResourceAsStream
(
"icons/lod1_32x32.png"
))
{
Image
img
=
new
Image
(
inStream
);
lod1View
.
setImage
(
img
);
}
try
(
InputStream
inStream
=
MainWindow
.
class
.
getResourceAsStream
(
"icons/lod2_32x32.png"
))
{
Image
img
=
new
Image
(
inStream
);
lod2View
.
setImage
(
img
);
}
try
(
InputStream
inStream
=
MainWindow
.
class
.
getResourceAsStream
(
"icons/lod3_32x32.png"
))
{
Image
img
=
new
Image
(
inStream
);
lod3View
.
setImage
(
img
);
}
try
(
InputStream
inStream
=
MainWindow
.
class
.
getResourceAsStream
(
"icons/lod4_32x32.png"
))
{
Image
img
=
new
Image
(
inStream
);
lod4View
.
setImage
(
img
);
}
try
(
InputStream
inStream
=
MainWindow
.
class
.
getResourceAsStream
(
"icons/about.png"
))
{
Image
img
=
new
Image
(
inStream
);
aboutImgView
.
setImage
(
img
);
}
try
(
InputStream
inStream
=
MainWindow
.
class
.
getResourceAsStream
(
"icons/save.png"
))
{
Image
img
=
new
Image
(
inStream
);
saveView
.
setImage
(
img
);
}
try
(
InputStream
inStream
=
MainWindow
.
class
.
getResourceAsStream
(
"icons/reset_camera.png"
))
{
Image
img
=
new
Image
(
inStream
);
resetCameraView
.
setImage
(
img
);
}
try
(
InputStream
inStream
=
MainWindow
.
class
.
getResourceAsStream
(
"icons/hide_roof.png"
))
{
Image
img
=
new
Image
(
inStream
);
hideRoofView
.
setImage
(
img
);
}
}
catch
(
IOException
e
)
{
// ignore close exception
}
}
private
void
setupReportButton
()
{
reportBtn
.
setDisable
(
true
);
reportBtn
.
setTooltip
(
new
Tooltip
(
Localization
.
getText
(
"MainToolBar.writeReports"
)));
reportBtn
.
setOnAction
(
ae
->
{
if
(
writeDialog
==
null
)
{
try
{
writeDialog
=
new
WriteReportDialog
(
stage
,
controller
,
mainWindow
);
}
catch
(
IOException
e
)
{
logger
.
catching
(
e
);
mainWindow
.
showExceptionDialog
(
e
);
}
}
if
(
writeDialog
!=
null
)
{
// writeDialog can be null if creation of said dialog fails
writeDialog
.
show
();
}
});
}
private
void
setupAboutButton
()
{
aboutBtn
.
setOnAction
(
ae
->
{
if
(
aboutDialog
==
null
)
{
try
{
aboutDialog
=
new
AboutDialog
(
stage
);
aboutDialog
.
show
();
}
catch
(
IOException
e
)
{
logger
.
error
(
"Could not load about dialog."
,
e
);
}
}
else
{
aboutDialog
.
show
();
}
});
}
private
void
setupLodButtons
()
{
lod1Btn
.
setOnAction
(
ae
->
{
if
(
lod1Btn
.
isSelected
())
{
renderer
.
enableLod1
();
}
else
{
renderer
.
disableLod1
();
}
});
lod2Btn
.
setOnAction
(
ae
->
{
if
(
lod2Btn
.
isSelected
())
{
renderer
.
enableLod2
();
}
else
{
renderer
.
disableLod2
();
}
});
lod3Btn
.
setOnAction
(
ae
->
{
if
(
lod3Btn
.
isSelected
())
{
renderer
.
enableLod3
();
}
else
{
renderer
.
disableLod3
();
}
});
lod4Btn
.
setOnAction
(
ae
->
{
if
(
lod4Btn
.
isSelected
())
{
renderer
.
enableLod4
();
}
else
{
renderer
.
disableLod4
();
}
});
}
private
void
setupSaveBtn
()
{
saveBtn
.
setOnAction
(
ae
->
controller
.
askAndSave
());
}
private
void
setupCheckButton
()
{
checkBtn
.
setDisable
(
true
);
checkBtn
.
setTooltip
(
new
Tooltip
(
Localization
.
getText
(
"MainToolBar.executeChecks"
)));
checkBtn
.
setOnAction
(
ae
->
{
if
(
checkDialog
==
null
)
{
try
{
checkDialog
=
new
CheckDialog
(
mainWindow
,
stage
,
controller
);
}
catch
(
IOException
e
)
{
mainWindow
.
showExceptionDialog
(
e
);
logger
.
catching
(
e
);
}
}
checkDialog
.
show
();
});
}
private
void
setupResetCameraButton
()
{
resetCameraBtn
.
setDisable
(
true
);
resetCameraBtn
.
setTooltip
(
new
Tooltip
(
Localization
.
getText
(
"MainToolBar.resetCamera"
)));
resetCameraBtn
.
setOnAction
(
ae
->
mainWindow
.
resetCamera
());
}
private
void
setupHideRoofButton
()
{
hideRoofBtn
.
setDisable
(
true
);
hideRoofBtn
.
setSelected
(
false
);
hideRoofBtn
.
setTooltip
(
new
Tooltip
(
Localization
.
getText
(
"MainToolBar.hideRoof"
)));
hideRoofBtn
.
setOnAction
(
ae
->
{
if
(
hideRoofBtn
.
isSelected
())
{
renderer
.
hideRoofs
();
}
else
{
renderer
.
showRoofs
();
}
});
}
public
Button
getCheckButton
()
{
return
checkBtn
;
}
public
ToggleButton
getGridButton
()
{
return
gridButton
;
}
public
ToggleButton
getCullingButton
()
{
return
cullingButton
;
}
public
Button
getSaveButton
()
{
return
saveBtn
;
}
public
Button
getWriteReportButton
()
{
return
reportBtn
;
}
public
ToggleButton
getLod1Btn
()
{
return
lod1Btn
;
}
public
ToggleButton
getLod2Btn
()
{
return
lod2Btn
;
}
public
ToggleButton
getLod3Btn
()
{
return
lod3Btn
;
}
public
ToggleButton
getLod4Btn
()
{
return
lod4Btn
;
}
public
ToggleButton
getHideRoofBtn
()
{
return
hideRoofBtn
;
}
public
Button
getWorldBtn
()
{
return
showWorldBtn
;
}
public
Button
getSaveBtn
()
{
return
saveBtn
;
}
public
Button
getResetCameraBtn
()
{
return
resetCameraBtn
;
}
public
HBox
getToolBar
()
{
return
toolBar
;
}
public
Button
getOpenBtn
()
{
return
openBtn
;
}
}
CityDoctorParent/Extensions/CityDoctorGUI/src/main/java/de/hft/stuttgart/citydoctor2/gui/MainWindow.java
View file @
02de0a22
package
de.hft.stuttgart.citydoctor2.gui
;
import
java.awt.image.BufferedImage
;
import
java.io.File
;
import
java.io.FileNotFoundException
;
import
java.io.IOException
;
import
java.util.List
;
import
java.util.Locale
;
import
java.util.Optional
;
import
java.util.Timer
;
import
java.util.TimerTask
;
import
javax.imageio.ImageIO
;
import
javafx.scene.chart.NumberAxis
;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.Logger
;
import
de.hft.stuttgart.citydoctor2.CityDoctorValidation
;
import
de.hft.stuttgart.citydoctor2.check.ValidationConfiguration
;
import
de.hft.stuttgart.citydoctor2.datastructure.BoundingBox
;
...
...
@@ -35,35 +19,9 @@ import javafx.beans.value.ChangeListener;
import
javafx.embed.swing.SwingFXUtils
;
import
javafx.fxml.FXML
;
import
javafx.fxml.FXMLLoader
;
import
javafx.scene.AmbientLight
;
import
javafx.scene.Group
;
import
javafx.scene.Node
;
import
javafx.scene.PerspectiveCamera
;
import
javafx.scene.Scene
;
import
javafx.scene.SceneAntialiasing
;
import
javafx.scene.SubScene
;
import
javafx.scene.control.Alert
;
import
javafx.scene.*
;
import
javafx.scene.control.*
;
import
javafx.scene.control.Alert.AlertType
;
import
javafx.scene.control.Button
;
import
javafx.scene.control.ButtonType
;
import
javafx.scene.control.ComboBox
;
import
javafx.scene.control.ContextMenu
;
import
javafx.scene.control.Label
;
import
javafx.scene.control.ListCell
;
import
javafx.scene.control.ListView
;
import
javafx.scene.control.MenuItem
;
import
javafx.scene.control.ProgressBar
;
import
javafx.scene.control.RadioButton
;
import
javafx.scene.control.SplitPane
;
import
javafx.scene.control.Tab
;
import
javafx.scene.control.TabPane
;
import
javafx.scene.control.TextArea
;
import
javafx.scene.control.TextField
;
import
javafx.scene.control.ToggleButton
;
import
javafx.scene.control.ToggleGroup
;
import
javafx.scene.control.ToolBar
;
import
javafx.scene.control.TreeItem
;
import
javafx.scene.control.TreeView
;
import
javafx.scene.image.Image
;
import
javafx.scene.image.ImageView
;
import
javafx.scene.image.WritableImage
;
...
...
@@ -78,6 +36,15 @@ import javafx.scene.layout.Priority;
import
javafx.scene.paint.Color
;
import
javafx.scene.transform.Rotate
;
import
javafx.stage.Stage
;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.Logger
;
import
javax.imageio.ImageIO
;
import
java.awt.image.BufferedImage
;
import
java.io.File
;
import
java.io.FileNotFoundException
;
import
java.io.IOException
;
import
java.util.*
;
public
class
MainWindow
extends
Application
{
...
...
@@ -673,7 +640,7 @@ public class MainWindow extends Application {
});
}
public
void
setDisableOfFeatureTab
(
FeatureType
featureType
,
boolean
value
){
public
void
setDisableOfFeatureTab
(
FeatureType
featureType
,
boolean
value
)
{
switch
(
featureType
)
{
case
BUILDING:
buildingsTab
.
setDisable
(
value
);
...
...
@@ -708,7 +675,7 @@ public class MainWindow extends Application {
}
}
public
void
activateAllTabs
(){
public
void
activateAllTabs
()
{
buildingsTab
.
setDisable
(
false
);
vegetationTab
.
setDisable
(
false
);
transportationTab
.
setDisable
(
false
);
...
...
@@ -921,7 +888,7 @@ public class MainWindow extends Application {
alignNorthArrow
();
}
if
(
me
.
getButton
()
==
MouseButton
.
SECONDARY
)
{
double
translationSpeed
=
Math
.
abs
(
camera
.
getTranslateZ
())
/
1000
;
double
translationSpeed
=
Math
.
abs
(
camera
.
getTranslateZ
())
/
1000
;
double
deltaX
=
me
.
getScreenX
()
-
dragX
;
double
deltaY
=
me
.
getScreenY
()
-
dragY
;
dragX
=
me
.
getScreenX
();
...
...
@@ -942,27 +909,27 @@ public class MainWindow extends Application {
cameraXRotation
.
setAngle
(
cameraYRot
);
}
public
void
alignNorthArrow
(){
public
void
alignNorthArrow
()
{
double
absRotZ
=
cameraZRotation
.
getAngle
()
-
360
*
Math
.
floor
(
cameraZRotation
.
getAngle
()
/
360
);
double
absRotX
=
cameraXRotation
.
getAngle
()
-
360
*
Math
.
floor
(
cameraXRotation
.
getAngle
()
/
360
);
double
northRot
;
if
(
80
<=
absRotX
&&
absRotX
<=
260
){
northRot
=
360
-
absRotZ
;
if
(
northArrow
.
getImage
()
!=
north
){
if
(
80
<=
absRotX
&&
absRotX
<=
260
)
{
northRot
=
360
-
absRotZ
;
if
(
northArrow
.
getImage
()
!=
north
)
{
northArrow
.
setImage
(
north
);
}
}
else
{
//Camera is below horizon line -> flip north arrow horizontally
northRot
=
(
absRotZ
+
180
)
%
360
;
if
(
northArrow
.
getImage
()
!=
northFlip
){
northArrow
.
setImage
(
northFlip
);
}
northRot
=
(
absRotZ
+
180
)
%
360
;
if
(
northArrow
.
getImage
()
!=
northFlip
)
{
northArrow
.
setImage
(
northFlip
);
}
}
northArrow
.
setRotate
(
northRot
);
}
public
void
resetCamera
(){
public
void
resetCamera
()
{
cameraXRot
=
CAMERA_INITIAL_X_ANGLE
;
cameraYRot
=
CAMERA_INITIAL_Y_ANGLE
;
cameraZRotation
.
setAngle
(
cameraXRot
);
...
...
@@ -1092,15 +1059,15 @@ public class MainWindow extends Application {
return
mainToolBar
.
getWorldBtn
();
}
public
Button
getResetCameraBtn
(){
public
Button
getResetCameraBtn
()
{
return
mainToolBar
.
getResetCameraBtn
();
}
public
ToggleButton
getHideRoofBtn
(){
public
ToggleButton
getHideRoofBtn
()
{
return
mainToolBar
.
getHideRoofBtn
();
}
public
ImageView
getNorthArrow
(){
public
ImageView
getNorthArrow
()
{
return
northArrow
;
}
...
...
CityDoctorParent/Extensions/CityDoctorGUI/src/main/java/de/hft/stuttgart/citydoctor2/gui/Renderer.java
View file @
02de0a22
package
de.hft.stuttgart.citydoctor2.gui
;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
java.util.Collection
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.Set
;
import
de.hft.stuttgart.citydoctor2.datastructure.*
;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.Logger
;
import
de.hft.stuttgart.citydoctor2.check.CheckError
;
import
de.hft.stuttgart.citydoctor2.check.Checkable
;
import
de.hft.stuttgart.citydoctor2.datastructure.*
;
import
de.hft.stuttgart.citydoctor2.gui.filter.ViewFilter
;
import
de.hft.stuttgart.citydoctor2.gui.tree.EdgeNode
;
import
de.hft.stuttgart.citydoctor2.gui.tree.ErrorItemVisitor
;
import
de.hft.stuttgart.citydoctor2.gui.tree.ErrorNode
;
import
de.hft.stuttgart.citydoctor2.gui.tree.LinearRingNode
;
import
de.hft.stuttgart.citydoctor2.gui.tree.PolygonNode
;
import
de.hft.stuttgart.citydoctor2.gui.tree.Renderable
;
import
de.hft.stuttgart.citydoctor2.gui.tree.VertexNode
;
import
de.hft.stuttgart.citydoctor2.gui.tree.*
;
import
de.hft.stuttgart.citydoctor2.math.Triangle3d
;
import
javafx.application.Platform
;
import
javafx.scene.control.TreeItem
;
import
javafx.scene.paint.Color
;
import
javafx.scene.shape.CullFace
;
import
javafx.scene.shape.DrawMode
;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.Logger
;
import
java.io.IOException
;
import
java.util.*
;
public
class
Renderer
{
private
static
final
Logger
logger
=
LogManager
.
getLogger
(
Renderer
.
class
);
private
TriangulatedGeometry
currentTriGeom
;
private
Geometry
currentGeometry
;
private
CullFace
currentCulling
=
CullFace
.
BACK
;
private
DrawMode
currentDrawMode
=
DrawMode
.
FILL
;
private
MainWindow
mainWindow
;
private
HighlightController
highlightController
;
private
ListErrorVisitor
errVisitor
;
private
LoadingInfoDialog
loadingDialog
;
private
List
<
ViewFilter
>
lodFilters
=
new
ArrayList
<>();
private
ViewFilter
roofFilter
;
private
Runnable
refresher
;
private
Runnable
errorUpdater
;
public
Renderer
(
MainWindow
mainWindow
,
HighlightController
highlightController
)
throws
IOException
{
this
.
mainWindow
=
mainWindow
;
this
.
highlightController
=
highlightController
;
loadingDialog
=
new
LoadingInfoDialog
(
mainWindow
.
getMainStage
());
errVisitor
=
new
ListErrorVisitor
(
highlightController
);
setupLodFilters
();
}
private
void
setupLodFilters
()
{
lodFilters
.
add
(
new
ViewFilter
()
{
@Override
public
boolean
useGeometry
(
CityObject
co
,
Geometry
geom
)
{
return
geom
.
getLod
()
==
Lod
.
LOD1
;
}
});
lodFilters
.
add
(
new
ViewFilter
()
{
@Override
public
boolean
useGeometry
(
CityObject
co
,
Geometry
geom
)
{
return
geom
.
getLod
()
==
Lod
.
LOD2
;
}
});
lodFilters
.
add
(
new
ViewFilter
()
{
@Override
public
boolean
useGeometry
(
CityObject
co
,
Geometry
geom
)
{
return
geom
.
getLod
()
==
Lod
.
LOD3
;
}
});
lodFilters
.
add
(
new
ViewFilter
()
{
@Override
protected
boolean
useGeometry
(
CityObject
co
,
Geometry
geom
)
{
return
geom
.
getLod
()
==
Lod
.
LOD0
;
}
});
lodFilters
.
add
(
new
ViewFilter
()
{
@Override
public
boolean
useGeometry
(
CityObject
co
,
Geometry
geom
)
{
return
geom
.
getLod
()
==
Lod
.
LOD4
;
}
});
roofFilter
=
new
ViewFilter
()
{
@Override
public
boolean
allowedToUse
(
CityObject
co
,
Geometry
geom
){
if
(!
this
.
isEnabled
()){
return
true
;
}
return
this
.
useGeometry
(
co
,
geom
);
}
@Override
public
boolean
useGeometry
(
CityObject
co
,
Geometry
geom
)
{
if
(
co
instanceof
BoundarySurface
bs
){
return
bs
.
getType
()
!=
BoundarySurfaceType
.
ROOF
;
}
return
true
;
}
};
roofFilter
.
setEnable
(
false
);
}
public
void
enableLod1
()
{
lodFilters
.
get
(
0
).
enable
();
if
(
refresher
!=
null
)
{
refresher
.
run
();
}
}
public
void
disableLod1
()
{
lodFilters
.
get
(
0
).
disable
();
if
(
refresher
!=
null
)
{
refresher
.
run
();
}
}
public
void
enableLod2
()
{
lodFilters
.
get
(
1
).
enable
();
if
(
refresher
!=
null
)
{
refresher
.
run
();
}
}
public
void
disableLod2
()
{
lodFilters
.
get
(
1
).
disable
();
if
(
refresher
!=
null
)
{
refresher
.
run
();
}
}
public
void
enableLod3
()
{
lodFilters
.
get
(
2
).
enable
();
if
(
refresher
!=
null
)
{
refresher
.
run
();
}
}
public
void
disableLod3
()
{
lodFilters
.
get
(
2
).
disable
();
if
(
refresher
!=
null
)
{
refresher
.
run
();
}
}
public
void
enableLod4
()
{
lodFilters
.
get
(
3
).
enable
();
if
(
refresher
!=
null
)
{
refresher
.
run
();
}
}
public
void
disableLod4
()
{
lodFilters
.
get
(
3
).
disable
();
if
(
refresher
!=
null
)
{
refresher
.
run
();
}
}
public
void
hideRoofs
(){
roofFilter
.
setEnable
(
true
);
if
(
refresher
!=
null
)
{
refresher
.
run
();
}
}
public
void
showRoofs
(){
roofFilter
.
setEnable
(
false
);
if
(
refresher
!=
null
)
{
refresher
.
run
();
}
}
public
void
render
(
Building
building
)
{
refresher
=
()
->
{
Set
<
ConcretePolygon
>
setupBuildingPolygons
=
setupBuildingPolygons
(
building
);
mainWindow
.
zoomOutForBoundingBox
(
BoundingBox
.
of
(
setupBuildingPolygons
));
render
(
setupBuildingPolygons
);
Platform
.
runLater
(()
->
{
errorUpdater
=
()
->
displayErrors
(
building
);
errorUpdater
.
run
();
});
};
refresher
.
run
();
}
private
Set
<
ConcretePolygon
>
setupBuildingPolygons
(
Building
b
)
{
Set
<
ConcretePolygon
>
polygons
=
new
HashSet
<>();
addPolygons
(
b
,
polygons
);
for
(
BoundarySurface
bs
:
b
.
getBoundarySurfaces
())
{
addPolygons
(
bs
,
polygons
);
for
(
Opening
op
:
bs
.
getOpenings
())
{
addPolygons
(
op
,
polygons
);
}
}
for
(
Installation
bi
:
b
.
getBuildingInstallations
())
{
addPolygons
(
bi
,
polygons
);
for
(
BoundarySurface
bs
:
bi
.
getBoundarySurfaces
())
{
addPolygons
(
bs
,
polygons
);
for
(
Opening
op
:
bs
.
getOpenings
())
{
addPolygons
(
op
,
polygons
);
}
}
}
for
(
BuildingRoom
br
:
b
.
getBuildingRooms
())
{
addPolygons
(
br
,
polygons
);
for
(
BoundarySurface
bs
:
br
.
getBoundarySurfaceList
()){
addPolygons
(
bs
,
polygons
);
}
}
for
(
BuildingRoomFurniture
brf
:
b
.
getBuildingRoomFurnitureList
()){
addPolygons
(
brf
,
polygons
);
for
(
BoundarySurface
bs
:
brf
.
getBoundarySurfaceList
()){
addPolygons
(
bs
,
polygons
);
}
}
for
(
BuildingPart
bp
:
b
.
getBuildingParts
())
{
polygons
.
addAll
(
setupBuildingPartPolygons
(
bp
));
}
return
polygons
;
}
public
void
render
(
BuildingPart
bp
)
{
refresher
=
()
->
{
Set
<
ConcretePolygon
>
setupBuildingPartPolygons
=
setupBuildingPartPolygons
(
bp
);
mainWindow
.
zoomOutForBoundingBox
(
BoundingBox
.
of
(
setupBuildingPartPolygons
));
render
(
setupBuildingPartPolygons
);
Platform
.
runLater
(()
->
{
errorUpdater
=
()
->
displayErrors
(
bp
);
errorUpdater
.
run
();
});
};
refresher
.
run
();
}
private
Set
<
ConcretePolygon
>
setupBuildingPartPolygons
(
BuildingPart
bp
)
{
Set
<
ConcretePolygon
>
polygons
=
new
HashSet
<>();
addPolygons
(
bp
,
polygons
);
for
(
BoundarySurface
bs
:
bp
.
getBoundarySurfaces
())
{
addPolygons
(
bs
,
polygons
);
for
(
Opening
op
:
bs
.
getOpenings
())
{
addPolygons
(
op
,
polygons
);
}
}
for
(
Installation
bi
:
bp
.
getBuildingInstallations
())
{
addPolygons
(
bi
,
polygons
);
for
(
BoundarySurface
bs
:
bi
.
getBoundarySurfaces
())
{
addPolygons
(
bs
,
polygons
);
for
(
Opening
op
:
bs
.
getOpenings
())
{
addPolygons
(
op
,
polygons
);
}
}
}
return
polygons
;
}
public
void
render
(
AbstractRoom
room
){
refresher
=
()
->
{
Set
<
ConcretePolygon
>
setupRoomPolygons
=
setupRoomPolygons
(
room
);
mainWindow
.
zoomOutForBoundingBox
(
BoundingBox
.
of
(
setupRoomPolygons
));
render
(
setupRoomPolygons
);
Platform
.
runLater
(()
->
{
errorUpdater
=
()
->
displayErrors
(
room
);
errorUpdater
.
run
();
});
};
refresher
.
run
();
}
private
Set
<
ConcretePolygon
>
setupRoomPolygons
(
AbstractRoom
room
)
{
Set
<
ConcretePolygon
>
polygons
=
new
HashSet
<>();
addPolygons
(
room
,
polygons
);
for
(
BoundarySurface
bs
:
room
.
getBoundarySurfaceList
())
{
addPolygons
(
bs
,
polygons
);
for
(
Opening
op
:
bs
.
getOpenings
())
{
addPolygons
(
op
,
polygons
);
}
}
return
polygons
;
}
public
void
render
(
AbstractFurniture
furniture
){
refresher
=
()
->
{
Set
<
ConcretePolygon
>
setupFurniturePolygons
=
setupFurniturePolygons
(
furniture
);
mainWindow
.
zoomOutForBoundingBox
(
BoundingBox
.
of
(
setupFurniturePolygons
));
render
(
setupFurniturePolygons
);
Platform
.
runLater
(()
->
{
errorUpdater
=
()
->
displayErrors
(
furniture
);
errorUpdater
.
run
();
});
};
refresher
.
run
();
}
private
Set
<
ConcretePolygon
>
setupFurniturePolygons
(
AbstractFurniture
furniture
)
{
Set
<
ConcretePolygon
>
polygons
=
new
HashSet
<>();
addPolygons
(
furniture
,
polygons
);
for
(
BoundarySurface
bs
:
furniture
.
getBoundarySurfaceList
())
{
addPolygons
(
bs
,
polygons
);
for
(
Opening
op
:
bs
.
getOpenings
())
{
addPolygons
(
op
,
polygons
);
}
}
return
polygons
;
}
public
void
render
(
Storey
storey
){
refresher
=
()
->
{
Set
<
ConcretePolygon
>
setupStoreyPolygons
=
setupStoreyPolygons
(
storey
);
mainWindow
.
zoomOutForBoundingBox
(
BoundingBox
.
of
(
setupStoreyPolygons
));
render
(
setupStoreyPolygons
);
Platform
.
runLater
(()
->
{
errorUpdater
=
()
->
displayErrors
(
storey
);
errorUpdater
.
run
();
});
};
refresher
.
run
();
}
private
Set
<
ConcretePolygon
>
setupStoreyPolygons
(
Storey
storey
)
{
Set
<
ConcretePolygon
>
polygons
=
new
HashSet
<>();
addPolygons
(
storey
,
polygons
);
for
(
BoundarySurface
bs
:
storey
.
getBoundarySurfaces
())
{
addPolygons
(
bs
,
polygons
);
for
(
Opening
op
:
bs
.
getOpenings
())
{
addPolygons
(
op
,
polygons
);
}
}
return
polygons
;
}
public
void
render
(
BuildingUnit
buildingUnit
){
refresher
=
()
->
{
Set
<
ConcretePolygon
>
setupBuildingUnitPolgons
=
setupBuildingUnitPolygons
(
buildingUnit
);
mainWindow
.
zoomOutForBoundingBox
(
BoundingBox
.
of
(
setupBuildingUnitPolgons
));
render
(
setupBuildingUnitPolgons
);
Platform
.
runLater
(()
->
{
errorUpdater
=
()
->
displayErrors
(
buildingUnit
);
errorUpdater
.
run
();
});
};
refresher
.
run
();
}
private
Set
<
ConcretePolygon
>
setupBuildingUnitPolygons
(
BuildingUnit
buildingUnit
)
{
Set
<
ConcretePolygon
>
polygons
=
new
HashSet
<>();
addPolygons
(
buildingUnit
,
polygons
);
for
(
BoundarySurface
bs
:
buildingUnit
.
getBoundarySurfaces
())
{
addPolygons
(
bs
,
polygons
);
for
(
Opening
op
:
bs
.
getOpenings
())
{
addPolygons
(
op
,
polygons
);
}
}
return
polygons
;
}
public
void
render
(
Tunnel
tunnel
){
refresher
=
()
->
{
Set
<
ConcretePolygon
>
setupTunnelPolygons
=
setupTunnelPolygons
(
tunnel
);
mainWindow
.
zoomOutForBoundingBox
(
BoundingBox
.
of
(
setupTunnelPolygons
));
render
(
setupTunnelPolygons
);
Platform
.
runLater
(()
->
{
errorUpdater
=
()
->
displayErrors
(
tunnel
);
errorUpdater
.
run
();
});
};
refresher
.
run
();
}
private
Set
<
ConcretePolygon
>
setupTunnelPolygons
(
Tunnel
tunnel
)
{
Set
<
ConcretePolygon
>
polygons
=
new
HashSet
<>();
addPolygons
(
tunnel
,
polygons
);
for
(
BoundarySurface
bs
:
tunnel
.
getBoundarySurfaces
())
{
addPolygons
(
bs
,
polygons
);
}
for
(
Installation
ti
:
tunnel
.
getTunnelInstallations
())
{
addPolygons
(
ti
,
polygons
);
for
(
BoundarySurface
bs
:
ti
.
getBoundarySurfaces
())
{
addPolygons
(
bs
,
polygons
);
for
(
Opening
op
:
bs
.
getOpenings
())
{
addPolygons
(
op
,
polygons
);
}
}
}
for
(
TunnelHollow
th
:
tunnel
.
getTunnelHollows
())
{
addPolygons
(
th
,
polygons
);
for
(
BoundarySurface
bs
:
th
.
getBoundarySurfaceList
()){
addPolygons
(
bs
,
polygons
);
}
}
for
(
TunnelFurniture
tf
:
tunnel
.
getTunnelFurnitureList
()){
addPolygons
(
tf
,
polygons
);
for
(
BoundarySurface
bs
:
tf
.
getBoundarySurfaceList
()){
addPolygons
(
bs
,
polygons
);
}
}
for
(
TunnelPart
tp
:
tunnel
.
getTunnelParts
())
{
polygons
.
addAll
(
setupTunnelPartPolygons
(
tp
));
}
return
polygons
;
}
private
Set
<
ConcretePolygon
>
setupTunnelPartPolygons
(
TunnelPart
tp
)
{
Set
<
ConcretePolygon
>
polygons
=
new
HashSet
<>();
addPolygons
(
tp
,
polygons
);
for
(
BoundarySurface
bs
:
tp
.
getBoundarySurfaces
())
{
addPolygons
(
bs
,
polygons
);
for
(
Opening
op
:
bs
.
getOpenings
())
{
addPolygons
(
op
,
polygons
);
}
}
for
(
Installation
bi
:
tp
.
getTunnelInstallations
())
{
addPolygons
(
bi
,
polygons
);
for
(
BoundarySurface
bs
:
bi
.
getBoundarySurfaces
())
{
addPolygons
(
bs
,
polygons
);
for
(
Opening
op
:
bs
.
getOpenings
())
{
addPolygons
(
op
,
polygons
);
}
}
}
return
polygons
;
}
public
void
render
(
BridgeObject
bridge
)
{
refresher
=
()
->
{
Set
<
ConcretePolygon
>
setupBridgePolygons
=
setupBridgePolygons
(
bridge
);
mainWindow
.
zoomOutForBoundingBox
(
BoundingBox
.
of
(
setupBridgePolygons
));
render
(
setupBridgePolygons
);
Platform
.
runLater
(()
->
{
errorUpdater
=
()
->
displayErrors
(
bridge
);
errorUpdater
.
run
();
});
};
refresher
.
run
();
}
private
Set
<
ConcretePolygon
>
setupBridgePolygons
(
BridgeObject
bridge
)
{
Set
<
ConcretePolygon
>
polygons
=
new
HashSet
<>();
addPolygons
(
bridge
,
polygons
);
for
(
BoundarySurface
bs
:
bridge
.
getBoundarySurfaces
())
{
addPolygons
(
bs
,
polygons
);
}
for
(
BridgeConstructiveElement
consElement
:
bridge
.
getConstructiveElements
())
{
addPolygons
(
consElement
,
polygons
);
for
(
BoundarySurface
bs
:
consElement
.
getBoundarySurfaces
())
{
addPolygons
(
bs
,
polygons
);
}
}
for
(
Installation
inst
:
bridge
.
getBridgeInstallations
())
{
addPolygons
(
inst
,
polygons
);
for
(
BoundarySurface
bs
:
inst
.
getBoundarySurfaces
())
{
addPolygons
(
bs
,
polygons
);
}
}
return
polygons
;
}
public
void
render
(
CityObject
co
)
{
refresher
=
()
->
{
Set
<
ConcretePolygon
>
setupCityObjectPolygons
=
setupCityObjectPolygons
(
co
);
mainWindow
.
zoomOutForBoundingBox
(
BoundingBox
.
of
(
setupCityObjectPolygons
));
render
(
setupCityObjectPolygons
);
Platform
.
runLater
(()
->
{
errorUpdater
=
()
->
displayErrors
(
co
);
errorUpdater
.
run
();
});
};
refresher
.
run
();
}
public
void
render
(
ReliefObject
relief
)
{
refresher
=
()
->
{
Set
<
ConcretePolygon
>
setupCityObjectPolygons
=
setupReliefPolygons
(
relief
);
mainWindow
.
zoomOutForBoundingBox
(
BoundingBox
.
of
(
setupCityObjectPolygons
));
render
(
setupCityObjectPolygons
);
Platform
.
runLater
(()
->
{
errorUpdater
=
()
->
displayErrors
(
relief
);
errorUpdater
.
run
();
});
};
refresher
.
run
();
}
private
Set
<
ConcretePolygon
>
setupReliefPolygons
(
ReliefObject
relief
)
{
Set
<
ConcretePolygon
>
polygons
=
new
HashSet
<>();
addPolygons
(
relief
,
polygons
);
for
(
TinObject
tin
:
relief
.
getComponents
())
{
addPolygons
(
tin
,
polygons
);
}
return
polygons
;
}
public
void
render
(
Installation
bi
)
{
refresher
=
()
->
{
Set
<
ConcretePolygon
>
setupCityObjectPolygons
=
setupBuildingInstallationPolygons
(
bi
);
mainWindow
.
zoomOutForBoundingBox
(
BoundingBox
.
of
(
setupCityObjectPolygons
));
render
(
setupCityObjectPolygons
);
Platform
.
runLater
(()
->
{
errorUpdater
=
()
->
displayErrors
(
bi
);
errorUpdater
.
run
();
});
};
refresher
.
run
();
}
private
Set
<
ConcretePolygon
>
setupBuildingInstallationPolygons
(
Installation
bi
)
{
Set
<
ConcretePolygon
>
polygons
=
new
HashSet
<>();
addPolygons
(
bi
,
polygons
);
for
(
BoundarySurface
bs
:
bi
.
getBoundarySurfaces
())
{
addPolygons
(
bs
,
polygons
);
for
(
Opening
op
:
bs
.
getOpenings
())
{
addPolygons
(
op
,
polygons
);
}
}
return
polygons
;
}
public
void
render
(
CityFurniture
cf
)
{
refresher
=
()
->
{
Set
<
ConcretePolygon
>
setupCityFurniturePolygons
=
setupCityFurniturePolygons
(
cf
);
mainWindow
.
zoomOutForBoundingBox
(
BoundingBox
.
of
(
setupCityFurniturePolygons
));
render
(
setupCityFurniturePolygons
);
Platform
.
runLater
(()
->
{
errorUpdater
=
()
->
displayErrors
(
cf
);
errorUpdater
.
run
();
});
};
refresher
.
run
();
}
private
Set
<
ConcretePolygon
>
setupCityFurniturePolygons
(
CityFurniture
cf
)
{
Set
<
ConcretePolygon
>
polygons
=
new
HashSet
<>();
addPolygons
(
cf
,
polygons
);
return
polygons
;
}
public
void
render
(
GenericCityObject
gco
){
refresher
=
()
->
{
Set
<
ConcretePolygon
>
setupGenericCityObjectPolygons
=
setupGenericCityObjectPolygons
(
gco
);
mainWindow
.
zoomOutForBoundingBox
(
BoundingBox
.
of
(
setupGenericCityObjectPolygons
));
render
(
setupGenericCityObjectPolygons
);
Platform
.
runLater
(()
->
{
errorUpdater
=
()
->
displayErrors
(
gco
);
errorUpdater
.
run
();
});
};
refresher
.
run
();
}
private
Set
<
ConcretePolygon
>
setupGenericCityObjectPolygons
(
GenericCityObject
gco
)
{
Set
<
ConcretePolygon
>
polygons
=
new
HashSet
<>();
addPolygons
(
gco
,
polygons
);
for
(
BoundarySurface
bs
:
gco
.
getBoundarySurfaces
())
{
addPolygons
(
bs
,
polygons
);
for
(
Opening
op
:
bs
.
getOpenings
())
{
addPolygons
(
op
,
polygons
);
}
}
return
polygons
;
}
public
void
render
(
BoundarySurface
bs
)
{
refresher
=
()
->
{
Set
<
ConcretePolygon
>
setupBoundarySurfacePolygons
=
setupBoundarySurfacePolygons
(
bs
);
mainWindow
.
zoomOutForBoundingBox
(
BoundingBox
.
of
(
setupBoundarySurfacePolygons
));
render
(
setupBoundarySurfacePolygons
);
Platform
.
runLater
(()
->
{
errorUpdater
=
()
->
displayErrors
(
bs
);
errorUpdater
.
run
();
});
};
refresher
.
run
();
}
private
Set
<
ConcretePolygon
>
setupBoundarySurfacePolygons
(
BoundarySurface
bs
)
{
Set
<
ConcretePolygon
>
polygons
=
new
HashSet
<>();
addPolygons
(
bs
,
polygons
);
for
(
Opening
op
:
bs
.
getOpenings
())
{
addPolygons
(
op
,
polygons
);
}
return
polygons
;
}
private
Set
<
ConcretePolygon
>
setupCityObjectPolygons
(
CityObject
co
)
{
Set
<
ConcretePolygon
>
polygons
=
new
HashSet
<>();
addPolygons
(
co
,
polygons
);
return
polygons
;
}
private
void
addPolygons
(
CityObject
co
,
Set
<
ConcretePolygon
>
polygons
)
{
for
(
Geometry
geom
:
co
.
getGeometries
())
{
boolean
used
=
false
;
for
(
ViewFilter
filter
:
lodFilters
)
{
if
(
filter
.
allowedToUse
(
co
,
geom
))
{
used
=
true
;
break
;
}
}
if
(
used
)
{
if
(
roofFilter
.
allowedToUse
(
co
,
geom
))
{
addConcretePolygons
(
polygons
,
geom
);
}
}
}
}
private
void
displayErrors
(
Checkable
c
)
{
if
(!
c
.
isValidated
())
{
return
;
}
List
<
CheckError
>
errors
=
new
ArrayList
<>();
c
.
collectContainedErrors
(
errors
);
// filter out duplicate errors (polygon can be contained in multiple geometries)
Set
<
CheckError
>
errorSet
=
new
HashSet
<>(
errors
);
for
(
CheckError
err
:
errorSet
)
{
ErrorNode
node
=
new
ErrorNode
(
err
);
TreeItem
<
Renderable
>
errItem
=
new
TreeItem
<>(
node
);
ErrorItemVisitor
visitor
=
new
ErrorItemVisitor
(
errItem
);
err
.
accept
(
visitor
);
mainWindow
.
getErrorTree
().
getRoot
().
getChildren
().
add
(
errItem
);
}
}
public
void
render
(
Geometry
geom
)
{
refresher
=
()
->
{
Platform
.
runLater
(
this
::
clearGeometryTrees
);
currentTriGeom
=
TriangulatedGeometry
.
of
(
geom
);
if
(
geom
.
getEdges
()
==
null
&&
currentGeometry
!=
null
)
{
// if there are no edges available low memory mode is enabled
// clear the old geometry of all meta information
currentGeometry
.
clearMetaInformation
();
}
errVisitor
.
setGeometry
(
currentTriGeom
);
Platform
.
runLater
(()
->
{
setupRenderState
();
if
(
geom
.
getEdges
()
==
null
)
{
// create edges and vertices so they can be listed in the gui
geom
.
prepareForChecking
();
// remember the geometry, so it can be cleared if another is displayed
currentGeometry
=
geom
;
}
addGeometryDataToView
(
geom
);
mainWindow
.
zoomOutForBoundingBox
(
BoundingBox
.
of
(
geom
.
getPolygons
()));
errorUpdater
=
()
->
displayErrors
(
geom
);
errorUpdater
.
run
();
});
};
refresher
.
run
();
}
private
void
addGeometryDataToView
(
Geometry
geom
)
{
for
(
Polygon
p
:
geom
.
getPolygons
())
{
if
(
p
instanceof
CompositePolygon
){
continue
;
}
addPolygonToView
(
p
);
}
for
(
Edge
e
:
geom
.
getEdges
())
{
addEdgeToView
(
e
);
}
for
(
Vertex
v
:
geom
.
getVertices
())
{
addVertexToView
(
v
);
}
}
private
void
addVertexToView
(
Vertex
v
)
{
Renderable
cf
=
new
VertexNode
(
v
);
TreeItem
<
Renderable
>
ti
=
new
TreeItem
<>(
cf
);
mainWindow
.
getVertexView
().
getRoot
().
getChildren
().
add
(
ti
);
}
private
void
addEdgeToView
(
Edge
e
)
{
EdgeNode
cf
=
new
EdgeNode
(
e
);
TreeItem
<
Renderable
>
ti
=
new
TreeItem
<>(
cf
);
mainWindow
.
getEdgeView
().
getRoot
().
getChildren
().
add
(
ti
);
}
private
void
addPolygonToView
(
Polygon
p
)
{
CheckStatus
cs
=
determineCheckStatus
(
p
);
PolygonNode
cf
=
new
PolygonNode
(
p
,
cs
);
TreeItem
<
Renderable
>
ti
=
new
TreeItem
<>(
cf
);
mainWindow
.
getPolygonsView
().
getRoot
().
getChildren
().
add
(
ti
);
// add linear rings
CheckStatus
csRing
=
determineCheckStatus
(
p
.
getExteriorRing
());
Renderable
ccRing
=
new
LinearRingNode
(
p
.
getExteriorRing
(),
csRing
);
TreeItem
<
Renderable
>
tiRing
=
new
TreeItem
<>(
ccRing
);
ti
.
getChildren
().
add
(
tiRing
);
for
(
Vertex
v
:
p
.
getExteriorRing
().
getVertices
())
{
VertexNode
vn
=
new
VertexNode
(
v
);
TreeItem
<
Renderable
>
tiV
=
new
TreeItem
<>(
vn
);
tiRing
.
getChildren
().
add
(
tiV
);
}
for
(
LinearRing
lr
:
p
.
getInnerRings
())
{
CheckStatus
csInteriorRing
=
determineCheckStatus
(
lr
);
Renderable
ccInteriorRing
=
new
LinearRingNode
(
lr
,
csInteriorRing
);
TreeItem
<
Renderable
>
tiInteriorRing
=
new
TreeItem
<>(
ccInteriorRing
);
ti
.
getChildren
().
add
(
tiInteriorRing
);
for
(
Vertex
v
:
lr
.
getVertices
())
{
VertexNode
vn
=
new
VertexNode
(
v
);
TreeItem
<
Renderable
>
tiV
=
new
TreeItem
<>(
vn
);
tiRing
.
getChildren
().
add
(
tiV
);
}
}
}
private
CheckStatus
determineCheckStatus
(
Checkable
c
)
{
if
(!
c
.
isValidated
())
{
return
CheckStatus
.
NOT_CHECKED
;
}
if
(
c
.
containsAnyError
())
{
return
CheckStatus
.
ERROR
;
}
return
CheckStatus
.
OK
;
}
private
void
render
(
Collection
<?
extends
Polygon
>
polygons
)
{
Platform
.
runLater
(
this
::
clearGeometryTrees
);
currentTriGeom
=
TriangulatedGeometry
.
of
(
polygons
);
errVisitor
.
setGeometry
(
currentTriGeom
);
setupRenderState
();
}
private
void
clearGeometryTrees
()
{
highlightController
.
clearHighlights
();
mainWindow
.
getErrorTree
().
getRoot
().
getChildren
().
clear
();
mainWindow
.
getPolygonsView
().
getRoot
().
getChildren
().
clear
();
mainWindow
.
getEdgeView
().
getRoot
().
getChildren
().
clear
();
mainWindow
.
getVertexView
().
getRoot
().
getChildren
().
clear
();
}
public
void
renderBuildings
(
List
<
Building
>
objects
)
{
errorUpdater
=
null
;
refresher
=
()
->
{
Platform
.
runLater
(()
->
{
loadingDialog
.
show
();
clearGeometryTrees
();
});
Thread
t
=
new
Thread
(()
->
{
Set
<
ConcretePolygon
>
polygons
=
new
HashSet
<>();
for
(
Building
b
:
objects
)
{
collectBuildingPolygons
(
polygons
,
b
);
for
(
BuildingPart
bp
:
b
.
getBuildingParts
())
{
collectBuildingPolygons
(
polygons
,
bp
);
}
}
currentTriGeom
=
TriangulatedGeometry
.
of
(
polygons
);
errVisitor
.
setGeometry
(
currentTriGeom
);
Platform
.
runLater
(()
->
{
setupRenderState
();
mainWindow
.
zoomOutForBoundingBox
(
BoundingBox
.
of
(
polygons
));
loadingDialog
.
hide
();
});
});
t
.
setUncaughtExceptionHandler
((
thread
,
e
)
->
{
Platform
.
runLater
(()
->
loadingDialog
.
hide
());
logger
.
catching
(
e
);
});
t
.
start
();
};
refresher
.
run
();
}
public
void
render
(
CityDoctorModel
model
)
{
errorUpdater
=
null
;
refresher
=
()
->
{
Platform
.
runLater
(()
->
{
loadingDialog
.
show
();
clearGeometryTrees
();
});
Thread
t
=
new
Thread
(()
->
{
currentTriGeom
=
TriangulatedGeometry
.
of
(
model
,
lodFilters
);
errVisitor
.
setGeometry
(
currentTriGeom
);
Platform
.
runLater
(()
->
{
setupRenderState
();
mainWindow
.
zoomOutForBoundingBox
(
BoundingBox
.
of
(
model
));
loadingDialog
.
hide
();
});
});
t
.
setUncaughtExceptionHandler
((
thread
,
e
)
->
{
Platform
.
runLater
(()
->
loadingDialog
.
hide
());
logger
.
catching
(
e
);
});
t
.
start
();
};
refresher
.
run
();
}
public
void
renderVegetation
(
List
<
Vegetation
>
vegetation
)
{
renderCityObjects
(
vegetation
,
Color
.
LIGHTGREEN
);
}
public
void
renderTransportation
(
List
<
TransportationObject
>
transportation
)
{
renderCityObjects
(
transportation
,
Color
.
YELLOW
);
}
public
void
renderBridges
(
List
<
BridgeObject
>
bridges
)
{
renderCityObjects
(
bridges
,
Color
.
CORAL
);
}
public
void
renderWater
(
List
<
WaterObject
>
water
)
{
renderCityObjects
(
water
,
Color
.
LIGHTSKYBLUE
);
}
public
void
renderCityFurniture
(
List
<
CityFurniture
>
cityFurniture
){
errorUpdater
=
null
;
refresher
=
()
->
{
Platform
.
runLater
(()
->
{
loadingDialog
.
show
();
clearGeometryTrees
();
});
Thread
t
=
new
Thread
(()
->
{
Set
<
ConcretePolygon
>
polygons
=
new
HashSet
<>();
for
(
CityFurniture
cf
:
cityFurniture
)
{
collectCityFurniture
(
polygons
,
cf
);
}
currentTriGeom
=
TriangulatedGeometry
.
of
(
polygons
,
Color
.
BLUEVIOLET
);
errVisitor
.
setGeometry
(
currentTriGeom
);
Platform
.
runLater
(()
->
{
setupRenderState
();
mainWindow
.
zoomOutForBoundingBox
(
BoundingBox
.
of
(
polygons
));
loadingDialog
.
hide
();
});
});
t
.
setUncaughtExceptionHandler
((
thread
,
e
)
->
{
Platform
.
runLater
(()
->
loadingDialog
.
hide
());
logger
.
catching
(
e
);
});
t
.
start
();
};
refresher
.
run
();
}
public
void
renderTerrain
(
List
<
CityObject
>
land
)
{
renderLandObjects
(
land
,
Color
.
BROWN
);
}
private
void
renderLandObjects
(
List
<
CityObject
>
cos
,
Color
baseColor
)
{
errorUpdater
=
null
;
refresher
=
()
->
{
Platform
.
runLater
(()
->
{
loadingDialog
.
show
();
clearGeometryTrees
();
});
Thread
t
=
new
Thread
(()
->
{
Set
<
ConcretePolygon
>
polygons
=
new
HashSet
<>();
for
(
CityObject
co
:
cos
)
{
addPolygons
(
co
,
polygons
);
if
(
co
instanceof
ReliefObject
)
{
ReliefObject
relief
=
(
ReliefObject
)
co
;
for
(
TinObject
tin
:
relief
.
getComponents
())
{
addPolygons
(
tin
,
polygons
);
}
}
}
currentTriGeom
=
TriangulatedGeometry
.
of
(
polygons
,
baseColor
);
errVisitor
.
setGeometry
(
currentTriGeom
);
Platform
.
runLater
(()
->
{
setupRenderState
();
mainWindow
.
zoomOutForBoundingBox
(
BoundingBox
.
of
(
polygons
));
loadingDialog
.
hide
();
});
});
t
.
setUncaughtExceptionHandler
((
thread
,
e
)
->
Platform
.
runLater
(()
->
loadingDialog
.
hide
()));
t
.
start
();
};
refresher
.
run
();
}
public
void
renderCityObjects
(
List
<?
extends
CityObject
>
cos
,
Color
baseColor
)
{
errorUpdater
=
null
;
refresher
=
()
->
{
Platform
.
runLater
(()
->
{
loadingDialog
.
show
();
clearGeometryTrees
();
});
Thread
t
=
new
Thread
(()
->
{
Set
<
ConcretePolygon
>
polygons
=
new
HashSet
<>();
for
(
CityObject
co
:
cos
)
{
addPolygons
(
co
,
polygons
);
}
currentTriGeom
=
TriangulatedGeometry
.
of
(
polygons
,
baseColor
);
errVisitor
.
setGeometry
(
currentTriGeom
);
Platform
.
runLater
(()
->
{
setupRenderState
();
mainWindow
.
zoomOutForBoundingBox
(
BoundingBox
.
of
(
polygons
));
loadingDialog
.
hide
();
});
});
t
.
setUncaughtExceptionHandler
((
thread
,
e
)
->
Platform
.
runLater
(()
->
loadingDialog
.
hide
()));
t
.
start
();
};
refresher
.
run
();
}
public
void
renderTunnels
(
List
<
Tunnel
>
objects
){
errorUpdater
=
null
;
refresher
=
()
->
{
Platform
.
runLater
(()
->
{
loadingDialog
.
show
();
clearGeometryTrees
();
});
Thread
t
=
new
Thread
(()
->
{
Set
<
ConcretePolygon
>
polygons
=
new
HashSet
<>();
for
(
Tunnel
tunnel
:
objects
)
{
collectTunnelPolygons
(
polygons
,
tunnel
);
for
(
TunnelPart
tp
:
tunnel
.
getTunnelParts
())
{
collectTunnelPolygons
(
polygons
,
tp
);
}
}
currentTriGeom
=
TriangulatedGeometry
.
of
(
polygons
);
errVisitor
.
setGeometry
(
currentTriGeom
);
Platform
.
runLater
(()
->
{
setupRenderState
();
mainWindow
.
zoomOutForBoundingBox
(
BoundingBox
.
of
(
polygons
));
loadingDialog
.
hide
();
});
});
t
.
setUncaughtExceptionHandler
((
thread
,
e
)
->
{
Platform
.
runLater
(()
->
loadingDialog
.
hide
());
logger
.
catching
(
e
);
});
t
.
start
();
};
refresher
.
run
();
}
private
void
collectBuildingPolygons
(
Set
<
ConcretePolygon
>
polygons
,
AbstractBuilding
ab
)
{
addPolygons
(
ab
,
polygons
);
for
(
Installation
bi
:
ab
.
getBuildingInstallations
())
{
addPolygons
(
bi
,
polygons
);
for
(
BoundarySurface
bs
:
bi
.
getBoundarySurfaces
())
{
addPolygons
(
bs
,
polygons
);
for
(
Opening
o
:
bs
.
getOpenings
())
{
addPolygons
(
o
,
polygons
);
}
}
}
for
(
BuildingRoom
br
:
ab
.
getBuildingRooms
())
{
addPolygons
(
br
,
polygons
);
for
(
BoundarySurface
bs
:
br
.
getBoundarySurfaceList
()){
addPolygons
(
bs
,
polygons
);
}
}
for
(
BoundarySurface
bs
:
ab
.
getBoundarySurfaces
())
{
addPolygons
(
bs
,
polygons
);
for
(
Opening
o
:
bs
.
getOpenings
())
{
addPolygons
(
o
,
polygons
);
}
}
}
public
void
collectTunnelPolygons
(
Set
<
ConcretePolygon
>
polygons
,
AbstractTunnel
at
)
{}
private
void
collectCityFurniture
(
Set
<
ConcretePolygon
>
polygons
,
CityFurniture
cf
)
{
addPolygons
(
cf
,
polygons
);
}
private
void
addConcretePolygons
(
Set
<
ConcretePolygon
>
polygons
,
Geometry
geom
)
{
for
(
Polygon
p
:
geom
.
getPolygons
())
{
if
(
p
.
getOriginal
().
getPartOfSurface
()
!=
null
&&
!
roofFilter
.
allowedToUse
(
p
.
getOriginal
().
getPartOfSurface
(),
p
.
getParent
()))
continue
;
if
(
p
instanceof
CompositePolygon
)
continue
;
polygons
.
add
(
p
.
getOriginal
());
}
}
private
void
setupRenderState
()
{
currentTriGeom
.
setCullFace
(
currentCulling
);
currentTriGeom
.
setDrawMode
(
currentDrawMode
);
Platform
.
runLater
(()
->
{
mainWindow
.
getMeshGroup
().
getChildren
().
clear
();
mainWindow
.
getMeshGroup
().
getChildren
().
addAll
(
currentTriGeom
.
getMeshes
());
});
mainWindow
.
getGridButton
().
setDisable
(
false
);
mainWindow
.
getCullingButton
().
setDisable
(
false
);
}
public
void
showWireFrame
(
boolean
show
)
{
if
(
currentTriGeom
!=
null
)
{
if
(
show
)
{
currentDrawMode
=
DrawMode
.
LINE
;
}
else
{
currentDrawMode
=
DrawMode
.
FILL
;
}
currentTriGeom
.
setDrawMode
(
currentDrawMode
);
}
}
public
void
enableCulling
(
boolean
enable
)
{
if
(
currentTriGeom
!=
null
)
{
if
(
enable
)
{
currentCulling
=
CullFace
.
BACK
;
}
else
{
currentCulling
=
CullFace
.
NONE
;
}
currentTriGeom
.
setCullFace
(
currentCulling
);
}
}
public
void
clearCurrentRender
()
{
// don't render anything
Platform
.
runLater
(()
->
{
mainWindow
.
getMeshGroup
().
getChildren
().
clear
();
clearGeometryTrees
();
});
}
public
void
highlight
(
Polygon
p
)
{
highlightController
.
highlight
(
p
,
currentTriGeom
);
}
public
void
highlight
(
LinearRing
lr
)
{
highlightController
.
highlight
(
lr
,
currentTriGeom
);
}
public
void
highlight
(
Edge
e
)
{
highlightController
.
highlight
(
e
,
currentTriGeom
);
}
public
void
highlight
(
Vertex
v
)
{
highlightController
.
highlight
(
v
,
currentTriGeom
);
}
public
void
highlight
(
List
<
LinearRing
>
highlightedRings
)
{
highlightController
.
highlight
(
highlightedRings
,
currentTriGeom
);
}
public
void
highlightEdges
(
List
<
Edge
>
edges
)
{
highlightController
.
highlightEdges
(
edges
,
currentTriGeom
);
}
public
void
highlightPolygons
(
List
<
List
<
Polygon
>>
components
)
{
highlightController
.
highlightPolygons
(
components
,
currentTriGeom
);
}
public
void
addHighlight
(
Vertex
vertex
,
Color
c
)
{
highlightController
.
addHighlight
(
vertex
,
currentTriGeom
,
c
);
}
public
void
highlight
(
CheckError
err
)
{
err
.
accept
(
errVisitor
);
}
public
void
refresh
()
{
if
(
refresher
!=
null
)
{
refresher
.
run
();
}
}
public
void
updateErrors
()
{
if
(
errorUpdater
!=
null
)
{
errorUpdater
.
run
();
}
}
public
void
clearHighlights
()
{
highlightController
.
clearHighlights
();
}
public
void
addHighlight
(
Polygon
p
)
{
highlightController
.
addHighlight
(
p
,
currentTriGeom
);
}
public
void
addHighlight
(
Triangle3d
t
)
{
highlightController
.
highlight
(
t
,
currentTriGeom
);
}
public
void
reset
()
{
errorUpdater
=
null
;
refresher
=
null
;
}
private
static
final
Logger
logger
=
LogManager
.
getLogger
(
Renderer
.
class
);
private
TriangulatedGeometry
currentTriGeom
;
private
Geometry
currentGeometry
;
private
CullFace
currentCulling
=
CullFace
.
BACK
;
private
DrawMode
currentDrawMode
=
DrawMode
.
FILL
;
private
MainWindow
mainWindow
;
private
HighlightController
highlightController
;
private
ListErrorVisitor
errVisitor
;
private
LoadingInfoDialog
loadingDialog
;
private
List
<
ViewFilter
>
lodFilters
=
new
ArrayList
<>();
private
ViewFilter
roofFilter
;
private
Runnable
refresher
;
private
Runnable
errorUpdater
;
public
Renderer
(
MainWindow
mainWindow
,
HighlightController
highlightController
)
throws
IOException
{
this
.
mainWindow
=
mainWindow
;
this
.
highlightController
=
highlightController
;
loadingDialog
=
new
LoadingInfoDialog
(
mainWindow
.
getMainStage
());
errVisitor
=
new
ListErrorVisitor
(
highlightController
);
setupLodFilters
();
}
private
void
setupLodFilters
()
{
lodFilters
.
add
(
new
ViewFilter
()
{
@Override
public
boolean
useGeometry
(
CityObject
co
,
Geometry
geom
)
{
return
geom
.
getLod
()
==
Lod
.
LOD1
;
}
});
lodFilters
.
add
(
new
ViewFilter
()
{
@Override
public
boolean
useGeometry
(
CityObject
co
,
Geometry
geom
)
{
return
geom
.
getLod
()
==
Lod
.
LOD2
;
}
});
lodFilters
.
add
(
new
ViewFilter
()
{
@Override
public
boolean
useGeometry
(
CityObject
co
,
Geometry
geom
)
{
return
geom
.
getLod
()
==
Lod
.
LOD3
;
}
});
lodFilters
.
add
(
new
ViewFilter
()
{
@Override
protected
boolean
useGeometry
(
CityObject
co
,
Geometry
geom
)
{
return
geom
.
getLod
()
==
Lod
.
LOD0
;
}
});
lodFilters
.
add
(
new
ViewFilter
()
{
@Override
public
boolean
useGeometry
(
CityObject
co
,
Geometry
geom
)
{
return
geom
.
getLod
()
==
Lod
.
LOD4
;
}
});
roofFilter
=
new
ViewFilter
()
{
@Override
public
boolean
allowedToUse
(
CityObject
co
,
Geometry
geom
)
{
if
(!
this
.
isEnabled
())
{
return
true
;
}
return
this
.
useGeometry
(
co
,
geom
);
}
@Override
public
boolean
useGeometry
(
CityObject
co
,
Geometry
geom
)
{
if
(
co
instanceof
BoundarySurface
bs
)
{
return
bs
.
getType
()
!=
BoundarySurfaceType
.
ROOF
;
}
return
true
;
}
};
roofFilter
.
setEnable
(
false
);
}
public
void
enableLod1
()
{
lodFilters
.
get
(
0
).
enable
();
if
(
refresher
!=
null
)
{
refresher
.
run
();
}
}
public
void
disableLod1
()
{
lodFilters
.
get
(
0
).
disable
();
if
(
refresher
!=
null
)
{
refresher
.
run
();
}
}
public
void
enableLod2
()
{
lodFilters
.
get
(
1
).
enable
();
if
(
refresher
!=
null
)
{
refresher
.
run
();
}
}
public
void
disableLod2
()
{
lodFilters
.
get
(
1
).
disable
();
if
(
refresher
!=
null
)
{
refresher
.
run
();
}
}
public
void
enableLod3
()
{
lodFilters
.
get
(
2
).
enable
();
if
(
refresher
!=
null
)
{
refresher
.
run
();
}
}
public
void
disableLod3
()
{
lodFilters
.
get
(
2
).
disable
();
if
(
refresher
!=
null
)
{
refresher
.
run
();
}
}
public
void
enableLod4
()
{
lodFilters
.
get
(
3
).
enable
();
if
(
refresher
!=
null
)
{
refresher
.
run
();
}
}
public
void
disableLod4
()
{
lodFilters
.
get
(
3
).
disable
();
if
(
refresher
!=
null
)
{
refresher
.
run
();
}
}
public
void
hideRoofs
()
{
roofFilter
.
setEnable
(
true
);
if
(
refresher
!=
null
)
{
refresher
.
run
();
}
}
public
void
showRoofs
()
{
roofFilter
.
setEnable
(
false
);
if
(
refresher
!=
null
)
{
refresher
.
run
();
}
}
public
void
render
(
Building
building
)
{
refresher
=
()
->
{
Set
<
ConcretePolygon
>
setupBuildingPolygons
=
setupBuildingPolygons
(
building
);
mainWindow
.
zoomOutForBoundingBox
(
BoundingBox
.
of
(
setupBuildingPolygons
));
render
(
setupBuildingPolygons
);
Platform
.
runLater
(()
->
{
errorUpdater
=
()
->
displayErrors
(
building
);
errorUpdater
.
run
();
});
};
refresher
.
run
();
}
private
Set
<
ConcretePolygon
>
setupBuildingPolygons
(
Building
b
)
{
Set
<
ConcretePolygon
>
polygons
=
new
HashSet
<>();
addPolygons
(
b
,
polygons
);
for
(
BoundarySurface
bs
:
b
.
getBoundarySurfaces
())
{
addPolygons
(
bs
,
polygons
);
for
(
Opening
op
:
bs
.
getOpenings
())
{
addPolygons
(
op
,
polygons
);
}
}
for
(
Installation
bi
:
b
.
getBuildingInstallations
())
{
addPolygons
(
bi
,
polygons
);
for
(
BoundarySurface
bs
:
bi
.
getBoundarySurfaces
())
{
addPolygons
(
bs
,
polygons
);
for
(
Opening
op
:
bs
.
getOpenings
())
{
addPolygons
(
op
,
polygons
);
}
}
}
for
(
BuildingRoom
br
:
b
.
getBuildingRooms
())
{
addPolygons
(
br
,
polygons
);
for
(
BoundarySurface
bs
:
br
.
getBoundarySurfaceList
())
{
addPolygons
(
bs
,
polygons
);
}
}
for
(
BuildingRoomFurniture
brf
:
b
.
getBuildingRoomFurnitureList
())
{
addPolygons
(
brf
,
polygons
);
for
(
BoundarySurface
bs
:
brf
.
getBoundarySurfaceList
())
{
addPolygons
(
bs
,
polygons
);
}
}
for
(
BuildingPart
bp
:
b
.
getBuildingParts
())
{
polygons
.
addAll
(
setupBuildingPartPolygons
(
bp
));
}
return
polygons
;
}
public
void
render
(
BuildingPart
bp
)
{
refresher
=
()
->
{
Set
<
ConcretePolygon
>
setupBuildingPartPolygons
=
setupBuildingPartPolygons
(
bp
);
mainWindow
.
zoomOutForBoundingBox
(
BoundingBox
.
of
(
setupBuildingPartPolygons
));
render
(
setupBuildingPartPolygons
);
Platform
.
runLater
(()
->
{
errorUpdater
=
()
->
displayErrors
(
bp
);
errorUpdater
.
run
();
});
};
refresher
.
run
();
}
private
Set
<
ConcretePolygon
>
setupBuildingPartPolygons
(
BuildingPart
bp
)
{
Set
<
ConcretePolygon
>
polygons
=
new
HashSet
<>();
addPolygons
(
bp
,
polygons
);
for
(
BoundarySurface
bs
:
bp
.
getBoundarySurfaces
())
{
addPolygons
(
bs
,
polygons
);
for
(
Opening
op
:
bs
.
getOpenings
())
{
addPolygons
(
op
,
polygons
);
}
}
for
(
Installation
bi
:
bp
.
getBuildingInstallations
())
{
addPolygons
(
bi
,
polygons
);
for
(
BoundarySurface
bs
:
bi
.
getBoundarySurfaces
())
{
addPolygons
(
bs
,
polygons
);
for
(
Opening
op
:
bs
.
getOpenings
())
{
addPolygons
(
op
,
polygons
);
}
}
}
return
polygons
;
}
public
void
render
(
AbstractRoom
room
)
{
refresher
=
()
->
{
Set
<
ConcretePolygon
>
setupRoomPolygons
=
setupRoomPolygons
(
room
);
mainWindow
.
zoomOutForBoundingBox
(
BoundingBox
.
of
(
setupRoomPolygons
));
render
(
setupRoomPolygons
);
Platform
.
runLater
(()
->
{
errorUpdater
=
()
->
displayErrors
(
room
);
errorUpdater
.
run
();
});
};
refresher
.
run
();
}
private
Set
<
ConcretePolygon
>
setupRoomPolygons
(
AbstractRoom
room
)
{
Set
<
ConcretePolygon
>
polygons
=
new
HashSet
<>();
addPolygons
(
room
,
polygons
);
for
(
BoundarySurface
bs
:
room
.
getBoundarySurfaceList
())
{
addPolygons
(
bs
,
polygons
);
for
(
Opening
op
:
bs
.
getOpenings
())
{
addPolygons
(
op
,
polygons
);
}
}
return
polygons
;
}
public
void
render
(
AbstractFurniture
furniture
)
{
refresher
=
()
->
{
Set
<
ConcretePolygon
>
setupFurniturePolygons
=
setupFurniturePolygons
(
furniture
);
mainWindow
.
zoomOutForBoundingBox
(
BoundingBox
.
of
(
setupFurniturePolygons
));
render
(
setupFurniturePolygons
);
Platform
.
runLater
(()
->
{
errorUpdater
=
()
->
displayErrors
(
furniture
);
errorUpdater
.
run
();
});
};
refresher
.
run
();
}
private
Set
<
ConcretePolygon
>
setupFurniturePolygons
(
AbstractFurniture
furniture
)
{
Set
<
ConcretePolygon
>
polygons
=
new
HashSet
<>();
addPolygons
(
furniture
,
polygons
);
for
(
BoundarySurface
bs
:
furniture
.
getBoundarySurfaceList
())
{
addPolygons
(
bs
,
polygons
);
for
(
Opening
op
:
bs
.
getOpenings
())
{
addPolygons
(
op
,
polygons
);
}
}
return
polygons
;
}
public
void
render
(
Storey
storey
)
{
refresher
=
()
->
{
Set
<
ConcretePolygon
>
setupStoreyPolygons
=
setupStoreyPolygons
(
storey
);
mainWindow
.
zoomOutForBoundingBox
(
BoundingBox
.
of
(
setupStoreyPolygons
));
render
(
setupStoreyPolygons
);
Platform
.
runLater
(()
->
{
errorUpdater
=
()
->
displayErrors
(
storey
);
errorUpdater
.
run
();
});
};
refresher
.
run
();
}
private
Set
<
ConcretePolygon
>
setupStoreyPolygons
(
Storey
storey
)
{
Set
<
ConcretePolygon
>
polygons
=
new
HashSet
<>();
addPolygons
(
storey
,
polygons
);
for
(
BoundarySurface
bs
:
storey
.
getBoundarySurfaces
())
{
addPolygons
(
bs
,
polygons
);
for
(
Opening
op
:
bs
.
getOpenings
())
{
addPolygons
(
op
,
polygons
);
}
}
return
polygons
;
}
public
void
render
(
BuildingUnit
buildingUnit
)
{
refresher
=
()
->
{
Set
<
ConcretePolygon
>
setupBuildingUnitPolgons
=
setupBuildingUnitPolygons
(
buildingUnit
);
mainWindow
.
zoomOutForBoundingBox
(
BoundingBox
.
of
(
setupBuildingUnitPolgons
));
render
(
setupBuildingUnitPolgons
);
Platform
.
runLater
(()
->
{
errorUpdater
=
()
->
displayErrors
(
buildingUnit
);
errorUpdater
.
run
();
});
};
refresher
.
run
();
}
private
Set
<
ConcretePolygon
>
setupBuildingUnitPolygons
(
BuildingUnit
buildingUnit
)
{
Set
<
ConcretePolygon
>
polygons
=
new
HashSet
<>();
addPolygons
(
buildingUnit
,
polygons
);
for
(
BoundarySurface
bs
:
buildingUnit
.
getBoundarySurfaces
())
{
addPolygons
(
bs
,
polygons
);
for
(
Opening
op
:
bs
.
getOpenings
())
{
addPolygons
(
op
,
polygons
);
}
}
return
polygons
;
}
public
void
render
(
Tunnel
tunnel
)
{
refresher
=
()
->
{
Set
<
ConcretePolygon
>
setupTunnelPolygons
=
setupTunnelPolygons
(
tunnel
);
mainWindow
.
zoomOutForBoundingBox
(
BoundingBox
.
of
(
setupTunnelPolygons
));
render
(
setupTunnelPolygons
);
Platform
.
runLater
(()
->
{
errorUpdater
=
()
->
displayErrors
(
tunnel
);
errorUpdater
.
run
();
});
};
refresher
.
run
();
}
private
Set
<
ConcretePolygon
>
setupTunnelPolygons
(
Tunnel
tunnel
)
{
Set
<
ConcretePolygon
>
polygons
=
new
HashSet
<>();
addPolygons
(
tunnel
,
polygons
);
for
(
BoundarySurface
bs
:
tunnel
.
getBoundarySurfaces
())
{
addPolygons
(
bs
,
polygons
);
}
for
(
Installation
ti
:
tunnel
.
getTunnelInstallations
())
{
addPolygons
(
ti
,
polygons
);
for
(
BoundarySurface
bs
:
ti
.
getBoundarySurfaces
())
{
addPolygons
(
bs
,
polygons
);
for
(
Opening
op
:
bs
.
getOpenings
())
{
addPolygons
(
op
,
polygons
);
}
}
}
for
(
TunnelHollow
th
:
tunnel
.
getTunnelHollows
())
{
addPolygons
(
th
,
polygons
);
for
(
BoundarySurface
bs
:
th
.
getBoundarySurfaceList
())
{
addPolygons
(
bs
,
polygons
);
}
}
for
(
TunnelFurniture
tf
:
tunnel
.
getTunnelFurnitureList
())
{
addPolygons
(
tf
,
polygons
);
for
(
BoundarySurface
bs
:
tf
.
getBoundarySurfaceList
())
{
addPolygons
(
bs
,
polygons
);
}
}
for
(
TunnelPart
tp
:
tunnel
.
getTunnelParts
())
{
polygons
.
addAll
(
setupTunnelPartPolygons
(
tp
));
}
return
polygons
;
}
private
Set
<
ConcretePolygon
>
setupTunnelPartPolygons
(
TunnelPart
tp
)
{
Set
<
ConcretePolygon
>
polygons
=
new
HashSet
<>();
addPolygons
(
tp
,
polygons
);
for
(
BoundarySurface
bs
:
tp
.
getBoundarySurfaces
())
{
addPolygons
(
bs
,
polygons
);
for
(
Opening
op
:
bs
.
getOpenings
())
{
addPolygons
(
op
,
polygons
);
}
}
for
(
Installation
bi
:
tp
.
getTunnelInstallations
())
{
addPolygons
(
bi
,
polygons
);
for
(
BoundarySurface
bs
:
bi
.
getBoundarySurfaces
())
{
addPolygons
(
bs
,
polygons
);
for
(
Opening
op
:
bs
.
getOpenings
())
{
addPolygons
(
op
,
polygons
);
}
}
}
return
polygons
;
}
public
void
render
(
BridgeObject
bridge
)
{
refresher
=
()
->
{
Set
<
ConcretePolygon
>
setupBridgePolygons
=
setupBridgePolygons
(
bridge
);
mainWindow
.
zoomOutForBoundingBox
(
BoundingBox
.
of
(
setupBridgePolygons
));
render
(
setupBridgePolygons
);
Platform
.
runLater
(()
->
{
errorUpdater
=
()
->
displayErrors
(
bridge
);
errorUpdater
.
run
();
});
};
refresher
.
run
();
}
private
Set
<
ConcretePolygon
>
setupBridgePolygons
(
BridgeObject
bridge
)
{
Set
<
ConcretePolygon
>
polygons
=
new
HashSet
<>();
addPolygons
(
bridge
,
polygons
);
for
(
BoundarySurface
bs
:
bridge
.
getBoundarySurfaces
())
{
addPolygons
(
bs
,
polygons
);
}
for
(
BridgeConstructiveElement
consElement
:
bridge
.
getConstructiveElements
())
{
addPolygons
(
consElement
,
polygons
);
for
(
BoundarySurface
bs
:
consElement
.
getBoundarySurfaces
())
{
addPolygons
(
bs
,
polygons
);
}
}
for
(
Installation
inst
:
bridge
.
getBridgeInstallations
())
{
addPolygons
(
inst
,
polygons
);
for
(
BoundarySurface
bs
:
inst
.
getBoundarySurfaces
())
{
addPolygons
(
bs
,
polygons
);
}
}
return
polygons
;
}
public
void
render
(
CityObject
co
)
{
refresher
=
()
->
{
Set
<
ConcretePolygon
>
setupCityObjectPolygons
=
setupCityObjectPolygons
(
co
);
mainWindow
.
zoomOutForBoundingBox
(
BoundingBox
.
of
(
setupCityObjectPolygons
));
render
(
setupCityObjectPolygons
);
Platform
.
runLater
(()
->
{
errorUpdater
=
()
->
displayErrors
(
co
);
errorUpdater
.
run
();
});
};
refresher
.
run
();
}
public
void
render
(
ReliefObject
relief
)
{
refresher
=
()
->
{
Set
<
ConcretePolygon
>
setupCityObjectPolygons
=
setupReliefPolygons
(
relief
);
mainWindow
.
zoomOutForBoundingBox
(
BoundingBox
.
of
(
setupCityObjectPolygons
));
render
(
setupCityObjectPolygons
);
Platform
.
runLater
(()
->
{
errorUpdater
=
()
->
displayErrors
(
relief
);
errorUpdater
.
run
();
});
};
refresher
.
run
();
}
private
Set
<
ConcretePolygon
>
setupReliefPolygons
(
ReliefObject
relief
)
{
Set
<
ConcretePolygon
>
polygons
=
new
HashSet
<>();
addPolygons
(
relief
,
polygons
);
for
(
TinObject
tin
:
relief
.
getComponents
())
{
addPolygons
(
tin
,
polygons
);
}
return
polygons
;
}
public
void
render
(
Installation
bi
)
{
refresher
=
()
->
{
Set
<
ConcretePolygon
>
setupCityObjectPolygons
=
setupBuildingInstallationPolygons
(
bi
);
mainWindow
.
zoomOutForBoundingBox
(
BoundingBox
.
of
(
setupCityObjectPolygons
));
render
(
setupCityObjectPolygons
);
Platform
.
runLater
(()
->
{
errorUpdater
=
()
->
displayErrors
(
bi
);
errorUpdater
.
run
();
});
};
refresher
.
run
();
}
private
Set
<
ConcretePolygon
>
setupBuildingInstallationPolygons
(
Installation
bi
)
{
Set
<
ConcretePolygon
>
polygons
=
new
HashSet
<>();
addPolygons
(
bi
,
polygons
);
for
(
BoundarySurface
bs
:
bi
.
getBoundarySurfaces
())
{
addPolygons
(
bs
,
polygons
);
for
(
Opening
op
:
bs
.
getOpenings
())
{
addPolygons
(
op
,
polygons
);
}
}
return
polygons
;
}
public
void
render
(
CityFurniture
cf
)
{
refresher
=
()
->
{
Set
<
ConcretePolygon
>
setupCityFurniturePolygons
=
setupCityFurniturePolygons
(
cf
);
mainWindow
.
zoomOutForBoundingBox
(
BoundingBox
.
of
(
setupCityFurniturePolygons
));
render
(
setupCityFurniturePolygons
);
Platform
.
runLater
(()
->
{
errorUpdater
=
()
->
displayErrors
(
cf
);
errorUpdater
.
run
();
});
};
refresher
.
run
();
}
private
Set
<
ConcretePolygon
>
setupCityFurniturePolygons
(
CityFurniture
cf
)
{
Set
<
ConcretePolygon
>
polygons
=
new
HashSet
<>();
addPolygons
(
cf
,
polygons
);
return
polygons
;
}
public
void
render
(
GenericCityObject
gco
)
{
refresher
=
()
->
{
Set
<
ConcretePolygon
>
setupGenericCityObjectPolygons
=
setupGenericCityObjectPolygons
(
gco
);
mainWindow
.
zoomOutForBoundingBox
(
BoundingBox
.
of
(
setupGenericCityObjectPolygons
));
render
(
setupGenericCityObjectPolygons
);
Platform
.
runLater
(()
->
{
errorUpdater
=
()
->
displayErrors
(
gco
);
errorUpdater
.
run
();
});
};
refresher
.
run
();
}
private
Set
<
ConcretePolygon
>
setupGenericCityObjectPolygons
(
GenericCityObject
gco
)
{
Set
<
ConcretePolygon
>
polygons
=
new
HashSet
<>();
addPolygons
(
gco
,
polygons
);
for
(
BoundarySurface
bs
:
gco
.
getBoundarySurfaces
())
{
addPolygons
(
bs
,
polygons
);
for
(
Opening
op
:
bs
.
getOpenings
())
{
addPolygons
(
op
,
polygons
);
}
}
return
polygons
;
}
public
void
render
(
BoundarySurface
bs
)
{
refresher
=
()
->
{
Set
<
ConcretePolygon
>
setupBoundarySurfacePolygons
=
setupBoundarySurfacePolygons
(
bs
);
mainWindow
.
zoomOutForBoundingBox
(
BoundingBox
.
of
(
setupBoundarySurfacePolygons
));
render
(
setupBoundarySurfacePolygons
);
Platform
.
runLater
(()
->
{
errorUpdater
=
()
->
displayErrors
(
bs
);
errorUpdater
.
run
();
});
};
refresher
.
run
();
}
private
Set
<
ConcretePolygon
>
setupBoundarySurfacePolygons
(
BoundarySurface
bs
)
{
Set
<
ConcretePolygon
>
polygons
=
new
HashSet
<>();
addPolygons
(
bs
,
polygons
);
for
(
Opening
op
:
bs
.
getOpenings
())
{
addPolygons
(
op
,
polygons
);
}
return
polygons
;
}
private
Set
<
ConcretePolygon
>
setupCityObjectPolygons
(
CityObject
co
)
{
Set
<
ConcretePolygon
>
polygons
=
new
HashSet
<>();
addPolygons
(
co
,
polygons
);
return
polygons
;
}
private
void
addPolygons
(
CityObject
co
,
Set
<
ConcretePolygon
>
polygons
)
{
for
(
Geometry
geom
:
co
.
getGeometries
())
{
boolean
used
=
false
;
for
(
ViewFilter
filter
:
lodFilters
)
{
if
(
filter
.
allowedToUse
(
co
,
geom
))
{
used
=
true
;
break
;
}
}
if
(
used
)
{
if
(
roofFilter
.
allowedToUse
(
co
,
geom
))
{
addConcretePolygons
(
polygons
,
geom
);
}
}
}
}
private
void
displayErrors
(
Checkable
c
)
{
if
(!
c
.
isValidated
())
{
return
;
}
List
<
CheckError
>
errors
=
new
ArrayList
<>();
c
.
collectContainedErrors
(
errors
);
// filter out duplicate errors (polygon can be contained in multiple geometries)
Set
<
CheckError
>
errorSet
=
new
HashSet
<>(
errors
);
for
(
CheckError
err
:
errorSet
)
{
ErrorNode
node
=
new
ErrorNode
(
err
);
TreeItem
<
Renderable
>
errItem
=
new
TreeItem
<>(
node
);
ErrorItemVisitor
visitor
=
new
ErrorItemVisitor
(
errItem
);
err
.
accept
(
visitor
);
mainWindow
.
getErrorTree
().
getRoot
().
getChildren
().
add
(
errItem
);
}
}
public
void
render
(
Geometry
geom
)
{
refresher
=
()
->
{
Platform
.
runLater
(
this
::
clearGeometryTrees
);
currentTriGeom
=
TriangulatedGeometry
.
of
(
geom
);
if
(
geom
.
getEdges
()
==
null
&&
currentGeometry
!=
null
)
{
// if there are no edges available low memory mode is enabled
// clear the old geometry of all meta information
currentGeometry
.
clearMetaInformation
();
}
errVisitor
.
setGeometry
(
currentTriGeom
);
Platform
.
runLater
(()
->
{
setupRenderState
();
if
(
geom
.
getEdges
()
==
null
)
{
// create edges and vertices so they can be listed in the gui
geom
.
prepareForChecking
();
// remember the geometry, so it can be cleared if another is displayed
currentGeometry
=
geom
;
}
addGeometryDataToView
(
geom
);
mainWindow
.
zoomOutForBoundingBox
(
BoundingBox
.
of
(
geom
.
getPolygons
()));
errorUpdater
=
()
->
displayErrors
(
geom
);
errorUpdater
.
run
();
});
};
refresher
.
run
();
}
private
void
addGeometryDataToView
(
Geometry
geom
)
{
for
(
Polygon
p
:
geom
.
getPolygons
())
{
if
(
p
instanceof
CompositePolygon
)
{
continue
;
}
addPolygonToView
(
p
);
}
for
(
Edge
e
:
geom
.
getEdges
())
{
addEdgeToView
(
e
);
}
for
(
Vertex
v
:
geom
.
getVertices
())
{
addVertexToView
(
v
);
}
}
private
void
addVertexToView
(
Vertex
v
)
{
Renderable
cf
=
new
VertexNode
(
v
);
TreeItem
<
Renderable
>
ti
=
new
TreeItem
<>(
cf
);
mainWindow
.
getVertexView
().
getRoot
().
getChildren
().
add
(
ti
);
}
private
void
addEdgeToView
(
Edge
e
)
{
EdgeNode
cf
=
new
EdgeNode
(
e
);
TreeItem
<
Renderable
>
ti
=
new
TreeItem
<>(
cf
);
mainWindow
.
getEdgeView
().
getRoot
().
getChildren
().
add
(
ti
);
}
private
void
addPolygonToView
(
Polygon
p
)
{
CheckStatus
cs
=
determineCheckStatus
(
p
);
PolygonNode
cf
=
new
PolygonNode
(
p
,
cs
);
TreeItem
<
Renderable
>
ti
=
new
TreeItem
<>(
cf
);
mainWindow
.
getPolygonsView
().
getRoot
().
getChildren
().
add
(
ti
);
// add linear rings
CheckStatus
csRing
=
determineCheckStatus
(
p
.
getExteriorRing
());
Renderable
ccRing
=
new
LinearRingNode
(
p
.
getExteriorRing
(),
csRing
);
TreeItem
<
Renderable
>
tiRing
=
new
TreeItem
<>(
ccRing
);
ti
.
getChildren
().
add
(
tiRing
);
for
(
Vertex
v
:
p
.
getExteriorRing
().
getVertices
())
{
VertexNode
vn
=
new
VertexNode
(
v
);
TreeItem
<
Renderable
>
tiV
=
new
TreeItem
<>(
vn
);
tiRing
.
getChildren
().
add
(
tiV
);
}
for
(
LinearRing
lr
:
p
.
getInnerRings
())
{
CheckStatus
csInteriorRing
=
determineCheckStatus
(
lr
);
Renderable
ccInteriorRing
=
new
LinearRingNode
(
lr
,
csInteriorRing
);
TreeItem
<
Renderable
>
tiInteriorRing
=
new
TreeItem
<>(
ccInteriorRing
);
ti
.
getChildren
().
add
(
tiInteriorRing
);
for
(
Vertex
v
:
lr
.
getVertices
())
{
VertexNode
vn
=
new
VertexNode
(
v
);
TreeItem
<
Renderable
>
tiV
=
new
TreeItem
<>(
vn
);
tiRing
.
getChildren
().
add
(
tiV
);
}
}
}
private
CheckStatus
determineCheckStatus
(
Checkable
c
)
{
if
(!
c
.
isValidated
())
{
return
CheckStatus
.
NOT_CHECKED
;
}
if
(
c
.
containsAnyError
())
{
return
CheckStatus
.
ERROR
;
}
return
CheckStatus
.
OK
;
}
private
void
render
(
Collection
<?
extends
Polygon
>
polygons
)
{
Platform
.
runLater
(
this
::
clearGeometryTrees
);
currentTriGeom
=
TriangulatedGeometry
.
of
(
polygons
);
errVisitor
.
setGeometry
(
currentTriGeom
);
setupRenderState
();
}
private
void
clearGeometryTrees
()
{
highlightController
.
clearHighlights
();
mainWindow
.
getErrorTree
().
getRoot
().
getChildren
().
clear
();
mainWindow
.
getPolygonsView
().
getRoot
().
getChildren
().
clear
();
mainWindow
.
getEdgeView
().
getRoot
().
getChildren
().
clear
();
mainWindow
.
getVertexView
().
getRoot
().
getChildren
().
clear
();
}
public
void
renderBuildings
(
List
<
Building
>
objects
)
{
errorUpdater
=
null
;
refresher
=
()
->
{
Platform
.
runLater
(()
->
{
loadingDialog
.
show
();
clearGeometryTrees
();
});
Thread
t
=
new
Thread
(()
->
{
Set
<
ConcretePolygon
>
polygons
=
new
HashSet
<>();
for
(
Building
b
:
objects
)
{
collectBuildingPolygons
(
polygons
,
b
);
for
(
BuildingPart
bp
:
b
.
getBuildingParts
())
{
collectBuildingPolygons
(
polygons
,
bp
);
}
}
currentTriGeom
=
TriangulatedGeometry
.
of
(
polygons
);
errVisitor
.
setGeometry
(
currentTriGeom
);
Platform
.
runLater
(()
->
{
setupRenderState
();
mainWindow
.
zoomOutForBoundingBox
(
BoundingBox
.
of
(
polygons
));
loadingDialog
.
hide
();
});
});
t
.
setUncaughtExceptionHandler
((
thread
,
e
)
->
{
Platform
.
runLater
(()
->
loadingDialog
.
hide
());
logger
.
catching
(
e
);
});
t
.
start
();
};
refresher
.
run
();
}
public
void
render
(
CityDoctorModel
model
)
{
errorUpdater
=
null
;
refresher
=
()
->
{
Platform
.
runLater
(()
->
{
loadingDialog
.
show
();
clearGeometryTrees
();
});
Thread
t
=
new
Thread
(()
->
{
currentTriGeom
=
TriangulatedGeometry
.
of
(
model
,
lodFilters
);
errVisitor
.
setGeometry
(
currentTriGeom
);
Platform
.
runLater
(()
->
{
setupRenderState
();
mainWindow
.
zoomOutForBoundingBox
(
BoundingBox
.
of
(
model
));
loadingDialog
.
hide
();
});
});
t
.
setUncaughtExceptionHandler
((
thread
,
e
)
->
{
Platform
.
runLater
(()
->
loadingDialog
.
hide
());
logger
.
catching
(
e
);
});
t
.
start
();
};
refresher
.
run
();
}
public
void
renderVegetation
(
List
<
Vegetation
>
vegetation
)
{
renderCityObjects
(
vegetation
,
Color
.
LIGHTGREEN
);
}
public
void
renderTransportation
(
List
<
TransportationObject
>
transportation
)
{
renderCityObjects
(
transportation
,
Color
.
YELLOW
);
}
public
void
renderBridges
(
List
<
BridgeObject
>
bridges
)
{
renderCityObjects
(
bridges
,
Color
.
CORAL
);
}
public
void
renderWater
(
List
<
WaterObject
>
water
)
{
renderCityObjects
(
water
,
Color
.
LIGHTSKYBLUE
);
}
public
void
renderCityFurniture
(
List
<
CityFurniture
>
cityFurniture
)
{
errorUpdater
=
null
;
refresher
=
()
->
{
Platform
.
runLater
(()
->
{
loadingDialog
.
show
();
clearGeometryTrees
();
});
Thread
t
=
new
Thread
(()
->
{
Set
<
ConcretePolygon
>
polygons
=
new
HashSet
<>();
for
(
CityFurniture
cf
:
cityFurniture
)
{
collectCityFurniture
(
polygons
,
cf
);
}
currentTriGeom
=
TriangulatedGeometry
.
of
(
polygons
,
Color
.
BLUEVIOLET
);
errVisitor
.
setGeometry
(
currentTriGeom
);
Platform
.
runLater
(()
->
{
setupRenderState
();
mainWindow
.
zoomOutForBoundingBox
(
BoundingBox
.
of
(
polygons
));
loadingDialog
.
hide
();
});
});
t
.
setUncaughtExceptionHandler
((
thread
,
e
)
->
{
Platform
.
runLater
(()
->
loadingDialog
.
hide
());
logger
.
catching
(
e
);
});
t
.
start
();
};
refresher
.
run
();
}
public
void
renderTerrain
(
List
<
CityObject
>
land
)
{
renderLandObjects
(
land
,
Color
.
BROWN
);
}
private
void
renderLandObjects
(
List
<
CityObject
>
cos
,
Color
baseColor
)
{
errorUpdater
=
null
;
refresher
=
()
->
{
Platform
.
runLater
(()
->
{
loadingDialog
.
show
();
clearGeometryTrees
();
});
Thread
t
=
new
Thread
(()
->
{
Set
<
ConcretePolygon
>
polygons
=
new
HashSet
<>();
for
(
CityObject
co
:
cos
)
{
addPolygons
(
co
,
polygons
);
if
(
co
instanceof
ReliefObject
)
{
ReliefObject
relief
=
(
ReliefObject
)
co
;
for
(
TinObject
tin
:
relief
.
getComponents
())
{
addPolygons
(
tin
,
polygons
);
}
}
}
currentTriGeom
=
TriangulatedGeometry
.
of
(
polygons
,
baseColor
);
errVisitor
.
setGeometry
(
currentTriGeom
);
Platform
.
runLater
(()
->
{
setupRenderState
();
mainWindow
.
zoomOutForBoundingBox
(
BoundingBox
.
of
(
polygons
));
loadingDialog
.
hide
();
});
});
t
.
setUncaughtExceptionHandler
((
thread
,
e
)
->
Platform
.
runLater
(()
->
loadingDialog
.
hide
()));
t
.
start
();
};
refresher
.
run
();
}
public
void
renderCityObjects
(
List
<?
extends
CityObject
>
cos
,
Color
baseColor
)
{
errorUpdater
=
null
;
refresher
=
()
->
{
Platform
.
runLater
(()
->
{
loadingDialog
.
show
();
clearGeometryTrees
();
});
Thread
t
=
new
Thread
(()
->
{
Set
<
ConcretePolygon
>
polygons
=
new
HashSet
<>();
for
(
CityObject
co
:
cos
)
{
addPolygons
(
co
,
polygons
);
}
currentTriGeom
=
TriangulatedGeometry
.
of
(
polygons
,
baseColor
);
errVisitor
.
setGeometry
(
currentTriGeom
);
Platform
.
runLater
(()
->
{
setupRenderState
();
mainWindow
.
zoomOutForBoundingBox
(
BoundingBox
.
of
(
polygons
));
loadingDialog
.
hide
();
});
});
t
.
setUncaughtExceptionHandler
((
thread
,
e
)
->
Platform
.
runLater
(()
->
loadingDialog
.
hide
()));
t
.
start
();
};
refresher
.
run
();
}
public
void
renderTunnels
(
List
<
Tunnel
>
objects
)
{
errorUpdater
=
null
;
refresher
=
()
->
{
Platform
.
runLater
(()
->
{
loadingDialog
.
show
();
clearGeometryTrees
();
});
Thread
t
=
new
Thread
(()
->
{
Set
<
ConcretePolygon
>
polygons
=
new
HashSet
<>();
for
(
Tunnel
tunnel
:
objects
)
{
collectTunnelPolygons
(
polygons
,
tunnel
);
for
(
TunnelPart
tp
:
tunnel
.
getTunnelParts
())
{
collectTunnelPolygons
(
polygons
,
tp
);
}
}
currentTriGeom
=
TriangulatedGeometry
.
of
(
polygons
);
errVisitor
.
setGeometry
(
currentTriGeom
);
Platform
.
runLater
(()
->
{
setupRenderState
();
mainWindow
.
zoomOutForBoundingBox
(
BoundingBox
.
of
(
polygons
));
loadingDialog
.
hide
();
});
});
t
.
setUncaughtExceptionHandler
((
thread
,
e
)
->
{
Platform
.
runLater
(()
->
loadingDialog
.
hide
());
logger
.
catching
(
e
);
});
t
.
start
();
};
refresher
.
run
();
}
private
void
collectBuildingPolygons
(
Set
<
ConcretePolygon
>
polygons
,
AbstractBuilding
ab
)
{
addPolygons
(
ab
,
polygons
);
for
(
Installation
bi
:
ab
.
getBuildingInstallations
())
{
addPolygons
(
bi
,
polygons
);
for
(
BoundarySurface
bs
:
bi
.
getBoundarySurfaces
())
{
addPolygons
(
bs
,
polygons
);
for
(
Opening
o
:
bs
.
getOpenings
())
{
addPolygons
(
o
,
polygons
);
}
}
}
for
(
BuildingRoom
br
:
ab
.
getBuildingRooms
())
{
addPolygons
(
br
,
polygons
);
for
(
BoundarySurface
bs
:
br
.
getBoundarySurfaceList
())
{
addPolygons
(
bs
,
polygons
);
}
}
for
(
BoundarySurface
bs
:
ab
.
getBoundarySurfaces
())
{
addPolygons
(
bs
,
polygons
);
for
(
Opening
o
:
bs
.
getOpenings
())
{
addPolygons
(
o
,
polygons
);
}
}
}
public
void
collectTunnelPolygons
(
Set
<
ConcretePolygon
>
polygons
,
AbstractTunnel
at
)
{
}
private
void
collectCityFurniture
(
Set
<
ConcretePolygon
>
polygons
,
CityFurniture
cf
)
{
addPolygons
(
cf
,
polygons
);
}
private
void
addConcretePolygons
(
Set
<
ConcretePolygon
>
polygons
,
Geometry
geom
)
{
for
(
Polygon
p
:
geom
.
getPolygons
())
{
if
(
p
.
getOriginal
().
getPartOfSurface
()
!=
null
&&
!
roofFilter
.
allowedToUse
(
p
.
getOriginal
().
getPartOfSurface
(),
p
.
getParent
()))
continue
;
if
(
p
instanceof
CompositePolygon
)
continue
;
polygons
.
add
(
p
.
getOriginal
());
}
}
private
void
setupRenderState
()
{
currentTriGeom
.
setCullFace
(
currentCulling
);
currentTriGeom
.
setDrawMode
(
currentDrawMode
);
Platform
.
runLater
(()
->
{
mainWindow
.
getMeshGroup
().
getChildren
().
clear
();
mainWindow
.
getMeshGroup
().
getChildren
().
addAll
(
currentTriGeom
.
getMeshes
());
});
mainWindow
.
getGridButton
().
setDisable
(
false
);
mainWindow
.
getCullingButton
().
setDisable
(
false
);
}
public
void
showWireFrame
(
boolean
show
)
{
if
(
currentTriGeom
!=
null
)
{
if
(
show
)
{
currentDrawMode
=
DrawMode
.
LINE
;
}
else
{
currentDrawMode
=
DrawMode
.
FILL
;
}
currentTriGeom
.
setDrawMode
(
currentDrawMode
);
}
}
public
void
enableCulling
(
boolean
enable
)
{
if
(
currentTriGeom
!=
null
)
{
if
(
enable
)
{
currentCulling
=
CullFace
.
BACK
;
}
else
{
currentCulling
=
CullFace
.
NONE
;
}
currentTriGeom
.
setCullFace
(
currentCulling
);
}
}
public
void
clearCurrentRender
()
{
// don't render anything
Platform
.
runLater
(()
->
{
mainWindow
.
getMeshGroup
().
getChildren
().
clear
();
clearGeometryTrees
();
});
}
public
void
highlight
(
Polygon
p
)
{
highlightController
.
highlight
(
p
,
currentTriGeom
);
}
public
void
highlight
(
LinearRing
lr
)
{
highlightController
.
highlight
(
lr
,
currentTriGeom
);
}
public
void
highlight
(
Edge
e
)
{
highlightController
.
highlight
(
e
,
currentTriGeom
);
}
public
void
highlight
(
Vertex
v
)
{
highlightController
.
highlight
(
v
,
currentTriGeom
);
}
public
void
highlight
(
List
<
LinearRing
>
highlightedRings
)
{
highlightController
.
highlight
(
highlightedRings
,
currentTriGeom
);
}
public
void
highlightEdges
(
List
<
Edge
>
edges
)
{
highlightController
.
highlightEdges
(
edges
,
currentTriGeom
);
}
public
void
highlightPolygons
(
List
<
List
<
Polygon
>>
components
)
{
highlightController
.
highlightPolygons
(
components
,
currentTriGeom
);
}
public
void
addHighlight
(
Vertex
vertex
,
Color
c
)
{
highlightController
.
addHighlight
(
vertex
,
currentTriGeom
,
c
);
}
public
void
highlight
(
CheckError
err
)
{
err
.
accept
(
errVisitor
);
}
public
void
refresh
()
{
if
(
refresher
!=
null
)
{
refresher
.
run
();
}
}
public
void
updateErrors
()
{
if
(
errorUpdater
!=
null
)
{
errorUpdater
.
run
();
}
}
public
void
clearHighlights
()
{
highlightController
.
clearHighlights
();
}
public
void
addHighlight
(
Polygon
p
)
{
highlightController
.
addHighlight
(
p
,
currentTriGeom
);
}
public
void
addHighlight
(
Triangle3d
t
)
{
highlightController
.
highlight
(
t
,
currentTriGeom
);
}
public
void
reset
()
{
errorUpdater
=
null
;
refresher
=
null
;
}
}
Prev
1
2
3
4
Next
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