30 |
protected String getStations(Connection conn, double latitude, double longitude) throws SQLException { |
protected String getStations(Connection conn, double latitude, double longitude) throws SQLException { |
31 |
//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 |
32 |
final String SQL = "SELECT * FROM ( "+ |
final String SQL = "SELECT * FROM ( "+ |
33 |
" SELECT name,latitude,longitude,address,stationcode, " + |
" SELECT name,latitude,longitude,stationcode, " + |
34 |
" 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 " + |
35 |
" FROM trainstations " + |
" FROM trainstations " + |
36 |
" ) AS trainstations2 " + |
" ) AS trainstations2 " + |
59 |
|
|
60 |
buff.append("<name>").append( res.getString(1) ) .append("</name>\n"); |
buff.append("<name>").append( res.getString(1) ) .append("</name>\n"); |
61 |
buff.append("<latitude>").append( res.getDouble(2) ) .append("</latitude>\n"); |
buff.append("<latitude>").append( res.getDouble(2) ) .append("</latitude>\n"); |
62 |
buff.append("<longitude>").append( res.getDouble(3) ) .append("</longitude>\n"); |
buff.append("<longitude>").append( res.getDouble(3) ) .append("</longitude>\n"); |
63 |
buff.append("<address>").append( res.getString(4) ) .append("</address>\n"); |
buff.append("<stationcode>").append( res.getString(4) ) .append("</stationcode>\n"); |
64 |
buff.append("<stationcode>").append( res.getString(5) ) .append("</stationcode>\n"); |
buff.append("<calcdist>").append( res.getInt(5) ) .append("</calcdist>\n"); |
|
buff.append("<calcdist>").append( res.getDouble(6) ) .append("</calcdist>\n"); |
|
65 |
|
|
66 |
buff.append("</station>\n"); |
buff.append("</station>\n"); |
67 |
} |
} |