10 |
import com.google.code.geocoder.model.GeocoderResult; |
import com.google.code.geocoder.model.GeocoderResult; |
11 |
import com.google.code.geocoder.model.GeocoderStatus; |
import com.google.code.geocoder.model.GeocoderStatus; |
12 |
|
|
13 |
|
import com.google.common.util.concurrent.RateLimiter; |
14 |
|
|
15 |
import dk.daoas.daoadresseservice.admin.ServiceConfig; |
import dk.daoas.daoadresseservice.admin.ServiceConfig; |
16 |
import dk.daoas.daoadresseservice.beans.SearchRequest; |
import dk.daoas.daoadresseservice.beans.SearchRequest; |
17 |
import dk.daoas.daoadresseservice.beans.SearchResult; |
import dk.daoas.daoadresseservice.beans.SearchResult; |
22 |
public class GoogleStreetnameHelper implements StreetnameHelper { |
public class GoogleStreetnameHelper implements StreetnameHelper { |
23 |
|
|
24 |
ServiceConfig conf; |
ServiceConfig conf; |
25 |
|
RateLimiter limiter; |
26 |
|
|
27 |
public GoogleStreetnameHelper(ServiceConfig conf) { |
public GoogleStreetnameHelper(ServiceConfig conf) { |
28 |
this.conf = conf; |
this.conf = conf; |
29 |
|
|
30 |
|
limiter = RateLimiter.create( 10.0 ); //max 10 req /sec |
31 |
} |
} |
32 |
|
|
33 |
@Override |
@Override |
35 |
if (conf.useGoogle == false) |
if (conf.useGoogle == false) |
36 |
return null; |
return null; |
37 |
|
|
38 |
|
limiter.acquire(); |
39 |
|
|
40 |
result.google = true; |
result.google = true; |
41 |
|
|
42 |
try { |
try { |