Beispiel #1
0
 def test_create_subsets(self):
     self.assertEqual(
         TileGrid.create(4000,
                         3000,
                         500,
                         500, (-20., 10., 60., 70.),
                         inv_y=True),
         TileGrid(4, 1, 1, 500, 375, (-20., 10., 60., 70.), inv_y=True))
     self.assertEqual(
         TileGrid.create(4012,
                         3009,
                         500,
                         500, (-20., 10., 60., 70.),
                         inv_y=True),
         TileGrid(2,
                  3,
                  5,
                  669,
                  301, (-20.0, 9.980059820538386, 60.03988035892323, 70.),
                  inv_y=True))
     self.assertEqual(
         TileGrid.create(4000,
                         3000,
                         500,
                         500, (170., 10., -160., 70.),
                         inv_y=True),
         TileGrid(4,
                  1,
                  1,
                  500,
                  375, (170.0, 10.0, -160.0, 70.0),
                  inv_y=True))
Beispiel #2
0
 def test_repr(self):
     ts = TileGrid(4, 2, 1, 540, 540, GLOBAL_GEO_EXTENT, inv_y=False)
     self.assertEqual(
         repr(ts),
         'TileGrid(4, 2, 1, 540, 540, (-180.0, -90.0, 180.0, 90.0), inv_y=False)'
     )
     ts = TileGrid(4, 2, 1, 540, 540, GLOBAL_GEO_EXTENT, inv_y=True)
     self.assertEqual(
         repr(ts),
         'TileGrid(4, 2, 1, 540, 540, (-180.0, -90.0, 180.0, 90.0), inv_y=True)'
     )
Beispiel #3
0
    def test_create_illegal_geo_extent(self):
        # legal - explains why the next must fail
        self.assertEqual(
            TileGrid.create(50, 25, 5, 5, (0.0, 77.5, 25.0, 90.0), inv_y=True),
            TileGrid(2, 5, 2, 5, 7, (0.0, 76.0, 25.0, 90.0), inv_y=True))
        with self.assertRaises(ValueError):
            TileGrid.create(50, 25, 5, 5, (0.0, 77.5, 25.0, 90.0), inv_y=False)

        # legal - explains why the next must fail
        self.assertEqual(
            TileGrid.create(50, 25, 5, 5, (0., -90.0, 25., -77.5),
                            inv_y=False),
            TileGrid(2, 5, 2, 5, 7, (0.0, -90.0, 25.0, -76.0), inv_y=False))
        with self.assertRaises(ValueError):
            TileGrid.create(50, 25, 5, 5, (0., -90.0, 25., -77.5), inv_y=True)
Beispiel #4
0
 def test_width_and_height(self):
     ts = TileGrid(4, 2, 1, 540, 540, GLOBAL_GEO_EXTENT, inv_y=False)
     self.assertEqual(ts.width(2), 4320)
     self.assertEqual(ts.height(2), 2160)
     self.assertEqual(ts.max_width, 8640)
     self.assertEqual(ts.max_height, 4320)
     self.assertEqual(ts.min_width, 1080)
     self.assertEqual(ts.min_height, 540)
Beispiel #5
0
 def test_width_and_height(self):
     ts = TileGrid(4, 2, 1, 540, 540, POS_Y_AXIS_GLOBAL_RECT)
     self.assertEqual(ts.width(2), 4320)
     self.assertEqual(ts.height(2), 2160)
     self.assertEqual(ts.max_width, 8640)
     self.assertEqual(ts.max_height, 4320)
     self.assertEqual(ts.min_width, 1080)
     self.assertEqual(ts.min_height, 540)
Beispiel #6
0
 def test_str(self):
     ts = TileGrid(4, 2, 1, 540, 540, POS_Y_AXIS_GLOBAL_RECT)
     self.assertEqual(
         str(ts), 'number of pyramid levels: 4\n'
         'number of tiles at level zero: 2 x 1\n'
         'pyramid tile size: 540 x 540\n'
         'image size at level zero: 1080 x 540\n'
         'image size at level 3: 8640 x 4320')
