1 |
package dk.daoas.daoadresseservice; |
package dk.daoas.daoadresseservice; |
2 |
|
|
3 |
import java.sql.SQLException; |
import java.sql.SQLException; |
4 |
|
import java.text.SimpleDateFormat; |
5 |
import java.util.ArrayList; |
import java.util.ArrayList; |
6 |
import java.util.Collections; |
import java.util.Collections; |
7 |
|
import java.util.Date; |
8 |
import java.util.HashMap; |
import java.util.HashMap; |
9 |
import java.util.HashSet; |
import java.util.HashSet; |
10 |
import java.util.List; |
import java.util.List; |
13 |
import java.util.concurrent.ConcurrentHashMap; |
import java.util.concurrent.ConcurrentHashMap; |
14 |
|
|
15 |
import dk.daoas.daoadresseservice.AddressUtils.SplitResult; |
import dk.daoas.daoadresseservice.AddressUtils.SplitResult; |
16 |
|
import dk.daoas.daoadresseservice.admin.ServiceConfig; |
17 |
import dk.daoas.daoadresseservice.beans.Address; |
import dk.daoas.daoadresseservice.beans.Address; |
18 |
import dk.daoas.daoadresseservice.beans.DataStatisticsBean; |
import dk.daoas.daoadresseservice.beans.DataStatisticsBean; |
19 |
import dk.daoas.daoadresseservice.beans.ExtendedBean; |
import dk.daoas.daoadresseservice.beans.ExtendedBean; |
31 |
|
|
32 |
private Map<String,Long> helperCache; |
private Map<String,Long> helperCache; |
33 |
|
|
34 |
private DataStatisticsBean stats = new DataStatisticsBean(); |
private DataStatisticsBean stats = new DataStatisticsBean(); |
35 |
|
|
36 |
|
ServiceConfig config; |
37 |
|
|
38 |
|
public AdressSearch(ServiceConfig config) { |
39 |
|
this.config = config; |
40 |
|
} |
41 |
|
|
42 |
|
|
43 |
public SearchResult search(String postnrStr, String adresse) { |
public SearchResult search(String postnrStr, String adresse) { |
77 |
|
|
78 |
|
|
79 |
if ( gadeident == null) { |
if ( gadeident == null) { |
80 |
String googleVej = GeocodeHelper.googleHelper(postnr, split.vej ); |
if (config.useGoogle) { |
81 |
google = true; |
String googleVej = GeocodeHelper.googleHelper(config, postnr, split.vej ); |
82 |
|
google = true; |
|
if (googleVej != null) { |
|
|
String googleVasket = AddressUtils.vaskVejnavn( googleVej ); |
|
|
gadeident = postnrVeje.get(googleVasket); |
|
83 |
|
|
84 |
if (gadeident != null) { |
if (googleVej != null) { |
85 |
helperCache.put(helperSearchKey, gadeident); |
String googleVasket = AddressUtils.vaskVejnavn( googleVej ); |
86 |
|
gadeident = postnrVeje.get(googleVasket); |
87 |
|
|
88 |
|
if (gadeident != null) { |
89 |
|
helperCache.put(helperSearchKey, gadeident); |
90 |
|
} |
91 |
} |
} |
92 |
} |
} |
93 |
} |
} |
94 |
|
|
95 |
if ( gadeident == null) { |
if ( gadeident == null) { |
96 |
String osmVej = GeocodeHelper.openstreetmapHelper(postnr, split.vej ); |
if (config.useOpenStreetMaps) { |
97 |
osm = true; |
String osmVej = GeocodeHelper.openstreetmapHelper(postnr, split.vej ); |
98 |
|
osm = true; |
|
if (osmVej != null) { |
|
|
String osmVasket = AddressUtils.vaskVejnavn( osmVej ); |
|
|
gadeident = postnrVeje.get(osmVasket); |
|
99 |
|
|
100 |
if (gadeident != null) { |
if (osmVej != null) { |
101 |
helperCache.put(helperSearchKey, gadeident); |
String osmVasket = AddressUtils.vaskVejnavn( osmVej ); |
102 |
|
gadeident = postnrVeje.get(osmVasket); |
103 |
|
|
104 |
|
if (gadeident != null) { |
105 |
|
helperCache.put(helperSearchKey, gadeident); |
106 |
|
} |
107 |
} |
} |
108 |
} |
} |
109 |
} |
} |
290 |
default: |
default: |
291 |
stats.ikkeDaekketCount++; |
stats.ikkeDaekketCount++; |
292 |
} |
} |
293 |
} |
} |
294 |
|
|
295 |
|
|
296 |
|
stats.elapsed = stop-start1; |
297 |
|
stats.buildTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format( new Date() ); |
298 |
|
|
299 |
System.out.println("Build: direkteCount: " + stats.direkteCount); |
System.out.println("Build: direkteCount: " + stats.direkteCount); |
300 |
System.out.println("Build: extendedCount: " + stats.extendedCount); |
System.out.println("Build: extendedCount: " + stats.extendedCount); |