aboutsummaryrefslogtreecommitdiff
path: root/src/net/cbaines/suma/DataManager.java
diff options
context:
space:
mode:
authorChristopher Baines <cbaines8@gmail.com>2012-02-16 22:35:53 +0000
committerChristopher Baines <cbaines8@gmail.com>2012-02-16 22:35:53 +0000
commit3f10264e8dba0cd972647fbe1379f148b1ee6847 (patch)
tree2219a824f9aa865c1836998eb46757db6e708545 /src/net/cbaines/suma/DataManager.java
parent86629c735d4f7c48e1562825ca63ba3335363cbb (diff)
downloadsouthamptonuniversitymap-3f10264e8dba0cd972647fbe1379f148b1ee6847.tar
southamptonuniversitymap-3f10264e8dba0cd972647fbe1379f148b1ee6847.tar.gz
More progress on the route movement stuff, identified the bus stops that need addressing manualy, however I need to redefine the concept
of direction. As all of the routes that direction applies are circular, direction is only relevent for dealing with the bus stops that are present in the route more than once.
Diffstat (limited to 'src/net/cbaines/suma/DataManager.java')
-rw-r--r--src/net/cbaines/suma/DataManager.java76
1 files changed, 69 insertions, 7 deletions
diff --git a/src/net/cbaines/suma/DataManager.java b/src/net/cbaines/suma/DataManager.java
index 2af4b52..f065b07 100644
--- a/src/net/cbaines/suma/DataManager.java
+++ b/src/net/cbaines/suma/DataManager.java
@@ -269,13 +269,13 @@ public class DataManager {
route = new BusRoute(id, dataBits[1], dataBits[2].replace("\"", ""), uniLink);
- if (id == 326) {
- route.forwardDirection = "C";
- route.reverseDirection = "A";
- } else if (id == 329) {
- route.forwardDirection = "C";
- route.reverseDirection = "B";
- } else if (id == 327) {
+ if (id == 326) { // U1
+ route.forwardDirection = "A";
+ route.reverseDirection = "C";
+ } else if (id == 329) { // U2
+ route.forwardDirection = "B";
+ route.reverseDirection = "C";
+ } else if (id == 327) { // U6
route.forwardDirection = "H";
route.reverseDirection = "C";
}
@@ -801,4 +801,66 @@ public class DataManager {
return builder.toString();
}
+
+ public static void routeMovementTest(Context context) throws SQLException {
+
+ Dao<RouteStops, Integer> routeStopsDao = null;
+
+ if (helper == null)
+ helper = OpenHelperManager.getHelper(context, DatabaseHelper.class);
+ if (routeStopsDao == null)
+ routeStopsDao = helper.getRouteStopsDao();
+ if (busRouteDao == null)
+ busRouteDao = helper.getBusRouteDao();
+ if (busStopDao == null)
+ busStopDao = helper.getBusStopDao();
+
+ for (BusRoute busRoute : busRouteDao) {
+ if (!busRoute.code.startsWith("U") || busRoute.code.equals("U9")) {
+ continue;
+ }
+ List<RouteStops> routeStops = routeStopsDao.queryForEq(RouteStops.ROUTE_ID_FIELD_NAME, busRoute.id);
+
+ ArrayList<String> directions = new ArrayList<String>();
+ if (busRoute.forwardDirection != null) {
+ directions.add(busRoute.forwardDirection);
+ }
+ if (busRoute.reverseDirection != null) {
+ directions.add(busRoute.reverseDirection);
+ }
+ if (directions.size() == 0) {
+ directions.add(null);
+ }
+
+ BusStop startBusStop = null;
+
+ for (int moveAmount = 1; moveAmount >= -1; moveAmount = moveAmount - 2) {
+ for (String direction : directions) {
+ for (int busStop = 0; busStop < routeStops.size() && busStop >= 0; busStop = busStop + moveAmount) {
+ // if (routeStops.get(busStop).stop.equals(startBusStop))
+ // continue;
+ startBusStop = routeStops.get(busStop).stop;
+ busStopDao.refresh(startBusStop);
+
+ BusStop predictedNextStop = busRoute.moveInRoute(context, startBusStop, direction, moveAmount);
+
+ BusStop nextStop;
+ if (busStop == routeStops.size() - 1) {
+ nextStop = routeStops.get(0).stop;
+ } else {
+ nextStop = routeStops.get(busStop + 1).stop;
+ }
+ busStopDao.refresh(nextStop);
+
+ if (!nextStop.equals(predictedNextStop) && !startBusStop.equals(nextStop)) {
+ Log.e(TAG, "predicted: " + predictedNextStop + " next: " + nextStop);
+ Log.e(TAG, startBusStop.id + " " + nextStop.id);
+ return;
+ }
+ }
+ }
+ }
+ }
+
+ }
}