--- android/TrainInfoService/src/dk/thoerup/traininfoservice/LocateStations.java 2009/09/01 19:17:18 292 +++ android/TrainInfoService/src/dk/thoerup/traininfoservice/LocateStations.java 2009/09/10 19:00:31 309 @@ -30,9 +30,10 @@ protected String getStations(Connection conn, 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 name,latitude,longitude,address,stationcode, " + + " SELECT id,name,latitude,longitude,stationcode_fjrn,stationcode_stog, " + " earth_distance( ll_to_earth(latitude,longitude), ll_to_earth(?,?))::int AS calcdist " + " FROM trainstations " + + " WHERE latitude IS NOT NULL AND longitude IS NOT NULL " + " ) AS trainstations2 " + "ORDER BY calcdist ASC " + "LIMIT 4 "; @@ -57,12 +58,15 @@ while (res.next()) { buff.append("\n"); - buff.append("").append( res.getString(1) ) .append("\n"); - buff.append("").append( res.getDouble(2) ) .append("\n"); - buff.append("").append( res.getDouble(3) ) .append("\n"); - buff.append("
").append( res.getString(4) ) .append("
\n"); - buff.append("").append( res.getString(5) ) .append("\n"); - buff.append("").append( res.getDouble(6) ) .append("\n"); + buff.append("").append( res.getInt(1) ).append("\n"); + buff.append("").append( res.getString(2) ) .append("\n"); + buff.append("").append( res.getDouble(3) ) .append("\n"); + buff.append("").append( res.getDouble(4) ) .append("\n"); + res.getString(5); + buff.append("").append( !res.wasNull() ) .append("\n"); + res.getString(6); + buff.append("").append( !res.wasNull() ) .append("\n"); + buff.append("").append( res.getInt(7) ) .append("\n"); buff.append("
\n"); }