+ * This is a model with an linear acceleration and deceleration periods and a
+ * constant speed in between.
+ *
+ * @param distance the distance (in km)
+ * @return the duration of the trip (in hours) */
+ private static double distanceToTime(double distance) {
+ return Math.max(0, distance - 2 * ACCELERATION_DISTANCE) / MAX_SPEED
+ + Math.pow(Math.min(distance, 2 * ACCELERATION_DISTANCE) / MAX_SPEED, 2);
+ }
+
+ /** @param stop1
+ * @param nextLine
+ * @param i */
+ private static void fillStation(StopEntry stop, String[] nextLine, int index) {
+ nextLine[index] = stop.lname;
+ nextLine[index + 1] = MessageFormat.format("{0}, {1}",
+ GPS_FORMATTER.format(stop.latitude),
+ GPS_FORMATTER.format(stop.longitude));
+
+ }
+
+ /** @param stop
+ * @return */
+ private static StopEntry resolve(UnidentifiedStopEntry stop) {
+
+ if (stop.candidates.isEmpty()) {
+ LOGGER.severe("Unable to find stop name, will use a placeholder");
+ return stop;
+ }
+ if (stop.candidates.size() == 1) {
+ return stop.candidates.get(0);
+ }
+ Collections.sort(stop.candidates,
+ (Comparator super StopEntry>) (StopEntry s1,
+ StopEntry s2) -> (int) Math.signum((GPS.distance(stop.latitude,
+ stop.longitude, s1.latitude, s1.longitude)
+ - GPS.distance(stop.latitude, stop.longitude, s2.latitude,
+ s2.longitude))));
+
+ return stop.candidates.get(0);
+ }
+
+ private static List> buildPaths(String pathsJSON) {
+ List
> all = new ArrayList<>();
+ try {
+ JSONObject json = new JSONObject(pathsJSON);
+ JSONArray paths = json.getJSONArray("coordinates");
+ for (int i = 0; i < paths.length(); i++) {
+ JSONArray path = paths.getJSONArray(i);
+ List