diff options
author | Christopher Baines <cbaines8@gmail.com> | 2012-02-18 23:02:43 +0000 |
---|---|---|
committer | Christopher Baines <cbaines8@gmail.com> | 2012-02-18 23:02:43 +0000 |
commit | 8fcfee6f01df391476a884c73a8c6c9259e4165b (patch) | |
tree | c16d2f9175a1cf0eed9979ac65956a4d87bdabe8 | |
parent | 4ee5e20a86f34961ffaf2081f2602e1486de6f92 (diff) | |
download | southamptonuniversitymap-8fcfee6f01df391476a884c73a8c6c9259e4165b.tar southamptonuniversitymap-8fcfee6f01df391476a884c73a8c6c9259e4165b.tar.gz |
Ok, there are now non uni-link bus stops, but they cant be switched off....
-rw-r--r-- | assets/data.db | bin | 492544 -> 492544 bytes | |||
-rw-r--r-- | src/net/cbaines/suma/DataManager.java | 131 | ||||
-rw-r--r-- | src/net/cbaines/suma/MapActivity.java | 7 |
3 files changed, 58 insertions, 80 deletions
diff --git a/assets/data.db b/assets/data.db Binary files differindex a9a0745..a128ffd 100644 --- a/assets/data.db +++ b/assets/data.db diff --git a/src/net/cbaines/suma/DataManager.java b/src/net/cbaines/suma/DataManager.java index 140ddfa..c6a3a36 100644 --- a/src/net/cbaines/suma/DataManager.java +++ b/src/net/cbaines/suma/DataManager.java @@ -81,7 +81,7 @@ public class DataManager { TableUtils.clearTable(helper.getConnectionSource(), Building.class); - Log.i(TAG, "Loading buildings from csv"); + Log.i(TAG, "Begining loading buildings from csv"); HashMap<String, GeoPoint> buildingPoints = new HashMap<String, GeoPoint>(); @@ -103,26 +103,10 @@ public class DataManager { bufferedReader.close(); } catch (IOException e) { - // TODO Auto-generated catch block e.printStackTrace(); } - Log.i(TAG, "Number of building points " + buildingPoints.size()); - - /* - * inputStream = context.getResources().openRawResource(R.raw.buildings_shapes); bufferedReader = new - * BufferedReader(new InputStreamReader(inputStream)); - * - * try { String def = bufferedReader.readLine(); // Log.i(TAG, "Reading the definition " + def); - * - * while ((strLine = bufferedReader.readLine()) != null) { // Log.i(TAG, "Data: " + strLine); String[] dataBits - * = strLine.split(","); Polygon poly = Util.csPolygonToPolygon(strLine.split("\"")[1]); // Log.i(TAG, - * "Creating building with id " + dataBits[0] + " and " + poly); buildingPolys.put(dataBits[0], poly); } - * - * bufferedReader.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } - * - * Log.i(TAG, "Number of polys points " + buildingPolys.size()); - */ + // Log.i(TAG, "Number of building points " + buildingPoints.size()); inputStream = context.getAssets().open("building_estates.csv"); bufferedReader = new BufferedReader(new InputStreamReader(inputStream)); @@ -238,12 +222,10 @@ 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; // TODO Much - // hackage + + 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; // TODO Much - // hackage + + 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()); @@ -254,7 +236,6 @@ public class DataManager { bufferedReader.close(); } catch (IOException e) { - // TODO Auto-generated catch block Log.e(TAG, "Line: " + strLine); e.printStackTrace(); } @@ -277,10 +258,8 @@ public class DataManager { boolean uniLink; int id = Integer.parseInt(dataBits[0]); if (id == 326 || id == 468 || id == 327 || id == 329 || id == 354) { - Log.e(TAG, "Route " + id + " " + dataBits[1] + " is uni link"); uniLink = true; } else { - Log.e(TAG, "Route " + id + " " + dataBits[1] + " is not uni link"); uniLink = false; } @@ -304,7 +283,6 @@ public class DataManager { bufferedReader.close(); } catch (IOException e) { - // TODO Auto-generated catch block Log.e(TAG, "Line: " + strLine); e.printStackTrace(); } @@ -322,16 +300,16 @@ public class DataManager { // Log.i(TAG, "Data: " + strLine); String[] dataBits = strLine.split(","); - BusStop stop = busStopDao.queryForId(dataBits[2]); - if (stop != null) { + BusStop busStop = busStopDao.queryForId(dataBits[2]); + if (busStop != null) { // Log.i(TAG, "Found stop " + stop.id); } else { Log.w(TAG, "No stop found for " + dataBits[2]); continue; } - BusRoute route = busRouteDao.queryForId(Integer.parseInt(dataBits[0])); - if (route != null) { + BusRoute busRoute = busRouteDao.queryForId(Integer.parseInt(dataBits[0])); + if (busRoute != null) { // Log.i(TAG, "Found route " + route.id); } else { Log.w(TAG, "No route found for " + dataBits[0]); @@ -339,65 +317,64 @@ public class DataManager { } int sequence = Integer.parseInt(dataBits[1]); - Log.i(TAG, "Creating RouteStop " + stop.id + " " + route.code + " " + sequence); - - routeStopsDao.create(new RouteStops(stop, route, sequence)); - - if (route.id == 326) { // U1 - stop.routes = (byte) (stop.routes | 1); - } else if (route.id == 468) { // U1N - stop.routes = (byte) (stop.routes | (1 << 1)); - } else if (route.id == 329) { // U2 - stop.routes = (byte) (stop.routes | (1 << 2)); - } else if (route.id == 327) { // U6 - stop.routes = (byte) (stop.routes | (1 << 3)); - } else if (route.id == 354) { // U9 - stop.routes = (byte) (stop.routes | (1 << 4)); + Log.i(TAG, "Creating RouteStop " + busStop.id + " " + busRoute.code + " " + sequence); + + routeStopsDao.create(new RouteStops(busStop, busRoute, sequence)); + + if (busRoute.id == 326) { // U1 + busStop.routes = (byte) (busStop.routes | 1); + busStop.uniLink = true; + } else if (busRoute.id == 468) { // U1N + busStop.routes = (byte) (busStop.routes | (1 << 1)); + busStop.uniLink = true; + } else if (busRoute.id == 329) { // U2 + busStop.routes = (byte) (busStop.routes | (1 << 2)); + busStop.uniLink = true; + } else if (busRoute.id == 327) { // U6 + busStop.routes = (byte) (busStop.routes | (1 << 3)); + busStop.uniLink = true; + } else if (busRoute.id == 354) { // U9 + busStop.routes = (byte) (busStop.routes | (1 << 4)); + busStop.uniLink = true; } else { - stop.routes = 0; + busStop.routes = 0; } - Log.v(TAG, "Stop routes " + stop.routes); - busStopDao.update(stop); + // Log.v(TAG, "Stop routes " + busStop.routes); + busStopDao.update(busStop); } bufferedReader.close(); } catch (IOException e) { - // TODO Auto-generated catch block Log.e(TAG, "Line: " + strLine); e.printStackTrace(); } - 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; - } else { - stop.uniLink = true; - } - busStopDao.update(stop); - } + /* + * 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(); 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); } + */ Log.i(TAG, "Finished loading bus data"); } diff --git a/src/net/cbaines/suma/MapActivity.java b/src/net/cbaines/suma/MapActivity.java index c0a2aba..aa621da 100644 --- a/src/net/cbaines/suma/MapActivity.java +++ b/src/net/cbaines/suma/MapActivity.java @@ -78,7 +78,7 @@ public class MapActivity extends OrmLiteBaseActivity<DatabaseHelper> implements * 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 = true; + private boolean useBundledDatabase = false; private MapView mapView; private MapController mapController; @@ -823,8 +823,9 @@ public class MapActivity extends OrmLiteBaseActivity<DatabaseHelper> implements busStops = getHelper().getBusStopDao().queryForEq(BusStop.UNI_LINK_FIELD_NAME, false); - Log.v(TAG, "Finished fetching non Uni-Link BusStops at " - + (System.currentTimeMillis() - startTime)); + Log.v(TAG, + "Finished fetching " + busStops.size() + " non Uni-Link BusStops at " + + (System.currentTimeMillis() - startTime)); nonUniLinkBusStopOverlay = new BusStopOverlay(instance, busStops); } catch (SQLException e) { |