Docker Fixes

This commit is contained in:
Tim Zöller 2025-11-29 12:28:58 +01:00
parent ac53f04e0a
commit 8f797a51f1
5 changed files with 69 additions and 6 deletions

View file

@ -1,5 +1,6 @@
package org.operaton.fitpub.config;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.testcontainers.service.connection.ServiceConnection;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@ -13,10 +14,11 @@ import org.testcontainers.utility.DockerImageName;
*
* This ensures development environment matches production (PostgreSQL + PostGIS).
*
* Only active when NOT running in production profile.
* Only active when NOT running in production profile AND Testcontainers is on the classpath.
*/
@Configuration(proxyBeanMethods = false)
@Profile("!prod")
@ConditionalOnClass(PostgreSQLContainer.class)
public class TestcontainersConfiguration {
/**

View file

@ -262,7 +262,35 @@ public class ActivityController {
// Build GeoJSON FeatureCollection
ActivityDTO dto = ActivityDTO.fromEntity(activity);
if (dto.getSimplifiedTrack() == null) {
// Use high-resolution track points if available, otherwise fall back to simplified track
java.util.List<java.util.List<Double>> coordinates = new java.util.ArrayList<>();
if (dto.getTrackPoints() != null && !dto.getTrackPoints().isEmpty()) {
// Use high-resolution track points
for (java.util.Map<String, Object> point : dto.getTrackPoints()) {
Double longitude = (Double) point.get("longitude");
Double latitude = (Double) point.get("latitude");
Double elevation = (Double) point.get("elevation");
if (longitude != null && latitude != null) {
if (elevation != null) {
coordinates.add(java.util.List.of(longitude, latitude, elevation));
} else {
coordinates.add(java.util.List.of(longitude, latitude));
}
}
}
} else if (dto.getSimplifiedTrack() != null) {
// Fall back to simplified track if high-res not available
@SuppressWarnings("unchecked")
java.util.List<java.util.List<Double>> simplifiedCoords =
(java.util.List<java.util.List<Double>>) dto.getSimplifiedTrack().get("coordinates");
if (simplifiedCoords != null) {
coordinates = simplifiedCoords;
}
}
if (coordinates.isEmpty()) {
// Return empty FeatureCollection if no track data
return ResponseEntity.ok(java.util.Map.of(
"type", "FeatureCollection",
@ -270,10 +298,15 @@ public class ActivityController {
));
}
// Create GeoJSON geometry
java.util.Map<String, Object> geometry = new java.util.LinkedHashMap<>();
geometry.put("type", "LineString");
geometry.put("coordinates", coordinates);
// Create GeoJSON Feature with the track
java.util.Map<String, Object> feature = new java.util.LinkedHashMap<>();
feature.put("type", "Feature");
feature.put("geometry", dto.getSimplifiedTrack());
feature.put("geometry", geometry);
// Add properties
java.util.Map<String, Object> properties = new java.util.LinkedHashMap<>();