示例#1
0
 /**
  * Creates a wrapper that contains a collection of all queries that are generated as a result of
  * the radius query. It also contains a filter {@link com.amazonaws.geo.model.filters.GeoFilter}
  * that needs to be applied to the results of the query to ensure that everything is in the
  * radius. This is needed because queries are fired for every cell that intersects with the
  * radius' rectangle box.
  *
  * @param queryRequest the request that needs to be decorated with geo attributes
  * @param latitude the latitude of the center point for the radius query
  * @param longitude the longitude of the center point for the radius query
  * @param radius the radius (in metres)
  * @param config the configuration to be used for decorating the request with geo attributes
  * @param compositeKeyValue the value of the column that is used in the construction of the
  *     composite hash key(geoHashKey + someOtherColumnValue). This is needed when constructing
  *     queries that need a composite hash key. For eg. Fetch an item where lat/long is 23.78787,
  *     -70.6767 AND category = 'restaurants'
  * @return the wrapper containing the generated queries and the geo filter
  */
 public GeoQueryRequest radiusQuery(
     QueryRequest queryRequest,
     double latitude,
     double longitude,
     double radius,
     GeoConfig config,
     Optional<String> compositeKeyValue) {
   checkArgument(radius >= 0.0d, "radius has to be a positive value: %s", radius);
   checkConfigParams(
       config.getGeoIndexName(),
       config.getGeoHashKeyColumn(),
       config.getGeoHashColumn(),
       config.getGeoHashKeyLength());
   // Center latLong is needed for the radius filter
   S2LatLng centerLatLng = S2LatLng.fromDegrees(latitude, longitude);
   GeoFilter filter = GeoFilters.newRadiusFilter(centerLatLng, radius);
   // Bounding box is needed to generate queries for each cell that intersects with the bounding
   // box
   S2LatLngRect boundingBox = s2Manager.getBoundingBoxForRadiusQuery(latitude, longitude, radius);
   List<QueryRequest> geoQueries =
       geoQueryHelper.generateGeoQueries(queryRequest, boundingBox, config, compositeKeyValue);
   return new GeoQueryRequest(geoQueries, filter);
 }
示例#2
0
 @Override
 public int compare(final S2LatLng locA, final S2LatLng locB) {
   return me.getDistance(locA).compareTo(me.getDistance(locB));
 }
 /** Return the leaf cell containing the given {@link S2LatLng}. */
 public static S2CellId fromLatLng(S2LatLng ll) {
   return fromPoint(ll.toPoint());
 }