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, address," + |
" 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 " + |
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, address, 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 "; |
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,address,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 "; |
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 |
|
res.getString(7); |
109 |
|
buff.append("<metro>").append( !res.wasNull() ).append("</metro>\n"); |
110 |
|
|
111 |
String address = res.getString(7); |
String address = res.getString(8); |
112 |
buff.append("<address>").append( res.wasNull() ? "" : address ).append("</address>"); |
buff.append("<address>").append( res.wasNull() ? "" : address ).append("</address>"); |
113 |
buff.append("<calcdist>").append( res.getInt(8) ) .append("</calcdist>\n"); |
buff.append("<calcdist>").append( res.getInt(9) ) .append("</calcdist>\n"); |
114 |
|
|
115 |
buff.append("</station>\n"); |
buff.append("</station>\n"); |
116 |
} |
} |