use of eu.europa.ec.fisheries.ers.fa.utils.MovementTypeComparator in project UVMS-ActivityModule-APP by UnionVMS.
the class FluxMessageServiceBean method interpolatePointFromMovements.
private Geometry interpolatePointFromMovements(List<MovementType> movements, Date activityDate) throws ServiceException {
if (movements == null || movements.isEmpty()) {
return null;
}
Geometry faReportGeom;
Collections.sort(movements, new MovementTypeComparator());
Map<String, MovementType> movementTypeMap = getPreviousAndNextMovement(movements, activityDate);
MovementType nextMovement = movementTypeMap.get(NEXT);
MovementType previousMovement = movementTypeMap.get(PREVIOUS);
try {
if (previousMovement == null && nextMovement == null) {
faReportGeom = null;
} else if (nextMovement == null) {
faReportGeom = GeometryMapper.INSTANCE.wktToGeometry(previousMovement.getWkt()).getValue();
faReportGeom.setSRID(dialect.defaultSRID());
} else if (previousMovement == null) {
faReportGeom = GeometryMapper.INSTANCE.wktToGeometry(nextMovement.getWkt()).getValue();
faReportGeom.setSRID(dialect.defaultSRID());
} else {
faReportGeom = calculateIntermediatePoint(previousMovement, nextMovement, activityDate);
}
} catch (ParseException e) {
throw new ServiceException(e.getMessage(), e);
}
return faReportGeom;
}
Aggregations