com.google.appengine.api.datastore.GeoPt

Here are the examples of the java api class com.google.appengine.api.datastore.GeoPt taken from open source projects.

1. PlaceEndpoint#list()

Project: solutions-mobile-shopping-assistant-backend-java
File: PlaceEndpoint.java
/**
   * This method lists nearby places. It uses HTTP GET method.
   *
   * @return List of nearby places.
   */
@ApiMethod(httpMethod = "GET", path = "place")
public List<PlaceInfo> list(@Named("longitude") String longitudeString, @Named("latitude") String latitudeString, @Named("distanceInKm") long distanceInKm, @Named("count") int count, User user) throws ServiceException {
    float latitude;
    float longitude;
    GeoPt location;
    try {
        latitude = (float) Double.parseDouble(latitudeString);
    } catch (Exception e) {
        throw new BadRequestException("Invalid value of 'latitude' argument");
    }
    try {
        longitude = (float) Double.parseDouble(longitudeString);
    } catch (Exception e) {
        throw new BadRequestException("Invalid value of 'longitude' argument");
    }
    try {
        location = new GeoPt(latitude, longitude);
    } catch (Exception e) {
        throw new BadRequestException("Invalid pair of 'latitude' and 'longitude' arguments");
    }
    // limit the result set to up to 100 places within up to 200 km
    if (count > 100) {
        count = 100;
    } else if (count <= 0) {
        throw new BadRequestException("Invalid value of 'count' argument");
    }
    if (distanceInKm > 200) {
        distanceInKm = 200;
    } else if (distanceInKm < 0) {
        throw new BadRequestException("Invalid value of 'distanceInKm' argument");
    }
    List<PlaceInfo> places = PlacesHelper.getPlaces(location, 1000 * distanceInKm, count);
    return places;
}