@Test public void testGetTilesToLoad() { int targetZ = 5; int z = 5; int x = 16; int y = 17; int minExpectedX = 15; int minExpectedY = 16; int expectedMatrixLen = 3; int expectedLen = expectedMatrixLen * expectedMatrixLen; List<TileCoord> tiles = GetWFSVectorTileHandler.getTilesToLoad(targetZ, z, x, y); for (TileCoord tile : tiles) { assertEquals(targetZ, tile.getZ()); } assertEquals(expectedLen, tiles.size()); Collections.sort(tiles, Comparator.comparing(TileCoord::getX).thenComparing(TileCoord::getY)); int index = 0; for (int i = 0; i < expectedMatrixLen; i++) { int expectedX = minExpectedX + i; for (int j = 0; j < expectedMatrixLen; j++) { int expectedY = minExpectedY + j; TileCoord tile = tiles.get(index++); assertEquals(expectedX, tile.getX()); assertEquals(expectedY, tile.getY()); } } }
protected static List<TileCoord> getTilesToLoad(int targetZ, int z, int x, int y) { int x1; int y1; int x2; int y2; int dz = z - targetZ; if (dz == 0) { x1 = x - 1; y1 = y - 1; x2 = x + 1; y2 = y + 1; } else if (dz < 0) { int d = (int) Math.pow(2, -dz); x1 = x * d; y1 = y * d; x2 = (x+1) * d; y2 = (y+1) * d; x1--; y1--; } else { int div = (int) Math.pow(2, dz); x1 = x / div; y1 = y / div; x2 = x1 + 1; y2 = y1 + 1; x1--; y1--; } int tileZ = targetZ; List<TileCoord> wfsTiles = new ArrayList<>(); for (int tileX = x1; tileX <= x2; tileX++) { for (int tileY = y1; tileY <= y2; tileY++) { wfsTiles.add(new TileCoord(tileZ, tileX, tileY)); } } return wfsTiles; }
GetWFSVectorTileHandler extends AbstractWFSFeaturesHandler { protected static List<TileCoord> getTilesToLoad(int targetZ, int z, int x, int y) { int x1; int y1; int x2; int y2; int dz = z - targetZ; if (dz == 0) { x1 = x - 1; y1 = y - 1; x2 = x + 1; y2 = y + 1; } else if (dz < 0) { int d = (int) Math.pow(2, -dz); x1 = x * d; y1 = y * d; x2 = (x+1) * d; y2 = (y+1) * d; x1--; y1--; } else { int div = (int) Math.pow(2, dz); x1 = x / div; y1 = y / div; x2 = x1 + 1; y2 = y1 + 1; x1--; y1--; } int tileZ = targetZ; List<TileCoord> wfsTiles = new ArrayList<>(); for (int tileX = x1; tileX <= x2; tileX++) { for (int tileY = y1; tileY <= y2; tileY++) { wfsTiles.add(new TileCoord(tileZ, tileX, tileY)); } } return wfsTiles; } }
GetWFSVectorTileHandler extends AbstractWFSFeaturesHandler { protected static List<TileCoord> getTilesToLoad(int targetZ, int z, int x, int y) { int x1; int y1; int x2; int y2; int dz = z - targetZ; if (dz == 0) { x1 = x - 1; y1 = y - 1; x2 = x + 1; y2 = y + 1; } else if (dz < 0) { int d = (int) Math.pow(2, -dz); x1 = x * d; y1 = y * d; x2 = (x+1) * d; y2 = (y+1) * d; x1--; y1--; } else { int div = (int) Math.pow(2, dz); x1 = x / div; y1 = y / div; x2 = x1 + 1; y2 = y1 + 1; x1--; y1--; } int tileZ = targetZ; List<TileCoord> wfsTiles = new ArrayList<>(); for (int tileX = x1; tileX <= x2; tileX++) { for (int tileY = y1; tileY <= y2; tileY++) { wfsTiles.add(new TileCoord(tileZ, tileX, tileY)); } } return wfsTiles; }  }
GetWFSVectorTileHandler extends AbstractWFSFeaturesHandler { protected static List<TileCoord> getTilesToLoad(int targetZ, int z, int x, int y) { int x1; int y1; int x2; int y2; int dz = z - targetZ; if (dz == 0) { x1 = x - 1; y1 = y - 1; x2 = x + 1; y2 = y + 1; } else if (dz < 0) { int d = (int) Math.pow(2, -dz); x1 = x * d; y1 = y * d; x2 = (x+1) * d; y2 = (y+1) * d; x1--; y1--; } else { int div = (int) Math.pow(2, dz); x1 = x / div; y1 = y / div; x2 = x1 + 1; y2 = y1 + 1; x1--; y1--; } int tileZ = targetZ; List<TileCoord> wfsTiles = new ArrayList<>(); for (int tileX = x1; tileX <= x2; tileX++) { for (int tileY = y1; tileY <= y2; tileY++) { wfsTiles.add(new TileCoord(tileZ, tileX, tileY)); } } return wfsTiles; }  @Override void init(); @Override void handleAction(ActionParameters params); }
GetWFSVectorTileHandler extends AbstractWFSFeaturesHandler { protected static List<TileCoord> getTilesToLoad(int targetZ, int z, int x, int y) { int x1; int y1; int x2; int y2; int dz = z - targetZ; if (dz == 0) { x1 = x - 1; y1 = y - 1; x2 = x + 1; y2 = y + 1; } else if (dz < 0) { int d = (int) Math.pow(2, -dz); x1 = x * d; y1 = y * d; x2 = (x+1) * d; y2 = (y+1) * d; x1--; y1--; } else { int div = (int) Math.pow(2, dz); x1 = x / div; y1 = y / div; x2 = x1 + 1; y2 = y1 + 1; x1--; y1--; } int tileZ = targetZ; List<TileCoord> wfsTiles = new ArrayList<>(); for (int tileX = x1; tileX <= x2; tileX++) { for (int tileY = y1; tileY <= y2; tileY++) { wfsTiles.add(new TileCoord(tileZ, tileX, tileY)); } } return wfsTiles; }  @Override void init(); @Override void handleAction(ActionParameters params);  }