GeoHashGrid { @SuppressWarnings("unchecked") List<Map<String,Object>> pluckAggBuckets(Map<String, Object> parentBucket, String aggKey) { if (!parentBucket.containsKey(aggKey)) { LOGGER.warning("Unable to pluck aggregation results, parent bucket does not contain required key:" + aggKey); throw new IllegalArgumentException(); } Map<String,Object> aggResults = (Map<String,Object>) parentBucket.get(aggKey); if (!aggResults.containsKey(BUCKETS_KEY)) { LOGGER.warning("Unable to pluck buckets, aggregation results bucket does not contain required key:" + BUCKETS_KEY); throw new IllegalArgumentException(); } return (List<Map<String,Object>>) aggResults.get(BUCKETS_KEY); } GeoHashGrid(); void initalize(ReferencedEnvelope srcEnvelope, SimpleFeatureCollection features); GridCoverage2D toGridCoverage2D(); void setParams(List<String> params); void setEmptyCellValue(Float value); double getCellWidth(); double getCellHeight(); Envelope getEnvelope(); ReferencedEnvelope getBoundingBox(); float[][] getGrid(); void setScale(RasterScale scale); static final String BUCKET_NAME_KEY; static final String BUCKETS_KEY; static final String DOC_COUNT_KEY; static final String VALUE_KEY; }
@Test public void testPluckAggBuckets() { List<Map<String,Object>> buckets = this.geohashGrid.pluckAggBuckets(AGG_BUCKET, AGG_KEY); assertEquals(AGG_RESULTS.length, buckets.size()); }
@Test(expected=IllegalArgumentException.class) public void testPluckAggBuckets_canNotFindAggKey() { this.geohashGrid.pluckAggBuckets(AGG_BUCKET, "noGonnaFindMe"); }