/[projects]/dao/DaoAdresseService/src/main/java/dk/daoas/daoadresseservice/AddressSearch.java
ViewVC logotype

Diff of /dao/DaoAdresseService/src/main/java/dk/daoas/daoadresseservice/AddressSearch.java

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

revision 2301 by torben, Sun Feb 15 16:09:11 2015 UTC revision 2309 by torben, Mon Feb 16 13:24:45 2015 UTC
# Line 23  public class AdressSearch { Line 23  public class AdressSearch {
23    
24          List<Address> alleAdresser;          List<Address> alleAdresser;
25                    
26            Map<String,Long> helperCache;
27            
28                    
29          Map<Integer,HundredePctBean> hundredePct;          Map<Integer,HundredePctBean> hundredePct;
30                    
# Line 32  public class AdressSearch { Line 34  public class AdressSearch {
34                  int postnr=0;                  int postnr=0;
35                  boolean google = false;                  boolean google = false;
36                  boolean osm = false;                  boolean osm = false;
37                    String helperSearchKey = "";
38                                    
39                  try {                  try {
40                          postnr = Integer.parseInt(postnrStr);                          postnr = Integer.parseInt(postnrStr);
# Line 55  public class AdressSearch { Line 58  public class AdressSearch {
58                                    
59                  Long gadeident =  postnrVeje.get(vasketVejnavn);                  Long gadeident =  postnrVeje.get(vasketVejnavn);
60                                    
61                    
62                  if ( gadeident == null) {                  if ( gadeident == null) {
63                          String osmVej = GeocodeHelper.openstreetmapHelper(postnr, split.vej );                          helperSearchKey = "" + postnr + "/" + vasketVejnavn;
64                          if (osmVej != null) {                          gadeident = helperCache.get(helperSearchKey);
                                 String osmVasket = AddressUtils.vaskVejnavn( osmVej );  
                                 gadeident =  postnrVeje.get(osmVasket);  
                                 osm = true;  
                         }  
65                  }                  }
66                                    
67                    
68                  if ( gadeident == null) {                  if ( gadeident == null) {
69                          String googleVej = GeocodeHelper.googleHelper(postnr, split.vej );                          String googleVej = GeocodeHelper.googleHelper(postnr, split.vej );
70                            google = true;
71                            
72                          if (googleVej != null) {                          if (googleVej != null) {
73                                  String googleVasket = AddressUtils.vaskVejnavn( googleVej );                                  String googleVasket = AddressUtils.vaskVejnavn( googleVej );
74                                  gadeident =  postnrVeje.get(googleVasket);                                  gadeident =  postnrVeje.get(googleVasket);
75                                  google = true;                                  
76                                    if (gadeident != null) {
77                                            helperCache.put(helperSearchKey, gadeident);
78                                    }
79                            }
80                    }
81                    
82                    if ( gadeident == null) {
83                            String osmVej = GeocodeHelper.openstreetmapHelper(postnr, split.vej );
84                            osm = true;
85                            
86                            if (osmVej != null) {
87                                    String osmVasket = AddressUtils.vaskVejnavn( osmVej );
88                                    gadeident =  postnrVeje.get(osmVasket);
89                                    
90                                    if (gadeident != null) {
91                                            helperCache.put(helperSearchKey, gadeident);
92                                    }
93                          }                          }
94                  }                  }
95                                    
# Line 105  public class AdressSearch { Line 125  public class AdressSearch {
125          public void buildSearchStructures() throws SQLException{          public void buildSearchStructures() throws SQLException{
126                  searchPostnrVejnavnGadeid = new HashMap<Integer, Map<String,Long>>();                  searchPostnrVejnavnGadeid = new HashMap<Integer, Map<String,Long>>();
127                  searchGadeidentAdresser = new HashMap<Long,  Map<String,Address>>();                  searchGadeidentAdresser = new HashMap<Long,  Map<String,Address>>();
128                                                    helperCache = new ConcurrentHashMap<String,Long>();
129                    
130                    long start1 = System.currentTimeMillis();
131                  System.out.println("Build -- stage 1");                  System.out.println("Build -- stage 1");
132                                    
133                  alleAdresser = DatabaseLayer.getAllAdresses();                  alleAdresser = DatabaseLayer.getAllAdresses();
# Line 148  public class AdressSearch { Line 170  public class AdressSearch {
170                                    
171                                    
172                  ////////////////////////////////////////////////////////////////////////////////////////                  ////////////////////////////////////////////////////////////////////////////////////////
173                    long start2 = System.currentTimeMillis();
174                    System.out.println("Build, stage1 elapsed: " + (start2-start1) );
175                  System.out.println("Build -- stage 2 udvidet dækning");                  System.out.println("Build -- stage 2 udvidet dækning");
176                                    
177                  List<ExtendedBean> extDao = DatabaseLayer.getExtendedAdresslist();                  List<ExtendedBean> extDao = DatabaseLayer.getExtendedAdresslist();
# Line 205  public class AdressSearch { Line 229  public class AdressSearch {
229                  idAddressMap = null;                  idAddressMap = null;
230                                    
231                  //////////////////////////////////////////////////////////////////////////////////////                  //////////////////////////////////////////////////////////////////////////////////////
232                    long start3 = System.currentTimeMillis();
233                    System.out.println("Build, stage2 elapsed: " + (start3-start2) );
234                  System.out.println("Build -- stage 3 - 100pct");                  System.out.println("Build -- stage 3 - 100pct");
235                                    
236                  hundredePct = DatabaseLayer.get100PctList();                  hundredePct = DatabaseLayer.get100PctList();
# Line 231  public class AdressSearch { Line 257  public class AdressSearch {
257                  }                  }
258                                    
259                  ////////////////////////////////////////////////////////////////////////////////////                  ////////////////////////////////////////////////////////////////////////////////////
260                    long stop = System.currentTimeMillis();
261                    System.out.println("Build, stage3 elapsed: " + (stop-start3) );
262                  System.out.println("Build -- Gathering statistics");                  System.out.println("Build -- Gathering statistics");
263                                    
264                  int direkteCount = 0;                  int direkteCount = 0;
# Line 259  public class AdressSearch { Line 287  public class AdressSearch {
287                  System.out.println("Build: hundredePctCount: " + hundredePctCount);                  System.out.println("Build: hundredePctCount: " + hundredePctCount);
288                  System.out.println("Build: ikkeDaekketCount: " + ikkeDaekketCount);                  System.out.println("Build: ikkeDaekketCount: " + ikkeDaekketCount);
289                                    
290                    System.out.println("Build: Total Elapsed: " + (stop-start1) );
291                  System.out.println("Build Completed");                  System.out.println("Build Completed");
292                                    
293          }          }

Legend:
Removed from v.2301  
changed lines
  Added in v.2309

  ViewVC Help
Powered by ViewVC 1.1.20