예제 #1
0
    def test_get_mpoly_from_geom(self):
        with self.assertRaises(CommandError) as c:
            _get_mpoly_from_geom(None)

        self.assertEqual(
            c.exception.message,
            "Expected a Polygon or MultiPolygon, got <type 'NoneType'>")
    def test_get_mpoly_from_geom(self):
        with self.assertRaises(CommandError) as c:
            _get_mpoly_from_geom(None)

        self.assertEqual(
            c.exception.message,
            "Expected a Polygon or MultiPolygon, got <type 'NoneType'>"
        )
예제 #3
0
from mfl_gis.management.commands.shared import _get_mpoly_from_geom

from ..models import (FacilityCoordinates, WorldBorder, CountyBoundary,
                      ConstituencyBoundary, WardBoundary)

CUR_DIR = os.path.dirname(__file__)
COUNTY_BORDER = DataSource(
    os.path.join(CUR_DIR, 'nairobi_county_boundary.geojson'))
CONSTITUENCY_BORDER = DataSource(
    os.path.join(CUR_DIR, 'dagoretti_north_constituency_boundary.geojson'))
WARD_BORDER = DataSource(
    os.path.join(CUR_DIR, 'kilimani_ward_boundary.geojson'))
KENYA_BORDER = DataSource(os.path.join(CUR_DIR, 'kenya_boundary.geojson'))

country_boundary_recipe = Recipe(WorldBorder,
                                 mpoly=_get_mpoly_from_geom(
                                     KENYA_BORDER[0].get_geoms()[0]))

county_recipe = Recipe(County)

county_boundary_recipe = Recipe(CountyBoundary,
                                area=foreign_key(county_recipe),
                                mpoly=_get_mpoly_from_geom(
                                    COUNTY_BORDER[0].get_geoms()[0]))

constituency_recipe = Recipe(
    Constituency,
    county=foreign_key(county_recipe),
)

constituency_boundary_recipe = Recipe(
    ConstituencyBoundary,
예제 #4
0
)

CUR_DIR = os.path.dirname(__file__)
COUNTY_BORDER = DataSource(
    os.path.join(CUR_DIR, 'nairobi_county_boundary.geojson'))
CONSTITUENCY_BORDER = DataSource(
    os.path.join(CUR_DIR, 'dagoretti_north_constituency_boundary.geojson'))
WARD_BORDER = DataSource(
    os.path.join(CUR_DIR, 'kilimani_ward_boundary.geojson'))
KENYA_BORDER = DataSource(
    os.path.join(CUR_DIR, 'kenya_boundary.geojson'))


country_boundary_recipe = Recipe(
    WorldBorder,
    mpoly=_get_mpoly_from_geom(KENYA_BORDER[0].get_geoms()[0])
)


county_recipe = Recipe(
    County
)

county_boundary_recipe = Recipe(
    CountyBoundary,
    area=foreign_key(county_recipe),
    mpoly=_get_mpoly_from_geom(COUNTY_BORDER[0].get_geoms()[0])
)

constituency_recipe = Recipe(
    Constituency,