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
Compare Revisions
040af2d29b2cb2c6aae2db6f7a2bb4eb95fc7e4b...2d57794b38269d8f588b97439753c98e05695651
Expand all
Show whitespace changes
Inline
Side-by-side
CityDoctorParent/CityDoctorModel/src/main/java/de/hft/stuttgart/citydoctor2/datastructure/TopLevelTransportFeature.java
0 → 100644
View file @
2d57794b
package
de.hft.stuttgart.citydoctor2.datastructure
;
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.deprecated.transportation.TransportationComplex
;
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.Waterway
;
import
org.citygml4j.core.util.geometry.GeometryFactory
;
import
java.util.ArrayList
;
import
java.util.List
;
public
class
TopLevelTransportFeature
extends
TransportationSpace
{
private
final
List
<
TransportSection
>
sections
=
new
ArrayList
<>();
private
final
List
<
TransportSection
>
intersections
=
new
ArrayList
<>();
public
static
TopLevelTransportFeature
from
(
Track
t
)
{
TopLevelTransportFeature
top
=
new
TopLevelTransportFeature
(
TransportationType
.
TRACK
);
top
.
setGmlObject
(
t
);
return
top
;
}
public
static
TopLevelTransportFeature
from
(
Road
r
)
{
TopLevelTransportFeature
top
=
new
TopLevelTransportFeature
(
TransportationType
.
ROAD
);
top
.
setGmlObject
(
r
);
return
top
;
}
public
static
TopLevelTransportFeature
from
(
Waterway
w
)
{
TopLevelTransportFeature
top
=
new
TopLevelTransportFeature
(
TransportationType
.
WATERWAY
);
top
.
setGmlObject
(
w
);
return
top
;
}
public
static
TopLevelTransportFeature
from
(
Railway
r
)
{
TopLevelTransportFeature
top
=
new
TopLevelTransportFeature
(
TransportationType
.
RAILWAY
);
top
.
setGmlObject
(
r
);
return
top
;
}
public
static
TopLevelTransportFeature
from
(
Square
s
)
{
TopLevelTransportFeature
top
=
new
TopLevelTransportFeature
(
TransportationType
.
SQUARE
);
top
.
setGmlObject
(
s
);
return
top
;
}
public
static
TopLevelTransportFeature
from
(
TransportationComplex
tc
)
{
TopLevelTransportFeature
top
=
new
TopLevelTransportFeature
(
TransportationType
.
TRANSPORTATION_COMPLEX
);
top
.
setGmlObject
(
tc
);
return
top
;
}
private
TopLevelTransportFeature
(
TransportationType
type
)
{
super
(
type
);
}
public
void
addSection
(
TransportSection
section
)
{
sections
.
add
(
section
);
}
public
void
addIntersection
(
TransportSection
section
)
{
intersections
.
add
(
section
);
}
public
List
<
TransportSection
>
getSections
()
{
return
sections
;
}
public
List
<
TransportSection
>
getIntersections
()
{
return
intersections
;
}
@Override
public
void
reCreateGeometries
(
GeometryFactory
factory
,
ParserConfiguration
config
)
{
super
.
reCreateGeometries
(
factory
,
config
);
for
(
TransportSection
section
:
sections
)
{
section
.
reCreateGeometries
(
factory
,
config
);
}
for
(
TransportSection
section
:
intersections
)
{
section
.
reCreateGeometries
(
factory
,
config
);
}
}
@Override
public
boolean
containsError
(
CheckId
checkIdentifier
)
{
boolean
hasError
=
super
.
containsError
(
checkIdentifier
);
if
(
hasError
)
{
return
true
;
}
for
(
TransportSection
section
:
sections
)
{
if
(
section
.
containsError
(
checkIdentifier
))
{
return
true
;
}
}
for
(
TransportSection
section
:
intersections
)
{
if
(
section
.
containsError
(
checkIdentifier
))
{
return
true
;
}
}
return
false
;
}
@Override
public
void
clearAllContainedCheckResults
()
{
super
.
clearAllContainedCheckResults
();
for
(
TransportSection
section
:
sections
)
{
section
.
clearAllContainedCheckResults
();
}
for
(
TransportSection
section
:
intersections
)
{
section
.
clearAllContainedCheckResults
();
}
}
@Override
public
void
collectContainedErrors
(
List
<
CheckError
>
errors
)
{
super
.
collectContainedErrors
(
errors
);
for
(
TransportSection
section
:
sections
)
{
section
.
collectContainedErrors
(
errors
);
}
for
(
TransportSection
section
:
intersections
)
{
section
.
collectContainedErrors
(
errors
);
}
}
@Override
public
boolean
containsAnyError
()
{
boolean
hasError
=
super
.
containsAnyError
();
if
(
hasError
)
{
return
true
;
}
for
(
TransportSection
section
:
sections
)
{
if
(
section
.
containsAnyError
())
{
return
true
;
}
}
for
(
TransportSection
section
:
intersections
)
{
if
(
section
.
containsAnyError
())
{
return
true
;
}
}
return
false
;
}
@Override
public
void
accept
(
Check
c
)
{
super
.
accept
(
c
);
if
(
c
.
canExecute
(
this
))
{
c
.
check
(
this
);
}
for
(
TransportSection
section
:
sections
)
{
section
.
accept
(
c
);
}
for
(
TransportSection
section
:
intersections
)
{
section
.
accept
(
c
);
}
}
@Override
public
void
unsetGmlGeometries
()
{
super
.
unsetGmlGeometries
();
for
(
TransportSection
section
:
sections
)
{
section
.
unsetGmlGeometries
();
}
for
(
TransportSection
section
:
intersections
)
{
section
.
unsetGmlGeometries
();
}
}
@Override
public
CityObject
getTopLevelCityObject
()
{
return
this
;
}
@Override
public
String
toString
()
{
return
"TopLevelTransportFeature [id="
+
getGmlId
()
+
"]"
;
}
@Override
public
void
prepareForChecking
()
{
super
.
prepareForChecking
();
for
(
TransportSection
section
:
sections
)
{
section
.
prepareForChecking
();
}
for
(
TransportSection
section
:
intersections
)
{
section
.
prepareForChecking
();
}
}
@Override
public
void
clearMetaInformation
()
{
super
.
clearMetaInformation
();
for
(
TransportSection
section
:
sections
)
{
section
.
clearMetaInformation
();
}
for
(
TransportSection
section
:
intersections
)
{
section
.
clearMetaInformation
();
}
}
@Override
public
void
collectInstances
(
CopyHandler
handler
)
{
super
.
collectInstances
(
handler
);
for
(
TransportSection
section
:
sections
)
{
section
.
collectInstances
(
handler
);
}
for
(
TransportSection
section
:
intersections
)
{
section
.
collectInstances
(
handler
);
}
}
@Override
public
void
fillValues
(
Copyable
original
,
CopyHandler
handler
)
{
super
.
fillValues
(
original
,
handler
);
TransportationObject
originalTo
=
(
TransportationObject
)
original
;
for
(
TransportSection
section
:
sections
)
{
section
.
fillValues
(
originalTo
,
handler
);
}
for
(
TransportSection
section
:
intersections
)
{
section
.
fillValues
(
originalTo
,
handler
);
}
}
@Override
public
Copyable
createCopyInstance
()
{
return
new
TopLevelTransportFeature
(
type
);
}
}
CityDoctorParent/CityDoctorModel/src/main/java/de/hft/stuttgart/citydoctor2/datastructure/TrafficAreaObject.java
0 → 100644
View file @
2d57794b
package
de.hft.stuttgart.citydoctor2.datastructure
;
import
de.hft.stuttgart.citydoctor2.parser.ParserConfiguration
;
import
de.hft.stuttgart.citydoctor2.utils.CityGmlUtils
;
import
org.citygml4j.core.model.transportation.AuxiliaryTrafficArea
;
import
org.citygml4j.core.model.transportation.TrafficArea
;
import
org.citygml4j.core.util.geometry.GeometryFactory
;
import
org.xmlobjects.gml.model.geometry.aggregates.MultiSurface
;
import
org.xmlobjects.gml.model.geometry.aggregates.MultiSurfaceProperty
;
public
class
TrafficAreaObject
extends
TransportationObject
{
public
enum
TrafficAreaType
{
TRAFFIC_AREA
,
AUXILIARY_TRAFFIC_AREA
}
public
TrafficAreaObject
(
TrafficAreaType
trafficAreaType
)
{
if
(
trafficAreaType
==
TrafficAreaType
.
TRAFFIC_AREA
)
{
setType
(
TransportationType
.
TRAFFIC_AREA
);
}
else
{
setType
(
TransportationType
.
AUXILLIARY_TRAFFIC_AREA
);
}
}
@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
TRAFFIC_AREA:
TrafficArea
ta
=
(
TrafficArea
)
super
.
getGmlObject
();
setMultiSurfaceAccordingToLod
(
ta
,
ms
,
geom
.
getLod
());
break
;
case
AUXILLIARY_TRAFFIC_AREA:
AuxiliaryTrafficArea
ata
=
(
AuxiliaryTrafficArea
)
super
.
getGmlObject
();
setMultiSurfaceAccordingToLod
(
ata
,
ms
,
geom
.
getLod
());
break
;
}
}
else
{
throw
new
IllegalStateException
(
"Geometry in TransportationObject cannot be of type "
+
geom
.
getType
()
+
". Only MultiSurface allowed"
);
}
}
}
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
(
TrafficArea
ta
,
MultiSurface
ms
,
Lod
lod
)
{
switch
(
lod
)
{
case
LOD0:
ta
.
setLod0MultiSurface
(
new
MultiSurfaceProperty
(
ms
));
break
;
case
LOD1:
ta
.
setLod1MultiSurface
(
new
MultiSurfaceProperty
(
ms
));
break
;
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
unsetGmlGeometries
()
{
switch
(
type
)
{
case
TRAFFIC_AREA:
TrafficArea
ta
=
(
TrafficArea
)
super
.
getGmlObject
();
ta
.
setLod2MultiSurface
(
null
);
ta
.
setLod3MultiSurface
(
null
);
ta
.
getDeprecatedProperties
().
setLod4MultiSurface
(
null
);
break
;
case
AUXILLIARY_TRAFFIC_AREA:
AuxiliaryTrafficArea
ata
=
(
AuxiliaryTrafficArea
)
super
.
getGmlObject
();
ata
.
setLod0MultiSurface
(
null
);
ata
.
setLod1MultiSurface
(
null
);
ata
.
setLod2MultiSurface
(
null
);
ata
.
setLod3MultiSurface
(
null
);
ata
.
getDeprecatedProperties
().
setLod4MultiSurface
(
null
);
break
;
}
}
@Override
public
CityObject
getTopLevelCityObject
()
{
return
this
;
}
@Override
public
String
toString
()
{
return
"TrafficArea [id="
+
getGmlId
()
+
"]"
;
}
}
CityDoctorParent/CityDoctorModel/src/main/java/de/hft/stuttgart/citydoctor2/datastructure/TrafficSpaceObject.java
0 → 100644
View file @
2d57794b
package
de.hft.stuttgart.citydoctor2.datastructure
;
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.AbstractSpace
;
import
org.citygml4j.core.util.geometry.GeometryFactory
;
import
org.xmlobjects.gml.model.geometry.aggregates.MultiSurface
;
import
org.xmlobjects.gml.model.geometry.aggregates.MultiSurfaceProperty
;
import
java.util.ArrayList
;
import
java.util.List
;
public
class
TrafficSpaceObject
extends
TransportationObject
{
private
final
List
<
TrafficAreaObject
>
trafficAreas
=
new
ArrayList
<>();
public
enum
TrafficSpaceType
{
TRAFFIC_SPACE
,
AUXILIARY_TRAFFIC_SPACE
}
public
TrafficSpaceObject
(
TrafficSpaceType
trafficSpaceType
)
{
if
(
trafficSpaceType
==
TrafficSpaceType
.
TRAFFIC_SPACE
)
{
super
.
setType
(
TransportationType
.
TRAFFIC_SPACE
);
}
else
{
super
.
setType
(
TransportationType
.
AUXILLIARY_TRAFFIC_SPACE
);
}
}
public
List
<
TrafficAreaObject
>
getTrafficAreas
()
{
return
trafficAreas
;
}
public
void
addTrafficArea
(
TrafficAreaObject
trafficAreaObject
)
{
trafficAreas
.
add
(
trafficAreaObject
);
}
@Override
public
void
reCreateGeometries
(
GeometryFactory
factory
,
ParserConfiguration
config
)
{
for
(
Geometry
geom
:
getGeometries
())
{
if
(
geom
instanceof
ImplicitGeometryHolder
)
{
continue
;
}
MultiSurface
ms
=
CityGmlUtils
.
createMultiSurface
(
geom
,
factory
,
config
);
AbstractSpace
ats
=
(
AbstractSpace
)
super
.
getGmlObject
();
setMultiSurfaceAccordingToLod
(
ats
,
ms
,
geom
.
getLod
());
}
for
(
TrafficAreaObject
tao
:
trafficAreas
)
{
tao
.
reCreateGeometries
(
factory
,
config
);
}
}
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
boolean
containsError
(
CheckId
checkIdentifier
)
{
boolean
hasError
=
super
.
containsError
(
checkIdentifier
);
if
(
hasError
)
{
return
true
;
}
for
(
TrafficAreaObject
tao
:
trafficAreas
)
{
if
(
tao
.
containsError
(
checkIdentifier
))
{
return
true
;
}
}
return
false
;
}
@Override
public
void
clearAllContainedCheckResults
()
{
super
.
clearAllContainedCheckResults
();
for
(
TrafficAreaObject
tao
:
trafficAreas
)
{
tao
.
clearAllContainedCheckResults
();
}
}
@Override
public
void
collectContainedErrors
(
List
<
CheckError
>
errors
)
{
super
.
collectContainedErrors
(
errors
);
for
(
TrafficAreaObject
tao
:
trafficAreas
)
{
tao
.
collectContainedErrors
(
errors
);
}
}
@Override
public
boolean
containsAnyError
()
{
boolean
hasError
=
super
.
containsAnyError
();
if
(
hasError
)
{
return
true
;
}
for
(
TrafficAreaObject
tao
:
trafficAreas
)
{
if
(
tao
.
containsAnyError
())
{
return
true
;
}
}
return
false
;
}
@Override
public
void
accept
(
Check
c
)
{
super
.
accept
(
c
);
if
(
c
.
canExecute
(
this
))
{
c
.
check
(
this
);
}
for
(
TrafficAreaObject
tao
:
trafficAreas
)
{
tao
.
accept
(
c
);
}
}
@Override
public
void
unsetGmlGeometries
()
{
AbstractSpace
ats
=
(
AbstractSpace
)
super
.
getGmlObject
();
ats
.
setLod0MultiSurface
(
null
);
ats
.
setLod2MultiSurface
(
null
);
ats
.
setLod3MultiSurface
(
null
);
for
(
TrafficAreaObject
tao
:
trafficAreas
)
{
tao
.
unsetGmlGeometries
();
}
}
@Override
public
CityObject
getTopLevelCityObject
()
{
return
this
;
}
@Override
public
String
toString
()
{
return
"TransportationSpaceObject [id="
+
getGmlId
()
+
"]"
;
}
@Override
public
void
prepareForChecking
()
{
super
.
prepareForChecking
();
for
(
TrafficAreaObject
tao
:
trafficAreas
)
{
tao
.
prepareForChecking
();
}
}
@Override
public
void
clearMetaInformation
()
{
super
.
clearMetaInformation
();
for
(
TrafficAreaObject
tao
:
trafficAreas
)
{
tao
.
clearMetaInformation
();
}
}
@Override
public
void
collectInstances
(
CopyHandler
handler
)
{
super
.
collectInstances
(
handler
);
for
(
TrafficAreaObject
tao
:
trafficAreas
)
{
handler
.
addInstance
(
tao
);
}
}
@Override
public
void
fillValues
(
Copyable
original
,
CopyHandler
handler
)
{
super
.
fillValues
(
original
,
handler
);
TrafficSpaceObject
originalTao
=
(
TrafficSpaceObject
)
original
;
for
(
TrafficAreaObject
tao
:
originalTao
.
trafficAreas
)
{
trafficAreas
.
add
(
handler
.
getCopyInstance
(
tao
));
}
super
.
setGmlObject
(
originalTao
.
getGmlObject
());
}
@Override
public
Copyable
createCopyInstance
()
{
return
new
TrafficSpaceObject
(
null
);
}
}
CityDoctorParent/CityDoctorModel/src/main/java/de/hft/stuttgart/citydoctor2/datastructure/TransportSection.java
0 → 100644
View file @
2d57794b
package
de.hft.stuttgart.citydoctor2.datastructure
;
public
class
TransportSection
extends
TransportationSpace
{
public
enum
SectionType
{
SECTION
,
INTERSECTION
}
public
TransportSection
(
SectionType
sectionType
)
{
super
(
TransportationType
.
SECTION
);
if
(
sectionType
==
SectionType
.
INTERSECTION
)
{
super
.
setType
(
TransportationType
.
INTERSECTION
);
}
}
}
CityDoctorParent/CityDoctorModel/src/main/java/de/hft/stuttgart/citydoctor2/datastructure/TransportationObject.java
View file @
2d57794b
...
...
@@ -43,190 +43,33 @@ import java.util.List;
*
* @author Matthias Betz
*/
public
class
TransportationObject
extends
CityObject
{
public
abstract
class
TransportationObject
extends
CityObject
{
@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
ROAD
,
TRACK
,
RAILWAY
,
TRAFFIC_AREA
,
AUXILLIARY_TRAFFIC_AREA
,
TRANSPORTATION_COMPLEX
,
SQUARE
,
AUXILLIARY_TRAFFIC_SPACE
,
TRAFFIC_SPACE
,
WATERWAY
,
SECTION
,
INTERSECTION
}
private
AbstractCityObject
ato
;
private
final
List
<
TransportationObject
>
composesOf
=
new
ArrayList
<>(
1
);
private
final
TransportationType
type
;
protected
TransportationType
type
;
public
TransportationObject
(
TransportationType
type
)
{
this
.
type
=
type
;
}
@Override
public
FeatureType
getFeatureType
()
{
return
FeatureType
.
TRANSPORTATION
;
}
@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
(
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
(
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
(
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
(
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
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
clearAllContainedCheckResults
()
{
super
.
clearAllContainedCheckResults
();
for
(
TransportationObject
to
:
composesOf
)
{
to
.
clearAllContainedCheckResults
();
}
}
@Override
public
void
collectContainedErrors
(
List
<
CheckError
>
errors
)
{
super
.
collectContainedErrors
(
errors
);
for
(
TransportationObject
to
:
composesOf
)
{
to
.
collectContainedErrors
(
errors
);
}
protected
TransportationObject
()
{
}
@Override
public
boolean
containsAnyError
()
{
boolean
hasError
=
super
.
containsAnyError
();
if
(
hasError
)
{
return
true
;
}
for
(
TransportationObject
to
:
composesOf
)
{
if
(
to
.
containsAnyError
())
{
return
true
;
}
}
return
false
;
void
setType
(
TransportationType
type
)
{
this
.
type
=
type
;
}
@Override
public
void
accept
(
Check
c
)
{
super
.
accept
(
c
);
if
(
c
.
canExecute
(
this
))
{
c
.
check
(
this
);
}
for
(
TransportationObject
to
:
composesOf
)
{
to
.
accept
(
c
);
}
public
FeatureType
getFeatureType
()
{
return
FeatureType
.
TRANSPORTATION
;
}
@Override
...
...
@@ -234,50 +77,11 @@ public class TransportationObject extends CityObject {
return
ato
;
}
@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
setGmlObject
(
AbstractCityObject
tc
)
{
ato
=
tc
;
}
public
void
addChild
(
TransportationObject
subTrans
)
{
composesOf
.
add
(
subTrans
);
}
public
List
<
TransportationObject
>
getChildren
()
{
return
composesOf
;
}
public
TransportationType
getTransportationType
()
{
return
type
;
...
...
@@ -288,43 +92,17 @@ public class TransportationObject extends CityObject {
return
"TransportationObject [id="
+
getGmlId
()
+
"]"
;
}
@Override
public
void
prepareForChecking
()
{
super
.
prepareForChecking
();
for
(
TransportationObject
child
:
composesOf
)
{
child
.
prepareForChecking
();
}
}
@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
Copyable
createCopyInstance
()
{
return
n
ew
TransportationObject
(
type
)
;
return
n
ull
;
}
}
CityDoctorParent/CityDoctorModel/src/main/java/de/hft/stuttgart/citydoctor2/datastructure/TransportationSpace.java
0 → 100644
View file @
2d57794b
package
de.hft.stuttgart.citydoctor2.datastructure
;
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.AbstractSpace
;
import
org.citygml4j.core.model.transportation.AbstractTransportationSpace
;
import
org.citygml4j.core.util.geometry.GeometryFactory
;
import
org.xmlobjects.gml.model.geometry.aggregates.MultiSurface
;
import
org.xmlobjects.gml.model.geometry.aggregates.MultiSurfaceProperty
;
import
java.util.ArrayList
;
import
java.util.List
;
public
abstract
class
TransportationSpace
extends
TransportationObject
{
private
final
List
<
TrafficSpaceObject
>
trafficSpaces
=
new
ArrayList
<>();
private
final
List
<
TrafficSpaceObject
>
auxTrafficSpaces
=
new
ArrayList
<>();
protected
TransportationSpace
(
TransportationType
type
)
{
super
(
type
);
}
public
List
<
TrafficSpaceObject
>
getTrafficSpaces
()
{
return
trafficSpaces
;
}
public
List
<
TrafficSpaceObject
>
getAuxTrafficSpaces
()
{
return
auxTrafficSpaces
;
}
public
void
addTrafficSpace
(
TrafficSpaceObject
t
)
{
trafficSpaces
.
add
(
t
);
}
public
void
addAuxTrafficSpace
(
TrafficSpaceObject
t
)
{
auxTrafficSpaces
.
add
(
t
);
}
@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
(
super
.
getGmlObject
()
instanceof
AbstractTransportationSpace
ats
)
{
setMultiSurfaceAccordingToLod
(
ats
,
ms
,
geom
.
getLod
());
}
else
{
AbstractSpace
as
=
(
AbstractSpace
)
super
.
getGmlObject
();
setMultiSurfaceAccordingToLod
(
as
,
ms
,
geom
.
getLod
());
}
}
else
{
throw
new
IllegalStateException
(
"Geometry in TransportationObject cannot be of type "
+
geom
.
getType
()
+
". Only MultiSurface allowed"
);
}
}
for
(
TrafficSpaceObject
spaces
:
trafficSpaces
)
{
spaces
.
reCreateGeometries
(
factory
,
config
);
}
for
(
TrafficSpaceObject
spaces
:
auxTrafficSpaces
)
{
spaces
.
reCreateGeometries
(
factory
,
config
);
}
}
private
void
setMultiSurfaceAccordingToLod
(
AbstractTransportationSpace
ats
,
MultiSurface
ms
,
Lod
lod
)
{
switch
(
lod
)
{
case
LOD0
->
ats
.
setLod0MultiSurface
(
new
MultiSurfaceProperty
(
ms
));
case
LOD1
->
ats
.
getDeprecatedProperties
().
setLod1MultiSurface
(
new
MultiSurfaceProperty
(
ms
));
case
LOD2
->
ats
.
setLod2MultiSurface
(
new
MultiSurfaceProperty
(
ms
));
case
LOD3
->
ats
.
setLod3MultiSurface
(
new
MultiSurfaceProperty
(
ms
));
case
LOD4
->
ats
.
getDeprecatedProperties
().
setLod4MultiSurface
(
new
MultiSurfaceProperty
(
ms
));
default
->
throw
new
IllegalStateException
(
"cannot set geometry with LOD for AuxiliaryTrafficSpace: "
+
lod
);
}
}
private
void
setMultiSurfaceAccordingToLod
(
AbstractSpace
as
,
MultiSurface
ms
,
Lod
lod
)
{
switch
(
lod
)
{
case
LOD0:
as
.
setLod0MultiSurface
(
new
MultiSurfaceProperty
(
ms
));
break
;
case
LOD2:
as
.
setLod2MultiSurface
(
new
MultiSurfaceProperty
(
ms
));
break
;
case
LOD3:
as
.
setLod3MultiSurface
(
new
MultiSurfaceProperty
(
ms
));
break
;
default
:
throw
new
IllegalStateException
(
"cannot set geometry with LOD for AuxiliaryTrafficSpace: "
+
lod
);
}
}
@Override
public
boolean
containsError
(
CheckId
checkIdentifier
)
{
boolean
hasError
=
super
.
containsError
(
checkIdentifier
);
if
(
hasError
)
{
return
true
;
}
for
(
TrafficSpaceObject
to
:
trafficSpaces
)
{
if
(
to
.
containsError
(
checkIdentifier
))
{
return
true
;
}
}
for
(
TrafficSpaceObject
to
:
auxTrafficSpaces
)
{
if
(
to
.
containsError
(
checkIdentifier
))
{
return
true
;
}
}
return
false
;
}
@Override
public
void
clearAllContainedCheckResults
()
{
super
.
clearAllContainedCheckResults
();
for
(
TrafficSpaceObject
to
:
trafficSpaces
)
{
to
.
clearAllContainedCheckResults
();
}
for
(
TrafficSpaceObject
to
:
auxTrafficSpaces
)
{
to
.
clearAllContainedCheckResults
();
}
}
@Override
public
void
collectContainedErrors
(
List
<
CheckError
>
errors
)
{
super
.
collectContainedErrors
(
errors
);
for
(
TrafficSpaceObject
to
:
trafficSpaces
)
{
to
.
collectContainedErrors
(
errors
);
}
for
(
TrafficSpaceObject
to
:
auxTrafficSpaces
)
{
to
.
collectContainedErrors
(
errors
);
}
}
@Override
public
boolean
containsAnyError
()
{
boolean
hasError
=
super
.
containsAnyError
();
if
(
hasError
)
{
return
true
;
}
for
(
TrafficSpaceObject
to
:
trafficSpaces
)
{
if
(
to
.
containsAnyError
())
{
return
true
;
}
}
for
(
TrafficSpaceObject
to
:
auxTrafficSpaces
)
{
if
(
to
.
containsAnyError
())
{
return
true
;
}
}
return
false
;
}
@Override
public
void
accept
(
Check
c
)
{
super
.
accept
(
c
);
if
(
c
.
canExecute
(
this
))
{
c
.
check
(
this
);
}
for
(
TrafficSpaceObject
to
:
trafficSpaces
)
{
to
.
accept
(
c
);
}
for
(
TrafficSpaceObject
to
:
auxTrafficSpaces
)
{
to
.
accept
(
c
);
}
}
@Override
public
void
unsetGmlGeometries
()
{
AbstractSpace
ats
=
(
AbstractSpace
)
super
.
getGmlObject
();
ats
.
setLod0MultiSurface
(
null
);
ats
.
setLod2MultiSurface
(
null
);
ats
.
setLod3MultiSurface
(
null
);
for
(
TrafficSpaceObject
to
:
trafficSpaces
)
{
to
.
unsetGmlGeometries
();
}
for
(
TrafficSpaceObject
to
:
auxTrafficSpaces
)
{
to
.
unsetGmlGeometries
();
}
}
@Override
public
CityObject
getTopLevelCityObject
()
{
return
this
;
}
@Override
public
String
toString
()
{
return
"TransportationSpace [id="
+
getGmlId
()
+
"]"
;
}
@Override
public
void
prepareForChecking
()
{
super
.
prepareForChecking
();
for
(
TrafficSpaceObject
to
:
trafficSpaces
)
{
to
.
prepareForChecking
();
}
for
(
TrafficSpaceObject
to
:
auxTrafficSpaces
)
{
to
.
prepareForChecking
();
}
}
@Override
public
void
clearMetaInformation
()
{
super
.
clearMetaInformation
();
for
(
TrafficSpaceObject
to
:
trafficSpaces
)
{
to
.
clearMetaInformation
();
}
for
(
TrafficSpaceObject
to
:
auxTrafficSpaces
)
{
to
.
clearMetaInformation
();
}
}
@Override
public
void
collectInstances
(
CopyHandler
handler
)
{
super
.
collectInstances
(
handler
);
for
(
TrafficSpaceObject
to
:
trafficSpaces
)
{
to
.
collectInstances
(
handler
);
}
for
(
TrafficSpaceObject
to
:
auxTrafficSpaces
)
{
to
.
collectInstances
(
handler
);
}
}
@Override
public
void
fillValues
(
Copyable
original
,
CopyHandler
handler
)
{
super
.
fillValues
(
original
,
handler
);
TransportationObject
originalTo
=
(
TransportationObject
)
original
;
for
(
TrafficSpaceObject
to
:
trafficSpaces
)
{
to
.
fillValues
(
originalTo
,
handler
);
}
for
(
TrafficSpaceObject
to
:
auxTrafficSpaces
)
{
to
.
fillValues
(
originalTo
,
handler
);
}
}
}
CityDoctorParent/CityDoctorModel/src/main/java/de/hft/stuttgart/citydoctor2/datastructure/Tunnel.java
View file @
2d57794b
...
...
@@ -34,6 +34,11 @@ public class Tunnel extends AbstractTunnel {
}
}
@Override
public
CityObject
getTopLevelCityObject
()
{
return
this
;
}
@Override
public
void
accept
(
Check
c
)
{
super
.
accept
(
c
);
...
...
CityDoctorParent/CityDoctorModel/src/main/java/de/hft/stuttgart/citydoctor2/datastructure/TunnelConstructiveElement.java
View file @
2d57794b
...
...
@@ -31,12 +31,20 @@ public class TunnelConstructiveElement extends CityObject {
private
final
org
.
citygml4j
.
core
.
model
.
tunnel
.
TunnelConstructiveElement
gmlTunnelElement
;
private
final
List
<
BoundarySurface
>
boundarySurfaceList
=
new
ArrayList
<>();
private
AbstractTunnel
parent
;
public
TunnelConstructiveElement
(
org
.
citygml4j
.
core
.
model
.
tunnel
.
TunnelConstructiveElement
gmlObject
)
{
this
.
gmlTunnelElement
=
gmlObject
;
}
public
void
setParent
(
AbstractTunnel
parent
)
{
this
.
parent
=
parent
;
}
public
AbstractTunnel
getParent
()
{
return
parent
;
}
@Override
public
Copyable
createCopyInstance
()
{
return
new
TunnelConstructiveElement
(
gmlTunnelElement
);
...
...
@@ -60,6 +68,8 @@ public class TunnelConstructiveElement extends CityObject {
MultiSurface
ms
=
CityGmlUtils
.
createMultiSurface
(
geom
,
factory
,
config
);
setMultiSurfaceAccordingToLod
(
geom
,
ms
);
break
;
case
COMPOSITE_SURFACE:
throw
new
IllegalStateException
(
"Tunnel constructive element cannot have a composite surface geometry"
);
}
}
for
(
BoundarySurface
bs
:
boundarySurfaceList
)
{
...
...
@@ -186,6 +196,11 @@ public class TunnelConstructiveElement extends CityObject {
}
}
@Override
public
CityObject
getTopLevelCityObject
()
{
return
getParent
().
getTopLevelCityObject
();
}
@Override
public
FeatureType
getFeatureType
()
{
return
FeatureType
.
TUNNEL_CONSTRUCTION_ELEMENT
;
...
...
CityDoctorParent/CityDoctorModel/src/main/java/de/hft/stuttgart/citydoctor2/datastructure/TunnelHollow.java
View file @
2d57794b
...
...
@@ -43,6 +43,11 @@ public class TunnelHollow extends AbstractRoom {
parent
=
handler
.
getCopyInstance
(
oHollow
.
getParent
());
}
@Override
public
CityObject
getTopLevelCityObject
()
{
return
getParent
().
getTopLevelCityObject
();
}
@Override
public
void
collectInstances
(
CopyHandler
handler
)
{
super
.
collectInstances
(
handler
);
...
...
CityDoctorParent/CityDoctorModel/src/main/java/de/hft/stuttgart/citydoctor2/datastructure/TunnelPart.java
View file @
2d57794b
...
...
@@ -22,6 +22,11 @@ public class TunnelPart extends AbstractTunnel {
return
parent
;
}
@Override
public
CityObject
getTopLevelCityObject
()
{
return
getParent
().
getTopLevelCityObject
();
}
@Override
public
FeatureType
getFeatureType
()
{
return
FeatureType
.
TUNNEL_PART
;
...
...
CityDoctorParent/CityDoctorModel/src/main/java/de/hft/stuttgart/citydoctor2/datastructure/Vegetation.java
View file @
2d57794b
...
...
@@ -198,6 +198,11 @@ public class Vegetation extends CityObject {
}
}
@Override
public
CityObject
getTopLevelCityObject
()
{
return
this
;
}
public
void
setGmlObject
(
AbstractVegetationObject
avo
)
{
citygmlVegetation
=
avo
;
}
...
...
CityDoctorParent/CityDoctorModel/src/main/java/de/hft/stuttgart/citydoctor2/datastructure/WaterObject.java
View file @
2d57794b
...
...
@@ -106,6 +106,11 @@ public class WaterObject extends CityObject {
gmlWater
.
getDeprecatedProperties
().
setLod1MultiSurface
(
null
);
}
@Override
public
CityObject
getTopLevelCityObject
()
{
return
this
;
}
public
void
setGmlObject
(
WaterBody
waterBody
)
{
gmlWater
=
waterBody
;
}
...
...
CityDoctorParent/CityDoctorModel/src/main/java/de/hft/stuttgart/citydoctor2/mapper/citygml3/Citygml3FeatureMapper.java
View file @
2d57794b
This diff is collapsed.
Click to expand it.
CityDoctorParent/CityDoctorModel/src/main/java/de/hft/stuttgart/citydoctor2/mapper/citygml3/Citygml3GeometryMapper.java
View file @
2d57794b
...
...
@@ -59,10 +59,55 @@ public class Citygml3GeometryMapper extends GeometryWalker {
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
())
)
;
logger
.
warn
(
"No exterior:
{}
"
,
polygon
.
getId
());
}
}
@Override
public
void
visit
(
Surface
surface
)
{
if
(
surface
.
getPatches
()
!=
null
&&
!
surface
.
getPatches
().
isSetObjects
())
{
logger
.
warn
(
"Surface {} has no PolygonPatches."
,
surface
.
getId
());
return
;
}
PatchCollection
patchCollection
=
new
PatchCollection
();
GeometryWalker
patchCollector
=
new
GeometryWalker
()
{
@Override
public
void
visit
(
PolygonPatch
patch
)
{
parsePolygonPatch
(
patch
,
patchCollection
);
}
};
surface
.
getPatches
().
getObjects
().
forEach
(
abstractSurfacePatch
->
abstractSurfacePatch
.
accept
(
patchCollector
));
}
private
void
parsePolygonPatch
(
PolygonPatch
patch
,
PatchCollection
collection
)
{
AbstractRingProperty
exterior
=
patch
.
getExterior
();
List
<
AbstractRingProperty
>
interior
=
patch
.
getInterior
();
if
(
exterior
==
null
||
exterior
.
getObject
()
==
null
)
{
if
(
logger
.
isWarnEnabled
())
{
logger
.
warn
(
Localization
.
getText
(
"GeometryMapper.emptyPolygon"
));
}
return
;
}
ConcretePolygon
conc
=
new
ConcretePolygon
();
polygons
.
add
(
conc
);
currentRing
=
new
LinearRing
(
LinearRingType
.
EXTERIOR
);
exterior
.
getObject
().
accept
(
this
);
conc
.
setExteriorRing
(
currentRing
);
for
(
AbstractRingProperty
interiorGmlRing
:
interior
)
{
AbstractRing
gmlRing
=
interiorGmlRing
.
getObject
();
if
(
gmlRing
==
null
)
{
continue
;
}
currentRing
=
new
LinearRing
(
LinearRingType
.
INTERIOR
);
gmlRing
.
accept
(
this
);
conc
.
addInteriorRing
(
currentRing
);
}
collection
.
addPatchMember
(
conc
);
polygons
.
add
(
conc
);
}
private
void
parsePolygon
(
String
id
,
AbstractRingProperty
exterior
,
List
<
AbstractRingProperty
>
interior
)
{
if
(
exterior
==
null
||
exterior
.
getObject
()
==
null
)
{
if
(
logger
.
isWarnEnabled
())
{
...
...
CityDoctorParent/CityDoctorModel/src/main/java/de/hft/stuttgart/citydoctor2/math/MovedPolygon.java
View file @
2d57794b
...
...
@@ -39,6 +39,25 @@ public class MovedPolygon {
private
MovedRing
exteriorRing
;
private
List
<
MovedRing
>
innerRings
;
/**
* Moves the polygon by the first exterior vertex. The center of the polygon
* will not me the origin, the polygon will just be near the origin. This can
* eliviate numeric issues in large calculations.
*
* @param p the polygon that is moved to the center.
* @return the moved polygon.
*/
public
static
MovedPolygon
ofPolygon
(
Polygon
p
)
{
Vector3d
movedBy
=
p
.
getExteriorRing
().
getVertices
().
get
(
0
);
MovedPolygon
indPoly
=
new
MovedPolygon
();
indPoly
.
original
=
p
;
indPoly
.
exteriorRing
=
MovedRing
.
ofRing
(
p
.
getExteriorRing
(),
movedBy
);
for
(
LinearRing
inner
:
p
.
getInnerRings
())
{
indPoly
.
addInnerRing
(
MovedRing
.
ofRing
(
inner
,
movedBy
));
}
return
indPoly
;
}
public
static
MovedPolygon
ofPolygon
(
Polygon
p
,
Vector3d
movedBy
)
{
MovedPolygon
indPoly
=
new
MovedPolygon
();
indPoly
.
original
=
p
;
...
...
CityDoctorParent/CityDoctorModel/src/main/java/de/hft/stuttgart/citydoctor2/math/Polygon2d.java
View file @
2d57794b
...
...
@@ -41,6 +41,11 @@ public class Polygon2d {
return
projectTo2D
(
poly
,
axis
);
}
public
static
Polygon2d
withProjection
(
MovedPolygon
poly
)
{
ProjectionAxis
axis
=
ProjectionAxis
.
of
(
poly
.
getOriginal
());
return
projectTo2D
(
poly
,
axis
);
}
public
static
Polygon2d
withProjection
(
MovedPolygon
poly
,
ProjectionAxis
projectionAxis
)
{
return
projectTo2D
(
poly
,
projectionAxis
);
}
...
...
CityDoctorParent/CityDoctorModel/src/main/java/de/hft/stuttgart/citydoctor2/math/ProjectionAxis.java
View file @
2d57794b
...
...
@@ -87,12 +87,27 @@ public class ProjectionAxis {
this
.
axis
=
axis
;
}
/**
* This will write the two coordinates determined in this projection axis into a
* given array at the startIndex location. The array has to have at least a
* length of startIndex + 1.
*
* @param v the vector from which the coordinates are taken.
* @param array the array that is written to.
* @param startIndex the start location in the array.
*/
public
void
writeCoordinatesOfVectorInArray
(
Vector3d
v
,
double
[]
array
,
int
startIndex
)
{
array
[
startIndex
]
=
v
.
getCoordinate
(
axis
[
0
]);
array
[
startIndex
+
1
]
=
v
.
getCoordinate
(
axis
[
1
]);
}
public
Vector2d
project
(
Vector3d
v
)
{
return
new
Vector2d
(
v
.
getCoordinate
(
axis
[
0
]),
v
.
getCoordinate
(
axis
[
1
]));
}
/**
* calculates the missing coordinate for 3d vector from the plane and this axis.
*
* @return the projected 3d point.
*/
public
Vector3d
projectToPlane
(
Plane
plane
,
Vector2d
v
)
{
...
...
@@ -101,6 +116,7 @@ public class ProjectionAxis {
/**
* calculates the missing coordinate for 3d vector from the plane and this axis.
*
* @return the projected 3d point.
*/
public
Vector3d
projectToPlane
(
Plane
plane
,
double
vectorX
,
double
vectorY
)
{
...
...
CityDoctorParent/CityDoctorModel/src/main/java/de/hft/stuttgart/citydoctor2/math/Vector3d.java
View file @
2d57794b
...
...
@@ -22,6 +22,8 @@ import java.io.Serial;
import
java.io.Serializable
;
import
java.util.Arrays
;
import
org.locationtech.jts.geom.Coordinate
;
/**
* A three dimensional vector
*
...
...
@@ -45,6 +47,17 @@ public class Vector3d implements Serializable {
this
(
0
d
,
0
d
,
0
d
);
}
/**
* Convert JTS Coordinate class to Vector3d.
* @param coord JTS Coordinate
*/
public
Vector3d
(
Coordinate
coord
)
{
coords
=
new
double
[
3
];
coords
[
0
]
=
coord
.
getX
();
coords
[
1
]
=
coord
.
getY
();
coords
[
2
]
=
coord
.
getZ
();
}
public
Vector3d
(
double
x
,
double
y
,
double
z
)
{
coords
=
new
double
[
3
];
coords
[
0
]
=
x
;
...
...
CityDoctorParent/CityDoctorModel/src/main/java/de/hft/stuttgart/citydoctor2/parser/CityGmlParser.java
View file @
2d57794b
This diff is collapsed.
Click to expand it.
CityDoctorParent/CityDoctorModel/src/main/java/de/hft/stuttgart/citydoctor2/tesselation/EarcutTesselator.java
0 → 100644
View file @
2d57794b
package
de.hft.stuttgart.citydoctor2.tesselation
;
import
java.util.ArrayList
;
import
java.util.List
;
import
de.hft.stuttgart.citydoctor2.datastructure.LinearRing
;
import
de.hft.stuttgart.citydoctor2.datastructure.Polygon
;
import
de.hft.stuttgart.citydoctor2.datastructure.Vertex
;
import
de.hft.stuttgart.citydoctor2.math.ProjectionAxis
;
import
de.hft.stuttgart.citydoctor2.math.Triangle3d
;
import
earcut4j.Earcut
;
/**
* Tesselator to create triangles out of polygons. Uses earcut4j implementation.
*
* @author Matthias Betz
*
*/
public
class
EarcutTesselator
{
public
static
TesselatedPolygon
tesselatePolygon
(
Polygon
p
)
{
// sum number of vertices, don't use duplicate last point
// assume polygons are closed
int
nrOfVertices
=
p
.
getExteriorRing
().
getVertices
().
size
()
-
1
;
int
[]
holeStart
=
null
;
if
(!
p
.
getInnerRings
().
isEmpty
())
{
holeStart
=
new
int
[
p
.
getInnerRings
().
size
()];
List
<
LinearRing
>
innerRings
=
p
.
getInnerRings
();
for
(
int
i
=
0
;
i
<
innerRings
.
size
();
i
++)
{
LinearRing
r
=
innerRings
.
get
(
i
);
holeStart
[
i
]
=
nrOfVertices
;
nrOfVertices
+=
r
.
getVertices
().
size
()
-
1
;
}
}
// collect vertices
// find most dominant projection axis for 2d projection
ProjectionAxis
axis
=
ProjectionAxis
.
of
(
p
);
double
[]
vertices
=
new
double
[
nrOfVertices
*
2
];
List
<
Vertex
>
vertexObjects
=
new
ArrayList
<>();
addVerticesToList
(
p
.
getExteriorRing
(),
vertexObjects
);
for
(
LinearRing
innerRing
:
p
.
getInnerRings
())
{
addVerticesToList
(
innerRing
,
vertexObjects
);
}
// write the vector data according to the projection axis into the array
int
start
=
addRingToArray
(
p
.
getExteriorRing
(),
vertices
,
0
,
axis
);
for
(
LinearRing
innerRing
:
p
.
getInnerRings
())
{
start
=
addRingToArray
(
innerRing
,
vertices
,
start
,
axis
);
}
// triangulation
List
<
Integer
>
indices
=
Earcut
.
earcut
(
vertices
,
holeStart
,
2
);
List
<
Triangle3d
>
triangles
=
new
ArrayList
<>();
if
(
indices
.
size
()
%
3
!=
0
)
{
throw
new
IllegalStateException
();
}
for
(
int
i
=
0
;
i
<
indices
.
size
();
i
=
i
+
3
)
{
Triangle3d
t
=
new
Triangle3d
(
vertexObjects
.
get
(
indices
.
get
(
i
+
0
)),
vertexObjects
.
get
(
indices
.
get
(
i
+
1
)),
vertexObjects
.
get
(
indices
.
get
(
i
+
2
)));
triangles
.
add
(
t
);
}
return
new
TesselatedPolygon
(
triangles
,
p
);
}
private
static
void
addVerticesToList
(
LinearRing
ring
,
List
<
Vertex
>
vertexObjects
)
{
List
<
Vertex
>
vertices
=
ring
.
getVertices
();
for
(
int
i
=
0
;
i
<
vertices
.
size
()
-
1
;
i
++)
{
Vertex
v
=
vertices
.
get
(
i
);
vertexObjects
.
add
(
v
);
}
}
private
static
int
addRingToArray
(
LinearRing
ring
,
double
[]
vertices
,
int
start
,
ProjectionAxis
axis
)
{
List
<
Vertex
>
ringVertices
=
ring
.
getVertices
();
for
(
int
i
=
0
;
i
<
ringVertices
.
size
()
-
1
;
i
++)
{
Vertex
v
=
ringVertices
.
get
(
i
);
axis
.
writeCoordinatesOfVectorInArray
(
v
,
vertices
,
start
);
start
=
start
+
2
;
}
return
start
;
}
private
EarcutTesselator
()
{
}
}
Prev
1
2
3
4
5
6
7
…
13
Next