add h3 cells to trip model as preparation for route pattern detection
LocationBasedServices/sumoc-backend/pipeline/head This commit looks good

This commit is contained in:
2026-01-11 19:40:46 +01:00
parent 1b74f6125c
commit 160b883bfc
6 changed files with 149 additions and 7 deletions
@@ -1,21 +1,37 @@
package SuMoC.backend.trip;
import SuMoC.backend.h3.H3Service;
import SuMoC.backend.trip.dtos.NewTripDTO;
import SuMoC.backend.trip.dtos.TripDTO;
import SuMoC.backend.trip.models.Trip;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.List;
@Mapper(componentModel = "spring", uses = TripSegmentMapper.class)
public interface TripMapper {
@Mapper(componentModel = "spring", uses = {TripSegmentMapper.class, H3Service.class})
public abstract class TripMapper {
@Autowired
protected H3Service h3service;
@Mapping(source = "id", target = "tripId")
@Mapping(source = "user.id", target = "userId")
TripDTO toTripDTO(Trip trip);
public abstract TripDTO toTripDTO(Trip trip);
List<TripDTO> toTripDTOs(List<Trip> trips);
public abstract List<TripDTO> toTripDTOs(List<Trip> trips);
@Mapping(source = "tripSegments", target = "tripSegments")
Trip toTrip(NewTripDTO newTripDTO);
@Mapping(target = "startH3Cell", expression = "java(calculateH3CellStart(newTripDTO))")
@Mapping(target = "endH3Cell", expression = "java(calculateH3CellEnd(newTripDTO))")
public abstract Trip toTrip(NewTripDTO newTripDTO);
protected String calculateH3CellStart(NewTripDTO newTripDTO) {
return h3service.latLngToCellForRoute(newTripDTO.getStartLatitude(), newTripDTO.getStartLongitude());
}
protected String calculateH3CellEnd(NewTripDTO newTripDTO) {
return h3service.latLngToCellForRoute(newTripDTO.getEndLatitude(), newTripDTO.getEndLongitude());
}
}