Beispiel #1
0
    def test_aggregate(self):
        """Aggregation by boundaries works
        """

        # Name file names for hazard level and exposure
        boundary_filename = ('%s/kecamatan_jakarta_osm.shp' % TESTDATA)
        #data_filename = ('%s/Population_Jakarta_geographic.asc' % TESTDATA)

        # Get reference building impact data
        building_filename = ('%s/building_impact_scenario.shp' % TESTDATA)

        boundary_layer = read_layer(boundary_filename)
        building_layer = read_layer(building_filename)

        res = aggregate(data=building_layer,
                        boundaries=boundary_layer,
                        attribute_name='AFFECTED',
                        aggregation_function='count')

        #print res, len(res)
        #print boundary_layer, len(boundary_layer)
        msg = ('Number of aggregations %i should be the same as the '
               'number of specified boundaries %i' % (len(res),
                                                      len(boundary_layer)))
        assert len(res) == len(boundary_layer), msg
Beispiel #2
0
    def test_aggregate(self):
        """Aggregation by boundaries works
        """

        # Name file names for hazard level and exposure
        boundary_filename = ('%s/kecamatan_jakarta_osm.shp' % TESTDATA)
        #data_filename = ('%s/Population_Jakarta_geographic.asc' % TESTDATA)

        # Get reference building impact data
        building_filename = ('%s/building_impact_scenario.shp' % TESTDATA)

        boundary_layer = read_layer(boundary_filename)
        building_layer = read_layer(building_filename)

        res = aggregate(data=building_layer,
                        boundaries=boundary_layer,
                        attribute_name='AFFECTED',
                        aggregation_function='count')

        #print res, len(res)
        #print boundary_layer, len(boundary_layer)
        msg = ('Number of aggregations %i should be the same as the '
               'number of specified boundaries %i' %
               (len(res), len(boundary_layer)))
        assert len(res) == len(boundary_layer), msg
Beispiel #3
0
    def test_aggregate(self):
        """Test aggregate function behaves as expected."""

        class MockRasterData(object):
            """Fake raster data object."""

            def __init__(self):
                self.is_point_data = False
                self.is_raster_data = True

        class MockOtherData(object):
            """Fake other data object."""

            def __init__(self):
                self.is_point_data = False
                self.is_raster_data = False

        # Test raster data
        raster_data = MockRasterData()
        result = aggregate(raster_data)
        self.assertIsNone(result)

        # Test Not Point Data nor raster Data:
        other_data = MockOtherData()
        self.assertRaises(Exception, aggregate, other_data)
Beispiel #4
0
    def test_aggregate(self):
        """Test aggregate function behaves as expected."""
        class MockRasterData(object):
            """Fake raster data object."""
            def __init__(self):
                self.is_point_data = False
                self.is_raster_data = True

        class MockOtherData(object):
            """Fake other data object."""
            def __init__(self):
                self.is_point_data = False
                self.is_raster_data = False

        # Test raster data
        raster_data = MockRasterData()
        result = aggregate(raster_data)
        self.assertIsNone(result)

        # Test Not Point Data nor raster Data:
        other_data = MockOtherData()
        self.assertRaises(Exception, aggregate, other_data)