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 |
|
|
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(); |
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(); |