/[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 736 by torben, Tue May 18 20:39:22 2010 UTC revision 737 by torben, Wed May 19 07:40:00 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
105          public List<StationBean> getByLocation(double latitude, double longitude) throws SQLException {          public List<StationBean> getByLocation(double latitude, double longitude) throws SQLException {
106                  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," +
107                                           "       earth_distance( earth_coord, ll_to_earth(?,?))::int AS calcdist " +                                           "       earth_distance( earth_coord, ll_to_earth(?,?))::int AS calcdist " +
108                                           "FROM trainstations " +                                           "FROM trainstations " +
109                                           "WHERE enabled = true " +                                           "WHERE enabled = true AND abs(latitude-?)<2.5 AND abs (longitude-?)<2.5 " +
110                                           "ORDER BY calcdist ASC " +                                           "ORDER BY calcdist ASC " +
111                                           "LIMIT 4 ";                                           "LIMIT 4 ";
112                  List<StationBean> result;                  List<StationBean> result;
# Line 117  public class StationDAO { Line 118  public class StationDAO {
118                          stmt = conn.prepareStatement(SQL);                          stmt = conn.prepareStatement(SQL);
119                          stmt.setDouble(1, latitude);                          stmt.setDouble(1, latitude);
120                          stmt.setDouble(2, longitude);                          stmt.setDouble(2, longitude);
121                            stmt.setDouble(3, latitude);
122                            stmt.setDouble(4, longitude);                  
123                          res = stmt.executeQuery();                          res = stmt.executeQuery();
124                          result = convertResultset(res);                          result = convertResultset(res);
125                                                    

Legend:
Removed from v.736  
changed lines
  Added in v.737

  ViewVC Help
Powered by ViewVC 1.1.20