aboutsummaryrefslogtreecommitdiff
path: root/src/net/cbaines/suma/DataManager.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/net/cbaines/suma/DataManager.java')
-rw-r--r--src/net/cbaines/suma/DataManager.java112
1 files changed, 41 insertions, 71 deletions
diff --git a/src/net/cbaines/suma/DataManager.java b/src/net/cbaines/suma/DataManager.java
index fbede76..2234328 100644
--- a/src/net/cbaines/suma/DataManager.java
+++ b/src/net/cbaines/suma/DataManager.java
@@ -137,13 +137,9 @@ public class DataManager {
/*
* Polygon poly = buildingPolys.get(dataBits[1]);
*
- * if (poly != null) { bdg.outline = poly; // Log.i(TAG,
- * "Adding building " + key + " " +
- * bdg.point.getLatitudeE6() + " " +
- * bdg.point.getLongitudeE6() + " " + poly); } else { //
- * Log.i(TAG, "Adding building " + key + " " +
- * bdg.point.getLatitudeE6() + " " +
- * bdg.point.getLongitudeE6()); }
+ * if (poly != null) { bdg.outline = poly; // Log.i(TAG, "Adding building " + key + " " +
+ * bdg.point.getLatitudeE6() + " " + bdg.point.getLongitudeE6() + " " + poly); } else { // Log.i(TAG,
+ * "Adding building " + key + " " + bdg.point.getLatitudeE6() + " " + bdg.point.getLongitudeE6()); }
*/
// Log.i(TAG, "Creating building " + bdg.id + " " + bdg.name
@@ -167,13 +163,9 @@ public class DataManager {
/*
* Polygon poly = buildingPolys.get(dataBits[1]);
*
- * if (poly != null) { bdg.outline = poly; // Log.i(TAG,
- * "Adding building " + key + " " +
- * bdg.point.getLatitudeE6() + " " +
- * bdg.point.getLongitudeE6() + " " + poly); } else { //
- * Log.i(TAG, "Adding building " + key + " " +
- * bdg.point.getLatitudeE6() + " " +
- * bdg.point.getLongitudeE6()); }
+ * if (poly != null) { bdg.outline = poly; // Log.i(TAG, "Adding building " + key + " " +
+ * bdg.point.getLatitudeE6() + " " + bdg.point.getLongitudeE6() + " " + poly); } else { // Log.i(TAG,
+ * "Adding building " + key + " " + bdg.point.getLatitudeE6() + " " + bdg.point.getLongitudeE6()); }
*/
// Log.i(TAG, "Creating building " + bdg.id + " " + bdg.name
@@ -192,17 +184,13 @@ public class DataManager {
}
/*
- * for (Iterator<String> iter = buildingPoints.keySet().iterator();
- * iter.hasNext();) { String key = iter.next();
+ * for (Iterator<String> iter = buildingPoints.keySet().iterator(); iter.hasNext();) { String key = iter.next();
*
- * Building bdg = new Building(key, buildingPoints.get(key), false);
- * Polygon poly = buildingPolys.get(key);
+ * Building bdg = new Building(key, buildingPoints.get(key), false); Polygon poly = buildingPolys.get(key);
*
- * if (poly != null) { bdg.outline = poly; // Log.i(TAG,
- * "Adding building " + key + " " + bdg.point.getLatitudeE6() + " " +
- * bdg.point.getLongitudeE6() + " " + poly); } else { // Log.i(TAG,
- * "Adding building " + key + " " + bdg.point.getLatitudeE6() + " " +
- * bdg.point.getLongitudeE6()); }
+ * if (poly != null) { bdg.outline = poly; // Log.i(TAG, "Adding building " + key + " " + bdg.point.getLatitudeE6() + " "
+ * + bdg.point.getLongitudeE6() + " " + poly); } else { // Log.i(TAG, "Adding building " + key + " " +
+ * bdg.point.getLatitudeE6() + " " + bdg.point.getLongitudeE6()); }
*
* buildingDao.create(bdg); }
*/
@@ -239,18 +227,18 @@ public class DataManager {
// Log.i(TAG, "Whole " + dataBits[3] + " First bit " +
// quBitsLat[0] + " last bit " + quBitsLat[1]);
- double lat = Double.valueOf(quBitsLat[0])
- + Double.valueOf(quBitsLat[1].substring(0, quBitsLat[1].length() - 1)) / 60d;
+ double lat = Double.valueOf(quBitsLat[0]) + Double.valueOf(quBitsLat[1].substring(0, quBitsLat[1].length() - 1))
+ / 60d;
// Log.i(TAG, "Whole " + dataBits[4] + " First bit " +
// quBitsLng[0] + " last bit " + quBitsLng[1]);
- double lng = Double.valueOf(quBitsLng[0])
- + Double.valueOf(quBitsLng[1].substring(0, quBitsLng[1].length() - 1)) / 60d;
+ double lng = Double.valueOf(quBitsLng[0]) + Double.valueOf(quBitsLng[1].substring(0, quBitsLng[1].length() - 1))
+ / 60d;
GeoPoint point = new GeoPoint((int) (lat * 1e6), (int) (lng * -1e6));
// Log.i(TAG, "Lat " + point.getLatitudeE6() + " lng " +
// point.getLongitudeE6());
- busStopDao.create(new BusStop(dataBits[0].replace("\"", ""), dataBits[1].replace("\"", ""), dataBits[2]
- .replace("\"", ""), point));
+ busStopDao.create(new BusStop(dataBits[0].replace("\"", ""), dataBits[1].replace("\"", ""), dataBits[2].replace(
+ "\"", ""), point));
}
@@ -359,10 +347,6 @@ public class DataManager {
busStop.uniLink = true;
}
- if ((busStop.routes != 0) != busStop.uniLink || busStop.id.equals("SN120553")) {
- Log.e(TAG, busStop.id + " " + busStop.routes + " " + busStop.uniLink);
- }
-
// Log.v(TAG, "Stop routes " + busStop.routes);
busStopDao.update(busStop);
@@ -375,36 +359,26 @@ public class DataManager {
}
/*
- * for (Iterator<BusStop> busStopIter = busStopDao.iterator();
- * busStopIter.hasNext();) { BusStop stop = busStopIter.next(); //
- * Log.i(TAG, "Looking at stop " + stop.id);
+ * for (Iterator<BusStop> busStopIter = busStopDao.iterator(); busStopIter.hasNext();) { BusStop stop =
+ * busStopIter.next(); // Log.i(TAG, "Looking at stop " + stop.id);
*
*
- * QueryBuilder<RouteStops, Integer> routeStopsQueryBuilder =
- * routeStopsDao.queryBuilder();
+ * QueryBuilder<RouteStops, Integer> routeStopsQueryBuilder = routeStopsDao.queryBuilder();
* routeStopsQueryBuilder.where().eq(columnName, value)
*
- * DeleteBuilder<BusStop, String> deleteBuilder =
- * busStopDao.deleteBuilder(); // only delete the rows where password is
- * null deleteBuilder.where().in(RouteStops.STOP_ID_FIELD_NAME, objects)
- * accountDao.delete(deleteBuilder.prepare());
+ * DeleteBuilder<BusStop, String> deleteBuilder = busStopDao.deleteBuilder(); // only delete the rows where password is
+ * null deleteBuilder.where().in(RouteStops.STOP_ID_FIELD_NAME, objects) accountDao.delete(deleteBuilder.prepare());
*
*
- * QueryBuilder<RouteStops, Integer> routeStopsQueryBuilder =
- * routeStopsDao.queryBuilder();
- * routeStopsQueryBuilder.setCountOf(true);
- * routeStopsQueryBuilder.where().eq(RouteStops.STOP_ID_FIELD_NAME,
- * stop);
+ * QueryBuilder<RouteStops, Integer> routeStopsQueryBuilder = routeStopsDao.queryBuilder();
+ * routeStopsQueryBuilder.setCountOf(true); routeStopsQueryBuilder.where().eq(RouteStops.STOP_ID_FIELD_NAME, stop);
*
- * PreparedQuery<RouteStops> routeStopsPreparedQuery =
- * routeStopsQueryBuilder.prepare(); List<RouteStops> routeStops =
- * routeStopsDao.query(routeStopsPreparedQuery); // long num =
- * routeStopsDao.query(routeStopsPreparedQuery).size(); // Log.i(TAG,
- * "Number is " + num);
+ * PreparedQuery<RouteStops> routeStopsPreparedQuery = routeStopsQueryBuilder.prepare(); List<RouteStops> routeStops =
+ * routeStopsDao.query(routeStopsPreparedQuery); // long num = routeStopsDao.query(routeStopsPreparedQuery).size(); //
+ * Log.i(TAG, "Number is " + num);
*
- * stop.uniLink = false; for (RouteStops routeStop : routeStops) { if
- * (routeStop.busRoute.uniLink) { stop.uniLink = true; } }
- * busStopDao.update(stop); }
+ * stop.uniLink = false; for (RouteStops routeStop : routeStops) { if (routeStop.busRoute.uniLink) { stop.uniLink = true;
+ * } } busStopDao.update(stop); }
*/
Log.i(TAG, "Finished loading bus data");
@@ -454,8 +428,8 @@ public class DataManager {
Log.i(TAG, "Loaded sites from csv");
}
- private static Stop getStop(Context context, JSONObject stopObj, Set<BusRoute> routes, BusStop busStop)
- throws SQLException, JSONException {
+ private static Stop getStop(Context context, JSONObject stopObj, Set<BusRoute> routes, BusStop busStop) throws SQLException,
+ JSONException {
if (helper == null)
helper = OpenHelperManager.getHelper(context, DatabaseHelper.class);
@@ -504,13 +478,12 @@ public class DataManager {
route = tempRoute;
dir = null;
}
- } else {
- if (tempRoute == null) {
- Log.e(TAG, "tempRoute == null");
- }
- if (tempRoute.code == null) {
- Log.e(TAG, "tempRoute.code == null");
+ } else if (name.equals("U1E")) {
+ if (tempRoute.code.equals("U1")) {
+ route = tempRoute;
+ dir = "E";
}
+ } else {
if (tempRoute.code.equals(name.substring(0, 2))) {
route = tempRoute;
if (route.forwardDirection.equals(name.substring(2))) {
@@ -580,11 +553,9 @@ public class DataManager {
List<RouteStops> routeStops = routeStopsDao.query(routeStopsPreparedQuery);
if (routeStops.size() > 0) {
- Log.i(TAG, "Found " + routeStops.size() + " stops matching the destStop " + destStop + " on route "
- + route.code);
+ Log.i(TAG, "Found " + routeStops.size() + " stops matching the destStop " + destStop + " on route " + route.code);
} else {
- Log.w(TAG, "Found " + routeStops.size() + " stops matching the destStop " + destStop + " on route "
- + route.code);
+ Log.w(TAG, "Found " + routeStops.size() + " stops matching the destStop " + destStop + " on route " + route.code);
}
}
@@ -652,8 +623,7 @@ public class DataManager {
if (route != null) {
busRoutes.add(route);
} else {
- throw new RuntimeException("Route not found " + key.substring(key.length() - 3, key.length()) + " "
- + key);
+ throw new RuntimeException("Route not found " + key.substring(key.length() - 3, key.length()) + " " + key);
}
}
@@ -749,8 +719,8 @@ public class DataManager {
continue;
}
- Log.v(TAG, "Found stop for a unidentified " + stop.bus.toString() + " at " + stop.busStop.id
- + " at " + stop.arivalTime);
+ Log.v(TAG, "Found stop for a unidentified " + stop.bus.toString() + " at " + stop.busStop.id + " at "
+ + stop.arivalTime);
timetable.add(stop);