Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Mayer
CircularGreenSimCity
Commits
0b3a4414
Commit
0b3a4414
authored
May 31, 2024
by
Matthias Betz
Browse files
fix AlkisGreenEnricher not working with polygon
parent
f704c6b4
Changes
4
Hide whitespace changes
Inline
Side-by-side
enrich-citygml-with-greenarea/src/main/java/de/hft/stuttgart/citygml/green/alkis/AlkisGreenEnricher.java
View file @
0b3a4414
...
@@ -102,7 +102,7 @@ public class AlkisGreenEnricher
...
@@ -102,7 +102,7 @@ public class AlkisGreenEnricher
GreenEnricher
.
createTransformers
(
cityModel
);
GreenEnricher
.
createTransformers
(
cityModel
);
OsmData
osmData
=
new
OsmData
();
OsmData
osmData
=
new
OsmData
();
//
String boundingBoxString = GreenEnricher.extractAndConvertBoundingBox(cityModel, osmData);
String
boundingBoxString
=
GreenEnricher
.
extractAndConvertBoundingBox
(
cityModel
,
osmData
);
// String boundingBoxBasename = boundingBoxString.replace(",", "__").replace('.', '_');
// String boundingBoxBasename = boundingBoxString.replace(",", "__").replace('.', '_');
// Path osmCache = Paths.get("data", "cache", "osm_response_" + boundingBoxBasename + ".xml");
// Path osmCache = Paths.get("data", "cache", "osm_response_" + boundingBoxBasename + ".xml");
// if (!Files.exists(osmCache)) {
// if (!Files.exists(osmCache)) {
...
@@ -144,8 +144,6 @@ public class AlkisGreenEnricher
...
@@ -144,8 +144,6 @@ public class AlkisGreenEnricher
System
.
out
.
println
(
"Writing output file."
);
System
.
out
.
println
(
"Writing output file."
);
GreenEnricher
.
writeCityGML
(
cityModel
,
outputPath
);
GreenEnricher
.
writeCityGML
(
cityModel
,
outputPath
);
System
.
out
.
println
(
"Done"
);
System
.
out
.
println
(
"Done"
);
}
}
private
static
void
parseAlkisData
(
OsmData
osmData
,
Path
alkisDataPath
)
throws
MalformedURLException
,
IOException
{
private
static
void
parseAlkisData
(
OsmData
osmData
,
Path
alkisDataPath
)
throws
MalformedURLException
,
IOException
{
...
...
enrich-citygml-with-greenarea/src/main/java/de/hft/stuttgart/citygml/green/osm/TreeKatasterData.java
View file @
0b3a4414
...
@@ -50,7 +50,7 @@ public class TreeKatasterData {
...
@@ -50,7 +50,7 @@ public class TreeKatasterData {
if
(
treeHeightObject
==
null
)
{
if
(
treeHeightObject
==
null
)
{
continue
;
continue
;
}
}
int
treeHeight
=
Integer
.
parseInt
(
treeHeightObject
.
toString
());
double
treeHeight
=
Double
.
parseDouble
(
treeHeightObject
.
toString
());
double
crownHeight
=
CROWN_PERCENTAGE
*
treeHeight
;
double
crownHeight
=
CROWN_PERCENTAGE
*
treeHeight
;
double
trunkHeight
=
TRUNK_PERCENTAGE
*
treeHeight
;
double
trunkHeight
=
TRUNK_PERCENTAGE
*
treeHeight
;
tree
.
setCrownHeight
(
crownHeight
);
tree
.
setCrownHeight
(
crownHeight
);
...
@@ -65,8 +65,8 @@ public class TreeKatasterData {
...
@@ -65,8 +65,8 @@ public class TreeKatasterData {
if
(
trunkCirc
==
null
)
{
if
(
trunkCirc
==
null
)
{
continue
;
continue
;
}
}
int
circInCm
=
Integer
.
parseInt
(
trunkCirc
.
toString
());
double
circInCm
=
Double
.
parseDouble
(
trunkCirc
.
toString
());
if
(
circInCm
=
=
0
)
{
if
(
circInCm
<
=
0
.1
)
{
circInCm
=
89
;
circInCm
=
89
;
}
}
tree
.
setTrunkRadius
(
circInCm
/
(
2
*
Math
.
PI
)
/
100
);
tree
.
setTrunkRadius
(
circInCm
/
(
2
*
Math
.
PI
)
/
100
);
...
...
enrich-citygml-with-greenarea/src/main/java/de/hft/stuttgart/citygml/green/osm/TreeUtils.java
View file @
0b3a4414
...
@@ -2,6 +2,7 @@ package de.hft.stuttgart.citygml.green.osm;
...
@@ -2,6 +2,7 @@ package de.hft.stuttgart.citygml.green.osm;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.nio.file.Path
;
import
java.nio.file.Path
;
import
java.nio.file.Paths
;
import
java.util.Iterator
;
import
java.util.Iterator
;
import
java.util.UUID
;
import
java.util.UUID
;
import
org.citygml4j.core.model.core.AbstractCityObjectProperty
;
import
org.citygml4j.core.model.core.AbstractCityObjectProperty
;
...
@@ -9,6 +10,7 @@ import org.citygml4j.core.model.core.CityModel;
...
@@ -9,6 +10,7 @@ import org.citygml4j.core.model.core.CityModel;
import
org.citygml4j.core.model.vegetation.SolitaryVegetationObject
;
import
org.citygml4j.core.model.vegetation.SolitaryVegetationObject
;
import
org.locationtech.jts.geom.Coordinate
;
import
org.locationtech.jts.geom.Coordinate
;
import
org.locationtech.jts.geom.GeometryFactory
;
import
org.locationtech.jts.geom.GeometryFactory
;
import
org.locationtech.jts.geom.Point
;
import
org.locationtech.jts.geom.Polygon
;
import
org.locationtech.jts.geom.Polygon
;
import
org.xmlobjects.gml.model.basictypes.Code
;
import
org.xmlobjects.gml.model.basictypes.Code
;
import
org.xmlobjects.gml.model.geometry.aggregates.MultiSurface
;
import
org.xmlobjects.gml.model.geometry.aggregates.MultiSurface
;
...
@@ -23,6 +25,10 @@ public class TreeUtils {
...
@@ -23,6 +25,10 @@ public class TreeUtils {
throws
IOException
{
throws
IOException
{
TreeKatasterData
katasterData
=
TreeKatasterData
.
parseTreeKatasterData
(
baumKatasterPath
);
TreeKatasterData
katasterData
=
TreeKatasterData
.
parseTreeKatasterData
(
baumKatasterPath
);
generateTreesFromKataster
(
cityModel
,
katasterData
,
osmData
,
wktPolygon
);
generateTreesFromKataster
(
cityModel
,
katasterData
,
osmData
,
wktPolygon
);
// TreeKatasterData added = TreeKatasterData.parseTreeKatasterData(baumKatasterPath);
// filterDuplicateTrees(katasterData, added);
// generateTreesFromKataster(cityModel, added, osmData, wktPolygon);
// TreeKatasterData katasterData2 =
// TreeKatasterData katasterData2 =
// TreeKatasterData.parseTreeKatasterData(Paths.get("data",
// TreeKatasterData.parseTreeKatasterData(Paths.get("data",
...
@@ -36,6 +42,19 @@ public class TreeUtils {
...
@@ -36,6 +42,19 @@ public class TreeUtils {
// generateTreesFromOSM(cityModel, osmData, wktPolygon);
// generateTreesFromOSM(cityModel, osmData, wktPolygon);
}
}
private
static
void
filterDuplicateTrees
(
TreeKatasterData
truth
,
TreeKatasterData
added
)
{
for
(
Iterator
<
Tree
>
iterator
=
added
.
getTrees
().
iterator
();
iterator
.
hasNext
();)
{
Tree
tp
=
iterator
.
next
();
// if another tree from kataster is within 1m ignore it
for
(
Tree
tree
:
truth
.
getTrees
())
{
if
(
tp
.
getPoint
().
distance
(
tree
.
getPoint
())
<
1
)
{
iterator
.
remove
();
break
;
}
}
}
}
private
static
void
filterDuplicateTreesFromOSM
(
OsmData
osmData
,
TreeKatasterData
katasterData
)
{
private
static
void
filterDuplicateTreesFromOSM
(
OsmData
osmData
,
TreeKatasterData
katasterData
)
{
for
(
Iterator
<
TreePoint
>
iterator
=
osmData
.
getTreePoints
().
iterator
();
iterator
.
hasNext
();)
{
for
(
Iterator
<
TreePoint
>
iterator
=
osmData
.
getTreePoints
().
iterator
();
iterator
.
hasNext
();)
{
...
@@ -80,8 +99,9 @@ public class TreeUtils {
...
@@ -80,8 +99,9 @@ public class TreeUtils {
for
(
Tree
tree
:
katasterData
.
getTrees
())
{
for
(
Tree
tree
:
katasterData
.
getTrees
())
{
// check if tree is in area
// check if tree is in area
Coordinate
coordinate
=
tree
.
getPoint
().
getCoordinate
();
Coordinate
coordinate
=
tree
.
getPoint
().
getCoordinate
();
if
((
wktPolygon
!=
null
&&
!
wktPolygon
.
contains
(
FACTORY
.
createPoint
(
coordinate
)))
Point
point
=
FACTORY
.
createPoint
(
coordinate
);
||
!
osmData
.
getBoundingBox
().
contains
(
FACTORY
.
createPoint
(
coordinate
)))
{
if
((
wktPolygon
!=
null
&&
!
wktPolygon
.
contains
(
point
))
||
(
wktPolygon
==
null
&&
!
osmData
.
getBoundingBox
().
contains
(
point
)))
{
continue
;
continue
;
}
}
...
...
enrich-citygml-with-greenarea/src/test/java/de/hft/stuttgart/citygml/green/alkis/AlkisGreenEnricherTest.java
View file @
0b3a4414
...
@@ -27,7 +27,7 @@ class AlkisGreenEnricherTest
...
@@ -27,7 +27,7 @@ class AlkisGreenEnricherTest
AlkisGreenEnricher
.
main
(
args
);
AlkisGreenEnricher
.
main
(
args
);
assertTrue
(
Files
.
exists
(
outputGML
));
assertTrue
(
Files
.
exists
(
outputGML
));
}
}
@Test
@Test
void
testGreen
()
throws
Exception
{
void
testGreen
()
throws
Exception
{
Path
outputGML
=
Paths
.
get
(
"data/Grombühl_v4_case_study_enrich_test.gml"
);
Path
outputGML
=
Paths
.
get
(
"data/Grombühl_v4_case_study_enrich_test.gml"
);
...
...
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