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
74a743ad
Commit
74a743ad
authored
Jul 20, 2026
by
Eric Duminil
Browse files
Bugfix: envelope was wrong for negative coordinates
parent
873e6491
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/main/java/eu/simstadt/regionchooser/fast_xml_parser/CityObjectMember.java
View file @
74a743ad
...
...
@@ -59,9 +59,9 @@ private void extractCoordinates()
double
tempX
;
double
tempY
;
double
tempXMin
=
Double
.
MAX_VALUE
;
double
tempXMax
=
Double
.
M
IN
_VALUE
;
double
tempXMax
=
-
Double
.
M
AX
_VALUE
;
double
tempYMin
=
Double
.
MAX_VALUE
;
double
tempYMax
=
Double
.
M
IN
_VALUE
;
double
tempYMax
=
-
Double
.
M
AX
_VALUE
;
AutoPilot
coordinatesFinder
=
new
AutoPilot
(
navigator
);
...
...
src/test/java/eu/simstadt/regionchooser/fast_xml_parser/ConvexHullCalculatorTests.java
View file @
74a743ad
...
...
@@ -69,6 +69,24 @@ public void testAreaFromOneSmallRegion() throws IOException, XPathParseException
assertEquals
(
47.5
,
hectares
,
1
);
}
@Test
public
void
testExtractConvexHullFromKualaLumpurBuilding
()
throws
IOException
,
XPathParseException
{
// Regression test: local x coordinates are negative in this file (EPSG:3376, no false easting).
// CityObjectMember used to initialize xMax/yMax with Double.MIN_VALUE (the smallest POSITIVE double,
// not the most negative one), so xMax was never updated and stayed close to 0, stretching the hull
// thousands of kilometers away from the actual building.
Path
citygmlPath
=
repository
.
resolve
(
"KualaLumpur.proj/kuala_lumpur_simple_building.gml"
);
Geometry
hull
=
ConvexHullCalculator
.
calculateFromCityGML
(
citygmlPath
);
assertEquals
(
4
+
1
,
hull
.
getCoordinates
().
length
);
// Convex hull of a building should be a closed rectangle
org
.
locationtech
.
jts
.
geom
.
Envelope
envelope
=
hull
.
getEnvelopeInternal
();
assertTrue
(
envelope
.
getWidth
()
<
0.01
,
"Hull shouldn't stretch far away from the building: "
+
hull
);
assertTrue
(
envelope
.
getHeight
()
<
0.01
,
"Hull shouldn't stretch far away from the building: "
+
hull
);
Point
somewhereInsideTheBuilding
=
gf
.
createPoint
(
new
Coordinate
(
101.71204
,
3.15812
));
// WGS84
assertTrue
(
hull
.
contains
(
somewhereInsideTheBuilding
),
"Hull should contain the building, not Borneo"
);
}
@Test
public
void
testExtractConvexHullFromStoeckachNoBuildingPart
()
throws
IOException
,
XPathParseException
{
Path
citygmlPath
=
repository
.
resolve
(
"Stuttgart.proj/Stöckach_überarbeitete GML-NoBuildingPart.gml"
);
...
...
src/test/resources/testdata/KualaLumpur.proj/kuala_lumpur_simple_building.gml
0 → 100755
View file @
74a743ad
<?xml version="1.0" encoding="UTF-8" ?>
<core:CityModel
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://www.opengis.net/citygml/2.0./CityGML_2.0/CityGML.xsd"
xmlns=
"http://www.opengis.net/citygml/2.0"
xmlns:gen=
"http://www.opengis.net/citygml/generics/2.0"
xmlns:xlink=
"http://www.w3.org/1999/xlink"
xmlns:gml=
"http://www.opengis.net/gml"
xmlns:core=
"http://www.opengis.net/citygml/2.0"
xmlns:bldg=
"http://www.opengis.net/citygml/building/2.0"
>
<!-- Source: Empty, dummy CityGML -->
<!-- License: dl-de/by-2-0, HfT Stuttgart -->
<gml:boundedBy>
<gml:Envelope
srsName=
"EPSG:3376"
srsDimension=
"3"
>
<gml:lowerCorner>
-889613.339358 349764.475204 80.0
</gml:lowerCorner>
<gml:upperCorner>
-889603.339358 349774.475204 86.0
</gml:upperCorner>
</gml:Envelope>
</gml:boundedBy>
<core:cityObjectMember>
<bldg:Building
gml:id=
"UUID_Building_561_894749_29473"
>
<bldg:lod1Solid>
<gml:Solid>
<gml:exterior>
<gml:CompositeSurface>
<gml:surfaceMember>
<gml:Polygon
gml:id=
"PolyGMLID_123145_413088_65227_6493"
>
<gml:exterior>
<gml:LinearRing
gml:id=
"PolyGMLID_123145_413088_65227_6493_0"
>
<gml:posList
srsDimension=
"3"
>
-889603.339358 349764.475204 80.0 -889613.339358 349764.475204 80.0 -889613.339358 349774.475204 80.0 -889603.339358 349774.475204 80.0 -889603.339358 349764.475204 80.0
</gml:posList>
</gml:LinearRing>
</gml:exterior>
</gml:Polygon>
</gml:surfaceMember>
<gml:surfaceMember>
<gml:Polygon
gml:id=
"PolyGMLID_15801_95160_47227_2603"
>
<gml:exterior>
<gml:LinearRing
gml:id=
"PolyGMLID_15801_95160_47227_2603_0"
>
<gml:posList
srsDimension=
"3"
>
-889613.339358 349764.475204 80.0 -889603.339358 349764.475204 80.0 -889603.339358 349764.475204 86.0 -889613.339358 349764.475204 86.0 -889613.339358 349764.475204 80.0
</gml:posList>
</gml:LinearRing>
</gml:exterior>
</gml:Polygon>
</gml:surfaceMember>
<gml:surfaceMember>
<gml:Polygon
gml:id=
"PolyGMLID_128835_364700_34542_6511"
>
<gml:exterior>
<gml:LinearRing
gml:id=
"PolyGMLID_128835_364700_34542_6511_0"
>
<gml:posList
srsDimension=
"3"
>
-889613.339358 349774.475204 80.0 -889613.339358 349764.475204 80.0 -889613.339358 349764.475204 86.0 -889613.339358 349774.475204 86.0 -889613.339358 349774.475204 80.0
</gml:posList>
</gml:LinearRing>
</gml:exterior>
</gml:Polygon>
</gml:surfaceMember>
<gml:surfaceMember>
<gml:Polygon
gml:id=
"PolyGMLID_46588_274587_144056_6934"
>
<gml:exterior>
<gml:LinearRing
gml:id=
"PolyGMLID_46588_274587_144056_6934_0"
>
<gml:posList
srsDimension=
"3"
>
-889603.339358 349774.475204 80.0 -889613.339358 349774.475204 80.0 -889613.339358 349774.475204 86.0 -889603.339358 349774.475204 86.0 -889603.339358 349774.475204 80.0
</gml:posList>
</gml:LinearRing>
</gml:exterior>
</gml:Polygon>
</gml:surfaceMember>
<gml:surfaceMember>
<gml:Polygon
gml:id=
"PolyGMLID_115974_105373_166962_4355"
>
<gml:exterior>
<gml:LinearRing
gml:id=
"PolyGMLID_115974_105373_166962_4355_0"
>
<gml:posList
srsDimension=
"3"
>
-889603.339358 349764.475204 80.0 -889603.339358 349774.475204 80.0 -889603.339358 349774.475204 86.0 -889603.339358 349764.475204 86.0 -889603.339358 349764.475204 80.0
</gml:posList>
</gml:LinearRing>
</gml:exterior>
</gml:Polygon>
</gml:surfaceMember>
<gml:surfaceMember>
<gml:Polygon
gml:id=
"PolyGMLID_154385_655539_323643_7641"
>
<gml:exterior>
<gml:LinearRing
gml:id=
"PolyGMLID_154385_655539_323643_7641_0"
>
<gml:posList
srsDimension=
"3"
>
-889611.339358 349766.475204 83.0 -889605.339358 349766.475204 83.0 -889605.339358 349772.475204 83.0 -889611.339358 349772.475204 83.0 -889611.339358 349766.475204 83.0
</gml:posList>
</gml:LinearRing>
</gml:exterior>
</gml:Polygon>
</gml:surfaceMember>
<gml:surfaceMember>
<gml:Polygon
gml:id=
"PolyGMLID_86552_857417_249495_7137"
>
<gml:exterior>
<gml:LinearRing
gml:id=
"PolyGMLID_86552_857417_249495_7137_0"
>
<gml:posList
srsDimension=
"3"
>
-889611.339358 349766.475204 86.0 -889605.339358 349766.475204 86.0 -889605.339358 349766.475204 83.0 -889611.339358 349766.475204 83.0 -889611.339358 349766.475204 86.0
</gml:posList>
</gml:LinearRing>
</gml:exterior>
</gml:Polygon>
</gml:surfaceMember>
<gml:surfaceMember>
<gml:Polygon
gml:id=
"PolyGMLID_54514_515503_271074_9000"
>
<gml:exterior>
<gml:LinearRing
gml:id=
"PolyGMLID_54514_515503_271074_9000_0"
>
<gml:posList
srsDimension=
"3"
>
-889605.339358 349766.475204 86.0 -889605.339358 349772.475204 86.0 -889605.339358 349772.475204 83.0 -889605.339358 349766.475204 83.0 -889605.339358 349766.475204 86.0
</gml:posList>
</gml:LinearRing>
</gml:exterior>
</gml:Polygon>
</gml:surfaceMember>
<gml:surfaceMember>
<gml:Polygon
gml:id=
"PolyGMLID_136229_348966_81604_8025"
>
<gml:exterior>
<gml:LinearRing
gml:id=
"PolyGMLID_136229_348966_81604_8025_0"
>
<gml:posList
srsDimension=
"3"
>
-889605.339358 349772.475204 86.0 -889611.339358 349772.475204 86.0 -889611.339358 349772.475204 83.0 -889605.339358 349772.475204 83.0 -889605.339358 349772.475204 86.0
</gml:posList>
</gml:LinearRing>
</gml:exterior>
</gml:Polygon>
</gml:surfaceMember>
<gml:surfaceMember>
<gml:Polygon
gml:id=
"PolyGMLID_43290_873238_121022_9644"
>
<gml:exterior>
<gml:LinearRing
gml:id=
"PolyGMLID_43290_873238_121022_9644_0"
>
<gml:posList
srsDimension=
"3"
>
-889611.339358 349772.475204 86.0 -889611.339358 349766.475204 86.0 -889611.339358 349766.475204 83.0 -889611.339358 349772.475204 83.0 -889611.339358 349772.475204 86.0
</gml:posList>
</gml:LinearRing>
</gml:exterior>
</gml:Polygon>
</gml:surfaceMember>
<gml:surfaceMember>
<gml:Polygon
gml:id=
"PolyGMLID_140933_165585_46718_6797"
>
<gml:exterior>
<gml:LinearRing
gml:id=
"PolyGMLID_140933_165585_46718_6797_0"
>
<gml:posList
srsDimension=
"3"
>
-889613.339358 349764.475204 86.0 -889603.339358 349764.475204 86.0 -889603.339358 349774.475204 86.0 -889613.339358 349774.475204 86.0 -889613.339358 349764.475204 86.0
</gml:posList>
</gml:LinearRing>
</gml:exterior>
<gml:interior>
<gml:LinearRing
gml:id=
"PolyGMLID_140933_165585_46718_6797_0_0"
>
<gml:posList
srsDimension=
"3"
>
-889605.339358 349766.475204 86.0 -889611.339358 349766.475204 86.0 -889611.339358 349772.475204 86.0 -889605.339358 349772.475204 86.0 -889605.339358 349766.475204 86.0
</gml:posList>
</gml:LinearRing>
</gml:interior>
</gml:Polygon>
</gml:surfaceMember>
</gml:CompositeSurface>
</gml:exterior>
</gml:Solid>
</bldg:lod1Solid>
</bldg:Building>
</core:cityObjectMember>
</core:CityModel>
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