Show
Ignore:
Timestamp:
08/22/08 14:21:26 (5 months ago)
Author:
arneke
Message:

A few unit tests for custom SRSs

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/geowebcache/src/test/java/org/geowebcache/layer/GridCalculatorTest.java

    r337 r341  
    1919        BBOX bbox = new BBOX(0, 0, 180, 90); 
    2020        BBOX gridBase = new BBOX(-180, -90, 180, 90); 
    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(); 
    2924 
    3025        int[][] solution = { { 1, 0, 1, 0 }, { 2, 1, 3, 1 }, { 4, 2, 7, 3 }, 
     
    4540        BBOX bbox = new BBOX(0, 0, 180, 90); 
    4641        BBOX gridBase = new BBOX(-180, -90, 180, 90); 
    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(); 
    5645         
    5746        int[][] solution = { { 1, 0, 1, 0 }, { 2, 1, 3, 1 }, { 4, 2, 7, 3 }, 
     
    7362        BBOX bbox = new BBOX(-10.0, -10.0, 10.0, 10.0); 
    7463        BBOX gridBase = new BBOX(-180, -90, 180, 90); 
    75         int metaHeight = 3; 
    76         int metaWidth = 3; 
    7764 
    7865        Grid grid = new Grid(SRS.getEPSG4326(), bbox, gridBase, null); 
     
    8269                { 7, 3, 8, 4 }, { 15, 7, 16, 8 }, { 30, 14, 33, 17 }, 
    8370                { 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 } }; 
    8871 
    8972        for (int i = 0; i < solution.length; i++) { 
     
    10184        BBOX bbox = new BBOX(175.0, 87.0, 180.0, 90.0); 
    10285        BBOX gridBase = new BBOX(-180, -90, 180, 90); 
    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(); 
    11089 
    11190        int[][] solution = { { 1, 0, 1, 0 }, { 3, 1, 3, 1 }, { 7, 3, 7, 3 }, 
     
    129108                        -20037508.34, -20037508.34,  
    130109                        20037508.34, 20037508.34); 
    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(); 
    139113         
    140114        int[][] solution = { { 0, 0, 0, 0 }, { 1, 1, 1, 1 }, { 2, 2, 3, 3 }, 
     
    158132                        -20037508.34, -20037508.34,  
    159133                        20037508.34, 20037508.34); 
    160         int metaHeight = 3; 
    161         int metaWidth = 3; 
    162134         
    163135        Grid grid = new Grid(SRS.getEPSG900913(), bbox, gridBase, null); 
    164136        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 } }; 
    169137         
    170138        int[][] solution = { { 0, 0, 0, 0 }, { 1, 1, 1, 1 }, { 2, 2, 3, 3 }, 
     
    189157                        -20037508.34, -20037508.34,  
    190158                        20037508.34, 20037508.34); 
    191         int metaHeight = 3; 
    192         int metaWidth = 3; 
    193159         
    194160        Grid grid = new Grid(SRS.getEPSG900913(), bbox, gridBase, null); 
    195161        GridCalculator gridCalc = grid.getGridCalculator(); 
    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 } }; 
    200162         
    201163        int[][] solution = { { 0, 0, 0, 0 }, { 0, 0, 1, 1 }, { 1, 1, 2, 2 }, 
     
    218180        BBOX bbox = new BBOX(-124.73, 24.96, -66.97, 49.37); 
    219181        BBOX gridBase = new BBOX(-180, -90, 180, 90); 
    220         int metaHeight = 3; 
    221         int metaWidth = 3; 
    222182 
    223183        Grid grid = new Grid(SRS.getEPSG4326(), bbox, gridBase, null); 
     
    232192        BBOX bbox = new BBOX(-124.73, 24.96, -66.97, 49.37); 
    233193        BBOX gridBase = new BBOX(-180, -90, 180, 90); 
    234         int metaHeight = 3; 
    235         int metaWidth = 3; 
    236194         
    237195        Grid grid = new Grid(SRS.getEPSG4326(), bbox, gridBase, null); 
     
    260218        BBOX bbox = new BBOX(-124.731422, 24.955967, -66.969849, 49.371735); 
    261219        BBOX gridBase = new BBOX(-180, -90, 180, 90); 
    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(); 
    270223         
    271224        int[][] solution = { { 0, 0, 0, 0 }, { 0, 1, 1, 1 }, { 1, 2, 2, 3 }, 
     
    317270    } 
    318271     
     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     
    319299    
    320300