--- android/TrainInfoService/src/dk/thoerup/traininfoservice/db/StationDAO.java 2012/08/20 21:15:20 1831 +++ android/TrainInfoService/src/dk/thoerup/traininfoservice/db/StationDAO.java 2012/08/20 21:15:37 1832 @@ -55,6 +55,10 @@ String[] emptyArray = {}; station.setAliases( emptyArray ); } + + station.setTritStation( res.getInt(11) ); + if (res.wasNull()) + station.setTritStation( -1 ); return station; } @@ -95,7 +99,7 @@ } public StationEntry getById(int id) throws SQLException,NostationException { - String SQL = "SELECT id,name,latitude,longitude,stationcode_fjrn,stationcode_stog,stationcode_metro,address,0.0,aliases " + + String SQL = "SELECT id,name,latitude,longitude,stationcode_fjrn,stationcode_stog,stationcode_metro,address,0.0,aliases,tritstation " + "FROM trainstations WHERE id=" + id + " AND enabled=true"; StationBean stations = fetchStations(SQL, new NullSetter() ); @@ -116,7 +120,7 @@ * create operator ~~~ (procedure = rlike, leftarg = text, rightarg = text, commutator = ~~); */ public StationBean getByNameNormal(final String name) throws SQLException { - String SQL = "SELECT id,name,latitude,longitude,stationcode_fjrn,stationcode_stog, stationcode_metro, address, 0.0,aliases " + + String SQL = "SELECT id,name,latitude,longitude,stationcode_fjrn,stationcode_stog, stationcode_metro, address, 0.0,aliases,tritstation " + "FROM trainstations " + "WHERE (name ILIKE ? OR ? ~~~ ANY(aliases)) AND enabled = true " + "ORDER BY name "; @@ -135,7 +139,7 @@ public StationBean getByNameFuzzy(final String name) throws SQLException { String SQL = "SELECT * FROM (" + - " SELECT id,name,latitude,longitude,stationcode_fjrn,stationcode_stog, stationcode_metro, address, 0.0, aliases, " + + " SELECT id,name,latitude,longitude,stationcode_fjrn,stationcode_stog, stationcode_metro, address, 0.0, aliases, tritstation, " + " levenshtein(lower(name),lower(?) ) as leven " + " FROM trainstations " + " WHERE enabled = true ) as lev2 " + @@ -198,7 +202,7 @@ String limitExpression = (geolimit == true) ? "AND abs(latitude-?)<0.4 AND abs(longitude-?)<0.75 " : ""; String SQL = "SELECT id,name,latitude,longitude,stationcode_fjrn,stationcode_stog, stationcode_metro, address, " + - "earth_distance( earth_coord, ll_to_earth(?,?))::int AS calcdist,aliases " + + "earth_distance( earth_coord, ll_to_earth(?,?))::int AS calcdist,aliases,tritstation " + "FROM trainstations " + "WHERE enabled = true " + limitExpression + "ORDER BY calcdist ASC " + @@ -235,7 +239,7 @@ public StationBean getByList(String list) throws SQLException { - String SQL = "SELECT id,name,latitude,longitude,stationcode_fjrn,stationcode_stog,stationcode_metro, address,0.0,aliases " + + String SQL = "SELECT id,name,latitude,longitude,stationcode_fjrn,stationcode_stog,stationcode_metro, address,0.0,aliases,tritstation " + "FROM trainstations " + "WHERE id IN " + list + " AND enabled = true " + "ORDER BY name "; @@ -246,7 +250,7 @@ public StationEntry getSimpleByName(final String name) throws SQLException { - String SQL = "SELECT id,name,latitude,longitude,stationcode_fjrn,stationcode_stog, stationcode_metro, address, 0.0,aliases " + + String SQL = "SELECT id,name,latitude,longitude,stationcode_fjrn,stationcode_stog, stationcode_metro, address, 0.0,aliases,tritstation " + "FROM trainstations " + "WHERE name = ? AND enabled = true " + "LIMIT 1 "; @@ -278,7 +282,7 @@ //after 1.1.0 also used to populate client-side station list public StationBean dumpAll() throws SQLException { - String SQL = "SELECT id,name,latitude,longitude,stationcode_fjrn,stationcode_stog,stationcode_metro,address,0.0,aliases " + + String SQL = "SELECT id,name,latitude,longitude,stationcode_fjrn,stationcode_stog,stationcode_metro,address,0.0,aliases,tritstation " + "FROM trainstations WHERE enabled = true"; @@ -328,6 +332,7 @@ } + /* @Deprecated public static String getStationName(int stationID) { String station = ""; @@ -350,7 +355,7 @@ } return station; - } + }*/ public boolean hasDisabledStation(final String name) throws SQLException { String SQL = "Select count(*) as antal from trainstations where name = '" + name + "' and enabled=false " ; @@ -370,7 +375,7 @@ return (antal > 0); } - + /* @Deprecated public int getIdByName(final String name) throws SQLException { String SQL = "SELECT id,name,latitude,longitude,stationcode_fjrn,stationcode_stog, stationcode_metro, address, 0.0 " + @@ -392,5 +397,5 @@ } else { return -1; } - } + }*/ }