Beispiel #1
0
 /**
  * Creates a wrapper that contains a collection of all queries that are generated as a result of
  * this rectangle 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 bounding box of the queried rectangle. This is needed
  * because queries are fired for every cell that intersects with the rectangle's bounding box.
  *
  * @param queryRequest the request that needs to be decorated with geo attributes
  * @param minLatitude the latitude of the min point of the rectangle
  * @param minLongitude the longitude of the min point of the rectangle
  * @param maxLatitude the latitude of the max point of the rectangle
  * @param maxLongitude the longitude of the max point of the rectangle
  * @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 rectangleQuery(
     QueryRequest queryRequest,
     double minLatitude,
     double minLongitude,
     double maxLatitude,
     double maxLongitude,
     GeoConfig config,
     Optional<String> compositeKeyValue) {
   checkConfigParams(
       config.getGeoIndexName(),
       config.getGeoHashKeyColumn(),
       config.getGeoHashColumn(),
       config.getGeoHashKeyLength());
   // bounding box is needed for the filter and to generate the queries
   // for each cell that intersects with the bounding box
   S2LatLngRect boundingBox =
       s2Manager.getBoundingBoxForRectangleQuery(
           minLatitude, minLongitude, maxLatitude, maxLongitude);
   GeoFilter filter = GeoFilters.newRectangleFilter(boundingBox);
   List<QueryRequest> geoQueries =
       geoQueryHelper.generateGeoQueries(queryRequest, boundingBox, config, compositeKeyValue);
   return new GeoQueryRequest(geoQueries, filter);
 }
Beispiel #2
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);
 }