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
d163d7c4
Commit
d163d7c4
authored
Nov 26, 2020
by
Matthias Betz
Browse files
removing adjacency list for polygons. Redundant with adjacency list with linear rings
parent
adbb58d1
Pipeline
#1374
passed with stage
in 2 minutes and 18 seconds
Changes
5
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
CityDoctorParent/CityDoctorModel/src/main/java/de/hft/stuttgart/citydoctor2/datastructure/ConcretePolygon.java
View file @
d163d7c4
...
...
@@ -409,11 +409,11 @@ public class ConcretePolygon extends Polygon {
if
(
isLinkedTo
())
{
Geometry
geom2
=
linkedFromPolygon
.
getParent
();
for
(
Vertex
v
:
lr
.
getVertices
())
{
v
.
removeAdjacency
(
lr
,
this
,
geom2
);
v
.
removeAdjacency
(
lr
,
geom2
);
}
}
for
(
Vertex
v
:
lr
.
getVertices
())
{
v
.
removeAdjacency
(
lr
,
this
,
parent
);
v
.
removeAdjacency
(
lr
,
parent
);
}
}
...
...
CityDoctorParent/CityDoctorModel/src/main/java/de/hft/stuttgart/citydoctor2/datastructure/Geometry.java
View file @
d163d7c4
...
...
@@ -344,7 +344,7 @@ public class Geometry extends GmlElement {
v
.
clearAdjacentRings
(
this
);
}
// add ring to adjacent rings of vertex
v
.
addAdjacentRing
(
p
,
ring
,
this
);
v
.
addAdjacentRing
(
ring
,
this
);
}
}
...
...
CityDoctorParent/CityDoctorModel/src/main/java/de/hft/stuttgart/citydoctor2/datastructure/LinearRing.java
View file @
d163d7c4
...
...
@@ -204,17 +204,17 @@ public class LinearRing extends GmlElement {
return
;
}
if
(
parent
.
isLinkedTo
())
{
v
.
addAdjacentRing
(
parent
.
getLinkedFromPolygon
(),
this
,
parent
.
getLinkedFromPolygon
().
getParent
());
v
.
addAdjacentRing
(
this
,
parent
.
getLinkedFromPolygon
().
getParent
());
}
v
.
addAdjacentRing
(
parent
,
this
,
parent
.
getParent
());
v
.
addAdjacentRing
(
this
,
parent
.
getParent
());
}
public
void
addVertex
(
int
i
,
Vertex
v
)
{
vertices
.
add
(
i
,
v
);
if
(
parent
.
isLinkedTo
())
{
v
.
addAdjacentRing
(
parent
.
getLinkedFromPolygon
(),
this
,
parent
.
getLinkedFromPolygon
().
getParent
());
v
.
addAdjacentRing
(
this
,
parent
.
getLinkedFromPolygon
().
getParent
());
}
v
.
addAdjacentRing
(
parent
,
this
,
parent
.
getParent
());
v
.
addAdjacentRing
(
this
,
parent
.
getParent
());
}
@Override
...
...
CityDoctorParent/CityDoctorModel/src/main/java/de/hft/stuttgart/citydoctor2/datastructure/LinkedPolygon.java
View file @
d163d7c4
...
...
@@ -47,11 +47,11 @@ public class LinkedPolygon extends Polygon {
this
.
poly
=
poly
;
poly
.
setLinkedTo
(
this
);
for
(
Vertex
v
:
poly
.
getExteriorRing
().
getVertices
())
{
v
.
addAdjacentRing
(
this
,
poly
.
getExteriorRing
(),
parent
);
v
.
addAdjacentRing
(
poly
.
getExteriorRing
(),
parent
);
}
for
(
LinearRing
lr
:
poly
.
getInnerRings
())
{
for
(
Vertex
v
:
lr
.
getVertices
())
{
v
.
addAdjacentRing
(
this
,
lr
,
parent
);
v
.
addAdjacentRing
(
lr
,
parent
);
}
}
}
...
...
CityDoctorParent/CityDoctorModel/src/main/java/de/hft/stuttgart/citydoctor2/datastructure/Vertex.java
View file @
d163d7c4
...
...
@@ -37,7 +37,6 @@ public class Vertex extends Vector3d {
private
static
final
long
serialVersionUID
=
-
5525361920397934892L
;
private
List
<
SerializablePair
<
Geometry
,
HashSet
<
Polygon
>>>
adjacentPolygons
=
new
ArrayList
<>(
2
);
private
List
<
SerializablePair
<
Geometry
,
HashSet
<
LinearRing
>>>
adjacentRings
=
new
ArrayList
<>(
2
);
private
List
<
Vertex
>
neighbors
;
...
...
@@ -91,9 +90,8 @@ public class Vertex extends Vector3d {
throw
new
IllegalStateException
(
"Requested adjacent rings with Geometry not containing this vertex"
);
}
void
addAdjacentRing
(
Polygon
poly
,
LinearRing
ring
,
Geometry
geom
)
{
void
addAdjacentRing
(
LinearRing
ring
,
Geometry
geom
)
{
findAdjacentRingsForGeometry
(
geom
).
add
(
ring
);
findAdjacentPolygonsForGeometry
(
geom
).
add
(
poly
);
}
private
Set
<
LinearRing
>
findAdjacentRingsForGeometry
(
Geometry
geom
)
{
...
...
@@ -110,42 +108,32 @@ public class Vertex extends Vector3d {
return
adjacendRingsSet
;
}
private
Set
<
Polygon
>
findAdjacentPolygonsForGeometry
(
Geometry
geom
)
{
HashSet
<
Polygon
>
adjacendPolygonsSet
=
null
;
for
(
SerializablePair
<
Geometry
,
HashSet
<
Polygon
>>
adjacency
:
adjacentPolygons
)
{
if
(
adjacency
.
getValue0
()
==
geom
)
{
adjacendPolygonsSet
=
adjacency
.
getValue1
();
}
}
if
(
adjacendPolygonsSet
==
null
)
{
adjacendPolygonsSet
=
new
HashSet
<>(
4
);
adjacentPolygons
.
add
(
new
SerializablePair
<>(
geom
,
adjacendPolygonsSet
));
}
return
adjacendPolygonsSet
;
}
public
Set
<
Polygon
>
getAdjacentPolygonsWithoutNeighbor
(
Geometry
geom
)
{
for
(
SerializablePair
<
Geometry
,
HashSet
<
Polygon
>>
adjacency
:
adjacentPolygons
)
{
private
Set
<
Polygon
>
getAdjacentPolygonsWithoutNeighbor
(
Geometry
geom
)
{
for
(
SerializablePair
<
Geometry
,
HashSet
<
LinearRing
>>
adjacency
:
adjacentRings
)
{
if
(
adjacency
.
getValue0
()
==
geom
)
{
return
adjacency
.
getValue1
();
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
)
{
for
(
SerializablePair
<
Geometry
,
HashSet
<
Polygon
>>
adj
a
cency
:
adjacent
Polygon
s
)
{
if
(
adj
a
cency
.
getValue0
()
==
geom
)
{
if
(
neighbor
s
=
=
n
ull
||
neighbors
.
isEmpty
())
{
return
adj
a
cency
.
getValue1
()
;
}
else
{
Set
<
Polygon
>
polygons
=
new
HashSet
<>();
polygons
.
addAll
(
adjacency
.
getValue1
())
;
for
(
SerializablePair
<
Geometry
,
HashSet
<
LinearRing
>>
adj
e
cency
:
adjacent
Ring
s
)
{
if
(
adj
e
cency
.
getValue0
()
==
geom
)
{
Set
<
Polygon
>
polygon
s
=
n
ew
HashSet
<>();
for
(
LinearRing
lr
:
adj
e
cency
.
getValue1
()
)
{
polygons
.
add
(
lr
.
getParent
());
}
if
(
neighbors
!=
null
&&
!
neighbors
.
isEmpty
())
{
for
(
Vertex
neighbor
:
neighbors
)
{
polygons
.
addAll
(
neighbor
.
getAdjacentPolygonsWithoutNeighbor
(
geom
));
}
return
polygons
;
}
return
polygons
;
}
}
throw
new
IllegalStateException
(
"Requested adjacent polygons with Geometry not containing this vertex"
);
...
...
@@ -176,11 +164,9 @@ public class Vertex extends Vector3d {
public
void
clearAdjacentRings
(
Geometry
geometry
)
{
findAdjacentRingsForGeometry
(
geometry
).
clear
();
findAdjacentPolygonsForGeometry
(
geometry
).
clear
();
}
void
removeAdjacency
(
LinearRing
lr
,
Polygon
p
,
Geometry
geom
)
{
findAdjacentPolygonsForGeometry
(
geom
).
remove
(
p
);
void
removeAdjacency
(
LinearRing
lr
,
Geometry
geom
)
{
findAdjacentRingsForGeometry
(
geom
).
remove
(
lr
);
}
...
...
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