/[projects]/android/TrainInfoService/src/dk/thoerup/traininfoservice/StationDAO.java
ViewVC logotype

Diff of /android/TrainInfoService/src/dk/thoerup/traininfoservice/StationDAO.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 738 by torben, Wed May 19 07:40:00 2010 UTC revision 739 by torben, Wed May 19 09:53:25 2010 UTC
# Line 101  public class StationDAO { Line 101  public class StationDAO {
101                  return result;                  return result;
102          }          }
103                    
104          //the "hack" with max 2.5 degrees latitude and longitude is only valid since we only service danish trains          //the "hack" with max 1.5 degrees latitude and 2.5 degrees longitude is only valid since we only service danish trains
105            // in denmark 1.5dg latitude ~ 165km, 2.5dg longitude ~ 155km
106          public List<StationBean> getByLocation(double latitude, double longitude) throws SQLException {          public List<StationBean> getByLocation(double latitude, double longitude) throws SQLException {
107                  String SQL = "SELECT id,name,latitude,longitude,stationcode_fjrn,stationcode_stog, stationcode_metro, address," +                  String SQL = "SELECT id,name,latitude,longitude,stationcode_fjrn,stationcode_stog, stationcode_metro, address," +
108                                           "       earth_distance( earth_coord, ll_to_earth(?,?))::int AS calcdist " +                                           "       earth_distance( earth_coord, ll_to_earth(?,?))::int AS calcdist " +
109                                           "FROM trainstations " +                                           "FROM trainstations " +
110                                           "WHERE enabled = true AND abs(latitude-?)<2.5 AND abs (longitude-?)<2.5 " +                                           "WHERE enabled = true AND abs(latitude-?)<1.5 AND abs(longitude-?)<2.5 " +
111                                           "ORDER BY calcdist ASC " +                                           "ORDER BY calcdist ASC " +
112                                           "LIMIT 4 ";                                           "LIMIT 4 ";
113                  List<StationBean> result;                  List<StationBean> result;

Legend:
Removed from v.738  
changed lines
  Added in v.739

  ViewVC Help
Powered by ViewVC 1.1.20