Commit 7e7235d9 authored by Matthias Betz's avatar Matthias Betz
Browse files

formatting

parent d7d412aa
......@@ -33,9 +33,9 @@ import org.springframework.web.servlet.mvc.method.annotation.StreamingResponseBo
public class CityGMLServerController {
private static final Logger logger = LoggerFactory.getLogger(CityGMLServerController.class);
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 CoordinateTransformFactory ctFactory = new CoordinateTransformFactory();
private static final CoordinateTransform transform = ctFactory.createTransform(srcCrs, dstCrs);
......@@ -43,7 +43,7 @@ public class CityGMLServerController {
private WKTReader reader = new WKTReader();
private CityDB5Connector cityDbConnector;
private static final Object lock = new Object();
@Autowired
public CityGMLServerController(CityDB5Connector cityDbConnector) {
this.cityDbConnector = cityDbConnector;
......@@ -68,30 +68,28 @@ public class CityGMLServerController {
logger.info("No database found for year: {}", year);
return ResponseEntity.notFound().build();
}
StreamingResponseBody stream = out -> {
try {
logger.info("transforming geometry");
transformGeometry(geometry);
logger.info("Geometry transformed");
String transformedWkt = geometry.toText();
StreamingResponseBody stream = out -> {
try {
logger.info("transforming geometry");
transformGeometry(geometry);
logger.info("Geometry transformed");
String transformedWkt = geometry.toText();
cityDbConnector.exportCityGML("S_INTERSECTS(Envelope," + transformedWkt + ")", out, year);
logger.info("Finished request export");
} catch (ExecutionException e) {
logger.error("Failed to retrieve CityGML", e);
throw new RuntimeException("Failed to retrieve CityGML", e);
}
};
return ResponseEntity.ok()
.header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"citygml.gml\"")
.contentType(MediaType.APPLICATION_XML)
.body(stream);
};
return ResponseEntity.ok().header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"citygml.gml\"")
.contentType(MediaType.APPLICATION_XML).body(stream);
} catch (ParseException e) {
logger.error("Error parsing WKT: {}", wktPolygon, e);
return ResponseEntity.badRequest().build();
}
}
@PostMapping("/citygml")
public ResponseEntity<StreamingResponseBody> getCityGMLPost(@RequestBody String wktPolygon,
@RequestParam(required = false) List<String> attributes, @RequestParam(defaultValue = "2019") int year) {
......@@ -111,20 +109,18 @@ public class CityGMLServerController {
logger.info("No database found for year: {}", year);
return ResponseEntity.notFound().build();
}
StreamingResponseBody stream = out -> {
try {
transformGeometry(geometry);
String transformedWkt = geometry.toText();
StreamingResponseBody stream = out -> {
try {
transformGeometry(geometry);
String transformedWkt = geometry.toText();
cityDbConnector.exportCityGML("S_INTERSECTS(Envelope," + transformedWkt + ")", out, year);
} catch (ExecutionException e) {
logger.error("Failed to retrieve CityGML", e);
throw new RuntimeException("Failed to retrieve CityGML", e);
}
};
return ResponseEntity.ok()
.header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"citygml.gml\"")
.contentType(MediaType.APPLICATION_XML)
.body(stream);
};
return ResponseEntity.ok().header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"citygml.gml\"")
.contentType(MediaType.APPLICATION_XML).body(stream);
} catch (ParseException e) {
logger.error("Error parsing WKT: {}", wktPolygon, e);
......@@ -138,15 +134,15 @@ public class CityGMLServerController {
ed.edit(geom, new CoordinateOperation() {
@Override
public Coordinate[] edit(Coordinate[] coordinates, Geometry geometry) {
for (int i = 0; i < coordinates.length; i++) {
ProjCoordinate src = new ProjCoordinate(coordinates[i].x, coordinates[i].y);
ProjCoordinate dst = new ProjCoordinate();
transform.transform(src, dst);
coordinates[i] = new Coordinate(dst.x, dst.y);
}
return coordinates;
for (int i = 0; i < coordinates.length; i++) {
ProjCoordinate src = new ProjCoordinate(coordinates[i].x, coordinates[i].y);
ProjCoordinate dst = new ProjCoordinate();
transform.transform(src, dst);
coordinates[i] = new Coordinate(dst.x, dst.y);
}
return coordinates;
}
});
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment