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
3e042784
Commit
3e042784
authored
2 years ago
by
Matthias Betz
Browse files
Options
Download
Email Patches
Plain Diff
add alkis land use parsing
parent
eacaa411
master
eric_enrich_trees
gPMayer2-master-patch-26512
gPMayer2-master-patch-49202
No related merge requests found
Changes
19
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
19 changed files
enrich-citygml-with-greenarea/pom.xml
+13
-0
enrich-citygml-with-greenarea/pom.xml
enrich-citygml-with-greenarea/src/main/java/de/hft/stuttgart/citygml/green/alkis/AlkisGreenEnricher.java
+139
-0
...hft/stuttgart/citygml/green/alkis/AlkisGreenEnricher.java
enrich-citygml-with-greenarea/src/main/java/de/hft/stuttgart/citygml/green/osm/GreenEnricher.java
+236
-250
...ava/de/hft/stuttgart/citygml/green/osm/GreenEnricher.java
enrich-citygml-with-greenarea/src/main/java/de/hft/stuttgart/citygml/green/osm/LandUseArea.java
+29
-0
.../java/de/hft/stuttgart/citygml/green/osm/LandUseArea.java
enrich-citygml-with-greenarea/src/main/java/de/hft/stuttgart/citygml/green/osm/OsmData.java
+10
-0
...main/java/de/hft/stuttgart/citygml/green/osm/OsmData.java
enrich-citygml-with-greenarea/src/main/java/de/hft/stuttgart/citygml/green/osm/RoadArea.java
+29
-0
...ain/java/de/hft/stuttgart/citygml/green/osm/RoadArea.java
enrich-citygml-with-greenarea/src/main/java/de/hft/stuttgart/citygml/green/osm/TreeGenerator.java
+4
-4
...ava/de/hft/stuttgart/citygml/green/osm/TreeGenerator.java
enrich-citygml-with-greenarea/src/main/java/de/hft/stuttgart/citygml/green/osm/TreeKatasterData.java
+66
-0
.../de/hft/stuttgart/citygml/green/osm/TreeKatasterData.java
enrich-citygml-with-greenarea/src/main/java/de/hft/stuttgart/citygml/green/osm/TreeUtils.java
+83
-0
...in/java/de/hft/stuttgart/citygml/green/osm/TreeUtils.java
enrich-citygml-with-greenarea/src/main/java/de/hft/stuttgart/citygml/green/osm/jaxb/Bounds.java
+35
-0
.../java/de/hft/stuttgart/citygml/green/osm/jaxb/Bounds.java
enrich-citygml-with-greenarea/src/main/java/de/hft/stuttgart/citygml/green/osm/jaxb/Meta.java
+14
-0
...in/java/de/hft/stuttgart/citygml/green/osm/jaxb/Meta.java
enrich-citygml-with-greenarea/src/main/java/de/hft/stuttgart/citygml/green/osm/jaxb/OSM.java
+79
-0
...ain/java/de/hft/stuttgart/citygml/green/osm/jaxb/OSM.java
enrich-citygml-with-greenarea/src/main/java/de/hft/stuttgart/citygml/green/osm/jaxb/OsmMember.java
+43
-0
...va/de/hft/stuttgart/citygml/green/osm/jaxb/OsmMember.java
enrich-citygml-with-greenarea/src/main/java/de/hft/stuttgart/citygml/green/osm/jaxb/OsmNode.java
+44
-0
...java/de/hft/stuttgart/citygml/green/osm/jaxb/OsmNode.java
enrich-citygml-with-greenarea/src/main/java/de/hft/stuttgart/citygml/green/osm/jaxb/OsmRelation.java
+48
-0
.../de/hft/stuttgart/citygml/green/osm/jaxb/OsmRelation.java
enrich-citygml-with-greenarea/src/main/java/de/hft/stuttgart/citygml/green/osm/jaxb/OsmTag.java
+21
-0
.../java/de/hft/stuttgart/citygml/green/osm/jaxb/OsmTag.java
enrich-citygml-with-greenarea/src/main/java/de/hft/stuttgart/citygml/green/osm/jaxb/OsmWay.java
+47
-0
.../java/de/hft/stuttgart/citygml/green/osm/jaxb/OsmWay.java
enrich-citygml-with-greenarea/src/main/java/de/hft/stuttgart/citygml/green/osm/jaxb/WayNode.java
+28
-0
...java/de/hft/stuttgart/citygml/green/osm/jaxb/WayNode.java
enrich-citygml-with-greenarea/src/test/java/de/hft/stuttgart/citygml/green/alkis/AlkisGreenEnricherTest.java
+21
-0
...stuttgart/citygml/green/alkis/AlkisGreenEnricherTest.java
with
989 additions
and
254 deletions
+989
-254
enrich-citygml-with-greenarea/pom.xml
+
13
-
0
View file @
3e042784
...
@@ -25,6 +25,19 @@
...
@@ -25,6 +25,19 @@
</repositories>
</repositories>
<dependencies>
<dependencies>
<!-- https://mvnrepository.com/artifact/jakarta.xml.bind/jakarta.xml.bind-api -->
<dependency>
<groupId>
jakarta.xml.bind
</groupId>
<artifactId>
jakarta.xml.bind-api
</artifactId>
<version>
4.0.0
</version>
</dependency>
<dependency>
<groupId>
com.sun.xml.bind
</groupId>
<artifactId>
jaxb-impl
</artifactId>
<version>
4.0.0
</version>
<scope>
runtime
</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.geotools/gt-shapefile -->
<!-- https://mvnrepository.com/artifact/org.geotools/gt-shapefile -->
<dependency>
<dependency>
<groupId>
org.geotools
</groupId>
<groupId>
org.geotools
</groupId>
...
...
This diff is collapsed.
Click to expand it.
enrich-citygml-with-greenarea/src/main/java/de/hft/stuttgart/citygml/green/alkis/AlkisGreenEnricher.java
0 → 100644
+
139
-
0
View file @
3e042784
package
de.hft.stuttgart.citygml.green.alkis
;
import
java.io.IOException
;
import
java.net.MalformedURLException
;
import
java.nio.charset.StandardCharsets
;
import
java.nio.file.Files
;
import
java.nio.file.Path
;
import
java.nio.file.Paths
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Set
;
import
org.citygml4j.core.model.core.CityModel
;
import
org.citygml4j.xml.CityGMLContextException
;
import
org.citygml4j.xml.reader.CityGMLReadException
;
import
org.citygml4j.xml.writer.CityGMLWriteException
;
import
org.geotools.data.DataStore
;
import
org.geotools.data.DataStoreFinder
;
import
org.geotools.data.FeatureSource
;
import
org.geotools.feature.FeatureCollection
;
import
org.geotools.feature.FeatureIterator
;
import
org.locationtech.jts.geom.MultiPolygon
;
import
org.locationtech.jts.geom.Polygon
;
import
org.opengis.feature.simple.SimpleFeature
;
import
org.opengis.feature.simple.SimpleFeatureType
;
import
de.hft.stuttgart.citygml.green.osm.GreenArea
;
import
de.hft.stuttgart.citygml.green.osm.GreenEnricher
;
import
de.hft.stuttgart.citygml.green.osm.LandUseArea
;
import
de.hft.stuttgart.citygml.green.osm.OsmData
;
import
de.hft.stuttgart.citygml.green.osm.RoadArea
;
import
de.hft.stuttgart.citygml.green.osm.TreeUtils
;
import
jakarta.xml.bind.JAXBException
;
public
class
AlkisGreenEnricher
{
private
static
Set
<
String
>
greenAreaTypes
=
new
HashSet
<>();
private
static
Set
<
String
>
roadAreaTypes
=
new
HashSet
<>();
static
{
greenAreaTypes
.
add
(
"Wald"
);
greenAreaTypes
.
add
(
"Landwirtschaft"
);
greenAreaTypes
.
add
(
"Friedhof"
);
greenAreaTypes
.
add
(
"Gehölz"
);
greenAreaTypes
.
add
(
"Sport-, Freizeit- und Erholungsfläche"
);
roadAreaTypes
.
add
(
"Weg"
);
roadAreaTypes
.
add
(
"Straßenverkehr"
);
roadAreaTypes
.
add
(
"Bahnverkehr"
);
}
public
static
void
main
(
String
[]
args
)
throws
IOException
,
CityGMLContextException
,
CityGMLReadException
,
JAXBException
,
CityGMLWriteException
{
System
.
out
.
println
(
"Reading CityGML file"
);
Path
inFile
=
Paths
.
get
(
args
[
0
]);
CityModel
cityModel
=
GreenEnricher
.
readCityGml
(
inFile
);
GreenEnricher
.
createTransformers
(
cityModel
);
OsmData
osmData
=
new
OsmData
();
String
boundingBoxString
=
GreenEnricher
.
extractAndConvertBoundingBox
(
cityModel
,
osmData
);
// HttpResponse<String> response = getOsmData(boundingBoxString);
// Files.write(Path.of("osm_response.xml"), response.body().getBytes(StandardCharsets.UTF_8));
// String osmResponse = response.body();
String
osmResponse
=
Files
.
readString
(
Paths
.
get
(
"data"
,
"osm_response.xml"
));
System
.
out
.
println
(
"Parsing OSM response"
);
GreenEnricher
.
parseOsmResponse
(
osmResponse
,
osmData
);
// ignore green areas from osm
osmData
.
getGreenAreas
().
clear
();
parseAlkisData
(
osmData
);
System
.
out
.
println
(
"Fit data in bounding box"
);
GreenEnricher
.
fitToBoundingBox
(
osmData
);
GreenEnricher
.
convertGreenAreasToCityGML
(
cityModel
,
osmData
.
getGreenAreas
());
GreenEnricher
.
convertWaterAreasToCityGML
(
cityModel
,
osmData
);
GreenEnricher
.
convertRoadAreasToCityGML
(
cityModel
,
osmData
);
GreenEnricher
.
converLandUseAreasToCityGML
(
cityModel
,
osmData
);
TreeUtils
.
insertTrees
(
cityModel
,
osmData
);
GreenEnricher
.
clampToGround
(
cityModel
);
String
inputString
=
inFile
.
getFileName
().
toString
();
String
inputPathWithoutFileEnding
=
inputString
.
substring
(
0
,
inputString
.
lastIndexOf
(
'.'
));
Path
outputPath
=
Paths
.
get
(
"data"
,
inputPathWithoutFileEnding
+
"_with_alkis_greens.gml"
);
System
.
out
.
println
(
"Writing output file."
);
GreenEnricher
.
writeCityGML
(
cityModel
,
outputPath
);
System
.
out
.
println
(
"Done"
);
}
private
static
void
parseAlkisData
(
OsmData
osmData
)
throws
MalformedURLException
,
IOException
{
Path
alkisDataPath
=
Paths
.
get
(
"data"
,
"tn_09663"
,
"Nutzung.shp"
);
Map
<
String
,
Object
>
readParameters
=
new
HashMap
<>();
readParameters
.
put
(
"url"
,
alkisDataPath
.
toUri
().
toURL
());
readParameters
.
put
(
"charset"
,
StandardCharsets
.
UTF_8
);
DataStore
dataStore
=
DataStoreFinder
.
getDataStore
(
readParameters
);
String
typeName
=
dataStore
.
getTypeNames
()[
0
];
FeatureSource
<
SimpleFeatureType
,
SimpleFeature
>
source
=
dataStore
.
getFeatureSource
(
typeName
);
FeatureCollection
<
SimpleFeatureType
,
SimpleFeature
>
collection
=
source
.
getFeatures
();
List
<
GreenArea
>
greenAreas
=
osmData
.
getGreenAreas
();
List
<
RoadArea
>
roadAreas
=
osmData
.
getRoadAreas
();
List
<
LandUseArea
>
landUseAreas
=
osmData
.
getLandUseAreas
();
try
(
FeatureIterator
<
SimpleFeature
>
features
=
collection
.
features
())
{
while
(
features
.
hasNext
())
{
SimpleFeature
feature
=
features
.
next
();
MultiPolygon
geometry
=
(
MultiPolygon
)
feature
.
getAttribute
(
"the_geom"
);
String
nutzart
=
feature
.
getAttribute
(
"nutzart"
).
toString
();
if
(
geometry
.
getNumGeometries
()
>
1
)
{
throw
new
IllegalStateException
();
}
if
(
greenAreaTypes
.
contains
(
nutzart
))
{
greenAreas
.
add
(
new
GreenArea
((
Polygon
)
geometry
.
getGeometryN
(
0
)));
}
else
if
(
roadAreaTypes
.
contains
(
nutzart
))
{
roadAreas
.
add
(
new
RoadArea
((
Polygon
)
geometry
.
getGeometryN
(
0
)));
}
else
{
landUseAreas
.
add
(
new
LandUseArea
((
Polygon
)
geometry
.
getGeometryN
(
0
)));
}
}
}
}
}
This diff is collapsed.
Click to expand it.
enrich-citygml-with-greenarea/src/main/java/de/hft/stuttgart/citygml/green/osm/GreenEnricher.java
+
236
-
250
View file @
3e042784
This diff is collapsed.
Click to expand it.
enrich-citygml-with-greenarea/src/main/java/de/hft/stuttgart/citygml/green/osm/LandUseArea.java
0 → 100644
+
29
-
0
View file @
3e042784
package
de.hft.stuttgart.citygml.green.osm
;
import
org.locationtech.jts.geom.Polygon
;
public
class
LandUseArea
{
private
Polygon
area
;
public
LandUseArea
()
{
}
public
LandUseArea
(
Polygon
area
)
{
this
.
area
=
area
;
}
public
void
setArea
(
Polygon
area
)
{
this
.
area
=
area
;
}
public
Polygon
getArea
()
{
return
area
;
}
@Override
public
String
toString
()
{
return
"LandUseArea [area="
+
area
+
"]"
;
}
}
This diff is collapsed.
Click to expand it.
enrich-citygml-with-greenarea/src/main/java/de/hft/stuttgart/citygml/green/osm/OsmData.java
+
10
-
0
View file @
3e042784
...
@@ -14,6 +14,8 @@ public class OsmData {
...
@@ -14,6 +14,8 @@ public class OsmData {
private
List
<
TreeRow
>
treeRows
=
new
ArrayList
<>();
private
List
<
TreeRow
>
treeRows
=
new
ArrayList
<>();
private
List
<
Waterway
>
waterways
=
new
ArrayList
<>();
private
List
<
Waterway
>
waterways
=
new
ArrayList
<>();
private
List
<
WaterArea
>
waterAreas
=
new
ArrayList
<>();
private
List
<
WaterArea
>
waterAreas
=
new
ArrayList
<>();
private
List
<
RoadArea
>
roadAreas
=
new
ArrayList
<>();
private
List
<
LandUseArea
>
landUseAreas
=
new
ArrayList
<>();
public
void
setBoundingBox
(
Polygon
boundingBox
)
{
public
void
setBoundingBox
(
Polygon
boundingBox
)
{
this
.
boundingBox
=
boundingBox
;
this
.
boundingBox
=
boundingBox
;
...
@@ -42,5 +44,13 @@ public class OsmData {
...
@@ -42,5 +44,13 @@ public class OsmData {
public
List
<
TreeRow
>
getTreeRows
()
{
public
List
<
TreeRow
>
getTreeRows
()
{
return
treeRows
;
return
treeRows
;
}
}
public
List
<
RoadArea
>
getRoadAreas
()
{
return
roadAreas
;
}
public
List
<
LandUseArea
>
getLandUseAreas
()
{
return
landUseAreas
;
}
}
}
This diff is collapsed.
Click to expand it.
enrich-citygml-with-greenarea/src/main/java/de/hft/stuttgart/citygml/green/osm/RoadArea.java
0 → 100644
+
29
-
0
View file @
3e042784
package
de.hft.stuttgart.citygml.green.osm
;
import
org.locationtech.jts.geom.Polygon
;
public
class
RoadArea
{
private
Polygon
area
;
public
RoadArea
()
{
}
public
RoadArea
(
Polygon
area
)
{
this
.
area
=
area
;
}
public
void
setArea
(
Polygon
area
)
{
this
.
area
=
area
;
}
public
Polygon
getArea
()
{
return
area
;
}
@Override
public
String
toString
()
{
return
"RoadArea [area="
+
area
+
"]"
;
}
}
This diff is collapsed.
Click to expand it.
enrich-citygml-with-greenarea/src/main/java/de/hft/stuttgart/citygml/green/osm/TreeGenerator.java
+
4
-
4
View file @
3e042784
...
@@ -104,7 +104,7 @@ public class TreeGenerator {
...
@@ -104,7 +104,7 @@ public class TreeGenerator {
List
<
Coordinate
>
secondRing
=
ringCoordinates
.
get
(
1
);
List
<
Coordinate
>
secondRing
=
ringCoordinates
.
get
(
1
);
for
(
int
i
=
0
;
i
<
secondRing
.
size
();
i
++)
{
for
(
int
i
=
0
;
i
<
secondRing
.
size
();
i
++)
{
Coordinate
[]
coordArray
=
new
Coordinate
[]
{
topPoint
,
secondRing
.
get
(
i
),
secondRing
.
get
((
i
+
1
)
%
secondRing
.
size
()),
topPoint
};
Coordinate
[]
coordArray
=
new
Coordinate
[]
{
topPoint
,
secondRing
.
get
(
i
),
secondRing
.
get
((
i
+
1
)
%
secondRing
.
size
()),
topPoint
};
Polygon
polygon
=
GreenEnricher
.
geomFactory
.
createPolygon
(
coordArray
);
Polygon
polygon
=
GreenEnricher
.
GEOM_FACTORY
.
createPolygon
(
coordArray
);
var
convertedPoly
=
GreenEnricher
.
convertToCityGmlPoly
(
polygon
);
var
convertedPoly
=
GreenEnricher
.
convertToCityGmlPoly
(
polygon
);
ms
.
getSurfaceMember
().
add
(
new
SurfaceProperty
(
convertedPoly
));
ms
.
getSurfaceMember
().
add
(
new
SurfaceProperty
(
convertedPoly
));
}
}
...
@@ -118,7 +118,7 @@ public class TreeGenerator {
...
@@ -118,7 +118,7 @@ public class TreeGenerator {
Coordinate
p3
=
bottomRing
.
get
(
j
);
Coordinate
p3
=
bottomRing
.
get
(
j
);
Coordinate
p4
=
bottomRing
.
get
(
nextRingIndex
);
Coordinate
p4
=
bottomRing
.
get
(
nextRingIndex
);
Coordinate
[]
coordArray
=
new
Coordinate
[]
{
p1
,
p3
,
p4
,
p2
,
p1
};
Coordinate
[]
coordArray
=
new
Coordinate
[]
{
p1
,
p3
,
p4
,
p2
,
p1
};
Polygon
polygon
=
GreenEnricher
.
geomFactory
.
createPolygon
(
coordArray
);
Polygon
polygon
=
GreenEnricher
.
GEOM_FACTORY
.
createPolygon
(
coordArray
);
var
convertedPoly
=
GreenEnricher
.
convertToCityGmlPoly
(
polygon
);
var
convertedPoly
=
GreenEnricher
.
convertToCityGmlPoly
(
polygon
);
ms
.
getSurfaceMember
().
add
(
new
SurfaceProperty
(
convertedPoly
));
ms
.
getSurfaceMember
().
add
(
new
SurfaceProperty
(
convertedPoly
));
}
}
...
@@ -131,7 +131,7 @@ public class TreeGenerator {
...
@@ -131,7 +131,7 @@ public class TreeGenerator {
Coordinate
p1
=
bottomRing
.
get
(
i
);
Coordinate
p1
=
bottomRing
.
get
(
i
);
Coordinate
p2
=
bottomRing
.
get
(
nextRingIndex
);
Coordinate
p2
=
bottomRing
.
get
(
nextRingIndex
);
Coordinate
[]
coordArray
=
new
Coordinate
[]
{
p2
,
p1
,
bottomPoint
,
p2
};
Coordinate
[]
coordArray
=
new
Coordinate
[]
{
p2
,
p1
,
bottomPoint
,
p2
};
Polygon
polygon
=
GreenEnricher
.
geomFactory
.
createPolygon
(
coordArray
);
Polygon
polygon
=
GreenEnricher
.
GEOM_FACTORY
.
createPolygon
(
coordArray
);
var
convertedPoly
=
GreenEnricher
.
convertToCityGmlPoly
(
polygon
);
var
convertedPoly
=
GreenEnricher
.
convertToCityGmlPoly
(
polygon
);
ms
.
getSurfaceMember
().
add
(
new
SurfaceProperty
(
convertedPoly
));
ms
.
getSurfaceMember
().
add
(
new
SurfaceProperty
(
convertedPoly
));
}
}
...
@@ -140,7 +140,7 @@ public class TreeGenerator {
...
@@ -140,7 +140,7 @@ public class TreeGenerator {
}
}
private
static
Polygon
convertPolygon
(
List
<
Coordinate
>
trunkWestCoordinateList
)
{
private
static
Polygon
convertPolygon
(
List
<
Coordinate
>
trunkWestCoordinateList
)
{
return
GreenEnricher
.
geomFactory
return
GreenEnricher
.
GEOM_FACTORY
.
createPolygon
(
trunkWestCoordinateList
.
toArray
(
new
Coordinate
[
trunkWestCoordinateList
.
size
()]));
.
createPolygon
(
trunkWestCoordinateList
.
toArray
(
new
Coordinate
[
trunkWestCoordinateList
.
size
()]));
}
}
...
...
This diff is collapsed.
Click to expand it.
enrich-citygml-with-greenarea/src/main/java/de/hft/stuttgart/citygml/green/osm/TreeKatasterData.java
+
66
-
0
View file @
3e042784
package
de.hft.stuttgart.citygml.green.osm
;
package
de.hft.stuttgart.citygml.green.osm
;
import
java.io.IOException
;
import
java.nio.charset.StandardCharsets
;
import
java.nio.file.Path
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
org.geotools.data.DataStore
;
import
org.geotools.data.DataStoreFinder
;
import
org.geotools.data.FeatureSource
;
import
org.geotools.feature.FeatureCollection
;
import
org.geotools.feature.FeatureIterator
;
import
org.locationtech.jts.geom.Point
;
import
org.opengis.feature.simple.SimpleFeature
;
import
org.opengis.feature.simple.SimpleFeatureType
;
public
class
TreeKatasterData
{
public
class
TreeKatasterData
{
public
static
final
double
TRUNK_PERCENTAGE
=
0.2
;
public
static
final
double
CROWN_PERCENTAGE
=
1
-
TRUNK_PERCENTAGE
;
private
List
<
Tree
>
trees
;
private
List
<
Tree
>
trees
;
public
static
TreeKatasterData
parseTreeKatasterData
(
Path
path
)
throws
IOException
{
TreeKatasterData
result
=
new
TreeKatasterData
();
Map
<
String
,
Object
>
readParameters
=
new
HashMap
<>();
readParameters
.
put
(
"url"
,
path
.
toUri
().
toURL
());
readParameters
.
put
(
"charset"
,
StandardCharsets
.
UTF_8
);
DataStore
dataStore
=
DataStoreFinder
.
getDataStore
(
readParameters
);
String
typeName
=
dataStore
.
getTypeNames
()[
0
];
FeatureSource
<
SimpleFeatureType
,
SimpleFeature
>
source
=
dataStore
.
getFeatureSource
(
typeName
);
FeatureCollection
<
SimpleFeatureType
,
SimpleFeature
>
collection
=
source
.
getFeatures
();
try
(
FeatureIterator
<
SimpleFeature
>
features
=
collection
.
features
())
{
while
(
features
.
hasNext
())
{
SimpleFeature
feature
=
features
.
next
();
Tree
tree
=
new
Tree
();
Point
p
=
(
Point
)
feature
.
getAttribute
(
"the_geom"
);
tree
.
setPoint
(
p
);
String
type
=
feature
.
getAttribute
(
"Bezeichnun"
).
toString
();
tree
.
setType
(
type
);
Object
treeHeightObject
=
feature
.
getAttribute
(
"Baumhöhe"
);
if
(
treeHeightObject
==
null
)
{
continue
;
}
int
treeHeight
=
Integer
.
parseInt
(
treeHeightObject
.
toString
());
double
crownHeight
=
CROWN_PERCENTAGE
*
treeHeight
;
double
trunkHeight
=
TRUNK_PERCENTAGE
*
treeHeight
;
tree
.
setCrownHeight
(
crownHeight
);
tree
.
setTrunkHeight
(
trunkHeight
);
Object
crownWidth
=
feature
.
getAttribute
(
"Kronenbrei"
);
if
(
crownWidth
==
null
)
{
continue
;
}
tree
.
setCrownRadius
(
Float
.
parseFloat
(
crownWidth
.
toString
())
/
2
);
Object
trunkCirc
=
feature
.
getAttribute
(
"Stammumfan"
);
if
(
trunkCirc
==
null
)
{
continue
;
}
tree
.
setTrunkRadius
(
Integer
.
parseInt
(
trunkCirc
.
toString
())
/
(
2
*
Math
.
PI
)
/
100
);
result
.
getTrees
().
add
(
tree
);
}
}
return
result
;
}
public
List
<
Tree
>
getTrees
()
{
public
List
<
Tree
>
getTrees
()
{
if
(
trees
==
null
)
{
if
(
trees
==
null
)
{
trees
=
new
ArrayList
<>();
trees
=
new
ArrayList
<>();
...
...
This diff is collapsed.
Click to expand it.
enrich-citygml-with-greenarea/src/main/java/de/hft/stuttgart/citygml/green/osm/TreeUtils.java
0 → 100644
+
83
-
0
View file @
3e042784
package
de.hft.stuttgart.citygml.green.osm
;
import
java.io.IOException
;
import
java.nio.file.Paths
;
import
java.util.Iterator
;
import
java.util.UUID
;
import
org.citygml4j.core.model.core.AbstractCityObjectProperty
;
import
org.citygml4j.core.model.core.CityModel
;
import
org.citygml4j.core.model.vegetation.SolitaryVegetationObject
;
import
org.locationtech.jts.geom.Coordinate
;
import
org.xmlobjects.gml.model.basictypes.Code
;
import
org.xmlobjects.gml.model.geometry.aggregates.MultiSurface
;
import
org.xmlobjects.gml.model.geometry.aggregates.MultiSurfaceProperty
;
public
class
TreeUtils
{
public
static
void
insertTrees
(
CityModel
cityModel
,
OsmData
osmData
)
throws
IOException
{
TreeKatasterData
katasterData
=
TreeKatasterData
.
parseTreeKatasterData
(
Paths
.
get
(
"data"
,
"Baum.shp"
));
generateTreesFromKataster
(
cityModel
,
katasterData
);
// All kataster trees are taken, osm trees are removed
filterDuplicateTreesFromOSM
(
osmData
,
katasterData
);
generateTreesFromOSM
(
cityModel
,
osmData
);
}
private
static
void
filterDuplicateTreesFromOSM
(
OsmData
osmData
,
TreeKatasterData
katasterData
)
{
for
(
Iterator
<
TreePoint
>
iterator
=
osmData
.
getTreePoints
().
iterator
();
iterator
.
hasNext
();)
{
TreePoint
tp
=
iterator
.
next
();
// if another tree from kataster is within 3m ignore it
for
(
Tree
tree
:
katasterData
.
getTrees
())
{
if
(
tp
.
getPoint
().
distance
(
tree
.
getPoint
())
<
3
)
{
iterator
.
remove
();
}
}
}
}
private
static
void
generateTreesFromOSM
(
CityModel
cityModel
,
OsmData
osmData
)
{
for
(
TreePoint
tp
:
osmData
.
getTreePoints
())
{
// standard tree
double
trunkRadius
=
0.89
/
(
2
*
Math
.
PI
);
double
trunkHeight
=
TreeKatasterData
.
TRUNK_PERCENTAGE
*
11.46
;
double
crownHeight
=
TreeKatasterData
.
CROWN_PERCENTAGE
*
11.46
;
double
crownRadius
=
8
/
2
d
;
Coordinate
coordinate
=
tp
.
getPoint
().
getCoordinate
();
if
(
Double
.
isNaN
(
coordinate
.
z
))
{
coordinate
.
z
=
0
;
}
MultiSurface
generatedTree
=
TreeGenerator
.
generateTree
(
coordinate
,
trunkRadius
,
trunkHeight
,
crownRadius
,
crownRadius
,
crownHeight
);
SolitaryVegetationObject
cover
=
new
SolitaryVegetationObject
();
cover
.
setSpecies
(
new
Code
(
"Acer campestre"
));
cover
.
setId
(
UUID
.
randomUUID
().
toString
());
cover
.
setLod2MultiSurface
(
new
MultiSurfaceProperty
(
generatedTree
));
cityModel
.
getCityObjectMembers
().
add
(
new
AbstractCityObjectProperty
(
cover
));
}
}
private
static
void
generateTreesFromKataster
(
CityModel
cityModel
,
TreeKatasterData
katasterData
)
{
for
(
Tree
tree
:
katasterData
.
getTrees
())
{
double
trunkRadius
=
tree
.
getTrunkRadius
();
double
trunkHeight
=
tree
.
getTrunkHeight
();
double
crownHeight
=
tree
.
getCrownHeight
();
double
crownRadius
=
tree
.
getCrownRadius
();
Coordinate
coordinate
=
tree
.
getPoint
().
getCoordinate
();
if
(
Double
.
isNaN
(
coordinate
.
z
))
{
coordinate
.
z
=
0
;
}
MultiSurface
generatedTree
=
TreeGenerator
.
generateTree
(
coordinate
,
trunkRadius
,
trunkHeight
,
crownRadius
,
crownRadius
,
crownHeight
);
SolitaryVegetationObject
cover
=
new
SolitaryVegetationObject
();
cover
.
setSpecies
(
new
Code
(
tree
.
getType
()));
cover
.
setId
(
UUID
.
randomUUID
().
toString
());
cover
.
setLod2MultiSurface
(
new
MultiSurfaceProperty
(
generatedTree
));
cityModel
.
getCityObjectMembers
().
add
(
new
AbstractCityObjectProperty
(
cover
));
}
}
}
This diff is collapsed.
Click to expand it.
enrich-citygml-with-greenarea/src/main/java/de/hft/stuttgart/citygml/green/osm/jaxb/Bounds.java
0 → 100644
+
35
-
0
View file @
3e042784
package
de.hft.stuttgart.citygml.green.osm.jaxb
;
import
jakarta.xml.bind.annotation.XmlAttribute
;
public
class
Bounds
{
@XmlAttribute
(
name
=
"minlat"
)
private
double
minLat
;
@XmlAttribute
(
name
=
"minlon"
)
private
double
minLon
;
@XmlAttribute
(
name
=
"maxlat"
)
private
double
maxLat
;
@XmlAttribute
(
name
=
"maxlon"
)
private
double
maxLon
;
public
double
getMaxLat
()
{
return
maxLat
;
}
public
double
getMaxLon
()
{
return
maxLon
;
}
public
double
getMinLat
()
{
return
minLat
;
}
public
double
getMinLon
()
{
return
minLon
;
}
}
This diff is collapsed.
Click to expand it.
enrich-citygml-with-greenarea/src/main/java/de/hft/stuttgart/citygml/green/osm/jaxb/Meta.java
0 → 100644
+
14
-
0
View file @
3e042784
package
de.hft.stuttgart.citygml.green.osm.jaxb
;
import
jakarta.xml.bind.annotation.XmlAttribute
;
public
class
Meta
{
@XmlAttribute
(
name
=
"osm_base"
)
private
String
osmBase
;
public
String
getOsmBase
()
{
return
osmBase
;
}
}
This diff is collapsed.
Click to expand it.
enrich-citygml-with-greenarea/src/main/java/de/hft/stuttgart/citygml/green/osm/jaxb/OSM.java
0 → 100644
+
79
-
0
View file @
3e042784
package
de.hft.stuttgart.citygml.green.osm.jaxb
;
import
java.util.ArrayList
;
import
java.util.List
;
import
jakarta.xml.bind.annotation.XmlAttribute
;
import
jakarta.xml.bind.annotation.XmlElement
;
import
jakarta.xml.bind.annotation.XmlElements
;
import
jakarta.xml.bind.annotation.XmlRootElement
;
@XmlRootElement
(
name
=
"osm"
)
public
class
OSM
{
@XmlAttribute
private
String
version
;
@XmlAttribute
private
String
generator
;
@XmlElement
private
String
note
;
@XmlElement
private
Meta
meta
;
@XmlElement
private
Bounds
bounds
;
@XmlElements
(
value
=
{
@XmlElement
(
name
=
"node"
,
type
=
OsmNode
.
class
)
})
private
List
<
OsmNode
>
nodes
;
@XmlElements
(
value
=
{
@XmlElement
(
name
=
"way"
,
type
=
OsmWay
.
class
)
})
private
List
<
OsmWay
>
ways
;
@XmlElements
(
value
=
{
@XmlElement
(
name
=
"relation"
,
type
=
OsmRelation
.
class
)
})
private
List
<
OsmRelation
>
relations
;
public
List
<
OsmRelation
>
getRelations
()
{
if
(
relations
==
null
)
{
relations
=
new
ArrayList
<>();
}
return
relations
;
}
public
List
<
OsmWay
>
getWays
()
{
if
(
ways
==
null
)
{
ways
=
new
ArrayList
<>();
}
return
ways
;
}
public
List
<
OsmNode
>
getNodes
()
{
if
(
nodes
==
null
)
{
nodes
=
new
ArrayList
<>();
}
return
nodes
;
}
public
Bounds
getBounds
()
{
return
bounds
;
}
public
String
getVersion
()
{
return
version
;
}
public
String
getGenerator
()
{
return
generator
;
}
public
String
getNote
()
{
return
note
;
}
public
Meta
getMeta
()
{
return
meta
;
}
}
This diff is collapsed.
Click to expand it.
enrich-citygml-with-greenarea/src/main/java/de/hft/stuttgart/citygml/green/osm/jaxb/OsmMember.java
0 → 100644
+
43
-
0
View file @
3e042784
package
de.hft.stuttgart.citygml.green.osm.jaxb
;
import
java.util.ArrayList
;
import
java.util.List
;
import
jakarta.xml.bind.annotation.XmlAttribute
;
import
jakarta.xml.bind.annotation.XmlElement
;
import
jakarta.xml.bind.annotation.XmlElements
;
public
class
OsmMember
{
@XmlAttribute
private
String
type
;
@XmlAttribute
private
String
ref
;
@XmlAttribute
private
String
role
;
@XmlElements
(
value
=
{
@XmlElement
(
name
=
"nd"
,
type
=
WayNode
.
class
)
})
private
List
<
WayNode
>
nodes
;
public
List
<
WayNode
>
getNodes
()
{
if
(
nodes
==
null
)
{
nodes
=
new
ArrayList
<>();
}
return
nodes
;
}
public
String
getRef
()
{
return
ref
;
}
public
String
getRole
()
{
return
role
;
}
public
String
getType
()
{
return
type
;
}
}
This diff is collapsed.
Click to expand it.
enrich-citygml-with-greenarea/src/main/java/de/hft/stuttgart/citygml/green/osm/jaxb/OsmNode.java
0 → 100644
+
44
-
0
View file @
3e042784
package
de.hft.stuttgart.citygml.green.osm.jaxb
;
import
java.util.ArrayList
;
import
java.util.List
;
import
jakarta.xml.bind.annotation.XmlAttribute
;
import
jakarta.xml.bind.annotation.XmlElement
;
import
jakarta.xml.bind.annotation.XmlElements
;
public
class
OsmNode
{
@XmlAttribute
private
String
id
;
@XmlAttribute
private
double
lat
;
@XmlAttribute
private
double
lon
;
@XmlElements
(
value
=
{
@XmlElement
(
name
=
"tag"
,
type
=
OsmTag
.
class
)
})
private
List
<
OsmTag
>
tags
;
public
String
getId
()
{
return
id
;
}
public
double
getLat
()
{
return
lat
;
}
public
double
getLon
()
{
return
lon
;
}
public
List
<
OsmTag
>
getTags
()
{
if
(
tags
==
null
)
{
tags
=
new
ArrayList
<>();
}
return
tags
;
}
}
This diff is collapsed.
Click to expand it.
enrich-citygml-with-greenarea/src/main/java/de/hft/stuttgart/citygml/green/osm/jaxb/OsmRelation.java
0 → 100644
+
48
-
0
View file @
3e042784
package
de.hft.stuttgart.citygml.green.osm.jaxb
;
import
java.util.ArrayList
;
import
java.util.List
;
import
jakarta.xml.bind.annotation.XmlAttribute
;
import
jakarta.xml.bind.annotation.XmlElement
;
import
jakarta.xml.bind.annotation.XmlElements
;
public
class
OsmRelation
{
@XmlAttribute
private
String
id
;
@XmlElement
private
Bounds
bounds
;
@XmlElements
(
value
=
{
@XmlElement
(
name
=
"member"
,
type
=
OsmMember
.
class
)
})
private
List
<
OsmMember
>
members
;
@XmlElements
(
value
=
{
@XmlElement
(
name
=
"tag"
,
type
=
OsmTag
.
class
)
})
private
List
<
OsmTag
>
tags
;
public
List
<
OsmTag
>
getTags
()
{
if
(
tags
==
null
)
{
tags
=
new
ArrayList
<>();
}
return
tags
;
}
public
List
<
OsmMember
>
getMembers
()
{
if
(
members
==
null
)
{
members
=
new
ArrayList
<>();
}
return
members
;
}
public
Bounds
getBounds
()
{
return
bounds
;
}
public
String
getId
()
{
return
id
;
}
}
This diff is collapsed.
Click to expand it.
enrich-citygml-with-greenarea/src/main/java/de/hft/stuttgart/citygml/green/osm/jaxb/OsmTag.java
0 → 100644
+
21
-
0
View file @
3e042784
package
de.hft.stuttgart.citygml.green.osm.jaxb
;
import
jakarta.xml.bind.annotation.XmlAttribute
;
public
class
OsmTag
{
@XmlAttribute
(
name
=
"k"
)
private
String
key
;
@XmlAttribute
(
name
=
"v"
)
private
String
value
;
public
String
getKey
()
{
return
key
;
}
public
String
getValue
()
{
return
value
;
}
}
This diff is collapsed.
Click to expand it.
enrich-citygml-with-greenarea/src/main/java/de/hft/stuttgart/citygml/green/osm/jaxb/OsmWay.java
0 → 100644
+
47
-
0
View file @
3e042784
package
de.hft.stuttgart.citygml.green.osm.jaxb
;
import
java.util.ArrayList
;
import
java.util.List
;
import
jakarta.xml.bind.annotation.XmlAttribute
;
import
jakarta.xml.bind.annotation.XmlElement
;
import
jakarta.xml.bind.annotation.XmlElements
;
public
class
OsmWay
{
@XmlAttribute
private
String
id
;
@XmlElement
private
Bounds
bounds
;
@XmlElements
(
value
=
{
@XmlElement
(
name
=
"nd"
,
type
=
WayNode
.
class
)
})
private
List
<
WayNode
>
nodes
;
@XmlElements
(
value
=
{
@XmlElement
(
name
=
"tag"
,
type
=
OsmTag
.
class
)
})
private
List
<
OsmTag
>
tags
;
public
List
<
OsmTag
>
getTags
()
{
if
(
tags
==
null
)
{
tags
=
new
ArrayList
<>();
}
return
tags
;
}
public
String
getId
()
{
return
id
;
}
public
Bounds
getBounds
()
{
return
bounds
;
}
public
List
<
WayNode
>
getNodes
()
{
if
(
nodes
==
null
)
{
nodes
=
new
ArrayList
<>();
}
return
nodes
;
}
}
This diff is collapsed.
Click to expand it.
enrich-citygml-with-greenarea/src/main/java/de/hft/stuttgart/citygml/green/osm/jaxb/WayNode.java
0 → 100644
+
28
-
0
View file @
3e042784
package
de.hft.stuttgart.citygml.green.osm.jaxb
;
import
jakarta.xml.bind.annotation.XmlAttribute
;
public
class
WayNode
{
@XmlAttribute
private
String
ref
;
@XmlAttribute
private
double
lat
;
@XmlAttribute
private
double
lon
;
public
double
getLat
()
{
return
lat
;
}
public
double
getLon
()
{
return
lon
;
}
public
String
getRef
()
{
return
ref
;
}
}
This diff is collapsed.
Click to expand it.
enrich-citygml-with-greenarea/src/test/java/de/hft/stuttgart/citygml/green/alkis/AlkisGreenEnricherTest.java
0 → 100644
+
21
-
0
View file @
3e042784
package
de.hft.stuttgart.citygml.green.alkis
;
import
java.io.IOException
;
import
org.citygml4j.xml.CityGMLContextException
;
import
org.citygml4j.xml.reader.CityGMLReadException
;
import
org.citygml4j.xml.writer.CityGMLWriteException
;
import
org.junit.jupiter.api.Test
;
import
jakarta.xml.bind.JAXBException
;
class
AlkisGreenEnricherTest
{
@Test
void
testAlkisGreen
()
throws
IOException
,
CityGMLContextException
,
CityGMLReadException
,
JAXBException
,
CityGMLWriteException
{
String
[]
args
=
new
String
[]
{
"data/Grombühl_v3.gml"
};
AlkisGreenEnricher
.
main
(
args
);
}
}
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