Beispiel #7
0
 def test_str(self):
     ts = TileGrid(4, 2, 1, 540, 540, GLOBAL_GEO_EXTENT, inv_y=False)
     self.assertEqual(
         str(ts), 'number of pyramid levels: 4\n'
         'number of tiles at level zero: 2 x 1\n'
         'pyramid tile size: 540 x 540\n'
         'image size at level zero: 1080 x 540\n'
         'image size at level 3: 8640 x 4320\n'
         'geographic extent: (-180.0, -90.0, 180.0, 90.0)\n'
         'y-axis points down: yes')
Beispiel #8
0
 def test_create_cci_ecv(self):
     # 72, 8, 85, 17
     # Soilmoisture CCI - daily L3S
     self.assertEqual(
         TileGrid.create(1440,
                         720,
                         500,
                         500,
                         GLOBAL_GEO_EXTENT,
                         inv_y=False),
         TileGrid(2, 2, 1, 360, 360, GLOBAL_GEO_EXTENT, inv_y=False))
     # Aerosol CCI - monthly
     self.assertEqual(
         TileGrid.create(7200,
                         3600,
                         500,
                         500,
                         GLOBAL_GEO_EXTENT,
                         inv_y=False),
         TileGrid(4, 2, 1, 450, 450, GLOBAL_GEO_EXTENT, inv_y=False))
     # Cloud CCI - monthly
     self.assertEqual(
         TileGrid.create(720, 360, 500, 500, GLOBAL_GEO_EXTENT, inv_y=True),
         TileGrid(1, 2, 1, 360, 360, GLOBAL_GEO_EXTENT, inv_y=True))
     # SST CCI - daily L4
     self.assertEqual(
         TileGrid.create(8640,
                         4320,
                         500,
                         500,
                         GLOBAL_GEO_EXTENT,
                         inv_y=True),
         TileGrid(4, 2, 1, 540, 540, GLOBAL_GEO_EXTENT, inv_y=True))
     # Land Cover CCI
     self.assertEqual(
         TileGrid.create(129600,
                         64800,
                         500,
                         500,
                         GLOBAL_GEO_EXTENT,
                         inv_y=False),
         TileGrid(6, 6, 3, 675, 675, GLOBAL_GEO_EXTENT, inv_y=False))
Beispiel #9
0
 def test_create_cci_ecv(self):
     # 72, 8, 85, 17
     # Soilmoisture CCI - daily L3S
     self.assertEqual(
         TileGrid.create(1440, 720, 500, 500, POS_Y_AXIS_GLOBAL_RECT),
         TileGrid(2, 2, 1, 360, 360, POS_Y_AXIS_GLOBAL_RECT))
     # Aerosol CCI - monthly
     self.assertEqual(
         TileGrid.create(7200, 3600, 500, 500, POS_Y_AXIS_GLOBAL_RECT),
         TileGrid(4, 2, 1, 450, 450, POS_Y_AXIS_GLOBAL_RECT))
     # Cloud CCI - monthly
     self.assertEqual(
         TileGrid.create(720, 360, 500, 500, NEG_Y_AXIS_GLOBAL_RECT),
         TileGrid(1, 2, 1, 360, 360, NEG_Y_AXIS_GLOBAL_RECT))
     # SST CCI - daily L4
     self.assertEqual(
         TileGrid.create(8640, 4320, 500, 500, NEG_Y_AXIS_GLOBAL_RECT),
         TileGrid(4, 2, 1, 540, 540, NEG_Y_AXIS_GLOBAL_RECT))
     # Land Cover CCI
     self.assertEqual(
         TileGrid.create(129600, 64800, 500, 500, POS_Y_AXIS_GLOBAL_RECT),
         TileGrid(6, 6, 3, 675, 675, POS_Y_AXIS_GLOBAL_RECT))
