/[projects]/dao/FuldDaekningWorker/src/main/java/dk/daoas/fulddaekning/Database.java
ViewVC logotype

Diff of /dao/FuldDaekningWorker/src/main/java/dk/daoas/fulddaekning/Database.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2238 by torben, Tue Dec 9 20:39:45 2014 UTC revision 2241 by torben, Wed Dec 10 09:50:33 2014 UTC
# Line 59  public class Database { Line 59  public class Database {
59          }                }      
60    
61          public BoundingBox getBoundingbox(String postnr) throws SQLException {          public BoundingBox getBoundingbox(String postnr) throws SQLException {
62                  String minPostnr = postnr.replace("x", "0");                  String minPostnr = postnr.replace('x', '0');
63                  String maxPostnr = postnr.replace("x", "9");                  String maxPostnr = postnr.replace('x', '9');
64    
65                  String sql =                  String sql =
66                                  "SELECT max(latitude) latmax, min(latitude) latmin, max(longitude) lngmax,min(longitude) lngmin  " +                                  "SELECT max(latitude) latmax, min(latitude) latmin, max(longitude) lngmax,min(longitude) lngmin  " +
# Line 87  public class Database { Line 87  public class Database {
87    
88          public Queue<Adresse> hentIkkedaekkedeAdresser(String postnr)  throws SQLException {          public Queue<Adresse> hentIkkedaekkedeAdresser(String postnr)  throws SQLException {
89                                    
90                  String minPostnr = postnr.replace("x", "0");                  String minPostnr = postnr.replace('x', '0');
91                  String maxPostnr = postnr.replace("x", "9");                  String maxPostnr = postnr.replace('x', '9');
92                                    
93                  ConcurrentLinkedQueue<Adresse> queue = new ConcurrentLinkedQueue<Adresse>();                  ConcurrentLinkedQueue<Adresse> queue = new ConcurrentLinkedQueue<Adresse>();
94    
# Line 124  public class Database { Line 124  public class Database {
124                  */                  */
125                                    
126                                    
127                  String sql = "SELECT concat(left(postnr,3),'x') as postnr2 " +                  String sql = "SELECT rpad(left(postnr,?),'4', 'x') as postnr2 " +
128                                           "FROM fulddaekning.adressetabel " +                                           "FROM fulddaekning.adressetabel " +
129                                           "WHERE postnr BETWEEN ? AND ? " +                                           "WHERE postnr BETWEEN ? AND ? " +
130                                           "AND rute is null " + // Træk kun liste på postnumre hvor der er ikke-dækkede adresser                                           "AND rute is null " + // Trae kun liste paa postnumre hvor der er ikke-daekede adresser
131                                             "AND (postnr NOT BETWEEN 3900 and 3999) " + //Skip alle groenlandske postnumre
132                                           "GROUP BY postnr2 " +                                           "GROUP BY postnr2 " +
133                                           "ORDER by postnr2 ";                                           "ORDER by postnr2 ";
134                                    
# Line 135  public class Database { Line 136  public class Database {
136                                                                                    
137                  PreparedStatement stmt = conn.prepareStatement(sql);                  PreparedStatement stmt = conn.prepareStatement(sql);
138                  //stmt.setString(1, Lookup.distributor );                  //stmt.setString(1, Lookup.distributor );
139                  stmt.setInt(1, consts.getMinPostnr());  
140                  stmt.setInt(2, consts.getMaxPostnr());                  stmt.setInt(1, consts.getPostnrGroup() );
141    
142                    stmt.setInt(2, consts.getMinPostnr());
143                    stmt.setInt(3, consts.getMaxPostnr());
144                  ResultSet res = stmt.executeQuery();                  ResultSet res = stmt.executeQuery();
145    
146                  while (res.next()) {                  while (res.next()) {
# Line 170  public class Database { Line 174  public class Database {
174                  stmt.setDouble(2, bbox.latitudeMax);                  stmt.setDouble(2, bbox.latitudeMax);
175                  stmt.setDouble(3, bbox.longitudeMin);                  stmt.setDouble(3, bbox.longitudeMin);
176                  stmt.setDouble(4, bbox.longitudeMax);                  stmt.setDouble(4, bbox.longitudeMax);
177                  stmt.setString(5, Lookup.distributor);                  stmt.setString(5, LookupMain.distributor);
178    
179                  List<Adresse> list = hentAdresseListe( stmt );                  List<Adresse> list = hentAdresseListe( stmt );
180                  return list.toArray( new Adresse[ list.size() ] );                  return list.toArray( new Adresse[ list.size() ] );
# Line 192  public class Database { Line 196  public class Database {
196                  PreparedStatement stmt = conn.prepareStatement(sql, java.sql.ResultSet.TYPE_FORWARD_ONLY, java.sql.ResultSet.CONCUR_READ_ONLY);                  PreparedStatement stmt = conn.prepareStatement(sql, java.sql.ResultSet.TYPE_FORWARD_ONLY, java.sql.ResultSet.CONCUR_READ_ONLY);
197                  stmt.setFetchSize(Integer.MIN_VALUE);                  stmt.setFetchSize(Integer.MIN_VALUE);
198    
199                  stmt.setString(1, Lookup.distributor);                  stmt.setString(1, LookupMain.distributor);
200    
201                  List<Adresse> list = hentAdresseListe( stmt );                  List<Adresse> list = hentAdresseListe( stmt );
202                  return list.toArray( new Adresse[ list.size() ] );                  return list.toArray( new Adresse[ list.size() ] );

Legend:
Removed from v.2238  
changed lines
  Added in v.2241

  ViewVC Help
Powered by ViewVC 1.1.20