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
087c83fa
Commit
087c83fa
authored
Oct 31, 2019
by
Eric Duminil
Browse files
RegionChooser: updating tests.
parent
62c77ff7
Changes
2
Hide whitespace changes
Inline
Side-by-side
test/eu/simstadt/regionchooser/RegionExtractorTests.java
View file @
087c83fa
...
...
@@ -12,6 +12,13 @@
public
class
RegionExtractorTests
{
private
static
final
String
CITY_OBJECT_MEMBER_REGEX
=
"<(core:)?cityObjectMember"
;
private
static
final
String
CITY_MODEL_HEADER
=
"<CityModel"
;
private
static
final
String
CORE_CITY_MODEL_HEADER
=
"<core:CityModel"
;
private
static
final
String
CITY_MODEL_FOOTER
=
"</CityModel"
;
private
static
final
String
CORE_CITY_MODEL_FOOTER
=
"</core:CityModel"
;
private
static
final
Path
repo
=
Paths
.
get
(
"../TestRepository"
);
public
static
int
countRegexMatches
(
String
str
,
String
subStr
)
{
Pattern
pattern
=
Pattern
.
compile
(
subStr
);
Matcher
matcher
=
pattern
.
matcher
(
str
);
...
...
@@ -26,17 +33,16 @@ public static int countRegexMatches(String str, String subStr) {
public
void
testExtract3BuildingsFromGSK3Model
()
throws
Throwable
{
//NOTE: Small region around Martinskirche in Grünbühl
String
wktPolygon
=
"POLYGON((3515848.896028535 5415823.108586172,3515848.9512289143 5415803.590347393,3515829.0815150724 5415803.338023346,3515830.9784850604 5415793.437034622,3515842.0946056456 5415793.272282251,3515843.3515515197 5415766.204935087,3515864.1064344468 5415766.557899496,3515876.489172751 5415805.433782301,3515876.343844858 5415822.009293416,3515848.896028535 5415823.108586172))"
;
Path
repo
=
Paths
.
get
(
"../TestRepository"
);
Path
citygmlPath
=
repo
.
resolve
(
"Gruenbuehl.proj/20140218_Gruenbuehl_LOD2.gml"
);
String
churchGMLString
=
RegionExtractor
.
selectRegionDirectlyFromCityGML
(
citygmlPath
,
wktPolygon
,
"EPSG:31467"
)
.
toString
();
assertEquals
(
countRegexMatches
(
churchGMLString
,
"<(core:)?cityObjectMember"
),
3
);
assertEquals
(
countRegexMatches
(
churchGMLString
,
CITY_OBJECT_MEMBER_REGEX
),
3
);
assertTrue
(
churchGMLString
.
contains
(
"Donaustr"
));
assertTrue
(
churchGMLString
.
contains
(
"DEBW_LOD2_203056"
));
assertTrue
(
churchGMLString
.
contains
(
"DEBW_LOD2_2869"
));
assertTrue
(
churchGMLString
.
contains
(
"DEBW_LOD2_2909"
));
assertTrue
(
churchGMLString
.
contains
(
"<core:CityModel"
));
// Header
assertTrue
(
churchGMLString
.
contains
(
"</core:CityModel"
));
// Footer
assertTrue
(
churchGMLString
.
contains
(
CORE_CITY_MODEL_HEADER
));
assertTrue
(
churchGMLString
.
contains
(
CORE_CITY_MODEL_FOOTER
));
assertTrue
(
"The exported CityGML should contain a new envelope with the correct EPSG"
,
churchGMLString
.
contains
(
"<gml:Envelope srsName=\"EPSG:31467\" srsDimension=\"3\">"
));
assertTrue
(
"The exported CityGML should contain a new envelope"
,
churchGMLString
...
...
@@ -49,16 +55,15 @@ public void testExtract3BuildingsFromGSK3Model() throws Throwable {
public
void
testExtractBuildingsWithoutCommentsInBetween
()
throws
Throwable
{
//NOTE: Small region around WashingtonSquare
String
wktPolygon
=
"POLYGON((300259.78663489706 62835.835907766595,300230.33294975647 62792.0482567884,300213.5667431851 62770.83143720031,300183.6592861123 62730.20347659383,300252.9947486632 62676.938468840905,300273.3862256562 62701.767105345614,300257.5250407747 62715.760413539596,300308.2754543957 62805.14198211394,300259.78663489706 62835.835907766595))"
;
Path
repo
=
Paths
.
get
(
"../TestRepository"
);
Path
citygmlPath
=
repo
.
resolve
(
"NewYork.proj/ManhattanSmall.gml"
);
String
archGMLString
=
RegionExtractor
.
selectRegionDirectlyFromCityGML
(
citygmlPath
,
wktPolygon
,
"EPSG:32118"
)
.
toString
();
assertEquals
(
countRegexMatches
(
archGMLString
,
"<(core:)?cityObjectMember"
),
2
);
assertEquals
(
countRegexMatches
(
archGMLString
,
CITY_OBJECT_MEMBER_REGEX
),
2
);
assertTrue
(
archGMLString
.
contains
(
"WASHINGTON SQUARE"
));
assertTrue
(
archGMLString
.
contains
(
"uuid_c0980a6e-05ea-4d09-bc83-efab226945a1"
));
assertTrue
(
archGMLString
.
contains
(
"uuid_0985cebb-922d-4b3e-95e5-15dc6089cd28"
));
assertTrue
(
archGMLString
.
contains
(
"<CityModel"
));
// Header
assertTrue
(
archGMLString
.
contains
(
"</CityModel"
));
// Footer
assertTrue
(
archGMLString
.
contains
(
CITY_MODEL_HEADER
));
assertTrue
(
archGMLString
.
contains
(
CITY_MODEL_FOOTER
));
assertFalse
(
"Comments between buildings shouldn't be extracted"
,
archGMLString
.
contains
(
"comment between buildings"
));
// Comment
assertFalse
(
"Comments after buildings shouldn't be extracted"
,
...
...
@@ -68,11 +73,10 @@ public void testExtractBuildingsWithoutCommentsInBetween() throws Throwable {
@Test
public
void
testExtractBuildingsAndChangeEnvelope
()
throws
Throwable
{
String
wktPolygon
=
"POLYGON((299761.8123557725 61122.68126771413,299721.46983062755 61058.11626595352,299780.84627343423 61021.99295737501,299823.9079725632 61083.3979344517,299761.8123557725 61122.68126771413))"
;
Path
repo
=
Paths
.
get
(
"../TestRepository"
);
Path
citygmlPath
=
repo
.
resolve
(
"NewYork.proj/FamilyCourt_LOD2_with_PLUTO_attributes.gml"
);
String
familyCourtBuilding
=
RegionExtractor
.
selectRegionDirectlyFromCityGML
(
citygmlPath
,
wktPolygon
,
"EPSG:32118"
).
toString
();
assertEquals
(
countRegexMatches
(
familyCourtBuilding
,
"<(core:)?cityObjectMember"
),
1
);
assertEquals
(
countRegexMatches
(
familyCourtBuilding
,
CITY_OBJECT_MEMBER_REGEX
),
1
);
assertTrue
(
familyCourtBuilding
.
contains
(
"Bldg_12210021066"
));
assertFalse
(
"The exported CityGML shouldn't contain the original envelope"
,
familyCourtBuilding
.
contains
(
"<gml:lowerCorner>298393.46959639067 59277.34021543693 -11.892070104139751</gml:lowerCorner>"
));
...
...
@@ -90,45 +94,41 @@ public void testExtractBuildingsAndChangeEnvelope() throws Throwable {
public
void
testExtract0BuildingsWithWrongCoordinates
()
throws
Throwable
{
//NOTE: Small region, far away from NYC
String
wktPolygon
=
"POLYGON((0 0, 0 1, 1 1, 1 0, 0 0))"
;
Path
repo
=
Paths
.
get
(
"../TestRepository"
);
Path
citygmlPath
=
repo
.
resolve
(
"NewYork.proj/ManhattanSmall.gml"
);
String
emptyGMLString
=
RegionExtractor
.
selectRegionDirectlyFromCityGML
(
citygmlPath
,
wktPolygon
,
"EPSG:32118"
)
.
toString
();
assertEquals
(
countRegexMatches
(
emptyGMLString
,
"<(core:)?cityObjectMember"
),
0
);
assertTrue
(
emptyGMLString
.
contains
(
"<CityModel"
));
// Header
assertTrue
(
emptyGMLString
.
contains
(
"</CityModel"
));
// Footer
assertEquals
(
countRegexMatches
(
emptyGMLString
,
CITY_OBJECT_MEMBER_REGEX
),
0
);
assertTrue
(
emptyGMLString
.
contains
(
CITY_MODEL_HEADER
));
assertTrue
(
emptyGMLString
.
contains
(
CITY_MODEL_FOOTER
));
}
@Test
public
void
testExtract0BuildingsFromEmptyGML
()
throws
Throwable
{
//NOTE: Small region, with too many spaces between coordinates
String
wktPolygon
=
"POLYGON((0 0, 0 1, 1 1, 1 0, 0 0))"
;
Path
repo
=
Paths
.
get
(
"../TestRepository"
);
Path
citygmlPath
=
repo
.
resolve
(
"NewYork.proj/empty_model.gml"
);
String
emptyGMLString
=
RegionExtractor
.
selectRegionDirectlyFromCityGML
(
citygmlPath
,
wktPolygon
,
"EPSG:32118"
)
.
toString
();
assertEquals
(
countRegexMatches
(
emptyGMLString
,
"<(core:)?cityObjectMember"
),
0
);
assertTrue
(
emptyGMLString
.
contains
(
"<core:CityModel"
));
// Header
assertTrue
(
emptyGMLString
.
contains
(
"</core:CityModel"
));
// Footer
assertEquals
(
countRegexMatches
(
emptyGMLString
,
CITY_OBJECT_MEMBER_REGEX
),
0
);
assertTrue
(
emptyGMLString
.
contains
(
CORE_CITY_MODEL_HEADER
));
assertTrue
(
emptyGMLString
.
contains
(
CORE_CITY_MODEL_FOOTER
));
}
@Test
public
void
testExtract0BuildingsFromWeirdGML
()
throws
Throwable
{
//NOTE: Small region, with too many spaces between coordinates
String
wktPolygon
=
"POLYGON((0 0, 0 1, 1 1, 1 0, 0 0))"
;
Path
repo
=
Paths
.
get
(
"../TestRepository"
);
Path
citygmlPath
=
repo
.
resolve
(
"NewYork.proj/broken_nyc_lod2.gml"
);
String
emptyGMLString
=
RegionExtractor
.
selectRegionDirectlyFromCityGML
(
citygmlPath
,
wktPolygon
,
"EPSG:32118"
)
.
toString
();
assertEquals
(
countRegexMatches
(
emptyGMLString
,
"<(core:)?cityObjectMember"
),
0
);
assertTrue
(
emptyGMLString
.
contains
(
"<core:CityModel"
));
// Header
assertTrue
(
emptyGMLString
.
contains
(
"</core:CityModel"
));
// Footer
assertEquals
(
countRegexMatches
(
emptyGMLString
,
CITY_OBJECT_MEMBER_REGEX
),
0
);
assertTrue
(
emptyGMLString
.
contains
(
CORE_CITY_MODEL_HEADER
));
assertTrue
(
emptyGMLString
.
contains
(
CORE_CITY_MODEL_FOOTER
));
}
@Test
public
void
testExtractBuildingsFromCitygmlWithoutZinEnvelope
()
throws
Throwable
{
String
wktPolygon
=
"POLYGON((3512683.1280912133 5404783.732132129,3512719.1608604863 5404714.627650777,3512831.40076119 5404768.344155442,3512790.239106708 5404838.614891164,3512683.1280912133 5404783.732132129))"
;
Path
repo
=
Paths
.
get
(
"../TestRepository"
);
Path
citygmlPath
=
repo
.
resolve
(
"Stuttgart.proj/Stuttgart_LOD0_LOD1_small.gml"
);
String
emptyGMLString
=
RegionExtractor
.
selectRegionDirectlyFromCityGML
(
citygmlPath
,
wktPolygon
,
"EPSG:31463"
)
.
toString
();
...
...
test/eu/simstadt/regionchooser/RegionExtractorWithDifferentInputTests.java
View file @
087c83fa
...
...
@@ -25,8 +25,8 @@
//NOTE: This test can be adapted to download a region which is too large for the server. Here with local coordinates
@Test
public
void
testExtractRegionWithLocalCRS
()
throws
NumberFormatException
,
XPathParseException
,
NavException
,
XPathEval
Exception
,
Pa
rse
Exception
,
IO
Exception
{
public
void
testExtractRegionWithLocalCRS
()
throws
IOException
,
XPathParseException
,
Nav
Exception
,
X
Pa
thEval
Exception
,
Parse
Exception
{
String
citygml
=
"DA13_DA14_3D_Buildings_Port_Morris.gml"
;
String
projectName
=
"NewYork"
;
Path
repo
=
Paths
.
get
(
"../TestRepository"
);
...
...
@@ -42,8 +42,8 @@ public void testExtractRegionWithLocalCRS() throws NumberFormatException, XPathP
//NOTE: This test can be adapted to download a region which is too large for the server. Here with WGS84 coordinates
@Test
public
void
testExtractRegionWithWGS84
()
throws
ParseException
,
IOException
,
NumberFormatException
,
XPathParseException
,
NavException
,
XPathEvalException
{
public
void
testExtractRegionWithWGS84
()
throws
ParseException
,
IOException
,
XPathParseException
,
NavException
,
XPathEvalException
{
String
wgs84WktPolygon
=
"POLYGON((-73.91140940026597 40.804246732157196,-73.91424181298568 40.80025100302325,-73.90934946374252 40.79755456207104,-73.90561582879378 40.80116062104605,-73.90960695580794 40.80340212653638,-73.91140940026597 40.804246732157196))"
;
String
citygml
=
"DA13_DA14_3D_Buildings_Port_Morris.gml"
;
String
projectName
=
"NewYork"
;
...
...
@@ -62,8 +62,8 @@ public void testExtractRegionWithWGS84() throws ParseException, IOException, Num
//NOTE: This test can be adapted to download a region which is too large for the server. Here with old coordinates from WebSimstadt
@Test
public
void
testExtractRegionWithOldCoordinates
()
throws
ParseException
,
IOException
,
NumberFormatException
,
XPathParseException
,
NavException
,
XPathEvalException
{
public
void
testExtractRegionWithOldCoordinates
()
throws
ParseException
,
IOException
,
XPathParseException
,
NavException
,
XPathEvalException
{
String
oldFormatPolygon
=
"(40.81173171854368,-73.93268437431763)\r\n"
+
"(40.81069231965162,-73.93068165999941)\r\n"
+
"(40.809176499753505,-73.92907948540162)\r\n"
+
...
...
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