Beispiel #10
0
 def test_to_json(self):
     ts = TileGrid(4, 2, 1, 540, 540, GLOBAL_GEO_EXTENT, inv_y=True)
     self.assertEqual(
         ts.to_json(), {
             'numLevels': 4,
             'numLevelZeroTilesX': 2,
             'numLevelZeroTilesY': 1,
             'tileHeight': 540,
             'tileWidth': 540,
             'invY': True,
             'extent': {
                 'west': -180.,
                 'south': -90.,
                 'east': 180.,
                 'north': 90.,
             },
         })
Beispiel #11
0
 def test_illegal_init(self):
     with self.assertRaises(ValueError):
         TileGrid(0, 2, 1, 540, 540, (0.0, 80., 20.0, 90.0), inv_y=True)
     with self.assertRaises(ValueError):
         TileGrid(4, 0, 1, 540, 540, (0.0, 80., 20.0, 90.0), inv_y=True)
     with self.assertRaises(ValueError):
         TileGrid(4, 2, 0, 540, 540, (0.0, 80., 20.0, 90.0), inv_y=True)
     with self.assertRaises(ValueError):
         TileGrid(4, 2, 1, 0, 540, (0.0, 80., 20.0, 90.0), inv_y=True)
     with self.assertRaises(ValueError):
         TileGrid(4, 2, 1, 540, 0, (0.0, 80., 20.0, 90.0), inv_y=True)
     with self.assertRaises(ValueError):
         TileGrid(4, 2, 1, 540, 540, (0.0, 80., 20.0, 90.01), inv_y=True)
Beispiel #12
0
 def get_pyramid() -> ImagePyramid:
     """
     Return an instance of a 'Natural Earth v2' image pyramid:
     * global coverage
     * JPEG RGB format
     * 3 levels of detail: 0 to 2
     * tile size: 256 pixels
     * 2 x 1 tiles on level zero
     """
     dir_path = os.path.join(os.path.dirname(__file__), 'res', 'ne2')
     return ImagePyramid(
         TileGrid(NaturalEarth2Image.NUM_LEVELS,
                  NaturalEarth2Image.NUM_LEVEL_0_TILES_X,
                  NaturalEarth2Image.NUM_LEVEL_0_TILES_Y,
                  NaturalEarth2Image.TILE_SIZE,
                  NaturalEarth2Image.TILE_SIZE, GeoExtent()), [
                      NaturalEarth2Image(dir_path, level)
                      for level in range(NaturalEarth2Image.NUM_LEVELS)
                  ])
Beispiel #13
0
 def test_num_tiles(self):
     ts = TileGrid(4, 2, 1, 540, 540, GLOBAL_GEO_EXTENT, inv_y=False)
     self.assertEqual(ts.num_tiles_x(0), 2)
     self.assertEqual(ts.num_tiles_y(0), 1)
     self.assertEqual(ts.num_tiles_x(3), 16)
     self.assertEqual(ts.num_tiles_y(3), 8)
Beispiel #14
0
 def test_create_cci_ecv_subsets(self):
     # Soilmoisture CCI - daily L3S - use case #6
     self.assertEqual(TileGrid.create(52, 36, 500, 500, (72, 8, 85, 17)),
                      TileGrid(1, 1, 1, 52, 36, (72., 8., 85., 17.)))
Beispiel #15
0
 def test_num_tiles(self):
     ts = TileGrid(4, 2, 1, 540, 540, POS_Y_AXIS_GLOBAL_RECT)
     self.assertEqual(ts.num_tiles_x(0), 2)
     self.assertEqual(ts.num_tiles_y(0), 1)
     self.assertEqual(ts.num_tiles_x(3), 16)
     self.assertEqual(ts.num_tiles_y(3), 8)
Beispiel #16
0
 def test_repr(self):
     ts = TileGrid(4, 2, 1, 540, 540, POS_Y_AXIS_GLOBAL_RECT)
     self.assertEqual(repr(ts), 'TileGrid(4, 2, 1, 540, 540, GeoExtend())')
     ts = TileGrid(4, 2, 1, 540, 540, NEG_Y_AXIS_GLOBAL_RECT)
     self.assertEqual(repr(ts),
                      'TileGrid(4, 2, 1, 540, 540, GeoExtend(inv_y=True))')