コード例 #1
0
ファイル: unittests.py プロジェクト: d-diaz/forestplanner
class AdjacencyTest(TestCase):
    '''
    Test that stand adjacency can be reliably determined
    self.prop = ForestProperty(..)
    adj = self.prop.adjacency
    # @property method with caching
    # returns what? list or txt or file handle?
    # does it also check for slivers or overlap?

    needs fixture
    '''
    def setUp(self):
        self.user = User.objects.create_user(
            'featuretest', '*****@*****.**', password='******')
        self.prop1 = ForestProperty(user=self.user, name="My Property", geometry_final=p1)
        self.prop1.save()

        d = os.path.dirname(__file__)
        self.shp_path = os.path.abspath(os.path.join(d, '..', 'fixtures',
            'testdata', 'test_stands.shp'))
        s = StandImporter(self.user)
        s.import_ogr(self.shp_path, forest_property=self.prop1)

    def test_adjacency(self):
        '''
        stand is adjacent to 332, 336, 405 and 412
        using default threshold of 1.0
        '''
        test_stand = Stand.objects.get(name='397')
        adj_stands = [Stand.objects.get(name=str(x)) for x in [332, 336, 405, 412]]
        adj = self.prop1.adjacency()
        for adj_stand in adj_stands:
            self.assertTrue(adj_stand.pk in adj[test_stand.pk])

    def test_adjacency_threshold(self):
        '''
        stand should be within 100 meters of 425 as well
        '''
        test_stand = Stand.objects.get(name='397')
        adj_stands = [Stand.objects.get(name=str(x)) for x in [332, 336, 405, 412, 425]]
        adj = self.prop1.adjacency(100.0)
        for adj_stand in adj_stands:
            self.assertTrue(adj_stand.pk in adj[test_stand.pk])
コード例 #2
0
ファイル: unittests.py プロジェクト: imclab/land_owner_tools
class AdjacencyTest(TestCase):
    '''
    Test that stand adjacency can be reliably determined
    self.prop = ForestProperty(..)
    adj = self.prop.adjacency 
    # @property method with caching
    # returns what? list or txt or file handle? 
    # does it also check for slivers or overlap? 

    needs fixture
    '''
    def setUp(self):
        self.user = User.objects.create_user(
            'featuretest', '*****@*****.**', password='******')
        self.prop1 = ForestProperty(user=self.user, name="My Property", geometry_final=p1)
        self.prop1.save()

        d = os.path.dirname(__file__)
        self.shp_path = os.path.abspath(os.path.join(d, '..', 'fixtures', 
            'testdata', 'test_stands.shp'))
        s = StandImporter(self.user)
        s.import_ogr(self.shp_path, forest_property=self.prop1) 

    def test_adjacency(self):
        '''
        stand is adjacent to 332, 336, 405 and 412
        using default threshold of 1.0
        '''
        test_stand = Stand.objects.get(name='397')
        adj_stands = [Stand.objects.get(name=str(x)) for x in [332, 336, 405, 412]]
        adj = self.prop1.adjacency()
        for adj_stand in adj_stands:
            self.assertTrue(adj_stand.pk in adj[test_stand.pk])

    def test_adjacency_threshold(self):
        '''
        stand should be within 100 meters of 425 as well
        '''
        test_stand = Stand.objects.get(name='397')
        adj_stands = [Stand.objects.get(name=str(x)) for x in [332, 336, 405, 412, 425]]
        adj = self.prop1.adjacency(100.0)
        for adj_stand in adj_stands:
            self.assertTrue(adj_stand.pk in adj[test_stand.pk])