Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Eric Duminil
RegionChooser
Commits
267d07c7
Commit
267d07c7
authored
Nov 28, 2023
by
Eric Duminil
Browse files
Testing that trees are found too.
parent
f173e626
Changes
2
Show whitespace changes
Inline
Side-by-side
src/main/java/eu/simstadt/regionchooser/RegionExtractor.java
View file @
267d07c7
...
@@ -62,21 +62,21 @@ static int selectRegionDirectlyFromCityGML(String wktPolygon, String srsName, Wr
...
@@ -62,21 +62,21 @@ static int selectRegionDirectlyFromCityGML(String wktPolygon, String srsName, Wr
LOGGER
.
info
(
"Parsing "
+
citygmlPath
);
LOGGER
.
info
(
"Parsing "
+
citygmlPath
);
//TODO: Allow citygmlPath for folders too, and iterate over gmls?
//TODO: Allow citygmlPath for folders too, and iterate over gmls?
citygml
=
new
CityGmlIterator
(
citygmlPath
);
citygml
=
new
CityGmlIterator
(
citygmlPath
);
for
(
CityObjectMember
buildingXml
Node
:
citygml
)
{
for
(
CityObjectMember
cityObject
Node
:
citygml
)
{
if
(
cityObjectsCount
==
0
)
{
if
(
cityObjectsCount
==
0
)
{
sb
.
append
(
replaceEnvelopeInHeader
(
citygml
.
getHeader
(),
poly
.
getEnvelopeInternal
(),
srsName
));
sb
.
append
(
replaceEnvelopeInHeader
(
citygml
.
getHeader
(),
poly
.
getEnvelopeInternal
(),
srsName
));
}
}
cityObjectsCount
+=
1
;
cityObjectsCount
+=
1
;
if
(
buildingXml
Node
.
hasCoordinates
())
{
if
(
cityObject
Node
.
hasCoordinates
())
{
Coordinate
coord
=
new
Coordinate
(
buildingXmlNode
.
x
,
buildingXml
Node
.
y
);
Coordinate
coord
=
new
Coordinate
(
cityObjectNode
.
x
,
cityObject
Node
.
y
);
Point
point
=
GEOMETRY_FACTORY
.
createPoint
(
coord
);
Point
point
=
GEOMETRY_FACTORY
.
createPoint
(
coord
);
if
(
point
.
within
(
poly
))
{
if
(
point
.
within
(
poly
))
{
if
(
buildingXml
Node
.
isBuilding
())
{
if
(
cityObject
Node
.
isBuilding
())
{
foundBuildingsCount
++;
foundBuildingsCount
++;
}
else
{
}
else
{
foundVegetationCount
++;
foundVegetationCount
++;
}
}
sb
.
append
(
buildingXml
Node
.
toString
());
sb
.
append
(
cityObject
Node
.
toString
());
}
}
}
}
if
(
cityObjectsCount
%
1000
==
0
)
{
if
(
cityObjectsCount
%
1000
==
0
)
{
...
...
src/test/java/eu/simstadt/regionchooser/fast_xml_parser/CitygmlParserTests.java
View file @
267d07c7
...
@@ -17,19 +17,19 @@
...
@@ -17,19 +17,19 @@
private
void
testNoNanInCoordinates
(
Path
citygmlPath
)
throws
XPathParseException
{
private
void
testNoNanInCoordinates
(
Path
citygmlPath
)
throws
XPathParseException
{
CityGmlIterator
buildingXmlNodes
=
new
CityGmlIterator
(
citygmlPath
);
CityGmlIterator
buildingXmlNodes
=
new
CityGmlIterator
(
citygmlPath
);
for
(
CityObjectMember
buildingXml
Node
:
buildingXmlNodes
)
{
for
(
CityObjectMember
cityObject
Node
:
buildingXmlNodes
)
{
assertTrue
(
buildingXml
Node
.
hasCoordinates
(),
"Buildings should have coordinates"
);
assertTrue
(
cityObject
Node
.
hasCoordinates
(),
"Building
and vegetation
s should have coordinates"
);
assertFalse
(
Double
.
isNaN
(
buildingXml
Node
.
x
),
COORDINATE_SHOULD_BE_A_DOUBLE
);
assertFalse
(
Double
.
isNaN
(
cityObject
Node
.
x
),
COORDINATE_SHOULD_BE_A_DOUBLE
);
assertFalse
(
Double
.
isNaN
(
buildingXml
Node
.
y
),
COORDINATE_SHOULD_BE_A_DOUBLE
);
assertFalse
(
Double
.
isNaN
(
cityObject
Node
.
y
),
COORDINATE_SHOULD_BE_A_DOUBLE
);
assertFalse
(
Double
.
isNaN
(
buildingXml
Node
.
xMax
),
COORDINATE_SHOULD_BE_A_DOUBLE
);
assertFalse
(
Double
.
isNaN
(
cityObject
Node
.
xMax
),
COORDINATE_SHOULD_BE_A_DOUBLE
);
assertFalse
(
Double
.
isNaN
(
buildingXml
Node
.
yMax
),
COORDINATE_SHOULD_BE_A_DOUBLE
);
assertFalse
(
Double
.
isNaN
(
cityObject
Node
.
yMax
),
COORDINATE_SHOULD_BE_A_DOUBLE
);
assertFalse
(
Double
.
isNaN
(
buildingXml
Node
.
xMin
),
COORDINATE_SHOULD_BE_A_DOUBLE
);
assertFalse
(
Double
.
isNaN
(
cityObject
Node
.
xMin
),
COORDINATE_SHOULD_BE_A_DOUBLE
);
assertFalse
(
Double
.
isNaN
(
buildingXml
Node
.
yMin
),
COORDINATE_SHOULD_BE_A_DOUBLE
);
assertFalse
(
Double
.
isNaN
(
cityObject
Node
.
yMin
),
COORDINATE_SHOULD_BE_A_DOUBLE
);
// Some SolitaryVegetationObjects are defined with a single point.
// Some SolitaryVegetationObjects are defined with a single point.
assertTrue
(
buildingXml
Node
.
xMax
>=
buildingXml
Node
.
x
,
COORDINATES_SHOULD_BE_PLAUSIBLE
);
assertTrue
(
cityObject
Node
.
xMax
>=
cityObject
Node
.
x
,
COORDINATES_SHOULD_BE_PLAUSIBLE
);
assertTrue
(
buildingXml
Node
.
yMax
>=
buildingXml
Node
.
y
,
COORDINATES_SHOULD_BE_PLAUSIBLE
);
assertTrue
(
cityObject
Node
.
yMax
>=
cityObject
Node
.
y
,
COORDINATES_SHOULD_BE_PLAUSIBLE
);
assertTrue
(
buildingXml
Node
.
xMin
<=
buildingXml
Node
.
x
,
COORDINATES_SHOULD_BE_PLAUSIBLE
);
assertTrue
(
cityObject
Node
.
xMin
<=
cityObject
Node
.
x
,
COORDINATES_SHOULD_BE_PLAUSIBLE
);
assertTrue
(
buildingXml
Node
.
yMin
<=
buildingXml
Node
.
y
,
COORDINATES_SHOULD_BE_PLAUSIBLE
);
assertTrue
(
cityObject
Node
.
yMin
<=
cityObject
Node
.
y
,
COORDINATES_SHOULD_BE_PLAUSIBLE
);
}
}
}
}
...
@@ -38,6 +38,16 @@ public void testExtractCoordsFromStuttgart() throws XPathParseException {
...
@@ -38,6 +38,16 @@ public void testExtractCoordsFromStuttgart() throws XPathParseException {
Path
repo
=
Paths
.
get
(
REGION_CHOOSER_TESTDATA
,
"Stuttgart.proj"
);
Path
repo
=
Paths
.
get
(
REGION_CHOOSER_TESTDATA
,
"Stuttgart.proj"
);
Path
citygmlPath
=
repo
.
resolve
(
"Stuttgart_LOD0_LOD1_buildings_and_trees.gml"
);
Path
citygmlPath
=
repo
.
resolve
(
"Stuttgart_LOD0_LOD1_buildings_and_trees.gml"
);
testNoNanInCoordinates
(
citygmlPath
);
testNoNanInCoordinates
(
citygmlPath
);
CityGmlIterator
buildingXmlNodes
=
new
CityGmlIterator
(
citygmlPath
);
boolean
foundBuildings
=
false
;
boolean
foundTrees
=
false
;
for
(
CityObjectMember
cityObjectNode
:
buildingXmlNodes
)
{
boolean
isBuilding
=
cityObjectNode
.
isBuilding
();
foundBuildings
|=
isBuilding
;
foundTrees
|=
!
isBuilding
;
}
assertTrue
(
foundBuildings
,
"At least one building should have been found."
);
assertTrue
(
foundTrees
,
"At least one tree should have been found."
);
}
}
@Test
@Test
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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