Closed oliviadargel closed 2 years ago
`
request := {MIN_DISTANCE, MAX_DISTANCE}
requestedDistance := {1,2,3,4...}
Route giveMeMyRoute(request, requestedDistance){
// 1km difference in Coordinates
const ONE_KM_DIFF = 0.015060
requestDistanceInCoordinates = ONE_KM_DIFF x requestedDistance
Direction[] capitalDir = {North,East,South,West}
Coordinates userPos = getCurrentUserCoordinates() // or other defined starting point
Route[] potentialRoutes
for(Direction dir: capitalDir){
// calculates new coordinate from our starting point in the current direction with the given distance
Coordinate potentialDestination = (tryToFindNewLocationFromHere(userPos, requestDistanceInCoordinates, dir))
if(hereApi.checkIfRoutingIsPossible(potentialDestination)){
Route potentialRoute = hereApi.calculatePotentialRoute(userPos, potentialDestination)
potentialRoutes.add(potentialRoute)
}
}
if(request.equals(MIN_DISTANCE)){
for(Route current: potentialRoutes){
if(checkIfDistanceIsAtLeast(current, requestedDistance)){
return current
}
}
return giveMeMyRoute(request, requestedDistance + 1)
}else if(request.equals(MAX_DISTANCE)){
for(Route current: potentialRoutes){
if(checkIfDistanceIsAtMost(current, requestedDistance)){
return current
}
}
return giveMeMyRoute(request, requestedDistance - 1)
}else{
throw Error(unknown request)
}
}
`
Alternative:
Direction[] capitalDir = {N,NE,E,SE,S,SW,W,NW}
User story
Acceptance criteria
Definition of done