diff --git a/docker-compose.yml b/docker-compose.yml index 818c566..fae4b2b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -44,7 +44,7 @@ services: SPRING_JPA_HIBERNATE_DDL_AUTO: validate SPRING_JPA_SHOW_SQL: ${JPA_SHOW_SQL:-false} SPRING_JPA_PROPERTIES_HIBERNATE_FORMAT_SQL: ${JPA_FORMAT_SQL:-false} - SPRING_JPA_PROPERTIES_HIBERNATE_DIALECT: org.hibernate.spatial.dialect.postgis.PostgisDialect + SPRING_JPA_PROPERTIES_HIBERNATE_DIALECT: org.hibernate.dialect.PostgreSQLDialect # Flyway Configuration SPRING_FLYWAY_ENABLED: true @@ -55,8 +55,8 @@ services: SERVER_PORT: ${APP_PORT:-8080} # Application Configuration - APP_DOMAIN: ${APP_DOMAIN} - APP_BASE_URL: ${APP_BASE_URL} + FITPUB_DOMAIN: ${APP_DOMAIN} + FITPUB_BASE_URL: ${APP_BASE_URL} # Security Configuration JWT_SECRET: ${JWT_SECRET} diff --git a/pom.xml b/pom.xml index 31327cd..b3204dc 100644 --- a/pom.xml +++ b/pom.xml @@ -78,6 +78,7 @@ + org.springframework.boot spring-boot-testcontainers @@ -173,6 +174,27 @@ org.projectlombok lombok + + + org.springframework.boot + spring-boot-testcontainers + + + org.testcontainers + testcontainers + + + org.testcontainers + postgresql + + + org.testcontainers + jdbc + + + org.testcontainers + database-commons + diff --git a/src/main/java/org/operaton/fitpub/config/TestcontainersConfiguration.java b/src/main/java/org/operaton/fitpub/config/TestcontainersConfiguration.java index 64108d9..27fbfaa 100644 --- a/src/main/java/org/operaton/fitpub/config/TestcontainersConfiguration.java +++ b/src/main/java/org/operaton/fitpub/config/TestcontainersConfiguration.java @@ -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 { /** diff --git a/src/main/java/org/operaton/fitpub/controller/ActivityController.java b/src/main/java/org/operaton/fitpub/controller/ActivityController.java index 4b6d80b..0260683 100644 --- a/src/main/java/org/operaton/fitpub/controller/ActivityController.java +++ b/src/main/java/org/operaton/fitpub/controller/ActivityController.java @@ -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> coordinates = new java.util.ArrayList<>(); + + if (dto.getTrackPoints() != null && !dto.getTrackPoints().isEmpty()) { + // Use high-resolution track points + for (java.util.Map 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> simplifiedCoords = + (java.util.List>) 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 geometry = new java.util.LinkedHashMap<>(); + geometry.put("type", "LineString"); + geometry.put("coordinates", coordinates); + // Create GeoJSON Feature with the track java.util.Map feature = new java.util.LinkedHashMap<>(); feature.put("type", "Feature"); - feature.put("geometry", dto.getSimplifiedTrack()); + feature.put("geometry", geometry); // Add properties java.util.Map properties = new java.util.LinkedHashMap<>(); diff --git a/src/main/resources/application-prod.yml b/src/main/resources/application-prod.yml index ca9fdbb..efafdce 100644 --- a/src/main/resources/application-prod.yml +++ b/src/main/resources/application-prod.yml @@ -2,6 +2,12 @@ # Activated with: java -jar fitpub.jar --spring.profiles.active=prod spring: + # Disable Testcontainers auto-configuration in production + autoconfigure: + exclude: + - org.springframework.boot.testcontainers.service.connection.ContainerConnectionDetailsAutoConfiguration + - org.springframework.boot.testcontainers.lifecycle.TestcontainersLifecycleBeanPostProcessor + # Production datasource - must be configured via environment variables datasource: url: ${SPRING_DATASOURCE_URL}