Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Eric Duminil
RegionChooser
Commits
f173e626
Commit
f173e626
authored
Nov 28, 2023
by
Eric Duminil
Browse files
CityObject: Checking if Building or not
parent
c49391c1
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/main/java/eu/simstadt/regionchooser/RegionExtractor.java
View file @
f173e626
...
...
@@ -53,7 +53,7 @@ static int selectRegionDirectlyFromCityGML(String wktPolygon, String srsName, Wr
int
cityObjectsCount
=
0
;
int
foundBuildingsCount
=
0
;
//
int foundVegetationCount = 0;
int
foundVegetationCount
=
0
;
Geometry
poly
=
WKT_READER
.
read
(
wktPolygon
);
CityGmlIterator
citygml
=
null
;
...
...
@@ -71,7 +71,11 @@ static int selectRegionDirectlyFromCityGML(String wktPolygon, String srsName, Wr
Coordinate
coord
=
new
Coordinate
(
buildingXmlNode
.
x
,
buildingXmlNode
.
y
);
Point
point
=
GEOMETRY_FACTORY
.
createPoint
(
coord
);
if
(
point
.
within
(
poly
))
{
foundBuildingsCount
++;
if
(
buildingXmlNode
.
isBuilding
())
{
foundBuildingsCount
++;
}
else
{
foundVegetationCount
++;
}
sb
.
append
(
buildingXmlNode
.
toString
());
}
}
...
...
@@ -90,6 +94,9 @@ static int selectRegionDirectlyFromCityGML(String wktPolygon, String srsName, Wr
}
LOGGER
.
info
(
"Buildings found in selected region : "
+
foundBuildingsCount
);
if
(
foundVegetationCount
>
0
)
{
LOGGER
.
info
(
"Vegetation found in selected region : "
+
foundVegetationCount
);
}
//NOTE: This could be a problem if header starts with <core:CityModel> and footer ends with </CityModel>
sb
.
append
(
citygml
.
getFooter
());
return
foundBuildingsCount
;
...
...
src/main/java/eu/simstadt/regionchooser/fast_xml_parser/CityObjectMember.java
View file @
f173e626
...
...
@@ -14,14 +14,11 @@
public
class
CityObjectMember
{
//TODO: Check it's the only correct possibility.
//FIXME: BuildingPart too!
static
final
String
XPATH_PATTERN
=
"/CityModel/cityObjectMember[Building or SolitaryVegetationObject or PlantCover]"
;
private
int
nodeOffset
;
private
int
nodeLength
;
private
VTDNav
navigator
;
private
AutoPilot
coordinatesFinder
;
public
Double
x
;
public
Double
xMin
;
public
Double
xMax
;
...
...
@@ -33,18 +30,28 @@
public
CityObjectMember
(
VTDNav
navigator
,
int
nodeOffset
,
int
nodeLength
)
throws
XPathParseException
,
XPathEvalException
,
NavException
{
this
.
navigator
=
navigator
;
this
.
coordinatesFinder
=
new
AutoPilot
(
navigator
);
this
.
nodeLength
=
nodeLength
;
this
.
nodeOffset
=
nodeOffset
;
extractCoordinates
();
//TODO: Get Node ID too, in order to avoid duplicates?
//TODO: Now that "Building" can be Vegetation too, define a method to check class?
}
public
boolean
hasCoordinates
()
{
return
coordinatesCount
>
0
;
}
public
boolean
isBuilding
()
{
try
{
this
.
navigator
.
push
();
AutoPilot
checkBuilding
=
new
AutoPilot
(
this
.
navigator
);
checkBuilding
.
selectXPath
(
"./Building"
);
return
checkBuilding
.
evalXPath
()
!=
-
1
;
}
catch
(
XPathEvalException
|
NavException
|
XPathParseException
ex
)
{
return
false
;
}
finally
{
this
.
navigator
.
pop
();
}
}
private
void
extractCoordinates
()
throws
XPathParseException
,
XPathEvalException
,
NavException
{
double
xTotal
=
0
;
...
...
@@ -56,6 +63,9 @@ private void extractCoordinates()
double
tempYMin
=
Double
.
MAX_VALUE
;
double
tempYMax
=
Double
.
MIN_VALUE
;
AutoPilot
coordinatesFinder
=
new
AutoPilot
(
navigator
);
coordinatesFinder
.
selectXPath
(
".//posList|.//pos"
);
while
(
coordinatesFinder
.
evalXPath
()
!=
-
1
)
{
long
offsetAndLength
=
navigator
.
getContentFragment
();
...
...
src/test/java/eu/simstadt/regionchooser/RegionExtractorTests.java
View file @
f173e626
...
...
@@ -173,7 +173,6 @@ void testExtractBuildingsAndRemoveOld() throws Throwable {
StringWriter
gmlWriter
=
new
StringWriter
();
int
count
=
RegionExtractor
.
selectRegionDirectlyFromCityGML
(
wktPolygon
,
"EPSG:25832"
,
gmlWriter
,
citygmlPath
);
String
oneAachenBuilding
=
gmlWriter
.
toString
();
System
.
out
.
println
(
oneAachenBuilding
);
assertEquals
(
1
,
count
);
assertEquals
(
1
,
countRegexMatches
(
oneAachenBuilding
,
CITY_OBJECT_MEMBER_REGEX
));
assertTrue
(
oneAachenBuilding
.
contains
(
"DENW39AL10003jfi"
));
...
...
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