--- android/DroidRadarService/src/dk/thoerup/droidradarservice/LocationService.java 2009/08/18 19:33:08 272
+++ android/DroidRadarService/src/dk/thoerup/droidradarservice/LocationService.java 2009/08/21 12:21:32 273
@@ -58,9 +58,12 @@
protected String locateDroids(Connection conn, long imei, double latitude, double longitude) throws SQLException {
//inner select is workaround from not being able to use a calculated column directly in where clause
final String SQL = "SELECT * FROM ( "+
- " select imei,handle,groupname,latitude,longitude,updated, earth_distance( ll_to_earth(latitude,longitude), ll_to_earth(?,?)) AS calcdist " +
- " from droidradar " +
- " WHERE imei <> ? AND updated > now() - interval '15 minutes' ) AS droidradar2 " +
+ " SELECT imei,handle,groupname,latitude,longitude, " +
+ " extract(epoch from now())::int - extract(epoch from updated)::int AS lastupdate, " +
+ " earth_distance( ll_to_earth(latitude,longitude), ll_to_earth(56,9))::int AS calcdist " +
+ " FROM droidradar " +
+ " WHERE imei <> ? AND updated > now() - interval '15 minutes' " +
+ " ) AS droidradar2 " +
"WHERE calcdist < 64000 " +
"ORDER BY calcdist ASC ";
@@ -89,7 +92,7 @@
buff.append("").append(res.getString(3) ) .append("\n");
buff.append("").append(res.getString(4) ) .append("\n");
buff.append("").append(res.getString(5) ) .append("\n");
- buff.append("").append(res.getTimestamp(6) ) .append("\n");
+ buff.append("").append(res.getInt(6) ) .append("\n");
buff.append("").append(res.getDouble(7) ) .append("\n");
buff.append("\n");