diff options
author | Christopher Baines <cbaines8@gmail.com> | 2012-02-08 18:11:17 +0000 |
---|---|---|
committer | Christopher Baines <cbaines8@gmail.com> | 2012-02-08 18:11:17 +0000 |
commit | 574ea86a77bf4911ae6956c9127ea3bf862352a3 (patch) | |
tree | 58a9b64e373011fd0f66e9da2259175006165753 /src/net | |
parent | 347f8a6187e7bc84bbc988bb171840224daae967 (diff) | |
download | southamptonuniversitymap-574ea86a77bf4911ae6956c9127ea3bf862352a3.tar southamptonuniversitymap-574ea86a77bf4911ae6956c9127ea3bf862352a3.tar.gz |
Begun the process of adding more of the bus data.
Diffstat (limited to 'src/net')
-rw-r--r-- | src/net/cbaines/suma/BusRoute.java | 9 | ||||
-rw-r--r-- | src/net/cbaines/suma/DataManager.java | 54 | ||||
-rw-r--r-- | src/net/cbaines/suma/SouthamptonUniversityMapActivity.java | 7 |
3 files changed, 24 insertions, 46 deletions
diff --git a/src/net/cbaines/suma/BusRoute.java b/src/net/cbaines/suma/BusRoute.java index b25b5d0..2dacfd2 100644 --- a/src/net/cbaines/suma/BusRoute.java +++ b/src/net/cbaines/suma/BusRoute.java @@ -63,10 +63,13 @@ public class BusRoute { @DatabaseField(canBeNull = true) String reverseDirection; + @DatabaseField(canBeNull = false) + boolean uniLink; + BusRoute() { } - public BusRoute(Integer id, String code, String label, String forwardDirection, String reverseDirection) { + public BusRoute(Integer id, String code, String label, String forwardDirection, String reverseDirection, boolean uniLink) { this.id = id.intValue(); this.code = code; this.label = label; @@ -74,8 +77,8 @@ public class BusRoute { this.reverseDirection = reverseDirection; } - public BusRoute(Integer id, String code, String label) { - this(id, code, label, null, null); + public BusRoute(Integer id, String code, String label, boolean uniLink) { + this(id, code, label, null, null, uniLink); } public String toString() { diff --git a/src/net/cbaines/suma/DataManager.java b/src/net/cbaines/suma/DataManager.java index 536cc64..770e649 100644 --- a/src/net/cbaines/suma/DataManager.java +++ b/src/net/cbaines/suma/DataManager.java @@ -62,9 +62,9 @@ import com.j256.ormlite.table.TableUtils; public class DataManager { - final static String TAG = "DataManager"; + private final static String TAG = "DataManager"; - final static String busStopUrl = "http://data.southampton.ac.uk/bus-stop/"; + private final static String busStopUrl = "http://data.southampton.ac.uk/bus-stop/"; private static DatabaseHelper helper; private static Dao<BusRoute, Integer> busRoutes; @@ -256,10 +256,17 @@ public class DataManager { String[] dataBits = strLine.split(","); BusRoute route; + + boolean uniLink = false; + int id = Integer.parseInt(dataBits[0]); + if (id == 326 || id == 468 || id == 327 || id == 329 || id == 354) { + uniLink = true; + } + if (dataBits.length > 3) { - route = new BusRoute(Integer.parseInt(dataBits[0]), dataBits[1], dataBits[2].replace("\"", ""), dataBits[3], dataBits[4]); + route = new BusRoute(id, dataBits[1], dataBits[2].replace("\"", ""), dataBits[3], dataBits[4], uniLink); } else { - route = new BusRoute(Integer.parseInt(dataBits[0]), dataBits[1], dataBits[2].replace("\"", "")); + route = new BusRoute(id, dataBits[1], dataBits[2].replace("\"", ""), uniLink); } // Log.i(TAG, "Loaded route " + route.id + " " + route.code + " " + route.label); busRouteDao.create(route); @@ -317,6 +324,8 @@ public class DataManager { stop.routes = (byte) (stop.routes | (1 << 3)); } else if (route.id == 354) { // U9 stop.routes = (byte) (stop.routes | (1 << 4)); + } else { + stop.routes = 0; } Log.v(TAG, "Stop routes " + stop.routes); @@ -331,43 +340,6 @@ public class DataManager { e.printStackTrace(); } - long sizeBeforeRemoval = busStopDao.countOf(); - - // Removing busstops not used by unilink busses - 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(); 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()); - */ - - QueryBuilder<RouteStops, Integer> routeStopsQueryBuilder = routeStopsDao.queryBuilder(); - routeStopsQueryBuilder.setCountOf(true); - routeStopsQueryBuilder.where().eq(RouteStops.STOP_ID_FIELD_NAME, stop); - - PreparedQuery<RouteStops> routeStopsPreparedQuery = routeStopsQueryBuilder.prepare(); - long num = routeStopsDao.countOf(routeStopsPreparedQuery); - // long num = routeStopsDao.query(routeStopsPreparedQuery).size(); - // Log.i(TAG, "Number is " + num); - if (num == 0) { - // Log.i(TAG, "Removing " + stop.id); - stop.uniLink = false; - if (onlyUniLink) { - busStopIter.remove(); - } - } else { - stop.uniLink = true; - } - } - - long sizeAfterRemoval = busStopDao.countOf(); - - Log.i(TAG, "Removed " + (sizeBeforeRemoval - sizeAfterRemoval) + " stops (from " + sizeBeforeRemoval + ") now have " + sizeAfterRemoval); - Log.i(TAG, "Finished loading bus data"); } diff --git a/src/net/cbaines/suma/SouthamptonUniversityMapActivity.java b/src/net/cbaines/suma/SouthamptonUniversityMapActivity.java index c67ceea..f624a43 100644 --- a/src/net/cbaines/suma/SouthamptonUniversityMapActivity.java +++ b/src/net/cbaines/suma/SouthamptonUniversityMapActivity.java @@ -76,7 +76,7 @@ import com.j256.ormlite.dao.Dao; public class SouthamptonUniversityMapActivity extends OrmLiteBaseActivity<DatabaseHelper> implements MapViewConstants, Runnable, RouteColorConstants, OnChildClickListener, OnItemClickListener, OnItemLongClickListener, OnSharedPreferenceChangeListener, Preferences { - private boolean useBundledDatabase = true; + private boolean useBundledDatabase = false; private MapView mapView; private MapController mapController; @@ -384,6 +384,9 @@ public class SouthamptonUniversityMapActivity extends OrmLiteBaseActivity<Databa Log.i(TAG, "Begining to show the route overlays at " + (System.currentTimeMillis() - startTime)); for (BusRoute busRoute : getHelper().getBusRouteDao()) { + if (!busRoute.uniLink) { + continue; + } Log.v(TAG, "Looking at showing " + busRoute.code + " route overlay"); if (activityPrefs.getBoolean("Bus Routes:" + busRoute.code, ROUTE_OVERLAY_ENABLED_BY_DEFAULT)) { showRouteOverlay(busRoute); @@ -476,7 +479,7 @@ public class SouthamptonUniversityMapActivity extends OrmLiteBaseActivity<Databa routeOverlayU1E.getPaint().setPathEffect(new DashPathEffect(new float[] { 20, 16 }, 0)); routeOverlayU1E.setEnabled(activityPrefs.getBoolean("Bus Routes:" + route.code, true)); - routeOverlays.put(new BusRoute(1000, "U1E", "U1e Route Label"), routeOverlayU1E); + routeOverlays.put(new BusRoute(1000, "U1E", "U1e Route Label", true), routeOverlayU1E); overlays.put("Bus Routes:" + route.code + "E", routeOverlayU1E); } else if (route.code.equals("U1N")) { resource = getResources().openRawResource(R.raw.u1n); |