Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
sektorsim
CityGML Server
Commits
7e7235d9
Commit
7e7235d9
authored
Jul 16, 2026
by
Matthias Betz
Browse files
formatting
parent
d7d412aa
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/main/java/de/hft/stuttgart/sektorsim/server/controller/CityGMLServerController.java
View file @
7e7235d9
...
@@ -33,9 +33,9 @@ import org.springframework.web.servlet.mvc.method.annotation.StreamingResponseBo
...
@@ -33,9 +33,9 @@ import org.springframework.web.servlet.mvc.method.annotation.StreamingResponseBo
public
class
CityGMLServerController
{
public
class
CityGMLServerController
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
CityGMLServerController
.
class
);
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
CityGMLServerController
.
class
);
private
static
final
CRSFactory
crsFactory
=
new
CRSFactory
();
private
static
final
CRSFactory
crsFactory
=
new
CRSFactory
();
private
static
final
CoordinateReferenceSystem
srcCrs
=
crsFactory
.
createFromName
(
"EPSG:4326"
);
// WGS84
private
static
final
CoordinateReferenceSystem
srcCrs
=
crsFactory
.
createFromName
(
"EPSG:4326"
);
// WGS84
private
static
final
CoordinateReferenceSystem
dstCrs
=
crsFactory
.
createFromName
(
"EPSG:25832"
);
// UTM32N / ETRS89
private
static
final
CoordinateReferenceSystem
dstCrs
=
crsFactory
.
createFromName
(
"EPSG:25832"
);
// UTM32N / ETRS89
private
static
final
CoordinateTransformFactory
ctFactory
=
new
CoordinateTransformFactory
();
private
static
final
CoordinateTransformFactory
ctFactory
=
new
CoordinateTransformFactory
();
private
static
final
CoordinateTransform
transform
=
ctFactory
.
createTransform
(
srcCrs
,
dstCrs
);
private
static
final
CoordinateTransform
transform
=
ctFactory
.
createTransform
(
srcCrs
,
dstCrs
);
...
@@ -43,7 +43,7 @@ public class CityGMLServerController {
...
@@ -43,7 +43,7 @@ public class CityGMLServerController {
private
WKTReader
reader
=
new
WKTReader
();
private
WKTReader
reader
=
new
WKTReader
();
private
CityDB5Connector
cityDbConnector
;
private
CityDB5Connector
cityDbConnector
;
private
static
final
Object
lock
=
new
Object
();
private
static
final
Object
lock
=
new
Object
();
@Autowired
@Autowired
public
CityGMLServerController
(
CityDB5Connector
cityDbConnector
)
{
public
CityGMLServerController
(
CityDB5Connector
cityDbConnector
)
{
this
.
cityDbConnector
=
cityDbConnector
;
this
.
cityDbConnector
=
cityDbConnector
;
...
@@ -68,30 +68,28 @@ public class CityGMLServerController {
...
@@ -68,30 +68,28 @@ public class CityGMLServerController {
logger
.
info
(
"No database found for year: {}"
,
year
);
logger
.
info
(
"No database found for year: {}"
,
year
);
return
ResponseEntity
.
notFound
().
build
();
return
ResponseEntity
.
notFound
().
build
();
}
}
StreamingResponseBody
stream
=
out
->
{
StreamingResponseBody
stream
=
out
->
{
try
{
try
{
logger
.
info
(
"transforming geometry"
);
logger
.
info
(
"transforming geometry"
);
transformGeometry
(
geometry
);
transformGeometry
(
geometry
);
logger
.
info
(
"Geometry transformed"
);
logger
.
info
(
"Geometry transformed"
);
String
transformedWkt
=
geometry
.
toText
();
String
transformedWkt
=
geometry
.
toText
();
cityDbConnector
.
exportCityGML
(
"S_INTERSECTS(Envelope,"
+
transformedWkt
+
")"
,
out
,
year
);
cityDbConnector
.
exportCityGML
(
"S_INTERSECTS(Envelope,"
+
transformedWkt
+
")"
,
out
,
year
);
logger
.
info
(
"Finished request export"
);
logger
.
info
(
"Finished request export"
);
}
catch
(
ExecutionException
e
)
{
}
catch
(
ExecutionException
e
)
{
logger
.
error
(
"Failed to retrieve CityGML"
,
e
);
logger
.
error
(
"Failed to retrieve CityGML"
,
e
);
throw
new
RuntimeException
(
"Failed to retrieve CityGML"
,
e
);
throw
new
RuntimeException
(
"Failed to retrieve CityGML"
,
e
);
}
}
};
};
return
ResponseEntity
.
ok
()
return
ResponseEntity
.
ok
().
header
(
HttpHeaders
.
CONTENT_DISPOSITION
,
"attachment; filename=\"citygml.gml\""
)
.
header
(
HttpHeaders
.
CONTENT_DISPOSITION
,
"attachment; filename=\"citygml.gml\""
)
.
contentType
(
MediaType
.
APPLICATION_XML
).
body
(
stream
);
.
contentType
(
MediaType
.
APPLICATION_XML
)
.
body
(
stream
);
}
catch
(
ParseException
e
)
{
}
catch
(
ParseException
e
)
{
logger
.
error
(
"Error parsing WKT: {}"
,
wktPolygon
,
e
);
logger
.
error
(
"Error parsing WKT: {}"
,
wktPolygon
,
e
);
return
ResponseEntity
.
badRequest
().
build
();
return
ResponseEntity
.
badRequest
().
build
();
}
}
}
}
@PostMapping
(
"/citygml"
)
@PostMapping
(
"/citygml"
)
public
ResponseEntity
<
StreamingResponseBody
>
getCityGMLPost
(
@RequestBody
String
wktPolygon
,
public
ResponseEntity
<
StreamingResponseBody
>
getCityGMLPost
(
@RequestBody
String
wktPolygon
,
@RequestParam
(
required
=
false
)
List
<
String
>
attributes
,
@RequestParam
(
defaultValue
=
"2019"
)
int
year
)
{
@RequestParam
(
required
=
false
)
List
<
String
>
attributes
,
@RequestParam
(
defaultValue
=
"2019"
)
int
year
)
{
...
@@ -111,20 +109,18 @@ public class CityGMLServerController {
...
@@ -111,20 +109,18 @@ public class CityGMLServerController {
logger
.
info
(
"No database found for year: {}"
,
year
);
logger
.
info
(
"No database found for year: {}"
,
year
);
return
ResponseEntity
.
notFound
().
build
();
return
ResponseEntity
.
notFound
().
build
();
}
}
StreamingResponseBody
stream
=
out
->
{
StreamingResponseBody
stream
=
out
->
{
try
{
try
{
transformGeometry
(
geometry
);
transformGeometry
(
geometry
);
String
transformedWkt
=
geometry
.
toText
();
String
transformedWkt
=
geometry
.
toText
();
cityDbConnector
.
exportCityGML
(
"S_INTERSECTS(Envelope,"
+
transformedWkt
+
")"
,
out
,
year
);
cityDbConnector
.
exportCityGML
(
"S_INTERSECTS(Envelope,"
+
transformedWkt
+
")"
,
out
,
year
);
}
catch
(
ExecutionException
e
)
{
}
catch
(
ExecutionException
e
)
{
logger
.
error
(
"Failed to retrieve CityGML"
,
e
);
logger
.
error
(
"Failed to retrieve CityGML"
,
e
);
throw
new
RuntimeException
(
"Failed to retrieve CityGML"
,
e
);
throw
new
RuntimeException
(
"Failed to retrieve CityGML"
,
e
);
}
}
};
};
return
ResponseEntity
.
ok
()
return
ResponseEntity
.
ok
().
header
(
HttpHeaders
.
CONTENT_DISPOSITION
,
"attachment; filename=\"citygml.gml\""
)
.
header
(
HttpHeaders
.
CONTENT_DISPOSITION
,
"attachment; filename=\"citygml.gml\""
)
.
contentType
(
MediaType
.
APPLICATION_XML
).
body
(
stream
);
.
contentType
(
MediaType
.
APPLICATION_XML
)
.
body
(
stream
);
}
catch
(
ParseException
e
)
{
}
catch
(
ParseException
e
)
{
logger
.
error
(
"Error parsing WKT: {}"
,
wktPolygon
,
e
);
logger
.
error
(
"Error parsing WKT: {}"
,
wktPolygon
,
e
);
...
@@ -138,15 +134,15 @@ public class CityGMLServerController {
...
@@ -138,15 +134,15 @@ public class CityGMLServerController {
ed
.
edit
(
geom
,
new
CoordinateOperation
()
{
ed
.
edit
(
geom
,
new
CoordinateOperation
()
{
@Override
@Override
public
Coordinate
[]
edit
(
Coordinate
[]
coordinates
,
Geometry
geometry
)
{
public
Coordinate
[]
edit
(
Coordinate
[]
coordinates
,
Geometry
geometry
)
{
for
(
int
i
=
0
;
i
<
coordinates
.
length
;
i
++)
{
for
(
int
i
=
0
;
i
<
coordinates
.
length
;
i
++)
{
ProjCoordinate
src
=
new
ProjCoordinate
(
coordinates
[
i
].
x
,
coordinates
[
i
].
y
);
ProjCoordinate
src
=
new
ProjCoordinate
(
coordinates
[
i
].
x
,
coordinates
[
i
].
y
);
ProjCoordinate
dst
=
new
ProjCoordinate
();
ProjCoordinate
dst
=
new
ProjCoordinate
();
transform
.
transform
(
src
,
dst
);
transform
.
transform
(
src
,
dst
);
coordinates
[
i
]
=
new
Coordinate
(
dst
.
x
,
dst
.
y
);
coordinates
[
i
]
=
new
Coordinate
(
dst
.
x
,
dst
.
y
);
}
}
return
coordinates
;
return
coordinates
;
}
}
});
});
}
}
}
}
...
...
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