GeoHashGrid { String pluckBucketName(Map<String, Object> bucket) { if (!bucket.containsKey(BUCKET_NAME_KEY)) { LOGGER.warning("Unable to pluck key, bucket does not contain required field:" + BUCKET_NAME_KEY); throw new IllegalArgumentException(); } return bucket.get(BUCKET_NAME_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 testPluckBucketName() { String plucked = this.geohashGrid.pluckBucketName(SIMPLE_BUCKET); assertEquals(BUCKET_NAME, plucked); }
@Test public void testPluckBucketName_doubleKey() { Map<String,Object> bucket = new HashMap<>(); bucket.put(GeoHashGrid.BUCKET_NAME_KEY, 2.0); bucket.put("doc_count", DOC_COUNT); String plucked = this.geohashGrid.pluckBucketName(bucket); assertEquals("2.0", plucked); }
@Test(expected=IllegalArgumentException.class) public void testPluckBucketName_invalidKey() { Map<String,Object> bucket = new HashMap<>(); bucket.put("invalid", "invalid"); this.geohashGrid.pluckBucketName(bucket); }