use of com.google.maps.model.LatLng in project cas by apereo.
the class GoogleMapsGeoLocationService method locate.
@Override
public GeoLocationResponse locate(final Double latitude, final Double longitude) {
if (latitude == null || longitude == null) {
LOGGER.debug("latitude/longitude must not be null in order for geolocation to proceed");
return null;
}
final GeoLocationResponse r = new GeoLocationResponse();
r.setLatitude(latitude);
r.setLongitude(longitude);
final LatLng latlng = new LatLng(latitude, longitude);
try {
final GeocodingResult[] results = GeocodingApi.reverseGeocode(this.context, latlng).await();
if (results != null && results.length > 0) {
Arrays.stream(results).map(result -> result.formattedAddress).forEach(r::addAddress);
return r;
}
} catch (final Exception e) {
LOGGER.error(e.getMessage(), e);
}
return r;
}
use of com.google.maps.model.LatLng in project amos-ss17-alexa by c-i-ber.
the class LocationTest method placesTest.
@Test
public void placesTest() throws InterruptedException {
Address dummyAddress = new Address();
String slotValue = "Sparkasse";
LatLng deviceLocation = GeoCoder.getLatLng(dummyAddress);
List<Place> places = PlaceFinder.findNearbyPlace(deviceLocation, slotValue);
Place place = PlaceFinder.findOpeningHoursPlace(places, slotValue);
log.warn("Addresse: " + place.getAddress());
for (Hours.Period period : place.getHours().getPeriods()) {
log.info("Place: " + period.getOpeningDay());
log.info("Place: " + period.getOpeningTime());
log.info("Place: " + period.getClosingTime());
}
}
Aggregations