|
36 | 36 | import static com.facebook.presto.common.function.OperatorType.CAST; |
37 | 37 | import static com.facebook.presto.common.type.BigintType.BIGINT; |
38 | 38 | import static com.facebook.presto.common.type.IntegerType.INTEGER; |
39 | | -import static com.facebook.presto.geospatial.BingTile.MAX_ZOOM_LEVEL; |
40 | 39 | import static com.facebook.presto.geospatial.BingTileUtils.EARTH_RADIUS_KM; |
41 | 40 | import static com.facebook.presto.geospatial.BingTileUtils.LATITUDE_OUT_OF_RANGE; |
42 | 41 | import static com.facebook.presto.geospatial.BingTileUtils.LONGITUDE_OUT_OF_RANGE; |
|
59 | 58 | import static com.facebook.presto.geospatial.BingTileUtils.mapSize; |
60 | 59 | import static com.facebook.presto.geospatial.BingTileUtils.tileToEnvelope; |
61 | 60 | import static com.facebook.presto.geospatial.BingTileUtils.tileXYToLatitudeLongitude; |
62 | | -import static com.facebook.presto.geospatial.GeometryUtils.contains; |
63 | | -import static com.facebook.presto.geospatial.GeometryUtils.disjoint; |
64 | 61 | import static com.facebook.presto.geospatial.GeometryUtils.isPointOrRectangle; |
65 | 62 | import static com.facebook.presto.geospatial.serde.EsriGeometrySerde.deserialize; |
66 | 63 | import static com.facebook.presto.geospatial.serde.EsriGeometrySerde.deserializeEnvelope; |
|
69 | 66 | import static com.facebook.presto.geospatial.type.GeometryType.GEOMETRY_TYPE_NAME; |
70 | 67 | import static com.facebook.presto.spi.StandardErrorCode.INVALID_CAST_ARGUMENT; |
71 | 68 | import static com.facebook.presto.spi.StandardErrorCode.INVALID_FUNCTION_ARGUMENT; |
72 | | -import static com.google.common.base.Preconditions.checkArgument; |
73 | | -import static com.google.common.base.Verify.verify; |
74 | 69 | import static io.airlift.slice.Slices.utf8Slice; |
75 | 70 | import static java.lang.Math.asin; |
76 | 71 | import static java.lang.Math.atan2; |
|
90 | 85 | */ |
91 | 86 | public class BingTileFunctions |
92 | 87 | { |
93 | | - private static final int OPTIMIZED_TILING_MIN_ZOOM_LEVEL = 10; |
94 | 88 | private static final Block EMPTY_TILE_ARRAY = BIGINT.createFixedSizeBlockBuilder(0).build(); |
95 | 89 |
|
96 | 90 | private BingTileFunctions() {} |
@@ -547,82 +541,6 @@ private static double addDistanceToLatitude( |
547 | 541 | return newLatitude; |
548 | 542 | } |
549 | 543 |
|
550 | | - private static BingTile[] getTilesInBetween(BingTile leftUpperTile, BingTile rightLowerTile, int zoomLevel) |
551 | | - { |
552 | | - checkArgument(leftUpperTile.getZoomLevel() == rightLowerTile.getZoomLevel()); |
553 | | - checkArgument(leftUpperTile.getZoomLevel() > zoomLevel); |
554 | | - |
555 | | - int divisor = 1 << (leftUpperTile.getZoomLevel() - zoomLevel); |
556 | | - int minX = (int) Math.floor(leftUpperTile.getX() / divisor); |
557 | | - int maxX = (int) Math.floor(rightLowerTile.getX() / divisor); |
558 | | - int minY = (int) Math.floor(leftUpperTile.getY() / divisor); |
559 | | - int maxY = (int) Math.floor(rightLowerTile.getY() / divisor); |
560 | | - |
561 | | - BingTile[] tiles = new BingTile[(maxX - minX + 1) * (maxY - minY + 1)]; |
562 | | - int index = 0; |
563 | | - for (int x = minX; x <= maxX; x++) { |
564 | | - for (int y = minY; y <= maxY; y++) { |
565 | | - tiles[index] = BingTile.fromCoordinates(x, y, OPTIMIZED_TILING_MIN_ZOOM_LEVEL); |
566 | | - index++; |
567 | | - } |
568 | | - } |
569 | | - |
570 | | - return tiles; |
571 | | - } |
572 | | - |
573 | | - /** |
574 | | - * Identifies a minimum set of tiles at specified zoom level that cover intersection of the |
575 | | - * specified geometry and a specified tile of the same or lower level. Adds tiles to provided |
576 | | - * BlockBuilder. |
577 | | - */ |
578 | | - private static void appendIntersectingSubtiles( |
579 | | - OGCGeometry ogcGeometry, |
580 | | - int zoomLevel, |
581 | | - BingTile tile, |
582 | | - BlockBuilder blockBuilder) |
583 | | - { |
584 | | - int tileZoomLevel = tile.getZoomLevel(); |
585 | | - checkArgument(tileZoomLevel <= zoomLevel); |
586 | | - |
587 | | - Envelope tileEnvelope = tileToEnvelope(tile); |
588 | | - if (tileZoomLevel == zoomLevel) { |
589 | | - if (!disjoint(tileEnvelope, ogcGeometry)) { |
590 | | - BIGINT.writeLong(blockBuilder, tile.encode()); |
591 | | - } |
592 | | - return; |
593 | | - } |
594 | | - |
595 | | - if (contains(ogcGeometry, tileEnvelope)) { |
596 | | - int subTileCount = 1 << (zoomLevel - tileZoomLevel); |
597 | | - int minX = subTileCount * tile.getX(); |
598 | | - int minY = subTileCount * tile.getY(); |
599 | | - for (int x = minX; x < minX + subTileCount; x++) { |
600 | | - for (int y = minY; y < minY + subTileCount; y++) { |
601 | | - BIGINT.writeLong(blockBuilder, BingTile.fromCoordinates(x, y, zoomLevel).encode()); |
602 | | - } |
603 | | - } |
604 | | - return; |
605 | | - } |
606 | | - |
607 | | - if (disjoint(tileEnvelope, ogcGeometry)) { |
608 | | - return; |
609 | | - } |
610 | | - |
611 | | - int minX = 2 * tile.getX(); |
612 | | - int minY = 2 * tile.getY(); |
613 | | - int nextZoomLevel = tileZoomLevel + 1; |
614 | | - verify(nextZoomLevel <= MAX_ZOOM_LEVEL); |
615 | | - for (int x = minX; x < minX + 2; x++) { |
616 | | - for (int y = minY; y < minY + 2; y++) { |
617 | | - appendIntersectingSubtiles( |
618 | | - ogcGeometry, |
619 | | - zoomLevel, |
620 | | - BingTile.fromCoordinates(x, y, nextZoomLevel), |
621 | | - blockBuilder); |
622 | | - } |
623 | | - } |
624 | | - } |
625 | | - |
626 | 544 | private static boolean withinDistance(GreatCircleDistanceToPoint distanceFunction, double maxDistance, Point point) |
627 | 545 | { |
628 | 546 | return distanceFunction.distance(point.getY(), point.getX()) <= maxDistance; |
|
0 commit comments