use of com.esri.core.geometry.ogc.OGCGeometry in project presto by prestodb.
the class TestSpatialPartitioningInternalAggregation method test.
@Test(dataProvider = "partitionCount")
public void test(int partitionCount) {
InternalAggregationFunction function = getFunction();
List<OGCGeometry> geometries = makeGeometries();
Block geometryBlock = makeGeometryBlock(geometries);
Block partitionCountBlock = BlockAssertions.createRLEBlock(partitionCount, geometries.size());
String expectedValue = getSpatialPartitioning(geometries, partitionCount);
AccumulatorFactory accumulatorFactory = function.bind(Ints.asList(0, 1), Optional.empty());
Page page = new Page(geometryBlock, partitionCountBlock);
Accumulator accumulator = accumulatorFactory.createAccumulator(UpdateMemory.NOOP);
accumulator.addInput(page);
String aggregation = (String) BlockAssertions.getOnlyValue(accumulator.getFinalType(), getFinalBlock(accumulator));
assertEquals(aggregation, expectedValue);
GroupedAccumulator groupedAggregation = accumulatorFactory.createGroupedAccumulator(UpdateMemory.NOOP);
groupedAggregation.addInput(createGroupByIdBlock(0, page.getPositionCount()), page);
String groupValue = (String) getGroupValue(groupedAggregation, 0);
assertEquals(groupValue, expectedValue);
}
use of com.esri.core.geometry.ogc.OGCGeometry in project presto by prestodb.
the class TestBingTile method assertTileCovering.
private void assertTileCovering(String wkt, int zoom, List<String> quadkeys) {
OGCGeometry geometry = OGCGeometry.fromText(wkt);
List<String> actual = findDissolvedTileCovering(geometry, zoom).stream().map(BingTile::toQuadKey).sorted().collect(toImmutableList());
List<String> expected = ImmutableList.sortedCopyOf(quadkeys);
assertEquals(actual, expected, format("Actual:\n%s\nExpected:\n%s", actual, expected));
}
use of com.esri.core.geometry.ogc.OGCGeometry in project presto by prestodb.
the class TestGeometrySerialization method testEsriSerialization.
private static void testEsriSerialization(String wkt) {
OGCGeometry expected = OGCGeometry.fromText(wkt);
OGCGeometry actual = deserialize(serialize(expected));
assertGeometryEquals(actual, expected);
}
use of com.esri.core.geometry.ogc.OGCGeometry in project presto by prestodb.
the class TestGeometrySerialization method tryDeserializeJtsFromEsri.
private static void tryDeserializeJtsFromEsri(String wkt) {
OGCGeometry esriGeometry = OGCGeometry.fromText(wkt);
JtsGeometrySerde.deserialize(EsriGeometrySerde.serialize(esriGeometry));
}
use of com.esri.core.geometry.ogc.OGCGeometry in project presto by prestodb.
the class BingTileFunctions method geometryToBingTiles.
@Description("Given a geometry and a zoom level, returns the minimum set of Bing tiles of that zoom level that fully covers that geometry")
@ScalarFunction("geometry_to_bing_tiles")
@SqlType("array(" + BingTileType.NAME + ")")
public static Block geometryToBingTiles(@SqlType(GEOMETRY_TYPE_NAME) Slice input, @SqlType(StandardTypes.INTEGER) long zoomLevelInput) {
Envelope envelope = deserializeEnvelope(input);
if (envelope.isEmpty()) {
return EMPTY_TILE_ARRAY;
}
int zoomLevel = toIntExact(zoomLevelInput);
GeometrySerializationType type = deserializeType(input);
List<BingTile> covering;
if (type == GeometrySerializationType.POINT || type == GeometrySerializationType.ENVELOPE) {
covering = findMinimalTileCovering(envelope, zoomLevel);
} else {
OGCGeometry ogcGeometry = deserialize(input);
if (isPointOrRectangle(ogcGeometry, envelope)) {
covering = findMinimalTileCovering(envelope, zoomLevel);
} else {
covering = findMinimalTileCovering(ogcGeometry, zoomLevel);
}
}
BlockBuilder blockBuilder = BIGINT.createBlockBuilder(null, covering.size());
for (BingTile tile : covering) {
BIGINT.writeLong(blockBuilder, tile.encode());
}
return blockBuilder.build();
}
Aggregations