This commit is contained in:
@@ -1,10 +1,15 @@
|
||||
package SuMoC.backend.carta;
|
||||
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Service;
|
||||
import sumoc.backend.carta.client.api.CartaApi;
|
||||
import sumoc.backend.carta.client.api.MapApi;
|
||||
import sumoc.backend.carta.client.model.Direction;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneOffset;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
@Service
|
||||
public class CartaClient {
|
||||
|
||||
@@ -25,46 +30,45 @@ public class CartaClient {
|
||||
* @param alternatives Number of alternatives
|
||||
* @param walkingSpeed
|
||||
* @param transferTime
|
||||
* @param accessible
|
||||
* @param parking
|
||||
* @param type 0=tram, 1=subway, 2=rail, 3=bus, 4=ferry, 5=cablecar, 6=gondola, 7=funicular, 8=trolleybus, 9=monorail
|
||||
* @param type 0=tram, 1=subway, 2=rail, 3=bus, 4=ferry, 5=cablecar, 6=gondola, 7=funicular, 8=trolleybus, 9=monorail - after inspecting innamoruhr 10 = add bikes?
|
||||
* @param range
|
||||
* @param location
|
||||
* @param location Context for name resolution
|
||||
* @return
|
||||
*/
|
||||
public Direction getRoute(
|
||||
@Async
|
||||
public CompletableFuture<Direction> asyncGetRoute(
|
||||
String origin,
|
||||
String destination,
|
||||
String mode,
|
||||
Long arrivalTime,
|
||||
Long departureTime,
|
||||
LocalDateTime arrivalTime,
|
||||
LocalDateTime departureTime,
|
||||
Integer alternatives,
|
||||
Double walkingSpeed,
|
||||
Integer transferTime,
|
||||
Boolean accessible,
|
||||
Boolean parking,
|
||||
String type,
|
||||
Integer range,
|
||||
String location
|
||||
) {
|
||||
try {
|
||||
String uid = null; // Optional user identifier
|
||||
return cartaApi.getDirection(
|
||||
return CompletableFuture.completedFuture(cartaApi.getDirection(
|
||||
origin,
|
||||
destination,
|
||||
mode, // possible values: walking, driving, cycling
|
||||
arrivalTime,
|
||||
departureTime,
|
||||
mode.toLowerCase(), // possible values: walking, driving, cycling
|
||||
arrivalTime.toEpochSecond(ZoneOffset.UTC),
|
||||
departureTime.toEpochSecond(ZoneOffset.UTC),
|
||||
alternatives,
|
||||
walkingSpeed,
|
||||
transferTime,
|
||||
accessible,
|
||||
parking,
|
||||
false,
|
||||
false,
|
||||
type,
|
||||
range,
|
||||
location,
|
||||
uid
|
||||
);
|
||||
null
|
||||
));
|
||||
|
||||
// } catch (InterruptedException e) {
|
||||
// return CompletableFuture.failedFuture(e);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user