本文整理汇总了Java中com.google.code.geocoder.model.GeocoderStatus类的典型用法代码示例。如果您正苦于以下问题:Java GeocoderStatus类的具体用法?Java GeocoderStatus怎么用?Java GeocoderStatus使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GeocoderStatus类属于com.google.code.geocoder.model包,在下文中一共展示了GeocoderStatus类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: locationToCoordinate
import com.google.code.geocoder.model.GeocoderStatus; //导入依赖的package包/类
public GeocoderGeometry locationToCoordinate(String location) throws IOException {
GeocoderGeometry coordinate = null;
if (location != null && !location.isEmpty()) {
GeocoderRequest request = new GeocoderRequest();
request.setAddress(location);
GeocodeResponse response = geocoder.geocode(request);
if (response.getStatus() == GeocoderStatus.OK) {
List<GeocoderResult> results = response.getResults();
for (GeocoderResult result : results) {
GeocoderGeometry geometry = result.getGeometry();
coordinate = geometry;
break;
}
}
}
return coordinate;
}
开发者ID:dlemmermann,项目名称:CalendarFX,代码行数:22,代码来源:GoogleGeocoderService.java
示例2: coordinateToLocation
import com.google.code.geocoder.model.GeocoderStatus; //导入依赖的package包/类
public String coordinateToLocation(GeocoderGeometry coordinate) throws IOException {
String location = null;
if (coordinate != null) {
GeocoderRequest request = new GeocoderRequest();
request.setLocation(coordinate.getLocation());
request.setBounds(coordinate.getBounds());
GeocodeResponse response = geocoder.geocode(request);
if (response.getStatus() == GeocoderStatus.OK) {
List<GeocoderResult> results = response.getResults();
for (GeocoderResult result : results) {
location = result.getFormattedAddress();
break;
}
}
}
return location;
}
开发者ID:dlemmermann,项目名称:CalendarFX,代码行数:21,代码来源:GoogleGeocoderService.java
示例3: testSitraObject
import com.google.code.geocoder.model.GeocoderStatus; //导入依赖的package包/类
@Test
public void testSitraObject() throws IOException{
String obt_domaine_skiable = "Domaines skiables";
String obt_patrimoine_naturel = "Patrimoine Naturel";
String obt_fetes_manifestations = "Fêtes et Manisfestations";
GeocoderRequest geocoderRequest = new GeocoderRequestBuilder().setAddress(obt_domaine_skiable).setRegion("fr").setLanguage("fr").getGeocoderRequest();
GeocodeResponse geocoderResponse = geocoder.geocode(geocoderRequest);
assertEquals(geocoderResponse.getStatus(), GeocoderStatus.ZERO_RESULTS);
geocoderRequest = new GeocoderRequestBuilder().setAddress(obt_patrimoine_naturel).setRegion("fr").setLanguage("fr").getGeocoderRequest();
geocoderResponse = geocoder.geocode(geocoderRequest);
assertEquals(geocoderResponse.getStatus(), GeocoderStatus.ZERO_RESULTS);
geocoderRequest = new GeocoderRequestBuilder().setAddress(obt_fetes_manifestations).setRegion("fr").setLanguage("fr").getGeocoderRequest();
geocoderResponse = geocoder.geocode(geocoderRequest);
assertEquals(geocoderResponse.getStatus(), GeocoderStatus.ZERO_RESULTS);
}
开发者ID:openwide-java,项目名称:owsi-core-parent,代码行数:19,代码来源:TestGeocoder.java
示例4: getGeoPt
import com.google.code.geocoder.model.GeocoderStatus; //导入依赖的package包/类
@Nullable
public static GeoPt getGeoPt(String addressStr) {
// TODO(avaliani): use an api key to avoid geocoding quota limits
final Geocoder geocoder = new Geocoder();
GeocoderRequest geocoderRequest = new GeocoderRequestBuilder()
.setAddress(addressStr)
.setLanguage("en")
.getGeocoderRequest();
GeocodeResponse geocoderResponse = geocoder.geocode(geocoderRequest);
if (geocoderResponse.getStatus() == GeocoderStatus.OK) {
GeocoderResult firstResult = geocoderResponse.getResults().get(0);
return new GeoPt(
firstResult.getGeometry().getLocation().getLat().floatValue(),
firstResult.getGeometry().getLocation().getLng().floatValue());
} else {
log.log(GEOCODE_LOG_LEVEL,
"Geocoding failed: status=" + geocoderResponse.getStatus() + ", " +
"response=" + geocoderResponse);
// TODO(avaliani): Properly handle geopt encoding failures. Retrying in cases where
// the error is over quota.
return null;
}
}
开发者ID:karma-exchange-org,项目名称:karma-exchange,代码行数:26,代码来源:GeocodingService.java
示例5: extractGeoResult
import com.google.code.geocoder.model.GeocoderStatus; //导入依赖的package包/类
protected void extractGeoResult(GeocodeResponse res, Exchange exchange) {
exchange.getIn().setHeader(GeoCoderConstants.STATUS, res.getStatus());
// should we include body
if (!endpoint.isHeadersOnly()) {
exchange.getIn().setBody(res);
}
if (res.getStatus() == GeocoderStatus.OK) {
exchange.getIn().setHeader(GeoCoderConstants.ADDRESS, res.getResults().get(0).getFormattedAddress());
// just grab the first element and its lat and lon
BigDecimal resLat = res.getResults().get(0).getGeometry().getLocation().getLat();
BigDecimal resLon = res.getResults().get(0).getGeometry().getLocation().getLng();
exchange.getIn().setHeader(GeoCoderConstants.LAT, resLat.toPlainString());
exchange.getIn().setHeader(GeoCoderConstants.LNG, resLon.toPlainString());
String resLatlng = resLat.toPlainString() + "," + resLon.toPlainString();
exchange.getIn().setHeader(GeoCoderConstants.LATLNG, resLatlng);
GeocoderAddressComponent country = getCountry(res);
if (country != null) {
exchange.getIn().setHeader(GeoCoderConstants.COUNTRY_SHORT, country.getShortName());
exchange.getIn().setHeader(GeoCoderConstants.COUNTRY_LONG, country.getLongName());
}
GeocoderAddressComponent city = getCity(res);
if (city != null) {
exchange.getIn().setHeader(GeoCoderConstants.CITY, city.getLongName());
}
}
}
开发者ID:HydAu,项目名称:Camel,代码行数:30,代码来源:GeoCoderProducer.java
示例6: testURL
import com.google.code.geocoder.model.GeocoderStatus; //导入依赖的package包/类
@Test
public void testURL() throws IOException {
//Obtenir une réponse
GeocoderRequest geocoderRequest = new GeocoderRequestBuilder().setAddress("Lyon, France").setLanguage("fr").getGeocoderRequest();
GeocodeResponse geocoderResponse = geocoder.geocode(geocoderRequest);
assertEquals(geocoderResponse.getStatus(), GeocoderStatus.OK);
}
开发者ID:openwide-java,项目名称:owsi-core-parent,代码行数:8,代码来源:TestGeocoder.java
示例7: reverseGeocoding
import com.google.code.geocoder.model.GeocoderStatus; //导入依赖的package包/类
@Test
public void reverseGeocoding() throws IOException {
GeocoderRequest geocoderRequest = new GeocoderRequestBuilder().setLocation(new LatLng("45.772216", "4.859242")).setLanguage("fr").getGeocoderRequest();
GeocodeResponse geocoderResponse = geocoder.geocode(geocoderRequest);
assertNotNull(geocoderResponse);
assertEquals(GeocoderStatus.OK, geocoderResponse.getStatus());
assertFalse(geocoderResponse.getResults().isEmpty());
final GeocoderResult geocoderResult = geocoderResponse.getResults().iterator().next();
assertTrue(geocoderResult.getFormattedAddress().contains("Rue Jean Novel"));
}
开发者ID:openwide-java,项目名称:owsi-core-parent,代码行数:11,代码来源:TestGeocoder.java
示例8: testTourismName
import com.google.code.geocoder.model.GeocoderStatus; //导入依赖的package包/类
@Test
public void testTourismName() throws IOException {
String domaine_skiable = "La croix fry"; //Domaine skiable
String restaurant = "Mc Donalds";
String fete = "Fêtes des lumières";
String parc = "Parc de la tête d'or";
GeocoderRequest geocoderRequest = new GeocoderRequestBuilder().setAddress(domaine_skiable).setRegion("fr").setLanguage("fr").getGeocoderRequest();
GeocodeResponse geocoderResponse = geocoder.geocode(geocoderRequest);
assertFalse(geocoderResponse.getResults().iterator().next().getTypes().contains(GeocoderResultType.POINT_OF_INTEREST.value()));
geocoderRequest = new GeocoderRequestBuilder().setAddress(restaurant).setRegion("fr").setLanguage("fr").getGeocoderRequest();
geocoderResponse = geocoder.geocode(geocoderRequest);
assertFalse(geocoderResponse.getResults().iterator().next().getTypes().contains(GeocoderResultType.POINT_OF_INTEREST.value()));
geocoderRequest = new GeocoderRequestBuilder().setAddress(fete).setRegion("fr").setLanguage("fr").getGeocoderRequest();
geocoderResponse = geocoder.geocode(geocoderRequest);
assertEquals(geocoderResponse.getStatus(), GeocoderStatus.ZERO_RESULTS);
geocoderRequest = new GeocoderRequestBuilder().setAddress("restaurant Lyon").setRegion("fr").setLanguage("fr").getGeocoderRequest();
geocoderResponse = geocoder.geocode(geocoderRequest);
assertFalse(geocoderResponse.getResults().iterator().next().getTypes().contains(GeocoderResultType.POINT_OF_INTEREST.value()));
geocoderRequest = new GeocoderRequestBuilder().setAddress(parc).setRegion("fr").setLanguage("fr").getGeocoderRequest();
geocoderResponse = geocoder.geocode(geocoderRequest);
assertTrue(geocoderResponse.getResults().iterator().next().getTypes().contains(GeocoderResultType.PARK.value()));
geocoderRequest = new GeocoderRequestBuilder().setAddress("Aéroport").setRegion("fr").setLanguage("fr").getGeocoderRequest();
geocoderResponse = geocoder.geocode(geocoderRequest);
assertTrue(geocoderResponse.getResults().iterator().next().getTypes().contains(GeocoderResultType.AIRPORT.value()));
geocoderRequest = new GeocoderRequestBuilder().setAddress("L'Yon, Vendée, Pays de la Loire").setRegion("fr").setLanguage("fr").getGeocoderRequest();
geocoderResponse = geocoder.geocode(geocoderRequest);
assertTrue(geocoderResponse.getResults().iterator().next().getTypes().contains(GeocoderResultType.NATURAL_FEATURE.value()));
}
开发者ID:openwide-java,项目名称:owsi-core-parent,代码行数:36,代码来源:TestGeocoder.java
示例9: getGeocode
import com.google.code.geocoder.model.GeocoderStatus; //导入依赖的package包/类
static public SearchNode getGeocode(String location) {
if (location == null)
return null;
Geocoder geocoder = new Geocoder();
LatLngBounds bounds = new LatLngBounds(
new LatLng(new BigDecimal(BOUNDS_SOUTHWEST_LAT), new BigDecimal(BOUNDS_SOUTHWEST_LON)),
new LatLng(new BigDecimal(BOUNDS_NORTHEAST_LAT), new BigDecimal(BOUNDS_NORTHEAST_LON)));
GeocoderRequest geocoderRequest = new GeocoderRequestBuilder()
.setAddress(location)
.setLanguage("de")
.setBounds(bounds)
.getGeocoderRequest();
GeocodeResponse geocoderResponse;
try {
geocoderResponse = geocoder.geocode(geocoderRequest);
if (geocoderResponse.getStatus() == GeocoderStatus.OK
& !geocoderResponse.getResults().isEmpty()) {
GeocoderResult geocoderResult =
geocoderResponse.getResults().iterator().next();
LatLng latitudeLongitude =
geocoderResult.getGeometry().getLocation();
// Only use first part of the address.
Scanner lineScanner = new Scanner(geocoderResult.getFormattedAddress());
lineScanner.useDelimiter(",");
return new SearchNode(
lineScanner.next(),
latitudeLongitude.getLat().doubleValue(),
latitudeLongitude.getLng().doubleValue());
}
} catch (IOException ex) {
ex.printStackTrace();
}
return null;
}
开发者ID:dhasenfratz,项目名称:hRouting_Android,代码行数:41,代码来源:GeocodeProvider.java
示例10: getGeoByPubLatLng
import com.google.code.geocoder.model.GeocoderStatus; //导入依赖的package包/类
private static void getGeoByPubLatLng(Pub pub, final Geocoder geocoder) {
GeocoderRequest request = new GeocoderRequestBuilder()
.setAddress(pub.getLocal())
.setLocation(new LatLng(new BigDecimal(pub.getLat()), new BigDecimal(pub.getLng())))
.setLanguage("en")
.getGeocoderRequest();
GeocodeResponse response = geocoder.geocode(request);
if (response.getStatus().equals(GeocoderStatus.OK)) {
List<GeocoderResult> results = response.getResults();
for (GeocoderResult geoResult : results) {
List<GeocoderAddressComponent> addressComponents = geoResult.getAddressComponents();
for (GeocoderAddressComponent address : addressComponents) {
if (address.getTypes().contains("locality")) {
pub.setCity(address.getLongName());
}
if (address.getTypes().contains("administrative_area_level_1")) {
pub.setState(address.getLongName());
}
if (address.getTypes().contains("country")) {
pub.setCountry(address.getLongName());
}
}
}
} else {
log.info(response.getStatus().name());
}
}
开发者ID:thiagoandrade6,项目名称:pubanywhere,代码行数:31,代码来源:GeocoderUtils.java
示例11: getGeoByPubAddress
import com.google.code.geocoder.model.GeocoderStatus; //导入依赖的package包/类
private static void getGeoByPubAddress(Pub pub, final Geocoder geocoder) {
GeocoderRequest request = new GeocoderRequestBuilder()
.setAddress(pub.getLocal())
.setLanguage("en")
.getGeocoderRequest();
GeocodeResponse response = geocoder.geocode(request);
if (response.getStatus().equals(GeocoderStatus.OK)) {
List<GeocoderResult> results = response.getResults();
for (GeocoderResult geoResult : results) {
BigDecimal lat = geoResult.getGeometry().getLocation().getLat();
BigDecimal lng = geoResult.getGeometry().getLocation().getLng();
pub.setLat(lat.doubleValue());
pub.setLng(lng.doubleValue());
List<GeocoderAddressComponent> addressComponents = geoResult.getAddressComponents();
for (GeocoderAddressComponent address : addressComponents) {
if (address.getTypes().contains("locality")) {
pub.setCity(address.getLongName());
}
if (address.getTypes().contains("administrative_area_level_1")) {
pub.setState(address.getLongName());
}
if (address.getTypes().contains("country")) {
pub.setCountry(address.getLongName());
}
}
}
} else {
log.info(response.getStatus().name());
}
}
开发者ID:thiagoandrade6,项目名称:pubanywhere,代码行数:36,代码来源:GeocoderUtils.java
示例12: getGeoByLatLng
import com.google.code.geocoder.model.GeocoderStatus; //导入依赖的package包/类
public static Map<String, String> getGeoByLatLng(Double lat, Double lng) {
Map<String, String> map = new HashMap<String, String>();
final Geocoder geocoder = new Geocoder();
GeocoderRequest request = new GeocoderRequestBuilder()
.setLocation(new LatLng(new BigDecimal(lat), new BigDecimal(lng)))
.setLanguage("en")
.getGeocoderRequest();
GeocodeResponse response = geocoder.geocode(request);
if (response.getStatus().equals(GeocoderStatus.OK)) {
List<GeocoderResult> results = response.getResults();
for (GeocoderResult geoResult : results) {
List<GeocoderAddressComponent> addressComponents = geoResult.getAddressComponents();
for (GeocoderAddressComponent address : addressComponents) {
if (address.getTypes().contains("locality")) {
map.put("CITY", address.getLongName());
}
if (address.getTypes().contains("administrative_area_level_1")) {
map.put("STATE", address.getLongName());
}
if (address.getTypes().contains("country")) {
map.put("COUNTRY", address.getLongName());
}
}
}
} else {
log.info(response.getStatus().name());
}
return map;
}
开发者ID:thiagoandrade6,项目名称:pubanywhere,代码行数:36,代码来源:GeocoderUtils.java
示例13: main
import com.google.code.geocoder.model.GeocoderStatus; //导入依赖的package包/类
public static void main(String[] args) {
final Geocoder geocoder = new Geocoder();
GeocoderRequest request = new GeocoderRequestBuilder()
.setAddress("The Promenade, Lahinch. Co. Clare. Ireland")
.setLanguage("en").getGeocoderRequest();
GeocodeResponse response = geocoder.geocode(request);
if (response.getStatus().equals(GeocoderStatus.OK)) {
List<GeocoderResult> results = response.getResults();
for (GeocoderResult geoResult : results) {
System.out.println(geoResult.getFormattedAddress());
BigDecimal lat = geoResult.getGeometry().getLocation().getLat();
BigDecimal lng = geoResult.getGeometry().getLocation().getLng();
System.out.println("lat: " + lat);
System.out.println("lng: " + lng);
List<GeocoderAddressComponent> addressComponents = geoResult.getAddressComponents();
for (GeocoderAddressComponent address : addressComponents) {
if (address.getTypes().contains("locality")) {
System.out.println("Cidade: " + address.getLongName());
}
if (address.getTypes().contains("administrative_area_level_1")) {
System.out.println("Estado: " + address.getLongName());
}
if (address.getTypes().contains("country")) {
System.out.println("País: " + address.getLongName());
}
}
}
}
}
开发者ID:thiagoandrade6,项目名称:pubanywhere,代码行数:37,代码来源:GoogleGeocoder.java
示例14: getLatLongZip
import com.google.code.geocoder.model.GeocoderStatus; //导入依赖的package包/类
private LatLong getLatLongZip( String zipcode ) {
final Geocoder geocoder = new Geocoder();
GeocoderRequest request = new GeocoderRequestBuilder().setAddress(zipcode).setLanguage("en").getGeocoderRequest();
GeocodeResponse response = geocoder.geocode(request);
LatLong ll = null;
if( response != null && response.getStatus() == GeocoderStatus.OK ) {
for( GeocoderResult geoResult : response.getResults() ) {
LatLng googLatLong = geoResult.getGeometry().getLocation();
ll = new LatLong( googLatLong.getLat().floatValue(), googLatLong.getLng().floatValue() );
}
}
return ll;
}
开发者ID:aws-reinvent-hackathon-2013-team,项目名称:UnitedWayRESTBackend,代码行数:15,代码来源:VolunteerService.java
示例15: geocode
import com.google.code.geocoder.model.GeocoderStatus; //导入依赖的package包/类
public static GeoPt geocode(String address) throws GeocodeFailedException, GeocodeNotFoundException {
// The underlying geocoder library fails if it receives an empty address.
if (address.trim().isEmpty()) {
throw new GeocodeFailedException(address, GeocoderStatus.INVALID_REQUEST);
}
String cacheKey = "geocode:" + address;
CacheProxy cache = new CacheProxy();
Object cacheEntry = cache.get(cacheKey);
// Backwards comparison -- cacheEntry may be null
if (INVALID_LOCATION.equals(cacheEntry)) {
throw new GeocodeNotFoundException(address);
}
if (cacheEntry != null) {
return (GeoPt) cacheEntry;
}
Geocoder geocoder = new Geocoder(); // TODO: Use Maps for Business?
GeocoderRequest request = new GeocoderRequestBuilder().setAddress(address).getGeocoderRequest();
GeocodeResponse response = geocoder.geocode(request);
GeocoderStatus status = response.getStatus();
if (status == GeocoderStatus.ZERO_RESULTS) {
cache.put(cacheKey, INVALID_LOCATION);
throw new GeocodeNotFoundException(address);
} else if (status != GeocoderStatus.OK) {
// We've encountered a temporary error, so return without caching the missing point.
throw new GeocodeFailedException(address, response.getStatus());
} else {
LatLng location = response.getResults().get(0).getGeometry().getLocation();
GeoPt geoPt = new GeoPt(location.getLat().floatValue(), location.getLng().floatValue());
cache.put(cacheKey, geoPt);
return geoPt;
}
}
开发者ID:openmash,项目名称:mashmesh,代码行数:38,代码来源:GeoUtils.java
示例16: processCurrentLocation
import com.google.code.geocoder.model.GeocoderStatus; //导入依赖的package包/类
protected void processCurrentLocation(Exchange exchange) throws Exception {
LOG.debug("Geocode for current address");
String json = exchange.getContext().getTypeConverter().mandatoryConvertTo(String.class, new URL("http://freegeoip.net/json/"));
if (isEmpty(json)) {
throw new IllegalStateException("Got the unexpected value '" + json + "' for the geolocation");
}
LOG.debug("Geocode response {}", json);
exchange.getIn().setHeader(GeoCoderConstants.STATUS, GeocoderStatus.OK);
ObjectMapper mapper = new ObjectMapper();
JsonNode node = mapper.readValue(json, JsonNode.class);
JsonNode latitudeNode = notNull(node.get("latitude"), "latitude");
JsonNode longitudeNode = notNull(node.get("longitude"), "longitude");
String resLatlng = latitudeNode.asText() + "," + longitudeNode.asText();
exchange.getIn().setHeader(GeoCoderConstants.LATLNG, resLatlng);
JsonNode countryCode = node.get("country_code");
JsonNode countryName = node.get("country_name");
if (countryCode != null) {
exchange.getIn().setHeader(GeoCoderConstants.COUNTRY_SHORT, countryCode.asText());
}
if (countryName != null) {
exchange.getIn().setHeader(GeoCoderConstants.COUNTRY_LONG, countryName.asText());
}
JsonNode regionCode = node.get("region_code");
JsonNode regionName = node.get("region_name");
if (regionCode != null) {
exchange.getIn().setHeader(GeoCoderConstants.REGION_CODE, regionCode.asText());
}
if (regionName != null) {
exchange.getIn().setHeader(GeoCoderConstants.REGION_NAME, regionName.asText());
}
JsonNode city = node.get("city");
if (city != null) {
exchange.getIn().setHeader(GeoCoderConstants.CITY, city.asText());
}
// should we include body
if (!endpoint.isHeadersOnly()) {
exchange.getIn().setBody(json);
}
}
开发者ID:HydAu,项目名称:Camel,代码行数:47,代码来源:GeoCoderProducer.java
示例17: setGeoLocation
import com.google.code.geocoder.model.GeocoderStatus; //导入依赖的package包/类
/**
* I am currently calling the Google Geolocation API.
* The limit for this api is 2400 per day.
*
* @author lancepoehler
* @throws InterruptedException
*
*/
public static boolean setGeoLocation(Location location) throws InterruptedException {
LOG.debug("Calling Google GeoLocation API");
try {
final Geocoder geocoder = new Geocoder();
GeocoderRequest geocoderRequest;
GeocodeResponse geocoderResponse=null;
//This will fail if it is not synchronized. The classes are not threadsafe
synchronized(GoogleGeocoderApiHelper.class) {
try {
final String address = buildAddressString(location);
if(address==null || StringUtils.isBlank(address)) {
LOG.error("Geocoder called with blank address, aborting call");
return false;
}
geocoderRequest = new GeocoderRequestBuilder()
.setAddress(address)
.setLanguage("en")
.getGeocoderRequest();
geocoderResponse = geocoder.geocode(geocoderRequest);
} catch(Throwable oops) {
LOG.error("Error calling geocoder service", oops);
return false;
}
}
if (geocoderResponse==null ||
geocoderResponse.getStatus()==null ||
geocoderResponse.getStatus() != GeocoderStatus.OK) {
return false;
}
String fullAddress = geocoderResponse.getResults().get(0).getFormattedAddress();
if (geocoderResponse.getResults().get(0).isPartialMatch())
{
if (!fullAddress.toLowerCase().contains(location.city.toLowerCase()) ||
!fullAddress.toLowerCase().contains(", "+location.state.toLowerCase())) {
return false;
}
} else if (StringUtils.isNotBlank(location.streetAddress) && //This will check for crazy addresses that are not returned with an address
fullAddress.toLowerCase().startsWith(location.city.toLowerCase() + ", " + location.state.toLowerCase())) {
return false;
}
GeoLoc geoLoc = new GeoLoc();
geoLoc.latitude = geocoderResponse.getResults().get(0).getGeometry().getLocation().getLat();
geoLoc.longitude = geocoderResponse.getResults().get(0).getGeometry().getLocation().getLng();
location.geoLoc = (geoLoc);
location.formattedAddress = fullAddress;
return true;
} catch (Exception e) {
e.printStackTrace();
return false;
}
}
开发者ID:lancempoe,项目名称:BikeFunWebService,代码行数:69,代码来源:GoogleGeocoderApiHelper.java
示例18: testGeocoderComponent
import com.google.code.geocoder.model.GeocoderStatus; //导入依赖的package包/类
@Test
public void testGeocoderComponent() throws Exception {
HttpClientConfigurer configurer = new GeocoderHttpClientConfigurer();
initialContext.bind("httpClientConfigurer", configurer);
CamelContext camelctx = new DefaultCamelContext();
camelctx.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("direct:start")
.to("geocoder:address:London, England?httpClientConfigurer=#httpClientConfigurer");
}
});
camelctx.start();
try {
// Geocoder API is sometimes flaky so retry the request if necessary
GeocodeResponse result = null;
int count = 0;
while (count < 5) {
ProducerTemplate template = camelctx.createProducerTemplate();
result = template.requestBody("direct:start", null, GeocodeResponse.class);
Assert.assertNotNull("Geocoder response is null", result);
// Skip further testing if we exceeded the API rate limit
GeocoderStatus status = result.getStatus();
Assume.assumeFalse("Geocoder API rate limit exceeded", status.equals(OVER_QUERY_LIMIT));
if (status.equals(OK)) {
break;
}
Thread.sleep(1000);
count++;
}
List<GeocoderResult> results = result.getResults();
Assert.assertNotNull("Geocoder results is null", result);
Assert.assertEquals("Expected 1 GeocoderResult to be returned", 1, results.size());
LatLng location = results.get(0).getGeometry().getLocation();
Assert.assertEquals("51.5073509", location.getLat().toPlainString());
Assert.assertEquals("-0.1277583", location.getLng().toPlainString());
} finally {
camelctx.stop();
initialContext.unbind("httpClientConfigurer");
}
}
开发者ID:wildfly-extras,项目名称:wildfly-camel,代码行数:50,代码来源:GeocoderIntegrationTest.java
示例19: GeocodeFailedException
import com.google.code.geocoder.model.GeocoderStatus; //导入依赖的package包/类
public GeocodeFailedException(String address, GeocoderStatus status) {
this.address = address;
this.status = status;
}
开发者ID:openmash,项目名称:mashmesh,代码行数:5,代码来源:GeocodeFailedException.java
示例20: getStatus
import com.google.code.geocoder.model.GeocoderStatus; //导入依赖的package包/类
public GeocoderStatus getStatus() {
return status;
}
开发者ID:openmash,项目名称:mashmesh,代码行数:4,代码来源:GeocodeFailedException.java
注:本文中的com.google.code.geocoder.model.GeocoderStatus类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论