Updated routingAPI to privde a list of moves isntead of raw coordinates, DrivingRoute.txt added to simulate that generation
This commit is contained in:
parent
2dbaf79393
commit
72f82fb425
2 changed files with 31 additions and 24 deletions
12
DrivingRoute.txt
Normal file
12
DrivingRoute.txt
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
FWD;0.2;20
|
||||||
|
LEFT;0.044;20
|
||||||
|
LEFT;0.1;35
|
||||||
|
LEFT;3.0;45
|
||||||
|
RIGHT;2.3;50
|
||||||
|
LEFT;0.3;50
|
||||||
|
FWD;9.6;70
|
||||||
|
RIGHT;0.3;50
|
||||||
|
RIGHT;0.2;35
|
||||||
|
LEFT;0.2;35
|
||||||
|
LEFT;0.4;35
|
||||||
|
RIGHT;0.08;20
|
|
@ -1,3 +1,8 @@
|
||||||
|
import java.util.Vector;
|
||||||
|
import java.nio.file.Paths;
|
||||||
|
import java.util.Scanner;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
//a collection of helper functions to act as responses for otherwise
|
//a collection of helper functions to act as responses for otherwise
|
||||||
//external calls in this implementation for demo purposes
|
//external calls in this implementation for demo purposes
|
||||||
|
|
||||||
|
@ -18,35 +23,25 @@ public class HelperFunctions {
|
||||||
return returnArray;
|
return returnArray;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double[][] routingAPI(double[] startCoords, double[] destinationCoords, Boolean tollsFlag, Boolean hwyFlag) {
|
public Object[] routingAPI(double[] startCoords, double[] destinationCoords, Boolean tollsFlag, Boolean hwyFlag) {
|
||||||
//ideally this would return a series of coordinates, but for the sake of the demo it's just
|
//method simulates a call to translate two pairs of coords into a driving route
|
||||||
//going to concatenate the start and end into a 2x2 array with just those two steps
|
//for demo purposes returns a pregenerated set of move instructions
|
||||||
//speed is also returned in MPH for the expected points as the third index in the array's second dimension
|
//located in DrivingRoute.txt as semicolon delimited strings for direction, distance, and speedLimit
|
||||||
double[][] routeArray = new double[2][3];
|
Vector<String[]> routeArray = new Vector<String[]>();
|
||||||
if (tollsFlag && hwyFlag) { //provides a result that both avoid tolls and major highways
|
if (tollsFlag && hwyFlag) { //provides a result that both avoid tolls and major highways
|
||||||
routeArray[0] = startCoords;
|
|
||||||
routeArray[1] = destinationCoords;
|
|
||||||
routeArray[0][2] = 45; //avg speed leg 1
|
|
||||||
routeArray[0][3] = 0; //tolls leg 1
|
|
||||||
routeArray[1][2] = 45; //avg speed leg 2
|
|
||||||
routeArray[1][3] = 0; //tolls leg 2
|
|
||||||
} else if (tollsFlag && !hwyFlag) { //provides a result that avoids tolls but not major highways
|
} else if (tollsFlag && !hwyFlag) { //provides a result that avoids tolls but not major highways
|
||||||
routeArray[0][2] = 60; //avg speed leg 1
|
|
||||||
routeArray[0][3] = 0; //tolls leg 1
|
|
||||||
routeArray[1][2] = 45; //avg speed leg 2
|
|
||||||
routeArray[1][3] = 0; //tolls leg 2
|
|
||||||
} else if (!tollsFlag && hwyFlag) { //provides a result that does not avoid tolls and does avoid major highways
|
} else if (!tollsFlag && hwyFlag) { //provides a result that does not avoid tolls and does avoid major highways
|
||||||
routeArray[0][2] = 45; //avg speed leg 1
|
|
||||||
routeArray[0][3] = 1.50; //tolls leg 1
|
|
||||||
routeArray[1][2] = 45; //avg speed leg 2
|
|
||||||
routeArray[1][3] = 0; //tolls leg 2
|
|
||||||
} else if (!tollsFlag && !hwyFlag) { //provides a result that does not avoid tolls or major highways
|
} else if (!tollsFlag && !hwyFlag) { //provides a result that does not avoid tolls or major highways
|
||||||
routeArray[0][2] = 60; //avg speed leg 1
|
try (Scanner infile = new Scanner(Paths.get("DrivingRoute.txt"))) {
|
||||||
routeArray[0][3] = 1.50; //tolls leg 1
|
while (infile.hasNext()) {
|
||||||
routeArray[1][2] = 45; //avg speed leg 2
|
routeArray.addElement(infile.nextLine().split(";"));
|
||||||
routeArray[1][3] = 0; //tolls leg 2
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
System.err.println("File handling error");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return routeArray;
|
return routeArray.toArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int[] internalTempSensors() {
|
public int[] internalTempSensors() {
|
||||||
|
|
Loading…
Reference in a new issue