Get a list of all the Cell Ids. @param latitude latitude @param longitude longitude @param width width @return List of Cells
(double latitude, double longitude, int width)
| 494 | * @return List of Cells |
| 495 | */ |
| 496 | public List<Long> getCellIds(double latitude, double longitude, int width) { |
| 497 | S2LatLng latLng = S2LatLng.fromDegrees(latitude, longitude); |
| 498 | S2CellId cellId = S2CellId.fromLatLng(latLng).parent(15); |
| 499 | |
| 500 | MutableInteger index = new MutableInteger(0); |
| 501 | MutableInteger jindex = new MutableInteger(0); |
| 502 | |
| 503 | |
| 504 | int level = cellId.level(); |
| 505 | int size = 1 << (S2CellId.MAX_LEVEL - level); |
| 506 | int face = cellId.toFaceIJOrientation(index, jindex, null); |
| 507 | |
| 508 | List<Long> cells = new ArrayList<Long>(); |
| 509 | |
| 510 | int halfWidth = (int) Math.floor(width / 2); |
| 511 | for (int x = -halfWidth; x <= halfWidth; x++) { |
| 512 | for (int y = -halfWidth; y <= halfWidth; y++) { |
| 513 | cells.add(S2CellId.fromFaceIJ(face, index.intValue() + x * size, jindex.intValue() + y * size) |
| 514 | .parent(15).id()); |
| 515 | } |
| 516 | } |
| 517 | return cells; |
| 518 | } |
| 519 | |
| 520 | /** |
| 521 | * Gets fort details. |
no test coverage detected