26 |
|
|
27 |
|
|
28 |
public SearchResult search(String postnrStr, String adresse) { |
public SearchResult search(String postnrStr, String adresse) { |
29 |
|
//long start1 = System.currentTimeMillis(); |
30 |
|
|
31 |
int postnr=0; |
int postnr=0; |
32 |
|
|
33 |
try { |
try { |
35 |
} catch (Exception E) { |
} catch (Exception E) { |
36 |
return new SearchResult(Status.ERROR_UNKNOWN_POSTAL); |
return new SearchResult(Status.ERROR_UNKNOWN_POSTAL); |
37 |
} |
} |
38 |
|
//long start2 = System.currentTimeMillis(); |
39 |
|
|
40 |
Map<String,Long> postnrVeje = searchPostnrVejnavnGadeid.get(postnr); |
Map<String,Long> postnrVeje = searchPostnrVejnavnGadeid.get(postnr); |
41 |
|
|
43 |
return new SearchResult(Status.ERROR_UNKNOWN_POSTAL); |
return new SearchResult(Status.ERROR_UNKNOWN_POSTAL); |
44 |
} |
} |
45 |
|
|
46 |
|
//long start3 = System.currentTimeMillis(); |
47 |
|
|
48 |
SplitResult split = AddressUtils.splitAdresse(adresse); |
SplitResult split = AddressUtils.splitAdresse(adresse); |
49 |
String vasketVejnavn = AddressUtils.vaskVejnavn( split.vej ); |
String vasketVejnavn = AddressUtils.vaskVejnavn( split.vej ); |
50 |
|
|
51 |
if (split.husnr.length() == 0) { |
if (split.husnr.length() == 0) { |
52 |
return new SearchResult(Status.ERROR_MISSING_HOUSENUMBER); |
return new SearchResult(Status.ERROR_MISSING_HOUSENUMBER); |
53 |
} |
} |
54 |
|
//long start4 = System.currentTimeMillis(); |
55 |
|
|
56 |
Long gadeident = postnrVeje.get(vasketVejnavn); |
Long gadeident = postnrVeje.get(vasketVejnavn); |
57 |
if (gadeident == null) { |
if (gadeident == null) { |
58 |
return new SearchResult(Status.ERROR_UNKNOWN_STREETNAME); |
return new SearchResult(Status.ERROR_UNKNOWN_STREETNAME); |
59 |
} |
} |
60 |
|
//long start5 = System.currentTimeMillis(); |
61 |
|
|
62 |
Map<String, Address> gade = searchGadeidentAdresser.get(gadeident); //Denne søgning må ikke fejle |
Map<String, Address> gade = searchGadeidentAdresser.get(gadeident); //Denne søgning må ikke fejle |
63 |
|
|
64 |
|
//long start6 = System.currentTimeMillis(); |
65 |
|
|
66 |
String husnrSearch = "" + split.husnr + split.litra; |
String husnrSearch = "" + split.husnr + split.litra; |
67 |
Address addr = gade.get(husnrSearch); |
Address addr = gade.get(husnrSearch); |
68 |
|
//long start7 = System.currentTimeMillis(); |
69 |
if (addr == null) { |
if (addr == null) { |
70 |
return new SearchResult(Status.ERROR_UNKNOWN_ADDRESSPOINT); |
return new SearchResult(Status.ERROR_UNKNOWN_ADDRESSPOINT); |
71 |
} |
} |
77 |
if (addr.distributor.equals("LUKKET")) { |
if (addr.distributor.equals("LUKKET")) { |
78 |
return new SearchResult(Status.STATUS_NOT_COVERED); //Skal vi have en special status til Lukkede adresser ? |
return new SearchResult(Status.STATUS_NOT_COVERED); //Skal vi have en special status til Lukkede adresser ? |
79 |
} |
} |
80 |
|
|
81 |
|
/* |
82 |
|
System.out.println("Search2: " + (start2-start1) ); |
83 |
|
System.out.println("Search3: " + (start3-start1) ); |
84 |
|
System.out.println("Search4: " + (start4-start1) ); |
85 |
|
System.out.println("Search5: " + (start5-start1) ); |
86 |
|
System.out.println("Search6: " + (start6-start1) ); |
87 |
|
System.out.println("Search7: " + (start7-start1) ); |
88 |
|
*/ |
89 |
|
|
90 |
|
|
91 |
|
|
92 |
return new SearchResult(addr); |
return new SearchResult(addr); |