Exemplo n.º 1
0
 def setUp(self):
     super().setUp()
     PolicyFactory.load_policies()
     test_objs = load_test_data(get_test_data())
     self.org = test_objs['organizations'][0]
     self.prj = test_objs['projects'][1]
     OrganizationRole.objects.create(organization=self.org,
                                     user=UserFactory.create(
                                         username='******',
                                         password='******'),
                                     admin=True)
     ResourceFactory.create_batch(2,
                                  content_object=self.prj,
                                  project=self.prj)
     su = SpatialUnitFactory(geometry=GEOSGeometry(
         '{"type": "Polygon",'
         '"coordinates": [['
         '[-5.1031494140625000,'
         ' 8.1299292850467957], '
         '[-5.0482177734375000, '
         '7.6837733211111425], '
         '[-4.6746826171875000, '
         '7.8252894725496338], '
         '[-4.8641967773437491, '
         '8.2278005261522775], '
         '[-5.1031494140625000, '
         '8.1299292850467957]]]}'),
                             project=self.prj,
                             type='MI',
                             attributes={})
     ResourceFactory.create(content_object=su, project=self.prj)
     party = PartyFactory.create(project=test_objs['projects'][1])
     tenure = TenureRelationshipFactory.create(
         project=self.prj,
         party=party,
         spatial_unit=su,
         tenure_type=TenureRelationshipType.objects.create(
             id='CR', label='Customary Rights'))
     ResourceFactory.create(content_object=su, project=self.prj)
     ResourceFactory.create(content_object=party, project=self.prj)
     ResourceFactory.create(content_object=tenure, project=self.prj)
Exemplo n.º 2
0
    def add_test_spatial_units(self):
        project = models.Project.objects.get(
            name__contains='Pekapuran Laut Test Project')

        # add attribute schema
        content_type = ContentType.objects.get(app_label='spatial',
                                               model='spatialunit')
        sch = Schema.objects.create(content_type=content_type,
                                    selectors=(project.organization.pk,
                                               project.pk))
        attr_type = AttributeType.objects.get(name="text")
        Attribute.objects.create(schema=sch,
                                 name='name',
                                 long_name='Name',
                                 required=False,
                                 index=1,
                                 attr_type=attr_type)

        su1 = SpatialUnitFactory(geometry=GEOSGeometry(
            '{"type": "Polygon",'
            '"coordinates": [['
            '[-245.3920519351959, -3.3337982265513184],'
            '[-245.39097905158997,  -3.333284113800722],'
            '[-245.39072155952454, -3.3345908165153215],'
            '[-245.39169788360596, -3.3351691925723728],'
            '[-245.3920519351959, -3.3337982265513184]]]'
            '}'),
                                 project=project,
                                 type='BU',
                                 attributes={'name': 'Building Unit (Test)'})

        su2 = SpatialUnitFactory(geometry=GEOSGeometry(
            '{"type": "Polygon",'
            '"coordinates": [['
            '[-245.39200901985168,  -3.333808937230755],'
            '[-245.39147257804868, -3.3335304595272377],'
            '[-245.391343832016, -3.3340338614721934],'
            '[-245.39186954498288, -3.3342480749876575],'
            '[-245.39200901985168,  -3.333808937230755]]'
            ']}'),
                                 project=project,
                                 type='AP',
                                 attributes={"name": "Apartment Unit (Test)"})

        SpatialRelationshipFactory(su1=su1, su2=su2, type='C', project=project)

        su3 = SpatialUnitFactory(geometry=GEOSGeometry(
            '{"type": "Polygon",'
            '"coordinates": [['
            '[-245.39088249206543,  -3.333262692430284],'
            '[-245.39021730422974, -3.3330699000753414],'
            '[-245.39001345634458,  -3.334312339033184],'
            '[-245.39063572883606,  -3.334580105844384],'
            '[-245.39088249206543,  -3.333262692430284]]'
            ']}'),
                                 project=project,
                                 type='PA',
                                 attributes={
                                     'name': 'Parcel (Test)',
                                 })

        su4 = SpatialUnitFactory(geometry=GEOSGeometry(
            '{"type": "Point",'
            '"coordinates": ['
            '-245.39034605026242, -3.333294824485769]}'),
                                 project=project,
                                 type='PA')

        SpatialRelationshipFactory(su1=su3, su2=su4, type='C', project=project)

        SpatialUnitFactory(geometry=GEOSGeometry(
            '{"type": "LineString",'
            '"coordinates": ['
            '[-245.3934037685394, -3.334258785662196],'
            '[-245.39109706878662, -3.3331984283161726],'
            '[-245.3895306587219, -3.3328342649235454]]}'),
                           project=project,
                           type='RW')

        SpatialUnitFactory(geometry=GEOSGeometry(
            '{"type": "Point",'
            '"coordinates": ['
            '-245.39366126060483, -3.334130257559935]}'),
                           project=project,
                           type='MI',
                           attributes={"name": 'Uncontained Point (Test)'})

        SpatialUnitFactory(
            geometry=GEOSGeometry('{"type": "Point",'
                                  '"coordinates": ['
                                  '-4.9383544921875,'
                                  '7.833452408875349'
                                  ']}'),
            project=models.Project.objects.get(name='Kibera Test Project'),
            type='MI',
            attributes={})