103 |
|
|
104 |
//the "hack" with max 1.5 degrees latitude and 2.5 degrees longitude is only valid since we only service danish trains |
//the "hack" with max 1.5 degrees latitude and 2.5 degrees longitude is only valid since we only service danish trains |
105 |
// in denmark 1.5dg latitude ~ 165km, 2.5dg longitude ~ 155km |
// in denmark 1.5dg latitude ~ 165km, 2.5dg longitude ~ 155km |
106 |
|
|
107 |
|
// the ultra fast method (and only slightly inaccurate as long as we only cover a limited geographically area) |
108 |
|
// is using an aproximation of the length of 1 latitude degree and 1 longitude degree and just use pythagoras to |
109 |
|
// calculate the distance: |
110 |
|
// sqrt( power(abs(latitude-?)*111320, 2) + power(abs(longitude-?)*63000,2) )::int as calcdist |
111 |
|
|
112 |
public List<StationBean> getByLocation(double latitude, double longitude) throws SQLException { |
public List<StationBean> getByLocation(double latitude, double longitude) throws SQLException { |
113 |
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," + |
114 |
" earth_distance( earth_coord, ll_to_earth(?,?))::int AS calcdist " + |
" earth_distance( earth_coord, ll_to_earth(?,?))::int AS calcdist " + |