aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristopher Baines <cbaines8@gmail.com>2012-02-17 20:50:17 +0000
committerChristopher Baines <cbaines8@gmail.com>2012-02-17 20:50:17 +0000
commit190cb3c6a16d6c65764f18afd5f5f19f1a912aac (patch)
treebbc997b60a30ea92568142db57de897c9ca49c16 /src
parentfd428ee33771a7bf95abad4d2e7beb882a368d41 (diff)
downloadsouthamptonuniversitymap-190cb3c6a16d6c65764f18afd5f5f19f1a912aac.tar
southamptonuniversitymap-190cb3c6a16d6c65764f18afd5f5f19f1a912aac.tar.gz
Fixed a bug with dest stop detection, and added a safeguard on the bus activity.
Diffstat (limited to 'src')
-rw-r--r--src/net/cbaines/suma/BuildingNumOverlay.java4
-rw-r--r--src/net/cbaines/suma/BusActivity.java11
-rw-r--r--src/net/cbaines/suma/BusRoute.java25
-rw-r--r--src/net/cbaines/suma/BusStopOverlay.java4
-rw-r--r--src/net/cbaines/suma/DataManager.java14
5 files changed, 45 insertions, 13 deletions
diff --git a/src/net/cbaines/suma/BuildingNumOverlay.java b/src/net/cbaines/suma/BuildingNumOverlay.java
index 47bee3c..9825616 100644
--- a/src/net/cbaines/suma/BuildingNumOverlay.java
+++ b/src/net/cbaines/suma/BuildingNumOverlay.java
@@ -181,7 +181,7 @@ public class BuildingNumOverlay extends Overlay {
@Override
public boolean onSingleTapUp(final MotionEvent event, final MapView mapView) {
- Log.v(TAG, "Pointer count for onSingleTapUp is " + event.getPointerCount() + " " + event.getAction());
+ Log.v(TAG, "Pointer count for onSingleTapUp is " + event.getPointerCount() + " " + event.getAction() + " " + event.describeContents());
if (event.getPointerCount() != 1) {
Log.v(TAG, "Pointer count for onSingleTapUp not 1, ignoring");
return false;
@@ -218,7 +218,7 @@ public class BuildingNumOverlay extends Overlay {
@Override
public boolean onLongPress(final MotionEvent event, final MapView mapView) {
- Log.v(TAG, "Pointer count for onLongPress is " + event.getPointerCount() + " " + event.getAction());
+ Log.v(TAG, "Pointer count for onLongPress is " + event.getPointerCount() + " " + event.getAction() + " " + event.describeContents());
if (event.getPointerCount() != 1) {
Log.v(TAG, "Pointer count for onLongPress not 1, ignoring");
return false;
diff --git a/src/net/cbaines/suma/BusActivity.java b/src/net/cbaines/suma/BusActivity.java
index 4b59117..f68c051 100644
--- a/src/net/cbaines/suma/BusActivity.java
+++ b/src/net/cbaines/suma/BusActivity.java
@@ -157,6 +157,12 @@ public class BusActivity extends OrmLiteBaseActivity<DatabaseHelper> implements
busStopsActive = new ArrayList<Boolean>();
busStopsActive.add(false);
+ if (bus.destination != null) {
+ Log.i(TAG, "Bus destination is " + bus.destination);
+ } else {
+ Log.i(TAG, "Bus destination is null");
+ }
+
for (int i = 0;; i++) {
BusStop nextStop = bus.route.moveInRoute(instance, busStops.get(i), bus.direction, 1);
@@ -166,6 +172,11 @@ public class BusActivity extends OrmLiteBaseActivity<DatabaseHelper> implements
busStops.add(nextStop);
busStopsActive.add(false);
+
+ if (busStops.size() > 50) {
+ Log.e(TAG, "Got more than 50 bus stops");
+ break;
+ }
}
refreshData = new Runnable() {
diff --git a/src/net/cbaines/suma/BusRoute.java b/src/net/cbaines/suma/BusRoute.java
index e1bf65b..cdb0e4d 100644
--- a/src/net/cbaines/suma/BusRoute.java
+++ b/src/net/cbaines/suma/BusRoute.java
@@ -62,9 +62,25 @@ public class BusRoute {
@DatabaseField(canBeNull = false)
String label;
+ /**
+ * The direction the bus is travelling if it is moving through the route and sequence is increasing.
+ * <ul>
+ * <li>U1 = A</li>
+ * <li>U2 = B</li>
+ * <li>U6 = H</li>
+ * </ul>
+ */
@DatabaseField(canBeNull = true)
String forwardDirection;
+ /**
+ * The direction the bus is travelling if it is moving through the route and sequence is decreasing.
+ * <ul>
+ * <li>U1 = C</li>
+ * <li>U2 = C</li>
+ * <li>U6 = C</li>
+ * </ul>
+ */
@DatabaseField(canBeNull = true)
String reverseDirection;
@@ -304,14 +320,13 @@ public class BusRoute {
Log.e(TAG, "Error, unknown bus stop " + busStop.id + " (" + busStop.description + ") that appears mutiple times in " + toString());
throw new RuntimeException("Error, unknown bus stop " + busStop.id + " that appears mutiple times in " + toString());
}
+ Log.v(TAG, "Selecting " + stopIndex + " for " + busStop.id + " as direction == " + direction);
}
}
}
if (moveAmount > 0) {
- Log.v(TAG,
- "Moving forward in direction " + direction + " " + moveAmount + " stops from " + busStop + " (" + stopIndex + "/"
- + routeStopsFound.size() + ")");
+ Log.v(TAG, "Moving forward " + moveAmount + " stops from " + busStop + " (" + stopIndex + "/" + routeStopsFound.size() + ")");
int stopWanted = stopIndex + moveAmount;
if ((stopWanted + 1) > routeStopsFound.size()) {
Log.v(TAG, "Off the end of the route");
@@ -334,9 +349,7 @@ public class BusRoute {
Log.v(TAG, "stopWanted " + stopWanted);
busStopDao.refresh(routeStopsFound.get(stopWanted).stop);
- Log.v(TAG,
- "Moving backwards in direction " + direction + " " + moveAmount + " stops from " + busStop + " to "
- + routeStopsFound.get(stopWanted).stop + " in route " + this);
+ Log.v(TAG, "Moving backwards " + moveAmount + " stops from " + busStop + " to " + routeStopsFound.get(stopWanted).stop + " in route " + this);
return routeStopsFound.get(stopWanted).stop;
}
diff --git a/src/net/cbaines/suma/BusStopOverlay.java b/src/net/cbaines/suma/BusStopOverlay.java
index 58f5bb0..6ef956b 100644
--- a/src/net/cbaines/suma/BusStopOverlay.java
+++ b/src/net/cbaines/suma/BusStopOverlay.java
@@ -226,7 +226,7 @@ public class BusStopOverlay extends Overlay implements RouteColorConstants {
public boolean onDoubleTap(final MotionEvent event, final MapView mapView) {
- Log.v(TAG, "Pointer count for onDoubleTap is " + event.getPointerCount() + " " + event.getAction());
+ Log.v(TAG, "Pointer count for onDoubleTap is " + event.getPointerCount() + " " + event.getAction() + " " + event.describeContents());
if (event.getPointerCount() != 1) {
Log.v(TAG, "Pointer count for onDoubleTap not 1, ignoring");
return false;
@@ -254,7 +254,7 @@ public class BusStopOverlay extends Overlay implements RouteColorConstants {
@Override
public boolean onLongPress(final MotionEvent event, final MapView mapView) {
- Log.v(TAG, "Pointer count for onLongPress is " + event.getPointerCount() + " " + event.getAction());
+ Log.v(TAG, "Pointer count for onLongPress is " + event.getPointerCount() + " " + event.getAction() + " " + event.describeContents());
if (event.getPointerCount() != 1) {
Log.v(TAG, "Pointer count for onLongPress not 1, ignoring");
return false;
diff --git a/src/net/cbaines/suma/DataManager.java b/src/net/cbaines/suma/DataManager.java
index f065b07..4959865 100644
--- a/src/net/cbaines/suma/DataManager.java
+++ b/src/net/cbaines/suma/DataManager.java
@@ -433,6 +433,9 @@ public class DataManager {
helper = OpenHelperManager.getHelper(context, DatabaseHelper.class);
if (busRouteDao == null)
busRouteDao = helper.getBusRouteDao();
+ Dao<RouteStops, Integer> routeStopsDao = null;
+ if (routeStopsDao == null)
+ routeStopsDao = helper.getRouteStopsDao();
if (busDao == null)
busDao = helper.getBusDao();
if (busStopDao == null)
@@ -513,13 +516,11 @@ public class DataManager {
BusStop destStop = null;
if (destString.equals("Central Station")) {
- destStop = busStopDao.queryForId("SNA19709");
+ destStop = busStopDao.queryForId("SN120520");
} else if (destString.equals("Civic Centre")) {
destStop = busStopDao.queryForId("SN120527");
} else if (destString.equals("City DG4")) {
destStop = busStopDao.queryForId("HAA13579");
- } else if (destString.equals("Central Station")) {
- destStop = busStopDao.queryForId("SN120520");
} else if (destString.equals("Airport")) {
destStop = busStopDao.queryForId("HA030184");
} else if (destString.equals("City, Town Quay")) {
@@ -540,6 +541,13 @@ public class DataManager {
Log.e(TAG, "Unknown end dest " + destString + " for route " + route.code);
}
+ QueryBuilder<RouteStops, Integer> routeStopsQueryBuilder = routeStopsDao.queryBuilder();
+ routeStopsQueryBuilder.where().eq(RouteStops.ROUTE_ID_FIELD_NAME, route.id).and().eq(RouteStops.STOP_ID_FIELD_NAME, destStop.id);
+ PreparedQuery<RouteStops> routeStopsPreparedQuery = routeStopsQueryBuilder.prepare();
+
+ List<RouteStops> routeStops = routeStopsDao.query(routeStopsPreparedQuery);
+ Log.i(TAG, "Found " + routeStops.size() + " stops matching the destStop " + destStop + " on route " + route.code);
+
Date now = new Date(System.currentTimeMillis());
String busID = null;