@Test public void testGeoHashGrid() throws Exception { features = TestUtil.createAggregationFeatures( ImmutableList.of( ImmutableMap.of( "_aggregation", mapper.writeValueAsBytes( ImmutableMap.of( "key", GeoHash.encodeHash( new LatLong(-89.9, -179.9), 1), "doc_count", 10))))); ReferencedEnvelope envelope = new ReferencedEnvelope(-180, 180, -90, 90, DefaultGeographicCRS.WGS84); geohashGrid.initalize(envelope, features); assertEquals(GeoHash.widthDegrees(1), geohashGrid.getCellWidth(), 1e-10); assertEquals(GeoHash.heightDegrees(1), geohashGrid.getCellHeight(), 1e-10); assertEquals( new Envelope( -180 + GeoHash.widthDegrees(1) / 2., 180 - GeoHash.widthDegrees(1) / 2., -90 + GeoHash.heightDegrees(1) / 2., 90 - GeoHash.heightDegrees(1) / 2.), geohashGrid.getEnvelope()); int ny = (int) Math.round(180 / geohashGrid.getCellHeight()); int nx = (int) Math.round(360 / GeoHash.widthDegrees(1)); float[][] expected = new float[ny][nx]; expected[ny - 1][0] = 10; assertEquals(ny, geohashGrid.getGrid().length); assertEquals(nx, geohashGrid.getGrid()[0].length); IntStream.range(0, ny) .forEach(i -> assertArrayEquals(expected[i], geohashGrid.getGrid()[i], 0.0f)); }
GeoHashGrid() { this.emptyCellValue = 0; this.scale = new RasterScale(); }
GeoHashGrid { GeoHashGrid() { this.emptyCellValue = 0; this.scale = new RasterScale(); } }
GeoHashGrid { GeoHashGrid() { this.emptyCellValue = 0; this.scale = new RasterScale(); } GeoHashGrid(); }
GeoHashGrid { GeoHashGrid() { this.emptyCellValue = 0; this.scale = new RasterScale(); } 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); }
GeoHashGrid { GeoHashGrid() { this.emptyCellValue = 0; this.scale = new RasterScale(); } 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; }