Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
CityDoctor
CityDoctor2
Commits
e51b0f28
Commit
e51b0f28
authored
Mar 23, 2021
by
Matthias Betz
Browse files
fixed utm zone calculation
added feature mapping tests
parent
ecd414c2
Pipeline
#2565
passed with stage
in 3 minutes and 5 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
CityDoctorParent/CityDoctorModel/src/main/java/de/hft/stuttgart/citydoctor2/parser/CityGmlParser.java
View file @
e51b0f28
...
...
@@ -554,17 +554,19 @@ public class CityGmlParser {
ProjCoordinate
p2
=
new
ProjCoordinate
();
BasicCoordinateTransform
bct
=
new
BasicCoordinateTransform
(
crs
,
wgs84
);
bct
.
transform
(
p1
,
p2
);
centerLong
=
p2
.
x
;
centerLat
=
p2
.
y
;
centerLong
=
p2
.
y
;
centerLat
=
p2
.
x
;
}
int
zone
=
(
int
)
(
31
+
Math
.
round
(
centerLong
/
6
));
CoordinateReferenceSystem
utm
;
if
(
centerLat
<
0
)
{
// south
utm
=
CRS_FACTORY
.
createFromParameters
(
"UTM"
,
"+proj=utm +zone="
+
zone
+
" +south"
);
logger
.
info
(
"Converting coordiante system to UTM zone {}S"
,
zone
);
utm
=
CRS_FACTORY
.
createFromParameters
(
"UTM"
,
"+proj=utm +ellps=WGS84 +units=m +zone="
+
zone
+
" +south"
);
}
else
{
// north
utm
=
CRS_FACTORY
.
createFromParameters
(
"UTM"
,
"+proj=utm +zone="
+
zone
);
logger
.
info
(
"Converting coordiante system to UTM zone {}N"
,
zone
);
utm
=
CRS_FACTORY
.
createFromParameters
(
"UTM"
,
"+proj=utm +ellps=WGS84 +units=m +zone="
+
zone
);
}
config
.
setCoordinateSystem
(
crs
,
utm
);
}
...
...
CityDoctorParent/CityDoctorModel/src/test/java/de/hft/stuttgart/citydoctor2/mapper/FeatureMapperTest.java
View file @
e51b0f28
...
...
@@ -19,10 +19,14 @@
package
de.hft.stuttgart.citydoctor2.mapper
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertNull
;
import
static
org
.
junit
.
Assert
.
fail
;
import
static
org
.
mockito
.
Mockito
.
mock
;
import
java.io.File
;
import
java.io.IOException
;
import
org.citygml4j.model.citygml.vegetation.PlantCover
;
import
org.citygml4j.model.citygml.waterbody.WaterBody
;
import
org.citygml4j.model.gml.geometry.aggregates.MultiSurface
;
import
org.citygml4j.model.gml.geometry.aggregates.MultiSurfaceProperty
;
...
...
@@ -30,12 +34,15 @@ import org.citygml4j.model.gml.geometry.primitives.Coord;
import
org.citygml4j.model.gml.geometry.primitives.Exterior
;
import
org.citygml4j.model.gml.geometry.primitives.LinearRing
;
import
org.citygml4j.model.gml.geometry.primitives.Polygon
;
import
org.citygml4j.model.gml.geometry.primitives.SurfaceProperty
;
import
org.junit.Rule
;
import
org.junit.Test
;
import
org.junit.rules.TemporaryFolder
;
import
de.hft.stuttgart.citydoctor2.datastructure.CityDoctorModel
;
import
de.hft.stuttgart.citydoctor2.datastructure.Geometry
;
import
de.hft.stuttgart.citydoctor2.datastructure.GeometryType
;
import
de.hft.stuttgart.citydoctor2.datastructure.Lod
;
import
de.hft.stuttgart.citydoctor2.datastructure.Vertex
;
import
de.hft.stuttgart.citydoctor2.datastructure.WaterObject
;
import
de.hft.stuttgart.citydoctor2.parser.ParserConfiguration
;
...
...
@@ -49,6 +56,49 @@ public class FeatureMapperTest {
@Rule
public
TemporaryFolder
folder
=
new
TemporaryFolder
();
@Test
public
void
testVisitWaterBody
()
{
WaterBody
body
=
new
WaterBody
();
FeatureMapper
mapper
=
new
FeatureMapper
(
mock
(
ParserConfiguration
.
class
),
new
File
(
""
));
mapper
.
visit
(
body
);
assertEquals
(
1
,
mapper
.
getModel
().
getWater
().
size
());
body
.
setId
(
"test1"
);
mapper
.
visit
(
body
);
assertEquals
(
2
,
mapper
.
getModel
().
getWater
().
size
());
WaterObject
waterObject
=
mapper
.
getModel
().
getWater
().
get
(
1
);
assertEquals
(
"test1"
,
waterObject
.
getGmlId
().
getGmlString
());
body
.
setLod1MultiSurface
(
createDummyMsp
());
mapper
.
visit
(
body
);
assertEquals
(
3
,
mapper
.
getModel
().
getWater
().
size
());
assertNull
(
body
.
getLod1MultiSurface
());
Geometry
geometry
=
mapper
.
getModel
().
getWater
().
get
(
2
).
getGeometries
().
get
(
0
);
assertEquals
(
1
,
geometry
.
getPolygons
().
size
());
assertEquals
(
Lod
.
LOD1
,
geometry
.
getLod
());
assertEquals
(
GeometryType
.
MULTI_SURFACE
,
geometry
.
getType
());
}
@Test
public
void
testVisitPlantCover
()
{
PlantCover
cover
=
new
PlantCover
();
FeatureMapper
mapper
=
new
FeatureMapper
(
mock
(
ParserConfiguration
.
class
),
new
File
(
""
));
mapper
.
visit
(
cover
);
}
private
MultiSurfaceProperty
createDummyMsp
()
{
LinearRing
ext
=
new
LinearRing
();
ext
.
addCoord
(
createCoord
(
0
,
0
,
0
));
ext
.
addCoord
(
createCoord
(
10
,
0
,
0
));
ext
.
addCoord
(
createCoord
(
10
,
10
,
0
));
ext
.
addCoord
(
createCoord
(
0
,
10
,
0
));
ext
.
addCoord
(
createCoord
(
0
,
0
,
0
));
Polygon
p
=
new
Polygon
();
p
.
setExterior
(
new
Exterior
(
ext
));
MultiSurface
ms
=
new
MultiSurface
();
ms
.
addSurfaceMember
(
new
SurfaceProperty
(
p
));
return
new
MultiSurfaceProperty
(
ms
);
}
@Test
public
void
testNeighboringVertices
()
throws
IOException
{
...
...
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