Ejemplo n.º 1
0
    def test_fill_missing_no_input(self):
        '''Test Configuration class.'''
        # Arrange
        config = hm.Configuration(use_defaults=True)

        # Act / Assert
        with self.assertRaisesRegex(ValueError, "no input specified"):
            config.fill_missing()
Ejemplo n.º 2
0
    def test_basic(self):
        '''Test Configuration class.'''
        # Act
        config = hm.Configuration(use_defaults=True)

        # Assert
        self.assertEqual(config.margin, 0)
        self.assertEqual(config.frequency, 1)
Ejemplo n.º 3
0
def setup_config(count):
    config = hm.Configuration()
    config.shapes = shapes_generator(count)
    config.projection = hm.EquirectangularProjection()
    config.projection.pixels_per_degree = 30
    config.decay = 1
    config.kernel = hm.LinearKernel(5)
    config.background = 'black'
    config.fill_missing()
    return config
Ejemplo n.º 4
0
    def test_choose_osm_zoom_with_zoom_in_config(self):
        # Arrange
        config = hm.Configuration(use_defaults=True)
        config.zoom = 2
        padding = 2

        # Act
        zoom = hm.choose_osm_zoom(config, padding)

        # Assert
        self.assertEqual(zoom, 2)
Ejemplo n.º 5
0
    def test_choose_osm_zoom_with_no_zoom_w_h_in_config(self):
        # Arrange
        config = hm.Configuration(use_defaults=True)
        padding = 2

        # Act
        # Act / Assert
        with self.assertRaisesRegex(
                ValueError, "For OSM, you must specify height, "
                "width, or zoom"):
            hm.choose_osm_zoom(config, padding)
Ejemplo n.º 6
0
    def test_choose_osm_zoom_with_w_h_in_config(self):
        # Arrange
        config = hm.Configuration(use_defaults=True)
        config.width = 400
        config.height = 200
        config.extent_in = hm.Extent(coords=(hm.LatLon(-10, -10),
                                             hm.LatLon(10, 10)))
        padding = 2

        # Act
        zoom = hm.choose_osm_zoom(config, padding)

        # Assert
        self.assertEqual(zoom, 3)
Ejemplo n.º 7
0
    def setup_config(self, iter):
        map = PIL.Image.open(config["map_img"])

        self.map_size = map.size

        self.hm_config = hm.Configuration()
        self.hm_config.width = map.size[0]
        self.hm_config.height = map.size[1]
        self.hm_config.margin = 0
        self.hm_config.zoom = 1
        self.hm_config.projection = hm.EquirectangularProjection()
        self.hm_config.projection.pixels_per_degree = 1
        self.hm_config.extent_out = hm.Extent(
            coords=[hm.Coordinate(c[0], c[1]) for c in [(0, 0), map.size]])
        self.hm_config.extent_in = hm.Extent(coords=[
            self.hm_config.projection.inverse_project(hm.Coordinate(
                c[0], c[1])) for c in [(0, 0), map.size]
        ])
        self.hm_config.shapes = iter
        self.hm_config.decay = 0.5
        self.hm_config.kernel = hm.LinearKernel(5)
        self.hm_config.background_image = map
        self.hm_config.fill_missing()
        return config