4 |
|
|
5 |
import com.google.gson.Gson; |
import com.google.gson.Gson; |
6 |
|
|
7 |
|
import com.google.common.util.concurrent.RateLimiter; |
8 |
|
|
9 |
|
|
10 |
import dk.daoas.daoadresseservice.admin.ServiceConfig; |
import dk.daoas.daoadresseservice.admin.ServiceConfig; |
11 |
import dk.daoas.daoadresseservice.beans.OSMAddress; |
import dk.daoas.daoadresseservice.beans.OSMAddress; |
12 |
import dk.daoas.daoadresseservice.beans.SearchRequest; |
import dk.daoas.daoadresseservice.beans.SearchRequest; |
19 |
public class OSMStreetnameHelper implements StreetnameHelper { |
public class OSMStreetnameHelper implements StreetnameHelper { |
20 |
|
|
21 |
ServiceConfig conf; |
ServiceConfig conf; |
22 |
|
RateLimiter limiter; |
23 |
|
|
24 |
public OSMStreetnameHelper(ServiceConfig conf) { |
public OSMStreetnameHelper(ServiceConfig conf) { |
25 |
this.conf = conf; |
this.conf = conf; |
26 |
|
|
27 |
|
limiter = RateLimiter.create( 10.0 ); //Max 10 requests pr sekund |
28 |
} |
} |
29 |
|
|
30 |
@Override |
@Override |
32 |
if (conf.useOpenStreetMaps == false) |
if (conf.useOpenStreetMaps == false) |
33 |
return null; |
return null; |
34 |
|
|
35 |
|
limiter.acquire(); |
36 |
|
|
37 |
result.osm = true; |
result.osm = true; |
38 |
|
|
39 |
try { |
try { |