diff options
author | Christopher Baines <cbaines8@gmail.com> | 2012-02-26 19:48:31 +0000 |
---|---|---|
committer | Christopher Baines <cbaines8@gmail.com> | 2012-02-26 19:48:31 +0000 |
commit | b640f758e603305a3c32c283c9237dbe47f2cdee (patch) | |
tree | 79d30398283ddca4b233f61886dbf10f7166935e /src | |
parent | 81c21ccf040f6c050525de99a8a8078bd8ef03ac (diff) | |
download | southamptonuniversitymap-b640f758e603305a3c32c283c9237dbe47f2cdee.tar southamptonuniversitymap-b640f758e603305a3c32c283c9237dbe47f2cdee.tar.gz |
Fixed another bug to do with a unreactive bus stop, improved the U1 route overlay.
Diffstat (limited to 'src')
-rw-r--r-- | src/net/cbaines/suma/BusStopOverlay.java | 4 | ||||
-rw-r--r-- | src/net/cbaines/suma/DataManager.java | 112 | ||||
-rw-r--r-- | src/net/cbaines/suma/DatabaseHelper.java | 2 | ||||
-rw-r--r-- | src/net/cbaines/suma/MapActivity.java | 27 |
4 files changed, 57 insertions, 88 deletions
diff --git a/src/net/cbaines/suma/BusStopOverlay.java b/src/net/cbaines/suma/BusStopOverlay.java index 176bd4f..7894be2 100644 --- a/src/net/cbaines/suma/BusStopOverlay.java +++ b/src/net/cbaines/suma/BusStopOverlay.java @@ -274,6 +274,8 @@ public class BusStopOverlay extends Overlay implements RouteColorConstants, Pref } private BusStop getSelectedItem(final MotionEvent event, final MapView mapView) { + Log.i(TAG, "Getting selected item"); + final Projection pj = mapView.getProjection(); final int eventX = (int) event.getX(); final int eventY = (int) event.getY(); @@ -281,7 +283,7 @@ public class BusStopOverlay extends Overlay implements RouteColorConstants, Pref /* These objects are created to avoid construct new ones every cycle. */ pj.fromMapPixels(eventX, eventY, mTouchScreenPoint); - for (int i = busStops.size() - 1; i > 0; i--) { + for (int i = busStops.size() - 1; i >= 0; i--) { BusStop busStop = busStops.get(i); pj.toPixels(busStop.point, mItemPoint); 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); diff --git a/src/net/cbaines/suma/DatabaseHelper.java b/src/net/cbaines/suma/DatabaseHelper.java index 2d8f9d2..4563d7c 100644 --- a/src/net/cbaines/suma/DatabaseHelper.java +++ b/src/net/cbaines/suma/DatabaseHelper.java @@ -40,7 +40,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper { private static final String DATABASE_PATH = "/data/data/net.cbaines.suma/databases/"; private static final String DATABASE_NAME = "data.db"; - private static final int DATABASE_VERSION = 39; + private static final int DATABASE_VERSION = 40; private static final String TAG = "DatabaseHelper"; diff --git a/src/net/cbaines/suma/MapActivity.java b/src/net/cbaines/suma/MapActivity.java index 33b12cd..14a1dd4 100644 --- a/src/net/cbaines/suma/MapActivity.java +++ b/src/net/cbaines/suma/MapActivity.java @@ -74,10 +74,10 @@ public class MapActivity extends OrmLiteBaseActivity<DatabaseHelper> implements OnItemClickListener, OnItemLongClickListener, OnSharedPreferenceChangeListener, Preferences { /** - * Enable to use the database in the assets folder, if its not enabled, the - * database is built from the csv files in the assets folder + * Enable to use the database in the assets folder, if its not enabled, the database is built from the csv files in the assets + * folder */ - private boolean useBundledDatabase = false; + private boolean useBundledDatabase = true; private MapView mapView; private MapController mapController; @@ -173,8 +173,7 @@ public class MapActivity extends OrmLiteBaseActivity<DatabaseHelper> implements OTHER_OVERLAY_NAMES }; /** - * The toast for this activity, storing the toast centrally allows it to be - * changed quickly, instead of a queue building up + * The toast for this activity, storing the toast centrally allows it to be changed quickly, instead of a queue building up */ Toast activityToast; @@ -205,10 +204,8 @@ public class MapActivity extends OrmLiteBaseActivity<DatabaseHelper> implements pastOverlays = (HashMap<String, Overlay>) getLastNonConfigurationInstance(); /* - * SensorManager mSensorManager = (SensorManager) - * getSystemService(Context.SENSOR_SERVICE); This code in the following - * constructor causes problems in some emulators, disable sensors to - * fix. + * SensorManager mSensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE); This code in the following + * constructor causes problems in some emulators, disable sensors to fix. */ Log.i(TAG, "Starting creating myLocationOverlay"); myLocationOverlay = new MyLocationOverlay(instance, mapView); @@ -555,10 +552,12 @@ public class MapActivity extends OrmLiteBaseActivity<DatabaseHelper> implements routeOverlayU1E.getPaint().setAlpha(145); routeOverlayU1E.getPaint().setStrokeWidth(12); routeOverlayU1E.getPaint().setPathEffect(new DashPathEffect(new float[] { 20, 16 }, 0)); - routeOverlayU1E.setEnabled(activityPrefs.getBoolean("Bus Routes:" + route.code, true)); busRouteOverlays.put(new BusRoute(1000, "U1E", "U1E Route Label", true), routeOverlayU1E); - overlays.put(BUS_ROUTE_OVERLAYS + route.code + "E", routeOverlayU1E); + overlays.put(BUS_ROUTE_OVERLAYS + "U1E", routeOverlayU1E); + synchronized (mapView.getOverlays()) { + mapView.getOverlays().add(routeOverlayU1E); + } } else if (route.code.equals("U1N")) { resource = getResources().openRawResource(R.raw.u1n); colour = U1N; @@ -1038,11 +1037,9 @@ public class MapActivity extends OrmLiteBaseActivity<DatabaseHelper> implements } /* - * public boolean onChildClick(ExpandableListView parent, View v, int - * groupPosition, int childPosition, long id) { + * public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) { * - * mapView.post(new Runnable() { public void run() { // - * updateEnabledOverlays(); TODO Fix whatever this did? + * mapView.post(new Runnable() { public void run() { // updateEnabledOverlays(); TODO Fix whatever this did? * mapView.invalidate(); } }); * * return true; } |