/[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 2784 by torben, Thu Nov 26 12:50:05 2015 UTC revision 2788 by torben, Tue Dec 1 11:08:56 2015 UTC
# Line 30  import dk.daoas.daoadresseservice.db.Dat Line 30  import dk.daoas.daoadresseservice.db.Dat
30  import dk.daoas.daoadresseservice.util.DaoUtils;  import dk.daoas.daoadresseservice.util.DaoUtils;
31  import dk.daoas.daoadresseservice.util.DeduplicateHelper;  import dk.daoas.daoadresseservice.util.DeduplicateHelper;
32  import dk.daoas.daoadresseservice.util.NaturalOrderComparator;  import dk.daoas.daoadresseservice.util.NaturalOrderComparator;
33    import dk.daoas.daoadresseservice.util.NearestShortTreeMap;
34    
35  public class AddressSearch {  public class AddressSearch {
36    
# Line 83  public class AddressSearch { Line 84  public class AddressSearch {
84                  return addr;                  return addr;
85          }          }
86                    
87            
88          public SearchResult search(String postnrStr, String adresse)  {          public SearchResult search(String postnrStr, String adresse)  {
89                    return search(postnrStr, adresse, false);
90            }
91            
92            
93            public SearchResult search(String postnrStr, String adresse, boolean naermesteHusnr)  {
94                                    
95                  postnrStr = postnrStr.trim();                  postnrStr = postnrStr.trim();
96                  adresse = adresse.trim();                  adresse = adresse.trim();
# Line 192  public class AddressSearch { Line 198  public class AddressSearch {
198                                    
199    
200                  if (litraList == null) { //Husnr ikke fundet                  if (litraList == null) { //Husnr ikke fundet
201                          result.status = Status.ERROR_UNKNOWN_ADDRESSPOINT;                          
202                          return result;                          if (naermesteHusnr) {
203                                    TreeMap<Short, Map<String,Address>> gadeTreeMap = (TreeMap<Short, Map<String,Address>>) gade;
204                                    result.anvendtHusnr = NearestShortTreeMap.getNearestKey(husnrSearch, gadeTreeMap);
205                                    
206                                    result.nearestHusnr = true;
207                                    litraList = gade.get(result.anvendtHusnr);
208                                    
209                                    
210                            } else {
211                                    result.status = Status.ERROR_UNKNOWN_ADDRESSPOINT;
212                                    return result;  
213                            }
214                  }                  }
215                                    
216                  Address addr = litraList.get( result.splitResult.litra );                  Address addr = litraList.get( result.splitResult.litra );
217                                    
218                  if (addr == null) {                  if (addr == null) { //litra ikke fundet
219                          if (config.nearestLitra == true) {                          if (config.nearestLitra == true) {
220                                  result.nearestLitra = true;                                  result.nearestLitra = true;
221                                  addr = litraList.values().iterator().next();                                                              addr = litraList.values().iterator().next();                            
# Line 248  public class AddressSearch { Line 265  public class AddressSearch {
265                  }                  }
266                                    
267                  if (gadeident == null) {                  if (gadeident == null) {
268                          String vej = levenshteinHelper.proposeStreetName(request, result);                          String vej = metaphoneHelper.proposeStreetName(request, result);
269                          if (vej != null) {                          if (vej != null) {
270                                  gadeident =  request.streetNames.get(vej);                                  gadeident =  request.streetNames.get(vej);
271                          }                          }
# Line 304  public class AddressSearch { Line 321  public class AddressSearch {
321                  Map<Integer,Address> idAddressMap = new HashMap<Integer,Address>( alleAdresser.size() );                  Map<Integer,Address> idAddressMap = new HashMap<Integer,Address>( alleAdresser.size() );
322                  DeduplicateHelper<String> aliasHelper = new DeduplicateHelper<String>();                  DeduplicateHelper<String> aliasHelper = new DeduplicateHelper<String>();
323                                    
324                    DeduplicateHelper<Short> shortHelper = new DeduplicateHelper<Short>();
325                    DeduplicateHelper<Integer> intHelper = new DeduplicateHelper<Integer>();
326                    
327                  for (Address a : alleAdresser) {                  for (Address a : alleAdresser) {
328                          idAddressMap.put(a.id, a);                          idAddressMap.put(a.id, a);
329                                                    
330                          Map<String,Integer> postnrVeje = searchPostnrVejnavnGadeid.get(a.postnr);                                        Short postnr = shortHelper.getInstance(a.postnr);
331                            
332                            Map<String,Integer> postnrVeje = searchPostnrVejnavnGadeid.get(postnr);        
333                                                    
334                          if (postnrVeje == null) {                          if (postnrVeje == null) {
335                                  postnrVeje = new ConcurrentHashMap<String,Integer>();                                  postnrVeje = new ConcurrentHashMap<String,Integer>();
336                                  searchPostnrVejnavnGadeid.put(a.postnr, postnrVeje);                                  searchPostnrVejnavnGadeid.put(postnr, postnrVeje);
337                          }                          }
338                                                                    
339                                                    
# Line 320  public class AddressSearch { Line 342  public class AddressSearch {
342                          if (gadeident == null) {                                                          if (gadeident == null) {                                
343                                  //postnrVeje.put(vasketVejnavn, a.gadeid);                                  //postnrVeje.put(vasketVejnavn, a.gadeid);
344                                                                    
345                                  gadeident = a.gadeid;                                  gadeident = intHelper.getInstance( a.gadeid );
346                                                                    
347                                  Set<String> aliaser = findVejAliaser(a.vejnavn);                                  Set<String> aliaser = findVejAliaser(a.vejnavn);
348                                  for(String alias : aliaser) {                                  for(String alias : aliaser) {
# Line 846  public class AddressSearch { Line 868  public class AddressSearch {
868          }          }
869                    
870          public Address getAdresse(int gadeid, String husnrStr) {          public Address getAdresse(int gadeid, String husnrStr) {
871                                    short husnr = Short.parseShort( husnrStr.replaceAll("[^\\d]","") );
872                  short husnr = Short.parseShort( husnrStr.replaceAll("\\d","") );                  String litra =  husnrStr.replaceAll("\\d", "");        
                 String litra =  husnrStr.replaceAll("^\\d", "");  
873                                    
874                  Map<Short,Map<String, Address>> gade = searchGadeidentAdresser.get(gadeid);                  Map<Short,Map<String, Address>> gade = searchGadeidentAdresser.get(gadeid);
875                  Map<String, Address> litraList = gade.get(husnr);                  Map<String, Address> litraList = gade.get(husnr);

Legend:
Removed from v.2784  
changed lines
  Added in v.2788

  ViewVC Help
Powered by ViewVC 1.1.20