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
Eric Duminil
RegionChooser
Commits
b8f660a3
Commit
b8f660a3
authored
5 years ago
by
Eric Duminil
Browse files
Options
Download
Email Patches
Plain Diff
Trying to convert to Junit 5
parent
ac674f49
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
pom.xml
+11
-5
pom.xml
src/test/java/eu/simstadt/geo/fast_xml_parser/CitygmlParserTests.java
+19
-19
...a/eu/simstadt/geo/fast_xml_parser/CitygmlParserTests.java
src/test/java/eu/simstadt/geo/fast_xml_parser/ConvexHullCalculatorTests.java
+13
-13
...mstadt/geo/fast_xml_parser/ConvexHullCalculatorTests.java
src/test/java/eu/simstadt/regionchooser/CRSfromCityGMLHeaderTests.java
+12
-7
.../eu/simstadt/regionchooser/CRSfromCityGMLHeaderTests.java
src/test/java/eu/simstadt/regionchooser/RegionExtractorTests.java
+34
-30
.../java/eu/simstadt/regionchooser/RegionExtractorTests.java
src/test/java/eu/simstadt/regionchooser/RegionExtractorWithDifferentInputTests.java
+12
-10
...regionchooser/RegionExtractorWithDifferentInputTests.java
with
101 additions
and
84 deletions
+101
-84
pom.xml
+
11
-
5
View file @
b8f660a3
...
@@ -6,8 +6,12 @@
...
@@ -6,8 +6,12 @@
<artifactId>
RegionChooser
</artifactId>
<artifactId>
RegionChooser
</artifactId>
<version>
0.1.0-SNAPSHOT
</version>
<version>
0.1.0-SNAPSHOT
</version>
<properties>
<properties>
<project.build.sourceEncoding>
UTF-8
</project.build.sourceEncoding>
<project.build.sourceEncoding>
UTF-8
</project.build.sourceEncoding>
<maven.compiler.source>
1.8
</maven.compiler.source>
<maven.compiler.target>
${maven.compiler.source}
</maven.compiler.target>
<junit-jupiter.version>
5.6.0
</junit-jupiter.version>
</properties>
</properties>
<scm>
<scm>
...
@@ -16,13 +20,14 @@
...
@@ -16,13 +20,14 @@
</scm>
</scm>
<dependencies>
<dependencies>
<!-- https://mvnrepository.com/artifact/junit/junit -->
<dependency>
<dependency>
<groupId>
junit
</groupId>
<groupId>
org.
junit
.jupiter
</groupId>
<artifactId>
junit
</artifactId>
<artifactId>
junit
-jupiter-engine
</artifactId>
<version>
4.12
</version>
<version>
${junit-jupiter.version}
</version>
<scope>
test
</scope>
<scope>
test
</scope>
</dependency>
</dependency>
<!-- https://mvnrepository.com/artifact/org.osgeo/proj4j -->
<!-- https://mvnrepository.com/artifact/org.osgeo/proj4j -->
<dependency>
<dependency>
<groupId>
org.osgeo
</groupId>
<groupId>
org.osgeo
</groupId>
...
@@ -123,7 +128,8 @@
...
@@ -123,7 +128,8 @@
</manifest>
</manifest>
<manifestEntries>
<manifestEntries>
<Implementation-URL>
http://simstadt.hft-stuttgart.de/
</Implementation-URL>
<Implementation-URL>
http://simstadt.hft-stuttgart.de/
</Implementation-URL>
<Implementation-Version>
${project.version} (${scmBranch}, rev. ${buildNumber}, ${timestamp})
</Implementation-Version>
<Implementation-Version>
${project.version} (${scmBranch}, rev.
${buildNumber}, ${timestamp})
</Implementation-Version>
</manifestEntries>
</manifestEntries>
</archive>
</archive>
</configuration>
</configuration>
...
...
This diff is collapsed.
Click to expand it.
src/test/java/eu/simstadt/geo/fast_xml_parser/CitygmlParserTests.java
+
19
-
19
View file @
b8f660a3
package
eu.simstadt.geo.fast_xml_parser
;
package
eu.simstadt.geo.fast_xml_parser
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
jupiter
.
api
.
Assert
ions
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertFalse
;
import
static
org
.
junit
.
jupiter
.
api
.
Assert
ions
.
assertFalse
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
import
static
org
.
junit
.
jupiter
.
api
.
Assert
ions
.
assertTrue
;
import
java.nio.file.Path
;
import
java.nio.file.Path
;
import
java.nio.file.Paths
;
import
java.nio.file.Paths
;
import
org.junit.Test
;
import
org.junit.
jupiter.api.
Test
;
import
com.ximpleware.XPathParseException
;
import
com.ximpleware.XPathParseException
;
...
@@ -18,17 +18,17 @@
...
@@ -18,17 +18,17 @@
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
(
BuildingXmlNode
buildingXmlNode
:
buildingXmlNodes
)
{
for
(
BuildingXmlNode
buildingXmlNode
:
buildingXmlNodes
)
{
assertTrue
(
"Buildings should have coordinates"
,
buildingXmlNode
.
hasCoordinates
()
);
assertTrue
(
buildingXmlNode
.
hasCoordinates
(),
"Buildings should have coordinates"
);
assertFalse
(
COORDINATE_SHOULD_BE_A_DOUBLE
,
Double
.
isNaN
(
buildingXmlNode
.
x
));
assertFalse
(
Double
.
isNaN
(
buildingXmlNode
.
x
)
,
COORDINATE_SHOULD_BE_A_DOUBLE
);
assertFalse
(
COORDINATE_SHOULD_BE_A_DOUBLE
,
Double
.
isNaN
(
buildingXmlNode
.
y
));
assertFalse
(
Double
.
isNaN
(
buildingXmlNode
.
y
)
,
COORDINATE_SHOULD_BE_A_DOUBLE
);
assertFalse
(
COORDINATE_SHOULD_BE_A_DOUBLE
,
Double
.
isNaN
(
buildingXmlNode
.
xMax
));
assertFalse
(
Double
.
isNaN
(
buildingXmlNode
.
xMax
)
,
COORDINATE_SHOULD_BE_A_DOUBLE
);
assertFalse
(
COORDINATE_SHOULD_BE_A_DOUBLE
,
Double
.
isNaN
(
buildingXmlNode
.
yMax
));
assertFalse
(
Double
.
isNaN
(
buildingXmlNode
.
yMax
)
,
COORDINATE_SHOULD_BE_A_DOUBLE
);
assertFalse
(
COORDINATE_SHOULD_BE_A_DOUBLE
,
Double
.
isNaN
(
buildingXmlNode
.
xMin
));
assertFalse
(
Double
.
isNaN
(
buildingXmlNode
.
xMin
)
,
COORDINATE_SHOULD_BE_A_DOUBLE
);
assertFalse
(
COORDINATE_SHOULD_BE_A_DOUBLE
,
Double
.
isNaN
(
buildingXmlNode
.
yMin
));
assertFalse
(
Double
.
isNaN
(
buildingXmlNode
.
yMin
)
,
COORDINATE_SHOULD_BE_A_DOUBLE
);
assertTrue
(
COORDINATES_SHOULD_BE_PLAUSIBLE
,
buildingXmlNode
.
xMax
>
buildingXmlNode
.
x
);
assertTrue
(
buildingXmlNode
.
xMax
>
buildingXmlNode
.
x
,
COORDINATES_SHOULD_BE_PLAUSIBLE
);
assertTrue
(
COORDINATES_SHOULD_BE_PLAUSIBLE
,
buildingXmlNode
.
yMax
>
buildingXmlNode
.
y
);
assertTrue
(
buildingXmlNode
.
yMax
>
buildingXmlNode
.
y
,
COORDINATES_SHOULD_BE_PLAUSIBLE
);
assertTrue
(
COORDINATES_SHOULD_BE_PLAUSIBLE
,
buildingXmlNode
.
xMin
<
buildingXmlNode
.
x
);
assertTrue
(
buildingXmlNode
.
xMin
<
buildingXmlNode
.
x
,
COORDINATES_SHOULD_BE_PLAUSIBLE
);
assertTrue
(
COORDINATES_SHOULD_BE_PLAUSIBLE
,
buildingXmlNode
.
yMin
<
buildingXmlNode
.
y
);
assertTrue
(
buildingXmlNode
.
yMin
<
buildingXmlNode
.
y
,
COORDINATES_SHOULD_BE_PLAUSIBLE
);
}
}
}
}
...
@@ -67,11 +67,11 @@ public void testExtractNoCoordsFromEmptyBuilding() throws XPathParseException {
...
@@ -67,11 +67,11 @@ public void testExtractNoCoordsFromEmptyBuilding() throws XPathParseException {
CityGmlIterator
buildingXmlNodes
=
new
CityGmlIterator
(
citygmlPath
);
CityGmlIterator
buildingXmlNodes
=
new
CityGmlIterator
(
citygmlPath
);
int
counter
=
0
;
int
counter
=
0
;
for
(
BuildingXmlNode
buildingXmlNode
:
buildingXmlNodes
)
{
for
(
BuildingXmlNode
buildingXmlNode
:
buildingXmlNodes
)
{
assertFalse
(
"Empty Buildings shouldn't have coordinates"
,
buildingXmlNode
.
hasCoordinates
()
);
assertFalse
(
buildingXmlNode
.
hasCoordinates
(),
"Empty Buildings shouldn't have coordinates"
);
assertTrue
(
"Coordinate should be a Nan"
,
Double
.
isNaN
(
buildingXmlNode
.
x
));
assertTrue
(
Double
.
isNaN
(
buildingXmlNode
.
x
)
,
"Coordinate should be a Nan"
);
assertTrue
(
"Coordinate should be a Nan"
,
Double
.
isNaN
(
buildingXmlNode
.
y
));
assertTrue
(
Double
.
isNaN
(
buildingXmlNode
.
y
)
,
"Coordinate should be a Nan"
);
counter
++;
counter
++;
}
}
assertEquals
(
"3 buildings should have been analyzed"
,
counter
,
3
);
assertEquals
(
3
,
counter
,
"3 buildings should have been analyzed"
);
}
}
}
}
This diff is collapsed.
Click to expand it.
src/test/java/eu/simstadt/geo/fast_xml_parser/ConvexHullCalculatorTests.java
+
13
-
13
View file @
b8f660a3
package
eu.simstadt.geo.fast_xml_parser
;
package
eu.simstadt.geo.fast_xml_parser
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
jupiter
.
api
.
Assert
ions
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
import
static
org
.
junit
.
jupiter
.
api
.
Assert
ions
.
assertTrue
;
import
java.io.File
;
import
java.io.File
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.nio.file.Files
;
import
java.nio.file.Files
;
...
@@ -9,7 +9,7 @@
...
@@ -9,7 +9,7 @@
import
java.nio.file.Paths
;
import
java.nio.file.Paths
;
import
java.util.Comparator
;
import
java.util.Comparator
;
import
java.util.concurrent.atomic.AtomicInteger
;
import
java.util.concurrent.atomic.AtomicInteger
;
import
org.junit.Test
;
import
org.junit.
jupiter.api.
Test
;
import
org.locationtech.jts.geom.Coordinate
;
import
org.locationtech.jts.geom.Coordinate
;
import
org.locationtech.jts.geom.Geometry
;
import
org.locationtech.jts.geom.Geometry
;
import
org.locationtech.jts.geom.GeometryFactory
;
import
org.locationtech.jts.geom.GeometryFactory
;
...
@@ -27,9 +27,9 @@
...
@@ -27,9 +27,9 @@
public
void
testExtractConvexHullFromOneBuilding
()
throws
IOException
,
XPathParseException
{
public
void
testExtractConvexHullFromOneBuilding
()
throws
IOException
,
XPathParseException
{
Path
citygmlPath
=
repository
.
resolve
(
"Gruenbuehl.proj/20140218_Gruenbuehl_LOD2_1building.gml"
);
Path
citygmlPath
=
repository
.
resolve
(
"Gruenbuehl.proj/20140218_Gruenbuehl_LOD2_1building.gml"
);
Geometry
hull
=
ConvexHullCalculator
.
calculateFromCityGML
(
citygmlPath
);
Geometry
hull
=
ConvexHullCalculator
.
calculateFromCityGML
(
citygmlPath
);
assertEquals
(
hull
.
getCoordinates
().
length
,
4
+
1
);
// Convex hull of a building should be a closed rectangle
assertEquals
(
4
+
1
,
hull
.
getCoordinates
().
length
);
// Convex hull of a building should be a closed rectangle
Point
someBuildingPoint
=
gf
.
createPoint
(
new
Coordinate
(
9.216845
,
48.878196
));
// WGS84
Point
someBuildingPoint
=
gf
.
createPoint
(
new
Coordinate
(
9.216845
,
48.878196
));
// WGS84
assertTrue
(
"Hull should contain every building point"
,
hull
.
contains
(
someBuildingPoint
)
);
assertTrue
(
hull
.
contains
(
someBuildingPoint
),
"Hull should contain every building point"
);
}
}
@Test
@Test
...
@@ -39,7 +39,7 @@ public void testExtractConvexHullFromOneSmallRegion() throws IOException, XPathP
...
@@ -39,7 +39,7 @@ public void testExtractConvexHullFromOneSmallRegion() throws IOException, XPathP
assertTrue
(
hull
.
getCoordinates
().
length
>
4
);
// Convex hull should have at least 4 corners
assertTrue
(
hull
.
getCoordinates
().
length
>
4
);
// Convex hull should have at least 4 corners
// Point somewhereBetweenBuildings = gf.createPoint(new Coordinate(3515883.6668538367, 5415843.300640578)); // Original coordinates, GSK3
// Point somewhereBetweenBuildings = gf.createPoint(new Coordinate(3515883.6668538367, 5415843.300640578)); // Original coordinates, GSK3
Point
somewhereBetweenBuildings
=
gf
.
createPoint
(
new
Coordinate
(
9.21552249084
,
48.87980446
));
// WGS84
Point
somewhereBetweenBuildings
=
gf
.
createPoint
(
new
Coordinate
(
9.21552249084
,
48.87980446
));
// WGS84
assertTrue
(
"Hull should contain region between buildings"
,
hull
.
contains
(
somewhereBetweenBuildings
)
);
assertTrue
(
hull
.
contains
(
somewhereBetweenBuildings
),
"Hull should contain region between buildings"
);
}
}
@Test
@Test
...
@@ -48,7 +48,7 @@ public void testExtractConvexHullFromStoeckachNoBuildingPart() throws IOExceptio
...
@@ -48,7 +48,7 @@ public void testExtractConvexHullFromStoeckachNoBuildingPart() throws IOExceptio
Geometry
hull
=
ConvexHullCalculator
.
calculateFromCityGML
(
citygmlPath
);
Geometry
hull
=
ConvexHullCalculator
.
calculateFromCityGML
(
citygmlPath
);
assertTrue
(
hull
.
getCoordinates
().
length
>
4
);
// Convex hull should have at least 4 corners
assertTrue
(
hull
.
getCoordinates
().
length
>
4
);
// Convex hull should have at least 4 corners
Point
somewhereBetweenBuildings
=
gf
.
createPoint
(
new
Coordinate
(
9.195212
,
48.789062
));
// WGS84
Point
somewhereBetweenBuildings
=
gf
.
createPoint
(
new
Coordinate
(
9.195212
,
48.789062
));
// WGS84
assertTrue
(
"Hull should contain region between buildings"
,
hull
.
contains
(
somewhereBetweenBuildings
)
);
assertTrue
(
hull
.
contains
(
somewhereBetweenBuildings
),
"Hull should contain region between buildings"
);
}
}
@Test
@Test
...
@@ -63,13 +63,13 @@ public void testExtractConvexHullFromEveryCitygmlInRepository() throws IOExcepti
...
@@ -63,13 +63,13 @@ public void testExtractConvexHullFromEveryCitygmlInRepository() throws IOExcepti
long
gmlCount
=
RegionChooserUtils
.
everyCityGML
(
repository
).
count
();
long
gmlCount
=
RegionChooserUtils
.
everyCityGML
(
repository
).
count
();
AtomicInteger
hullCount
=
new
AtomicInteger
(
0
);
AtomicInteger
hullCount
=
new
AtomicInteger
(
0
);
ConvexHullCalculator
.
extractHullsForEveryCityGML
(
repository
,
kmlHull
->
{
ConvexHullCalculator
.
extractHullsForEveryCityGML
(
repository
,
kmlHull
->
{
assertTrue
(
"KML hull should contain project name"
,
kmlHull
.
contains
(
"Data name=\"project\""
));
assertTrue
(
kmlHull
.
contains
(
"Data name=\"project\""
)
,
"KML hull should contain project name"
);
assertTrue
(
"KML hull should contain srs name"
,
kmlHull
.
contains
(
"Data name=\"srsName\""
));
assertTrue
(
kmlHull
.
contains
(
"Data name=\"srsName\""
)
,
"KML hull should contain srs name"
);
assertTrue
(
"KML hull should contain epsg id"
,
kmlHull
.
contains
(
"<value>EPSG:"
)
);
assertTrue
(
kmlHull
.
contains
(
"<value>EPSG:"
),
"KML hull should contain epsg id"
);
assertTrue
(
"KML hull should contain coordinates"
,
kmlHull
.
contains
(
"<coordinates>"
)
);
assertTrue
(
kmlHull
.
contains
(
"<coordinates>"
),
"KML hull should contain coordinates"
);
hullCount
.
getAndIncrement
();
hullCount
.
getAndIncrement
();
});
});
assertTrue
(
"At least "
+
minHullCount
+
" citygmls should be present in repository"
,
gmlCount
>=
minHullCount
);
assertTrue
(
gmlCount
>=
minHullCount
,
"At least "
+
minHullCount
+
" citygmls should be present in repository"
);
assertTrue
(
"At least "
+
minHullCount
+
" hulls should have been calculated"
,
hullCount
.
get
()
>=
minHullCount
);
assertTrue
(
hullCount
.
get
()
>=
minHullCount
,
"At least "
+
minHullCount
+
" hulls should have been calculated"
);
}
}
}
}
This diff is collapsed.
Click to expand it.
src/test/java/eu/simstadt/regionchooser/CRSfromCityGMLHeaderTests.java
+
12
-
7
View file @
b8f660a3
package
eu.simstadt.regionchooser
;
package
eu.simstadt.regionchooser
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.
assertEquals
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.
assertThrows
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.nio.file.Path
;
import
java.nio.file.Path
;
import
java.nio.file.Paths
;
import
java.nio.file.Paths
;
import
org.junit.Test
;
import
org.junit.
jupiter.api.
Test
;
import
eu.simstadt.geo.RegionChooserUtils
;
import
eu.simstadt.geo.RegionChooserUtils
;
...
@@ -13,17 +14,19 @@
...
@@ -13,17 +14,19 @@
private
Path
repo
=
Paths
.
get
(
"src/test/resources/testdata"
);
private
Path
repo
=
Paths
.
get
(
"src/test/resources/testdata"
);
private
void
testExtractCSRNameFromHeader
(
Path
citygmlPath
,
String
crsName
)
throws
IOException
{
private
void
testExtractCSRNameFromHeader
(
Path
citygmlPath
,
String
crsName
)
throws
IOException
{
assertEquals
(
crsName
,
RegionChooserUtils
.
crsFromCityGMLHeader
(
citygmlPath
).
toString
());
assertEquals
(
RegionChooserUtils
.
crsFromCityGMLHeader
(
citygmlPath
).
toString
()
,
crsName
);
}
}
@Test
@Test
public
void
testExtractCRSFromStuttgart
()
throws
IOException
{
public
void
testExtractCRSFromStuttgart
()
throws
IOException
{
testExtractCSRNameFromHeader
(
repo
.
resolve
(
"Stuttgart.proj/Stuttgart_LOD0_LOD1_buildings_and_trees.gml"
),
"EPSG:31463"
);
testExtractCSRNameFromHeader
(
repo
.
resolve
(
"Stuttgart.proj/Stuttgart_LOD0_LOD1_buildings_and_trees.gml"
),
"EPSG:31463"
);
}
}
@Test
@Test
public
void
testExtractCRSFromGruenbuehl
()
throws
IOException
{
public
void
testExtractCRSFromGruenbuehl
()
throws
IOException
{
testExtractCSRNameFromHeader
(
repo
.
resolve
(
"Gruenbuehl.proj/20140218_Gruenbuehl_LOD2_1building.gml"
),
"EPSG:31467"
);
testExtractCSRNameFromHeader
(
repo
.
resolve
(
"Gruenbuehl.proj/20140218_Gruenbuehl_LOD2_1building.gml"
),
"EPSG:31467"
);
}
}
@Test
@Test
...
@@ -46,9 +49,11 @@ public void testExtractCRSFromValladolid() throws IOException {
...
@@ -46,9 +49,11 @@ public void testExtractCRSFromValladolid() throws IOException {
testExtractCSRNameFromHeader
(
repo
.
resolve
(
"Others.proj/Valladolid_Spain_only_header.gml"
),
"EPSG:25830"
);
testExtractCSRNameFromHeader
(
repo
.
resolve
(
"Others.proj/Valladolid_Spain_only_header.gml"
),
"EPSG:25830"
);
}
}
@Test
(
expected
=
IllegalArgumentException
.
class
)
@Test
public
void
testDontExtractCRSFromBrokenCityGML
()
throws
IOException
{
public
void
testDontExtractCRSFromBrokenCityGML
()
throws
IOException
{
Path
citygmlPath
=
repo
.
resolve
(
"Others.proj/SimpleSolid_MSBS.gml"
);
Path
citygmlPath
=
repo
.
resolve
(
"Others.proj/SimpleSolid_MSBS.gml"
);
testExtractCSRNameFromHeader
(
citygmlPath
,
"Nothing found. Should throw an exception"
);
assertThrows
(
IllegalArgumentException
.
class
,
()
->
{
testExtractCSRNameFromHeader
(
citygmlPath
,
"Nothing found. Should throw an exception"
);
});
}
}
}
}
This diff is collapsed.
Click to expand it.
src/test/java/eu/simstadt/regionchooser/RegionExtractorTests.java
+
34
-
30
View file @
b8f660a3
package
eu.simstadt.regionchooser
;
package
eu.simstadt.regionchooser
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
jupiter
.
api
.
Assert
ions
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertFalse
;
import
static
org
.
junit
.
jupiter
.
api
.
Assert
ions
.
assertFalse
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
import
static
org
.
junit
.
jupiter
.
api
.
Assert
ions
.
assertTrue
;
import
java.nio.file.Path
;
import
java.nio.file.Path
;
import
java.nio.file.Paths
;
import
java.nio.file.Paths
;
import
java.util.regex.Matcher
;
import
java.util.regex.Matcher
;
import
java.util.regex.Pattern
;
import
java.util.regex.Pattern
;
import
org.junit.Test
;
import
org.junit.
jupiter.api.
Test
;
public
class
RegionExtractorTests
public
class
RegionExtractorTests
...
@@ -37,19 +37,19 @@ public void testExtract3BuildingsFromGSK3Model() throws Throwable {
...
@@ -37,19 +37,19 @@ public void testExtract3BuildingsFromGSK3Model() throws Throwable {
Path
citygmlPath
=
TEST_REPOSITORY
.
resolve
(
"Gruenbuehl.proj/20140218_Gruenbuehl_LOD2.gml"
);
Path
citygmlPath
=
TEST_REPOSITORY
.
resolve
(
"Gruenbuehl.proj/20140218_Gruenbuehl_LOD2.gml"
);
String
churchGMLString
=
RegionExtractor
.
selectRegionDirectlyFromCityGML
(
citygmlPath
,
wktPolygon
,
"EPSG:31467"
)
String
churchGMLString
=
RegionExtractor
.
selectRegionDirectlyFromCityGML
(
citygmlPath
,
wktPolygon
,
"EPSG:31467"
)
.
toString
();
.
toString
();
assertEquals
(
countRegexMatches
(
churchGMLString
,
CITY_OBJECT_MEMBER_REGEX
)
,
3
);
assertEquals
(
3
,
countRegexMatches
(
churchGMLString
,
CITY_OBJECT_MEMBER_REGEX
));
assertTrue
(
churchGMLString
.
contains
(
"Donaustr"
));
assertTrue
(
churchGMLString
.
contains
(
"Donaustr"
));
assertTrue
(
churchGMLString
.
contains
(
"DEBW_LOD2_203056"
));
assertTrue
(
churchGMLString
.
contains
(
"DEBW_LOD2_203056"
));
assertTrue
(
churchGMLString
.
contains
(
"DEBW_LOD2_2869"
));
assertTrue
(
churchGMLString
.
contains
(
"DEBW_LOD2_2869"
));
assertTrue
(
churchGMLString
.
contains
(
"DEBW_LOD2_2909"
));
assertTrue
(
churchGMLString
.
contains
(
"DEBW_LOD2_2909"
));
assertTrue
(
churchGMLString
.
contains
(
CORE_CITY_MODEL_HEADER
));
assertTrue
(
churchGMLString
.
contains
(
CORE_CITY_MODEL_HEADER
));
assertTrue
(
churchGMLString
.
contains
(
CORE_CITY_MODEL_FOOTER
));
assertTrue
(
churchGMLString
.
contains
(
CORE_CITY_MODEL_FOOTER
));
assertTrue
(
"The exported CityGML should contain a new envelope with the correct EPSG"
,
churchGMLString
assertTrue
(
churchGMLString
.
contains
(
"<gml:Envelope srsName=\"EPSG:31467\" srsDimension=\"3\">"
),
.
contains
(
"<gml:Envelope srsName=\"EPSG:31467\" srsDimension=\"3\">"
)
);
"The exported CityGML should contain a new envelope with the correct EPSG"
);
assertTrue
(
"The exported CityGML should contain a new envelope"
,
churchGMLString
assertTrue
(
churchGMLString
.
contains
(
"<gml:lowerCorner>3515829.0815150724 5415766.204935087 "
),
.
contains
(
"<gml:lowerCorner>3515829.0815150724 5415766.204935087 "
)
);
"The exported CityGML should contain a new envelope"
);
assertTrue
(
"The exported CityGML should contain a new envelope"
,
churchGMLString
assertTrue
(
churchGMLString
.
contains
(
"<gml:upperCorner>3515876.489172751 5415823.108586172 "
),
.
contains
(
"<gml:upperCorner>3515876.489172751 5415823.108586172 "
)
);
"The exported CityGML should contain a new envelope"
);
}
}
@Test
@Test
...
@@ -65,10 +65,10 @@ public void testExtractBuildingsWithoutCommentsInBetween() throws Throwable {
...
@@ -65,10 +65,10 @@ public void testExtractBuildingsWithoutCommentsInBetween() throws Throwable {
assertTrue
(
archGMLString
.
contains
(
"uuid_0985cebb-922d-4b3e-95e5-15dc6089cd28"
));
assertTrue
(
archGMLString
.
contains
(
"uuid_0985cebb-922d-4b3e-95e5-15dc6089cd28"
));
assertTrue
(
archGMLString
.
contains
(
CITY_MODEL_HEADER
));
assertTrue
(
archGMLString
.
contains
(
CITY_MODEL_HEADER
));
assertTrue
(
archGMLString
.
contains
(
CITY_MODEL_FOOTER
));
assertTrue
(
archGMLString
.
contains
(
CITY_MODEL_FOOTER
));
assertFalse
(
"C
omment
s
between buildings
shouldn't be extracted
"
,
assertFalse
(
archGMLString
.
contains
(
"c
omment between buildings"
)
,
archGMLString
.
contains
(
"c
omment between buildings
"
));
// Comment
"C
omment
s
between buildings
shouldn't be extracted"
);
assertFalse
(
"C
omment
s
after building
s shouldn't be extracted
"
,
assertFalse
(
archGMLString
.
contains
(
"c
omment after
last
building"
)
,
archGMLString
.
contains
(
"c
omment after
last
building
"
));
// Comment
"C
omment
s
after building
s shouldn't be extracted"
);
}
}
@Test
@Test
...
@@ -77,18 +77,22 @@ public void testExtractBuildingsAndChangeEnvelope() throws Throwable {
...
@@ -77,18 +77,22 @@ public void testExtractBuildingsAndChangeEnvelope() throws Throwable {
Path
citygmlPath
=
TEST_REPOSITORY
.
resolve
(
"NewYork.proj/FamilyCourt_LOD2_with_PLUTO_attributes.gml"
);
Path
citygmlPath
=
TEST_REPOSITORY
.
resolve
(
"NewYork.proj/FamilyCourt_LOD2_with_PLUTO_attributes.gml"
);
String
familyCourtBuilding
=
RegionExtractor
String
familyCourtBuilding
=
RegionExtractor
.
selectRegionDirectlyFromCityGML
(
citygmlPath
,
wktPolygon
,
EPSG_32118
).
toString
();
.
selectRegionDirectlyFromCityGML
(
citygmlPath
,
wktPolygon
,
EPSG_32118
).
toString
();
assertEquals
(
countRegexMatches
(
familyCourtBuilding
,
CITY_OBJECT_MEMBER_REGEX
)
,
1
);
assertEquals
(
1
,
countRegexMatches
(
familyCourtBuilding
,
CITY_OBJECT_MEMBER_REGEX
));
assertTrue
(
familyCourtBuilding
.
contains
(
"Bldg_12210021066"
));
assertTrue
(
familyCourtBuilding
.
contains
(
"Bldg_12210021066"
));
assertFalse
(
"The exported CityGML shouldn't contain the original envelope"
,
familyCourtBuilding
assertFalse
(
.
contains
(
"<gml:lowerCorner>298393.46959639067 59277.34021543693 -11.892070104139751</gml:lowerCorner>"
));
familyCourtBuilding
.
contains
(
assertFalse
(
"The exported CityGML shouldn't contain the original envelope"
,
familyCourtBuilding
"<gml:lowerCorner>298393.46959639067 59277.34021543693 -11.892070104139751</gml:lowerCorner>"
),
.
contains
(
"<gml:upperCorner>305641.79529639013 67101.44881543722 547.7591871983744</gml:upperCorner>"
));
"The exported CityGML shouldn't contain the original envelope"
);
assertTrue
(
"The exported CityGML should contain a new envelope with the original altitudes"
,
familyCourtBuilding
assertFalse
(
.
contains
(
"<gml:lowerCorner>299721.46983062755 61021.99295737501 -11.89"
));
familyCourtBuilding
.
contains
(
assertTrue
(
"The exported CityGML should contain a new envelope with the original altitudes"
,
familyCourtBuilding
"<gml:upperCorner>305641.79529639013 67101.44881543722 547.7591871983744</gml:upperCorner>"
),
.
contains
(
"<gml:upperCorner>299823.9079725632 61122.68126771413 547.75"
));
"The exported CityGML shouldn't contain the original envelope"
);
assertTrue
(
"The exported CityGML should contain a new envelope with the correct EPSG"
,
familyCourtBuilding
assertTrue
(
familyCourtBuilding
.
contains
(
"<gml:lowerCorner>299721.46983062755 61021.99295737501 -11.89"
),
.
contains
(
"<gml:Envelope srsName=\"EPSG:32118\" srsDimension=\"3\">"
));
"The exported CityGML should contain a new envelope with the original altitudes"
);
assertTrue
(
familyCourtBuilding
.
contains
(
"<gml:upperCorner>299823.9079725632 61122.68126771413 547.75"
),
"The exported CityGML should contain a new envelope with the original altitudes"
);
assertTrue
(
familyCourtBuilding
.
contains
(
"<gml:Envelope srsName=\"EPSG:32118\" srsDimension=\"3\">"
),
"The exported CityGML should contain a new envelope with the correct EPSG"
);
}
}
@Test
@Test
...
@@ -98,7 +102,7 @@ public void testExtract0BuildingsWithWrongCoordinates() throws Throwable {
...
@@ -98,7 +102,7 @@ public void testExtract0BuildingsWithWrongCoordinates() throws Throwable {
Path
citygmlPath
=
TEST_REPOSITORY
.
resolve
(
"NewYork.proj/ManhattanSmall.gml"
);
Path
citygmlPath
=
TEST_REPOSITORY
.
resolve
(
"NewYork.proj/ManhattanSmall.gml"
);
String
emptyGMLString
=
RegionExtractor
.
selectRegionDirectlyFromCityGML
(
citygmlPath
,
wktPolygon
,
EPSG_32118
)
String
emptyGMLString
=
RegionExtractor
.
selectRegionDirectlyFromCityGML
(
citygmlPath
,
wktPolygon
,
EPSG_32118
)
.
toString
();
.
toString
();
assertEquals
(
countRegexMatches
(
emptyGMLString
,
CITY_OBJECT_MEMBER_REGEX
)
,
0
);
assertEquals
(
0
,
countRegexMatches
(
emptyGMLString
,
CITY_OBJECT_MEMBER_REGEX
));
assertTrue
(
emptyGMLString
.
contains
(
CITY_MODEL_HEADER
));
assertTrue
(
emptyGMLString
.
contains
(
CITY_MODEL_HEADER
));
assertTrue
(
emptyGMLString
.
contains
(
CITY_MODEL_FOOTER
));
assertTrue
(
emptyGMLString
.
contains
(
CITY_MODEL_FOOTER
));
}
}
...
@@ -110,7 +114,7 @@ public void testExtract0BuildingsFromEmptyGML() throws Throwable {
...
@@ -110,7 +114,7 @@ public void testExtract0BuildingsFromEmptyGML() throws Throwable {
Path
citygmlPath
=
TEST_REPOSITORY
.
resolve
(
"NewYork.proj/empty_model.gml"
);
Path
citygmlPath
=
TEST_REPOSITORY
.
resolve
(
"NewYork.proj/empty_model.gml"
);
String
emptyGMLString
=
RegionExtractor
.
selectRegionDirectlyFromCityGML
(
citygmlPath
,
wktPolygon
,
EPSG_32118
)
String
emptyGMLString
=
RegionExtractor
.
selectRegionDirectlyFromCityGML
(
citygmlPath
,
wktPolygon
,
EPSG_32118
)
.
toString
();
.
toString
();
assertEquals
(
countRegexMatches
(
emptyGMLString
,
CITY_OBJECT_MEMBER_REGEX
)
,
0
);
assertEquals
(
0
,
countRegexMatches
(
emptyGMLString
,
CITY_OBJECT_MEMBER_REGEX
));
assertTrue
(
emptyGMLString
.
contains
(
CORE_CITY_MODEL_HEADER
));
assertTrue
(
emptyGMLString
.
contains
(
CORE_CITY_MODEL_HEADER
));
assertTrue
(
emptyGMLString
.
contains
(
CORE_CITY_MODEL_FOOTER
));
assertTrue
(
emptyGMLString
.
contains
(
CORE_CITY_MODEL_FOOTER
));
}
}
...
@@ -122,7 +126,7 @@ public void testExtract0BuildingsFromWeirdGML() throws Throwable {
...
@@ -122,7 +126,7 @@ public void testExtract0BuildingsFromWeirdGML() throws Throwable {
Path
citygmlPath
=
TEST_REPOSITORY
.
resolve
(
"NewYork.proj/broken_nyc_lod2.gml"
);
Path
citygmlPath
=
TEST_REPOSITORY
.
resolve
(
"NewYork.proj/broken_nyc_lod2.gml"
);
String
emptyGMLString
=
RegionExtractor
.
selectRegionDirectlyFromCityGML
(
citygmlPath
,
wktPolygon
,
EPSG_32118
)
String
emptyGMLString
=
RegionExtractor
.
selectRegionDirectlyFromCityGML
(
citygmlPath
,
wktPolygon
,
EPSG_32118
)
.
toString
();
.
toString
();
assertEquals
(
countRegexMatches
(
emptyGMLString
,
CITY_OBJECT_MEMBER_REGEX
)
,
0
);
assertEquals
(
0
,
countRegexMatches
(
emptyGMLString
,
CITY_OBJECT_MEMBER_REGEX
));
assertTrue
(
emptyGMLString
.
contains
(
CORE_CITY_MODEL_HEADER
));
assertTrue
(
emptyGMLString
.
contains
(
CORE_CITY_MODEL_HEADER
));
assertTrue
(
emptyGMLString
.
contains
(
CORE_CITY_MODEL_FOOTER
));
assertTrue
(
emptyGMLString
.
contains
(
CORE_CITY_MODEL_FOOTER
));
}
}
...
@@ -133,6 +137,6 @@ public void testExtractBuildingsFromCitygmlWithoutZinEnvelope() throws Throwable
...
@@ -133,6 +137,6 @@ public void testExtractBuildingsFromCitygmlWithoutZinEnvelope() throws Throwable
Path
citygmlPath
=
TEST_REPOSITORY
.
resolve
(
"Stuttgart.proj/Stuttgart_LOD0_LOD1_small.gml"
);
Path
citygmlPath
=
TEST_REPOSITORY
.
resolve
(
"Stuttgart.proj/Stuttgart_LOD0_LOD1_small.gml"
);
String
emptyGMLString
=
RegionExtractor
.
selectRegionDirectlyFromCityGML
(
citygmlPath
,
wktPolygon
,
"EPSG:31463"
)
String
emptyGMLString
=
RegionExtractor
.
selectRegionDirectlyFromCityGML
(
citygmlPath
,
wktPolygon
,
"EPSG:31463"
)
.
toString
();
.
toString
();
assertEquals
(
countRegexMatches
(
emptyGMLString
,
"<bldg:Building gml:id"
)
,
2
);
assertEquals
(
2
,
countRegexMatches
(
emptyGMLString
,
"<bldg:Building gml:id"
));
}
}
}
}
This diff is collapsed.
Click to expand it.
src/test/java/eu/simstadt/regionchooser/RegionExtractorWithDifferentInputTests.java
+
12
-
10
View file @
b8f660a3
package
eu.simstadt.regionchooser
;
package
eu.simstadt.regionchooser
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
import
static
org
.
junit
.
jupiter
.
api
.
Assert
ions
.
assertTrue
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.nio.file.Path
;
import
java.nio.file.Path
;
import
java.nio.file.Paths
;
import
java.nio.file.Paths
;
import
java.util.Arrays
;
import
java.util.Arrays
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
import
org.junit.Test
;
import
org.junit.
jupiter.api.
Test
;
import
org.locationtech.jts.geom.Polygon
;
import
org.locationtech.jts.geom.Polygon
;
import
org.locationtech.jts.io.ParseException
;
import
org.locationtech.jts.io.ParseException
;
import
org.locationtech.jts.io.WKTReader
;
import
org.locationtech.jts.io.WKTReader
;
...
@@ -36,8 +36,8 @@ public void testExtractRegionWithLocalCRS()
...
@@ -36,8 +36,8 @@ public void testExtractRegionWithLocalCRS()
CoordinateReferenceSystem
localCRS
=
RegionChooserUtils
.
crsFromCityGMLHeader
(
citygmlPath
);
CoordinateReferenceSystem
localCRS
=
RegionChooserUtils
.
crsFromCityGMLHeader
(
citygmlPath
);
StringBuilder
sb
=
RegionExtractor
.
selectRegionDirectlyFromCityGML
(
citygmlPath
,
wktPolygon
,
localCRS
.
getName
());
StringBuilder
sb
=
RegionExtractor
.
selectRegionDirectlyFromCityGML
(
citygmlPath
,
wktPolygon
,
localCRS
.
getName
());
assertTrue
(
"One weird shaped roof should be inside the region"
,
assertTrue
(
sb
.
toString
().
contains
(
"gml_ZVHMQQ6BZGRT0O3Q6RGXF12BDOV49QIZ58XB"
)
,
sb
.
toString
().
contains
(
"gml_ZVHMQQ6BZGRT0O3Q6RGXF12BDOV49QIZ58XB"
)
);
"One weird shaped roof should be inside the region"
);
}
}
//NOTE: This test can be adapted to download a region which is too large for the server. Here with WGS84 coordinates
//NOTE: This test can be adapted to download a region which is too large for the server. Here with WGS84 coordinates
...
@@ -52,11 +52,12 @@ public void testExtractRegionWithWGS84()
...
@@ -52,11 +52,12 @@ public void testExtractRegionWithWGS84()
Polygon
wgs84Polygon
=
(
Polygon
)
WKT_READER
.
read
(
wgs84WktPolygon
);
Polygon
wgs84Polygon
=
(
Polygon
)
WKT_READER
.
read
(
wgs84WktPolygon
);
CoordinateReferenceSystem
localCRS
=
RegionChooserUtils
.
crsFromCityGMLHeader
(
citygmlPath
);
CoordinateReferenceSystem
localCRS
=
RegionChooserUtils
.
crsFromCityGMLHeader
(
citygmlPath
);
String
localWktPolygon
=
WKT_WRITER
.
write
(
RegionChooserUtils
.
changePolygonCRS
(
wgs84Polygon
,
RegionChooserUtils
.
WGS84
,
localCRS
));
String
localWktPolygon
=
WKT_WRITER
.
write
(
RegionChooserUtils
.
changePolygonCRS
(
wgs84Polygon
,
RegionChooserUtils
.
WGS84
,
localCRS
));
StringBuilder
sb
=
RegionExtractor
.
selectRegionDirectlyFromCityGML
(
citygmlPath
,
localWktPolygon
,
StringBuilder
sb
=
RegionExtractor
.
selectRegionDirectlyFromCityGML
(
citygmlPath
,
localWktPolygon
,
localCRS
.
getName
());
localCRS
.
getName
());
assertTrue
(
"One weird shaped roof should be inside the region"
,
assertTrue
(
sb
.
toString
().
contains
(
"gml_ZVHMQQ6BZGRT0O3Q6RGXF12BDOV49QIZ58XB"
)
,
sb
.
toString
().
contains
(
"gml_ZVHMQQ6BZGRT0O3Q6RGXF12BDOV49QIZ58XB"
)
);
"One weird shaped roof should be inside the region"
);
}
}
//NOTE: This test can be adapted to download a region which is too large for the server. Here with old coordinates from WebSimstadt
//NOTE: This test can be adapted to download a region which is too large for the server. Here with old coordinates from WebSimstadt
...
@@ -100,12 +101,13 @@ public void testExtractRegionWithOldCoordinates()
...
@@ -100,12 +101,13 @@ public void testExtractRegionWithOldCoordinates()
Polygon
wgs84Polygon
=
(
Polygon
)
WKT_READER
.
read
(
wgs84WktPolygon
);
Polygon
wgs84Polygon
=
(
Polygon
)
WKT_READER
.
read
(
wgs84WktPolygon
);
CoordinateReferenceSystem
localCRS
=
RegionChooserUtils
.
crsFromCityGMLHeader
(
citygmlPath
);
CoordinateReferenceSystem
localCRS
=
RegionChooserUtils
.
crsFromCityGMLHeader
(
citygmlPath
);
String
localWktPolygon
=
WKT_WRITER
.
write
(
RegionChooserUtils
.
changePolygonCRS
(
wgs84Polygon
,
RegionChooserUtils
.
WGS84
,
localCRS
));
String
localWktPolygon
=
WKT_WRITER
.
write
(
RegionChooserUtils
.
changePolygonCRS
(
wgs84Polygon
,
RegionChooserUtils
.
WGS84
,
localCRS
));
StringBuilder
sb
=
RegionExtractor
.
selectRegionDirectlyFromCityGML
(
citygmlPath
,
localWktPolygon
,
StringBuilder
sb
=
RegionExtractor
.
selectRegionDirectlyFromCityGML
(
citygmlPath
,
localWktPolygon
,
localCRS
.
getName
());
localCRS
.
getName
());
assertTrue
(
"One weird shaped roof should be inside the region"
,
assertTrue
(
sb
.
toString
().
contains
(
"gml_ZVHMQQ6BZGRT0O3Q6RGXF12BDOV49QIZ58XB"
)
,
sb
.
toString
().
contains
(
"gml_ZVHMQQ6BZGRT0O3Q6RGXF12BDOV49QIZ58XB"
)
);
"One weird shaped roof should be inside the region"
);
}
}
//TODO: Write a method to merge RegionChooser results from multiple gmls
//TODO: Write a method to merge RegionChooser results from multiple gmls
...
...
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