--- android/TrainInfoService/src/dk/thoerup/traininfoservice/StationDAO.java 2010/06/15 05:33:14 848 +++ android/TrainInfoService/src/dk/thoerup/traininfoservice/StationDAO.java 2010/06/15 05:46:38 849 @@ -103,8 +103,8 @@ return result; } - //the "hack" with max 1.0 degrees latitude and 2.0 degrees longitude is only valid since we only service danish trains - // in denmark 1.0dg latitude ~ 110km, 2.0dg longitude ~ 120km + //the "hack" with max 0.7 degrees latitude and 1.2 degrees longitude is only valid since we only service danish trains + // in denmark 0.7dg latitude ~ 77km, 1.2dg longitude ~ 76km // the ultra fast method (and only slightly inaccurate as long as we only cover a limited geographically area) // is using an aproximation of the length of 1 latitude degree and 1 longitude degree and just use pythagoras to @@ -113,7 +113,7 @@ public List getByLocationWorker(double latitude, double longitude, boolean geolimit) throws SQLException { - String limitExpression = geolimit == true ? "AND abs(latitude-?)<1.0 AND abs(longitude-?)<2.0 " : ""; + String limitExpression = geolimit == true ? "AND abs(latitude-?)<0.7 AND abs(longitude-?)<1.2 " : ""; String SQL = "SELECT id,name,latitude,longitude,stationcode_fjrn,stationcode_stog, stationcode_metro, address, " + "earth_distance( earth_coord, ll_to_earth(?,?))::int AS calcdist " + @@ -121,6 +121,8 @@ "WHERE enabled = true " + limitExpression + "ORDER BY calcdist ASC " + "LIMIT " + LOCATION_LIMIT; + + List result; Connection conn = null; @@ -137,7 +139,7 @@ } res = stmt.executeQuery(); result = convertResultset(res); - + } finally { if (res != null) res.close();