Search in sources :

Example 1 with LatLng

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;
}
Also used : Arrays(java.util.Arrays) GeocodingResult(com.google.maps.model.GeocodingResult) Logger(org.slf4j.Logger) GeoApiContext(com.google.maps.GeoApiContext) LoggerFactory(org.slf4j.LoggerFactory) UserInfo(io.userinfo.client.UserInfo) StringUtils(org.apache.commons.lang3.StringUtils) GaeRequestHandler(com.google.maps.GaeRequestHandler) Info(io.userinfo.client.model.Info) InetAddress(java.net.InetAddress) TimeUnit(java.util.concurrent.TimeUnit) GeocodingApi(com.google.maps.GeocodingApi) GeoLocationResponse(org.apereo.cas.authentication.adaptive.geo.GeoLocationResponse) AbstractGeoLocationService(org.apereo.cas.support.geo.AbstractGeoLocationService) LatLng(com.google.maps.model.LatLng) GoogleMapsProperties(org.apereo.cas.configuration.model.support.geo.googlemaps.GoogleMapsProperties) Logger(org.slf4j.Logger) GaeRequestHandler(com.google.maps.GaeRequestHandler) GeocodingResult(com.google.maps.model.GeocodingResult) GeoLocationResponse(org.apereo.cas.authentication.adaptive.geo.GeoLocationResponse) LatLng(com.google.maps.model.LatLng)

Example 2 with LatLng

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());
    }
}
Also used : Address(amosalexa.services.bankcontact.Address) Hours(se.walkercrou.places.Hours) LatLng(com.google.maps.model.LatLng) Place(se.walkercrou.places.Place) Test(org.junit.Test)

Aggregations

LatLng (com.google.maps.model.LatLng)2 Address (amosalexa.services.bankcontact.Address)1 GaeRequestHandler (com.google.maps.GaeRequestHandler)1 GeoApiContext (com.google.maps.GeoApiContext)1 GeocodingApi (com.google.maps.GeocodingApi)1 GeocodingResult (com.google.maps.model.GeocodingResult)1 UserInfo (io.userinfo.client.UserInfo)1 Info (io.userinfo.client.model.Info)1 InetAddress (java.net.InetAddress)1 Arrays (java.util.Arrays)1 TimeUnit (java.util.concurrent.TimeUnit)1 StringUtils (org.apache.commons.lang3.StringUtils)1 GeoLocationResponse (org.apereo.cas.authentication.adaptive.geo.GeoLocationResponse)1 GoogleMapsProperties (org.apereo.cas.configuration.model.support.geo.googlemaps.GoogleMapsProperties)1 AbstractGeoLocationService (org.apereo.cas.support.geo.AbstractGeoLocationService)1 Test (org.junit.Test)1 Logger (org.slf4j.Logger)1 LoggerFactory (org.slf4j.LoggerFactory)1 Hours (se.walkercrou.places.Hours)1 Place (se.walkercrou.places.Place)1