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

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

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

revision 431 by torben, Sat Oct 10 08:33:27 2009 UTC revision 550 by torben, Tue Jan 26 20:24:41 2010 UTC
# Line 48  public class LocateStations extends Http Line 48  public class LocateStations extends Http
48                  if (req.getParameter("latitude") != null && req.getParameter("latitude") != null) {                  if (req.getParameter("latitude") != null && req.getParameter("latitude") != null) {
49                          //inner select is workaround from not being able to use a calculated column directly in where clause                          //inner select is workaround from not being able to use a calculated column directly in where clause
50                          SQL = "SELECT * FROM ( "+                          SQL = "SELECT * FROM ( "+
51                          "               SELECT id,name,latitude,longitude,stationcode_fjrn,stationcode_stog, " +                          "               SELECT id,name,latitude,longitude,stationcode_fjrn,stationcode_stog, stationcode_metro, address," +
52                          "                     earth_distance( ll_to_earth(latitude,longitude), ll_to_earth(?,?))::int AS calcdist " +                          "                     earth_distance( ll_to_earth(latitude,longitude), ll_to_earth(?,?))::int AS calcdist " +
53                          "               FROM trainstations " +                          "               FROM trainstations " +
54                          "               WHERE enabled = true " +                          "               WHERE enabled = true " +
# Line 61  public class LocateStations extends Http Line 61  public class LocateStations extends Http
61                          stmt.setDouble(1, latitude);                          stmt.setDouble(1, latitude);
62                          stmt.setDouble(2, longitude);                          stmt.setDouble(2, longitude);
63                  } else if (req.getParameter("name") != null) {                  } else if (req.getParameter("name") != null) {
64                          SQL = "SELECT id,name,latitude,longitude,stationcode_fjrn,stationcode_stog,0.0 " +                          SQL = "SELECT id,name,latitude,longitude,stationcode_fjrn,stationcode_stog, stationcode_metro, address, 0.0 " +
65                          "FROM trainstations " +                          "FROM trainstations " +
66                          "WHERE name ILIKE ? AND enabled = true " +                          "WHERE name ILIKE ? AND enabled = true " +
67                          "ORDER BY name ";                          "ORDER BY name ";
# Line 71  public class LocateStations extends Http Line 71  public class LocateStations extends Http
71                          stmt.setString(1, name + "%");                          stmt.setString(1, name + "%");
72                  } else if (req.getParameter("list") != null) {                  } else if (req.getParameter("list") != null) {
73                          String list = transformToIntList( req.getParameter("list"));                          String list = transformToIntList( req.getParameter("list"));
74                          SQL = "SELECT id,name,latitude,longitude,stationcode_fjrn,stationcode_stog,0.0 " +                          SQL = "SELECT id,name,latitude,longitude,stationcode_fjrn,stationcode_stog,stationcode_metro, address,0.0 " +
75                          "FROM trainstations " +                          "FROM trainstations " +
76                          "WHERE id IN " + list + " AND enabled = true " +                          "WHERE id IN " + list + " AND enabled = true " +
77                          "ORDER BY name ";                          "ORDER BY name ";
# Line 102  public class LocateStations extends Http Line 102  public class LocateStations extends Http
102                                  buff.append("<latitude>").append( res.getDouble(3) ) .append("</latitude>\n");                                  buff.append("<latitude>").append( res.getDouble(3) ) .append("</latitude>\n");
103                                  buff.append("<longitude>").append( res.getDouble(4) ) .append("</longitude>\n");                                  buff.append("<longitude>").append( res.getDouble(4) ) .append("</longitude>\n");
104                                  res.getString(5);                                  res.getString(5);
105                                  buff.append("<fjerntog>").append( !res.wasNull() ) .append("</fjerntog>\n");                                  buff.append("<regional>").append( !res.wasNull() ) .append("</regional>\n");
106                                  res.getString(6);                                  res.getString(6);
107                                  buff.append("<stog>").append( !res.wasNull() ) .append("</stog>\n");                                  buff.append("<strain>").append( !res.wasNull() ) .append("</strain>\n");
108                                  buff.append("<calcdist>").append( res.getInt(7) ) .append("</calcdist>\n");                                  res.getString(7);
109                                    buff.append("<metro>").append( !res.wasNull() ).append("</metro>\n");
110                                    
111                                    String address = res.getString(8);
112                                    buff.append("<address>").append( res.wasNull() ? "" : address ).append("</address>");                          
113                                    buff.append("<calcdist>").append( res.getInt(9) ) .append("</calcdist>\n");
114    
115                                  buff.append("</station>\n");                                                              buff.append("</station>\n");                            
116                          }                          }
# Line 145  public class LocateStations extends Http Line 150  public class LocateStations extends Http
150                                  if (conn != null) {                                  if (conn != null) {
151                                          conn.close();                                          conn.close();
152                                  }                                  }
153                          } catch (Throwable t) {}                          } catch (Exception t) {}
154                  }                  }
155          }          }
156    

Legend:
Removed from v.431  
changed lines
  Added in v.550

  ViewVC Help
Powered by ViewVC 1.1.20