| 21 | | int metaHeight = 1; |
| 22 | | int metaWidth = 1; |
| 23 | | |
| 24 | | Grid grid = new Grid(SRS.getEPSG4326(), bbox, gridBase, null); |
| 25 | | GridCalculator gridCalc = grid.getGridCalculator(); |
| 26 | | |
| 27 | | //int[][] solution = { { 1, 0, 1, 0 }, { 2, 1, 3, 1 }, { 4, 2, 7, 3 }, |
| 28 | | // { 8, 4, 15, 7 }, { 16, 8, 31, 15 } }; |
| | 21 | |
| | 22 | Grid grid = new Grid(SRS.getEPSG4326(), bbox, gridBase, null); |
| | 23 | GridCalculator gridCalc = grid.getGridCalculator(); |
| 47 | | int metaHeight = 3; |
| 48 | | int metaWidth = 3; |
| 49 | | |
| 50 | | Grid grid = new Grid(SRS.getEPSG4326(), bbox, gridBase, null); |
| 51 | | GridCalculator gridCalc = grid.getGridCalculator(); |
| 52 | | |
| 53 | | //int[][] solution = { { 1, 0, 1, 0 }, { 0, 0, 3, 1 }, { 3, 0, 7, 3 }, |
| 54 | | // { 6, 3, 15, 7 }, { 15, 6, 31, 15 }, { 30, 15, 63, 31 }, |
| 55 | | // { 63, 30, 127, 63 } }; |
| | 42 | |
| | 43 | Grid grid = new Grid(SRS.getEPSG4326(), bbox, gridBase, null); |
| | 44 | GridCalculator gridCalc = grid.getGridCalculator(); |
| 82 | 69 | { 7, 3, 8, 4 }, { 15, 7, 16, 8 }, { 30, 14, 33, 17 }, |
| 83 | 70 | { 60, 28, 67, 35 }, { 120, 56, 135, 71 } }; |
| 84 | | |
| 85 | | //int[][] solution = { { 0, 0, 1, 0 }, { 0, 0, 2, 1 }, { 3, 0, 5, 2 }, |
| 86 | | // { 6, 3, 8, 5 }, { 15, 6, 17, 8 }, { 30, 12, 35, 17 }, |
| 87 | | // { 60, 27, 68, 35 }, { 120, 54, 137, 71 } }; |
| 103 | | int metaHeight = 4; |
| 104 | | int metaWidth = 4; |
| 105 | | |
| 106 | | Grid grid = new Grid(SRS.getEPSG4326(), bbox, gridBase, null); |
| 107 | | GridCalculator gridCalc = grid.getGridCalculator(); |
| 108 | | //int[][] solution = { { 1, 0, 1, 0 }, { 3, 1, 3, 1 }, { 4, 0, 7, 3 }, |
| 109 | | // { 12, 4, 15, 7 }, { 28, 12, 31, 15 } }; |
| | 86 | |
| | 87 | Grid grid = new Grid(SRS.getEPSG4326(), bbox, gridBase, null); |
| | 88 | GridCalculator gridCalc = grid.getGridCalculator(); |
| 131 | | int metaHeight = 1; |
| 132 | | int metaWidth = 1; |
| 133 | | |
| 134 | | Grid grid = new Grid(SRS.getEPSG4326(), bbox, gridBase, null); |
| 135 | | GridCalculator gridCalc = grid.getGridCalculator(); |
| 136 | | |
| 137 | | //int[][] solution = { { 0, 0, 0, 0 }, { 1, 1, 1, 1 }, { 2, 2, 3, 3 }, |
| 138 | | // { 4, 4, 7, 7 }, { 8, 8, 15, 15 } }; |
| | 110 | |
| | 111 | Grid grid = new Grid(SRS.getEPSG4326(), bbox, gridBase, null); |
| | 112 | GridCalculator gridCalc = grid.getGridCalculator(); |
| 165 | | |
| 166 | | //int[][] solution = { { 0, 0, 0, 0 }, { 1, 1, 1, 1 }, { 0, 0, 3, 3 }, |
| 167 | | // { 3, 3, 7, 7 }, { 6, 6, 15, 15 }, { 15, 15, 31, 31 }, |
| 168 | | // { 30, 30, 63, 63 } }; |
| 196 | | |
| 197 | | //int[][] solution = { { 0, 0, 0, 0 }, { 0, 0, 1, 1 }, { 0, 0, 2, 2 }, |
| 198 | | // { 3, 3, 5, 5 }, { 6, 6, 8, 8 }, { 15, 15, 17, 17 }, |
| 199 | | // { 30, 30, 32, 32 }, { 60, 60, 65, 65 } }; |
| 262 | | int metaHeight = 1; |
| 263 | | int metaWidth = 1; |
| 264 | | |
| 265 | | Grid grid = new Grid(SRS.getEPSG4326(), bbox, gridBase, null); |
| 266 | | GridCalculator gridCalc = grid.getGridCalculator(); |
| 267 | | |
| 268 | | //int[][] solution = { { 0, 0, 0, 0 }, { 0, 1, 1, 1 }, { 1, 2, 2, 3 }, |
| 269 | | // { 2, 5, 5, 6 } }; |
| | 220 | |
| | 221 | Grid grid = new Grid(SRS.getEPSG4326(), bbox, gridBase, null); |
| | 222 | GridCalculator gridCalc = grid.getGridCalculator(); |
| | 272 | public void testCustomSRSGrid() throws Exception { |
| | 273 | // This mimics the Spearfish layer |
| | 274 | BBOX bbox = new BBOX(587334.20625,4912451.9275, 611635.54375,4936753.265000001); |
| | 275 | BBOX gridBase = new BBOX(587334.20625,4912451.9275, 611635.54375,4936753.265000001); |
| | 276 | |
| | 277 | // Test the basic algorithm for calculating appropriate resolutions |
| | 278 | Grid grid = new Grid(SRS.getSRS(26713), bbox, gridBase, null); |
| | 279 | GridCalculator gridCalc = grid.getGridCalculator(); |
| | 280 | assertTrue(Math.abs(gridCalc.getResolutions()[0] - 94.9270 ) / 94.9270 < 0.01); |
| | 281 | |
| | 282 | // Check the actual max bounds |
| | 283 | int[] solution = {0,0,0}; |
| | 284 | assertTrue(Arrays.equals(solution,gridCalc.gridLocation(bbox))); |
| | 285 | |
| | 286 | // Test a grid location |
| | 287 | int[] gridLoc = {1, 0, 1}; |
| | 288 | BBOX bboxSolution = new BBOX(599484.8750000002,4912451.9275,611635.5437500004,4924602.59625); |
| | 289 | assertTrue(bboxSolution.equals(gridCalc.bboxFromGridLocation(gridLoc))); |
| | 290 | |
| | 291 | // Now lets go the other way |
| | 292 | assertTrue(Arrays.equals(gridCalc.gridLocation(bboxSolution),gridLoc)); |
| | 293 | |
| | 294 | // This is a bit easy, but whatever |
| | 295 | int[] zoomedOut = gridCalc.getZoomedOutGridLoc(); |
| | 296 | assertTrue(Arrays.equals(solution,zoomedOut)); |
| | 297 | } |
| | 298 | |