Skip to content
GitLab
Explore
Projects
Groups
Snippets
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
11 months ago
by
Matthias Betz
Browse files
Options
Download
Email Patches
Plain Diff
fix AlkisGreenEnricher not working with polygon
parent
f704c6b4
master
gPMayer2-master-patch-26512
gPMayer2-master-patch-49202
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
enrich-citygml-with-greenarea/src/main/java/de/hft/stuttgart/citygml/green/alkis/AlkisGreenEnricher.java
+1
-3
...hft/stuttgart/citygml/green/alkis/AlkisGreenEnricher.java
enrich-citygml-with-greenarea/src/main/java/de/hft/stuttgart/citygml/green/osm/TreeKatasterData.java
+3
-3
.../de/hft/stuttgart/citygml/green/osm/TreeKatasterData.java
enrich-citygml-with-greenarea/src/main/java/de/hft/stuttgart/citygml/green/osm/TreeUtils.java
+22
-2
...in/java/de/hft/stuttgart/citygml/green/osm/TreeUtils.java
enrich-citygml-with-greenarea/src/test/java/de/hft/stuttgart/citygml/green/alkis/AlkisGreenEnricherTest.java
+1
-1
...stuttgart/citygml/green/alkis/AlkisGreenEnricherTest.java
with
27 additions
and
9 deletions
+27
-9
enrich-citygml-with-greenarea/src/main/java/de/hft/stuttgart/citygml/green/alkis/AlkisGreenEnricher.java
+
1
-
3
View file @
0b3a4414
...
...
@@ -102,7 +102,7 @@ public class AlkisGreenEnricher
GreenEnricher
.
createTransformers
(
cityModel
);
OsmData
osmData
=
new
OsmData
();
//
String boundingBoxString = GreenEnricher.extractAndConvertBoundingBox(cityModel, osmData);
String
boundingBoxString
=
GreenEnricher
.
extractAndConvertBoundingBox
(
cityModel
,
osmData
);
// String boundingBoxBasename = boundingBoxString.replace(",", "__").replace('.', '_');
// Path osmCache = Paths.get("data", "cache", "osm_response_" + boundingBoxBasename + ".xml");
// if (!Files.exists(osmCache)) {
...
...
@@ -144,8 +144,6 @@ public class AlkisGreenEnricher
System
.
out
.
println
(
"Writing output file."
);
GreenEnricher
.
writeCityGML
(
cityModel
,
outputPath
);
System
.
out
.
println
(
"Done"
);
}
private
static
void
parseAlkisData
(
OsmData
osmData
,
Path
alkisDataPath
)
throws
MalformedURLException
,
IOException
{
...
...
This diff is collapsed.
Click to expand it.
enrich-citygml-with-greenarea/src/main/java/de/hft/stuttgart/citygml/green/osm/TreeKatasterData.java
+
3
-
3
View file @
0b3a4414
...
...
@@ -50,7 +50,7 @@ public class TreeKatasterData {
if
(
treeHeightObject
==
null
)
{
continue
;
}
int
treeHeight
=
Integer
.
parseInt
(
treeHeightObject
.
toString
());
double
treeHeight
=
Double
.
parseDouble
(
treeHeightObject
.
toString
());
double
crownHeight
=
CROWN_PERCENTAGE
*
treeHeight
;
double
trunkHeight
=
TRUNK_PERCENTAGE
*
treeHeight
;
tree
.
setCrownHeight
(
crownHeight
);
...
...
@@ -65,8 +65,8 @@ public class TreeKatasterData {
if
(
trunkCirc
==
null
)
{
continue
;
}
int
circInCm
=
Integer
.
parseInt
(
trunkCirc
.
toString
());
if
(
circInCm
=
=
0
)
{
double
circInCm
=
Double
.
parseDouble
(
trunkCirc
.
toString
());
if
(
circInCm
<
=
0
.1
)
{
circInCm
=
89
;
}
tree
.
setTrunkRadius
(
circInCm
/
(
2
*
Math
.
PI
)
/
100
);
...
...
This diff is collapsed.
Click to expand it.
enrich-citygml-with-greenarea/src/main/java/de/hft/stuttgart/citygml/green/osm/TreeUtils.java
+
22
-
2
View file @
0b3a4414
...
...
@@ -2,6 +2,7 @@ package de.hft.stuttgart.citygml.green.osm;
import
java.io.IOException
;
import
java.nio.file.Path
;
import
java.nio.file.Paths
;
import
java.util.Iterator
;
import
java.util.UUID
;
import
org.citygml4j.core.model.core.AbstractCityObjectProperty
;
...
...
@@ -9,6 +10,7 @@ import org.citygml4j.core.model.core.CityModel;
import
org.citygml4j.core.model.vegetation.SolitaryVegetationObject
;
import
org.locationtech.jts.geom.Coordinate
;
import
org.locationtech.jts.geom.GeometryFactory
;
import
org.locationtech.jts.geom.Point
;
import
org.locationtech.jts.geom.Polygon
;
import
org.xmlobjects.gml.model.basictypes.Code
;
import
org.xmlobjects.gml.model.geometry.aggregates.MultiSurface
;
...
...
@@ -23,6 +25,10 @@ public class TreeUtils {
throws
IOException
{
TreeKatasterData
katasterData
=
TreeKatasterData
.
parseTreeKatasterData
(
baumKatasterPath
);
generateTreesFromKataster
(
cityModel
,
katasterData
,
osmData
,
wktPolygon
);
// TreeKatasterData added = TreeKatasterData.parseTreeKatasterData(baumKatasterPath);
// filterDuplicateTrees(katasterData, added);
// generateTreesFromKataster(cityModel, added, osmData, wktPolygon);
// TreeKatasterData katasterData2 =
// TreeKatasterData.parseTreeKatasterData(Paths.get("data",
...
...
@@ -36,6 +42,19 @@ public class TreeUtils {
// 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
)
{
for
(
Iterator
<
TreePoint
>
iterator
=
osmData
.
getTreePoints
().
iterator
();
iterator
.
hasNext
();)
{
...
...
@@ -80,8 +99,9 @@ public class TreeUtils {
for
(
Tree
tree
:
katasterData
.
getTrees
())
{
// check if tree is in area
Coordinate
coordinate
=
tree
.
getPoint
().
getCoordinate
();
if
((
wktPolygon
!=
null
&&
!
wktPolygon
.
contains
(
FACTORY
.
createPoint
(
coordinate
)))
||
!
osmData
.
getBoundingBox
().
contains
(
FACTORY
.
createPoint
(
coordinate
)))
{
Point
point
=
FACTORY
.
createPoint
(
coordinate
);
if
((
wktPolygon
!=
null
&&
!
wktPolygon
.
contains
(
point
))
||
(
wktPolygon
==
null
&&
!
osmData
.
getBoundingBox
().
contains
(
point
)))
{
continue
;
}
...
...
This diff is collapsed.
Click to expand it.
enrich-citygml-with-greenarea/src/test/java/de/hft/stuttgart/citygml/green/alkis/AlkisGreenEnricherTest.java
+
1
-
1
View file @
0b3a4414
...
...
@@ -27,7 +27,7 @@ class AlkisGreenEnricherTest
AlkisGreenEnricher
.
main
(
args
);
assertTrue
(
Files
.
exists
(
outputGML
));
}
@Test
void
testGreen
()
throws
Exception
{
Path
outputGML
=
Paths
.
get
(
"data/Grombühl_v4_case_study_enrich_test.gml"
);
...
...
This diff is collapsed.
Click to expand it.
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
Menu
Explore
Projects
Groups
Snippets