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
eef39ad1
Commit
eef39ad1
authored
Dec 19, 2023
by
Eric Duminil
Browse files
Checking whole bounding box for non-Buildings
parent
84404739
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/main/java/eu/simstadt/regionchooser/RegionExtractor.java
View file @
eef39ad1
...
...
@@ -11,6 +11,7 @@
import
org.locationtech.jts.geom.Geometry
;
import
org.locationtech.jts.geom.GeometryFactory
;
import
org.locationtech.jts.geom.Point
;
import
org.locationtech.jts.geom.Polygon
;
import
org.locationtech.jts.io.ParseException
;
import
org.locationtech.jts.io.WKTReader
;
import
com.ximpleware.NavException
;
...
...
@@ -54,7 +55,7 @@ static int selectRegionDirectlyFromCityGML(String wktPolygon, String srsName, Wr
int
cityObjectsCount
=
0
;
int
foundBuildingsCount
=
0
;
int
otherObjectsCount
=
0
;
Geometry
p
olygon
=
WKT_READER
.
read
(
wktPolygon
);
Geometry
selectionP
olygon
=
WKT_READER
.
read
(
wktPolygon
);
CityGmlIterator
citygml
=
null
;
for
(
int
i
=
0
;
i
<
citygmlPaths
.
length
;
i
++)
{
...
...
@@ -64,13 +65,13 @@ static int selectRegionDirectlyFromCityGML(String wktPolygon, String srsName, Wr
citygml
=
new
CityGmlIterator
(
citygmlPath
);
for
(
CityObjectMember
cityObjectNode
:
citygml
)
{
if
(
cityObjectsCount
==
0
)
{
sb
.
append
(
replaceEnvelopeInHeader
(
citygml
.
getHeader
(),
p
olygon
.
getEnvelopeInternal
(),
srsName
));
sb
.
append
(
replaceEnvelopeInHeader
(
citygml
.
getHeader
(),
selectionP
olygon
.
getEnvelopeInternal
(),
srsName
));
}
cityObjectsCount
+=
1
;
if
(
cityObjectNode
.
hasCoordinates
())
{
boolean
isBuilding
=
cityObjectNode
.
isBuilding
();
boolean
shouldBeIncluded
=
isBuilding
?
isBuildingCenterInPolygon
(
cityObjectNode
,
p
olygon
)
:
isBoundingBoxTouching
(
cityObjectNode
,
p
olygon
);
boolean
shouldBeIncluded
=
isBuilding
?
isBuildingCenterInPolygon
(
cityObjectNode
,
selectionP
olygon
)
:
isBoundingBoxTouching
(
cityObjectNode
,
selectionP
olygon
);
if
(
shouldBeIncluded
)
{
if
(
isBuilding
)
{
foundBuildingsCount
++;
...
...
@@ -108,10 +109,15 @@ static int selectRegionDirectlyFromCityGML(String wktPolygon, String srsName, Wr
* which might be desirable for roads or landuse.
*/
private
static
boolean
isBoundingBoxTouching
(
CityObjectMember
cityObjectNode
,
Geometry
polygon
)
{
return
point
(
cityObjectNode
.
xMax
,
cityObjectNode
.
yMax
).
within
(
polygon
)
||
point
(
cityObjectNode
.
xMax
,
cityObjectNode
.
yMin
).
within
(
polygon
)
||
point
(
cityObjectNode
.
xMin
,
cityObjectNode
.
yMin
).
within
(
polygon
)
||
point
(
cityObjectNode
.
xMin
,
cityObjectNode
.
yMax
).
within
(
polygon
);
Coordinate
[]
boundingBoxCoordinates
=
{
new
Coordinate
(
cityObjectNode
.
xMax
,
cityObjectNode
.
yMax
),
new
Coordinate
(
cityObjectNode
.
xMin
,
cityObjectNode
.
yMax
),
new
Coordinate
(
cityObjectNode
.
xMin
,
cityObjectNode
.
yMin
),
new
Coordinate
(
cityObjectNode
.
xMax
,
cityObjectNode
.
yMin
),
new
Coordinate
(
cityObjectNode
.
xMax
,
cityObjectNode
.
yMax
),
};
Polygon
boundingBox
=
GEOMETRY_FACTORY
.
createPolygon
(
boundingBoxCoordinates
);
return
boundingBox
.
intersects
(
polygon
);
}
...
...
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