/[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 491 by torben, Tue Oct 20 10:32:19 2009 UTC revision 492 by torben, Sun Nov 1 16:35:48 2009 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, 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, 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,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 105  public class LocateStations extends Http Line 105  public class LocateStations extends Http
105                                  buff.append("<fjerntog>").append( !res.wasNull() ) .append("</fjerntog>\n");                                  buff.append("<fjerntog>").append( !res.wasNull() ) .append("</fjerntog>\n");
106                                  res.getString(6);                                  res.getString(6);
107                                  buff.append("<stog>").append( !res.wasNull() ) .append("</stog>\n");                                  buff.append("<stog>").append( !res.wasNull() ) .append("</stog>\n");
108                                  buff.append("<calcdist>").append( res.getInt(7) ) .append("</calcdist>\n");                                  
109                                    String address = res.getString(7);
110                                    buff.append("<address>").append( res.wasNull() ? "" : address ).append("</address>");
111                                    buff.append("<calcdist>").append( res.getInt(8) ) .append("</calcdist>\n");
112    
113                                  buff.append("</station>\n");                                                              buff.append("</station>\n");                            
114                          }                          }

Legend:
Removed from v.491  
changed lines
  Added in v.492

  ViewVC Help
Powered by ViewVC 1.1.20