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
68891bca
Commit
68891bca
authored
Apr 21, 2017
by
duminil
Browse files
RegionChooser: CityGML can have pos or posList
parent
90070463
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/eu/simstadt/regionchooser/citygml_parser/BuildingXmlNode.java
View file @
68891bca
...
@@ -31,7 +31,7 @@ public Point getCenterOfMass() throws XPathParseException, NumberFormatException
...
@@ -31,7 +31,7 @@ public Point getCenterOfMass() throws XPathParseException, NumberFormatException
double
xTotal
=
0
;
double
xTotal
=
0
;
double
yTotal
=
0
;
double
yTotal
=
0
;
coordinatesFinder
.
selectXPath
(
".//posList"
);
coordinatesFinder
.
selectXPath
(
".//posList
|.//pos
"
);
while
(
coordinatesFinder
.
evalXPath
()
!=
-
1
)
{
while
(
coordinatesFinder
.
evalXPath
()
!=
-
1
)
{
long
offsetAndLength
=
navigator
.
getContentFragment
();
long
offsetAndLength
=
navigator
.
getContentFragment
();
int
coordinatesOffset
=
(
int
)
offsetAndLength
;
int
coordinatesOffset
=
(
int
)
offsetAndLength
;
...
...
test/eu/simstadt/regionchooser/test/CitygmlParserTests.java
View file @
68891bca
package
eu.simstadt.regionchooser.test
;
package
eu.simstadt.regionchooser.test
;
import
static
org
.
junit
.
Assert
.
assertFalse
;
import
static
org
.
junit
.
Assert
.
assertFalse
;
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.Test
;
import
com.ximpleware.NavException
;
import
com.ximpleware.XPathEvalException
;
import
com.ximpleware.XPathParseException
;
import
eu.simstadt.regionchooser.citygml_parser.BuildingXmlNode
;
import
eu.simstadt.regionchooser.citygml_parser.BuildingXmlNode
;
import
eu.simstadt.regionchooser.citygml_parser.CityGmlIterator
;
import
eu.simstadt.regionchooser.citygml_parser.CityGmlIterator
;
public
class
CitygmlParserTests
public
class
CitygmlParserTests
{
{
@Test
private
void
testNoNanInCoordinates
(
Path
citygmlPath
)
public
void
testExtractCoordsFromStuttgart
()
throws
Throwable
{
throws
NumberFormatException
,
XPathParseException
,
NavException
,
XPathEvalException
,
IOException
{
Path
repo
=
Paths
.
get
(
"../TestRepository"
);
Path
citygmlPath
=
repo
.
resolve
(
"Stuttgart.proj/Stuttgart_buildings_and_trees.gml"
);
CityGmlIterator
buildingXmlNodes
=
new
CityGmlIterator
(
citygmlPath
);
CityGmlIterator
buildingXmlNodes
=
new
CityGmlIterator
(
citygmlPath
);
for
(
BuildingXmlNode
buildingXmlNode
:
buildingXmlNodes
)
{
for
(
BuildingXmlNode
buildingXmlNode
:
buildingXmlNodes
)
{
double
x
=
buildingXmlNode
.
getCenterOfMass
().
getX
();
double
x
=
buildingXmlNode
.
getCenterOfMass
().
getX
();
...
@@ -21,5 +23,28 @@ public void testExtractCoordsFromStuttgart() throws Throwable {
...
@@ -21,5 +23,28 @@ public void testExtractCoordsFromStuttgart() throws Throwable {
assertFalse
(
"Coordinate should be a double"
,
Double
.
isNaN
(
x
));
assertFalse
(
"Coordinate should be a double"
,
Double
.
isNaN
(
x
));
assertFalse
(
"Coordinate should be a double"
,
Double
.
isNaN
(
y
));
assertFalse
(
"Coordinate should be a double"
,
Double
.
isNaN
(
y
));
}
}
}
@Test
public
void
testExtractCoordsFromStuttgart
()
throws
NumberFormatException
,
XPathParseException
,
NavException
,
XPathEvalException
,
IOException
{
Path
repo
=
Paths
.
get
(
"../TestRepository"
);
Path
citygmlPath
=
repo
.
resolve
(
"Stuttgart.proj/Stuttgart_LOD0_LOD1_buildings_and_trees.gml"
);
testNoNanInCoordinates
(
citygmlPath
);
}
@Test
public
void
testExtractCoordsFromGruenbuehl
()
throws
Throwable
{
Path
repo
=
Paths
.
get
(
"../TestRepository"
);
Path
citygmlPath
=
repo
.
resolve
(
"Gruenbuehl.proj/20140218_Gruenbuehl_LOD2_1building.gml"
);
testNoNanInCoordinates
(
citygmlPath
);
}
@Test
public
void
testExtractCoordsFromMunich
()
throws
Throwable
{
Path
repo
=
Paths
.
get
(
"../TestRepository"
);
Path
citygmlPath
=
repo
.
resolve
(
"Muenchen.proj/Munich_v_1_0_0.gml"
);
testNoNanInCoordinates
(
citygmlPath
);
}
}
}
}
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