diff options
-rw-r--r-- | assets/data.db | bin | 492544 -> 490496 bytes | |||
-rw-r--r-- | res/raw/u1.gpx | 78 | ||||
-rw-r--r-- | res/values/strings.xml | 2 | ||||
-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 |
7 files changed, 122 insertions, 103 deletions
diff --git a/assets/data.db b/assets/data.db Binary files differindex c8bcc9e..a423ad8 100644 --- a/assets/data.db +++ b/assets/data.db diff --git a/res/raw/u1.gpx b/res/raw/u1.gpx index f4a2959..9c6b8b1 100644 --- a/res/raw/u1.gpx +++ b/res/raw/u1.gpx @@ -6,11 +6,7 @@ <author> <name>chrisb8</name> </author> - <copyright author="chrisb8"> - <year>2012</year> - <license>http://creativecommons.org/licenses/by-sa/2.5</license> - </copyright> - <bounds minlat="50.8931914" minlon="-1.413991" maxlat="50.9497096" maxlon="-1.3635693" /> + <bounds minlat="50.8931914" minlon="-1.413991" maxlat="50.9510875" maxlon="-1.3604805" /> </metadata> <trk> <trkseg> <trkpt lat="50.93856691501375" lon="-1.389858740861517"> @@ -707,30 +703,84 @@ </trkpt> <trkpt lat="50.94787044001649" lon="-1.3654181548452817"> </trkpt> - <trkpt lat="50.948059177930084" lon="-1.3651121761154554"> + <trkpt lat="50.94799248088663" lon="-1.3652821421898902"> </trkpt> - <trkpt lat="50.94804022862618" lon="-1.3647837196758723"> + <trkpt lat="50.948067321535454" lon="-1.3651520308296194"> </trkpt> - <trkpt lat="50.94793882936343" lon="-1.364517890495079"> + <trkpt lat="50.94808341786292" lon="-1.3649568415499584"> </trkpt> - <trkpt lat="50.94795700170869" lon="-1.3643255985280005"> + <trkpt lat="50.94801036871538" lon="-1.3647664852048824"> </trkpt> - <trkpt lat="50.94809228449993" lon="-1.3641333065609227"> + <trkpt lat="50.94789539666481" lon="-1.3644898844797206"> + </trkpt> + <trkpt lat="50.94794750081306" lon="-1.364244811945236"> + </trkpt> + <trkpt lat="50.94807803319722" lon="-1.3641149949354963"> </trkpt> <trkpt lat="50.94900492826686" lon="-1.363783976154064"> </trkpt> - <trkpt lat="50.94970959006663" lon="-1.3635692501241612"> + <trkpt lat="50.94922612448903" lon="-1.3637726107322674"> + </trkpt> + <trkpt lat="50.949925521864046" lon="-1.3633727410168355"> + </trkpt> + <trkpt lat="50.95088489724039" lon="-1.3622359652166096"> + </trkpt> + <trkpt lat="50.95094089866836" lon="-1.3621156524317457"> + </trkpt> + <trkpt lat="50.95099045865623" lon="-1.3620923608704711"> + </trkpt> + <trkpt lat="50.95104336591252" lon="-1.3620865692619502"> + </trkpt> + <trkpt lat="50.95108274694678" lon="-1.3620449660752485"> + </trkpt> + <trkpt lat="50.95108747425934" lon="-1.3619648508105848"> + </trkpt> + <trkpt lat="50.95107460386968" lon="-1.3618887786819045"> + </trkpt> + <trkpt lat="50.95103658000929" lon="-1.3618312836604143"> + </trkpt> + <trkpt lat="50.95098772147682" lon="-1.3617343397610975"> + </trkpt> + <trkpt lat="50.95079757702995" lon="-1.360900763901581"> + </trkpt> + <trkpt lat="50.950790929645436" lon="-1.3607929067832814"> + </trkpt> + <trkpt lat="50.9508072158976" lon="-1.3606658025597322"> + </trkpt> + <trkpt lat="50.95080857308502" lon="-1.360571012969288"> + </trkpt> + <trkpt lat="50.9507665002565" lon="-1.3604956121587082"> + </trkpt> + <trkpt lat="50.950694569203414" lon="-1.3604805319965916"> + </trkpt> + <trkpt lat="50.950634852772886" lon="-1.3605494698805511"> + </trkpt> + <trkpt lat="50.95062399523185" lon="-1.3607002715017114"> + </trkpt> + <trkpt lat="50.95065928223103" lon="-1.3608704619027356"> + </trkpt> + <trkpt lat="50.950896790182426" lon="-1.3619023758532476"> + </trkpt> + <trkpt lat="50.95091579076608" lon="-1.362035943003418"> + </trkpt> + <trkpt lat="50.95088351253571" lon="-1.3622325277283418"> + </trkpt> + <trkpt lat="50.949926990872406" lon="-1.36337114827857"> + </trkpt> + <trkpt lat="50.94922612448908" lon="-1.3637680407530277"> </trkpt> <trkpt lat="50.94900492826686" lon="-1.3637807712879466"> </trkpt> - <trkpt lat="50.948090265356676" lon="-1.3641333065609227"> + <trkpt lat="50.948079407221186" lon="-1.3641128406266225"> </trkpt> - <trkpt lat="50.94795700170868" lon="-1.3643288033941185"> + <trkpt lat="50.947946822177556" lon="-1.3642437081936065"> </trkpt> - <trkpt lat="50.94793882936341" lon="-1.3645243002273146"> + <trkpt lat="50.94789878984583" lon="-1.3644909084397718"> </trkpt> <trkpt lat="50.9478072601364" lon="-1.3647390617373651"> </trkpt> + <trkpt lat="50.94772509800031" lon="-1.3649385299245318"> + </trkpt> <trkpt lat="50.947719833750206" lon="-1.365151545868109"> </trkpt> <trkpt lat="50.94773715200268" lon="-1.3655162727698977"> diff --git a/res/values/strings.xml b/res/values/strings.xml index e95a802..6333664 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -102,7 +102,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.< <!-- About Strings --> <string name="about">About</string> <string name="about_version">Version</string> - <string name="about_version_summary">0.3 (alpha)</string> + <string name="about_version_summary">0.4 (alpha)</string> <string name="about_copyright">Copyright</string> <string name="about_copyright_summary">© 2012, Christopher Baines</string> <string name="about_license">License</string> 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; } |