add h3 cells to trip model as preparation for route pattern detection
LocationBasedServices/sumoc-backend/pipeline/head This commit looks good
LocationBasedServices/sumoc-backend/pipeline/head This commit looks good
This commit is contained in:
@@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user