Exemplo n.º 1
0
 def test_multi_polygon_with_area(self):
     fire = copy.deepcopy(BASE_FIRE_PRE_FUELBEDS_ONE_ACTIVITY)
     fire['activity'][0]['location']['geojson'] = {
         "type": "MultiPolygon",
         "coordinates": [
             [
                 [
                     [-100.0, 34.0], [-101.0, 35.4], [-101.5, 34.4]
                 ],
                 # the hole is ignored in centroid computation
                 [
                     [-100.2, 35.2], [-100.3, 34.4], [-100.1, 34.3]
                 ]
             ],
             [
                 [
                     [-104.1, 34.12], [-102.4, 33.23]
                 ]
             ]
         ]
     }
     # Expect no change, due to not knowing how to divide area
     expected = copy.deepcopy(fire)
     splitactivity._split(fire, False)
     assert fire == expected
Exemplo n.º 2
0
 def test_lat_lng(self):
     fire = copy.deepcopy(BASE_FIRE_PRE_FUELBEDS_ONE_ACTIVITY)
     fire['activity'][0]['location']['latitide'] = 47.2
     fire['activity'][0]['location']['longitude'] = 108.2
     # Expect no change
     expected = copy.deepcopy(fire)
     splitactivity._split(fire, False)
     assert fire == expected
Exemplo n.º 3
0
 def test(self):
     fire = FIRE_NO_ACTIVITY = {
         "name": "North fire"
     }
     # Expect no change
     expected = copy.deepcopy(fire)
     splitactivity._split(fire, False)
     assert fire == expected
Exemplo n.º 4
0
 def test_point(self):
     fire = copy.deepcopy(BASE_FIRE_PRE_FUELBEDS_ONE_ACTIVITY)
     fire['activity'][0]['location']['geojson'] = {
         "type": "Point",
         "coordinates": [-102.0, 39.5]
     }
     # Expect no change
     expected = copy.deepcopy(fire)
     splitactivity._split(fire, False)
     assert fire == expected
Exemplo n.º 5
0
 def test_line_string(self):
     fire = copy.deepcopy(BASE_FIRE_PRE_FUELBEDS_ONE_ACTIVITY)
     fire['activity'][0]['location']['geojson'] = {
         "type": "LineString",
         "coordinates": [
             [-100.0, 34.0],
             [-101.0, 35.4]
         ]
     }
     # Expect no change
     expected = copy.deepcopy(fire)
     splitactivity._split(fire, False)
     assert fire == expected
Exemplo n.º 6
0
 def test_multi_polygon_no_area(self):
     fire = copy.deepcopy(BASE_FIRE_PRE_FUELBEDS_ONE_ACTIVITY)
     fire['activity'][0]['location'].pop('area')
     fire['activity'][0]['location']['geojson'] = {
         "type": "MultiPolygon",
         "coordinates": [
             [
                 [
                     [-100.0, 34.0], [-101.0, 35.4], [-101.5, 34.4]
                 ],
                 # the hole is ignored in centroid computation
                 [
                     [-100.2, 35.2], [-100.3, 34.4], [-100.1, 34.3]
                 ]
             ],
             [
                 [
                     [-104.1, 34.12], [-102.4, 33.23]
                 ]
             ]
         ]
     }
     expected = copy.deepcopy(fire)
     expected['activity'].append(copy.deepcopy(expected['activity'][0]))
     expected['activity'][0]['location']['geojson'] = {
         "type": "Polygon",
         "coordinates": [
             [
                 [-100.0, 34.0], [-101.0, 35.4], [-101.5, 34.4]
             ],
             # the hole is ignored in centroid computation
             [
                 [-100.2, 35.2], [-100.3, 34.4], [-100.1, 34.3]
             ]
         ]
     }
     expected['activity'][1]['location']['geojson'] = {
         "type": "Polygon",
         "coordinates": [
             [
                 [-104.1, 34.12], [-102.4, 33.23]
             ]
         ]
     }
     splitactivity._split(fire, False)
     assert fire == expected
Exemplo n.º 7
0
 def test_polygon_with_hole(self):
     fire = copy.deepcopy(BASE_FIRE_PRE_FUELBEDS_ONE_ACTIVITY)
     fire['activity'][0]['location']['geojson'] = {
        "type": "Polygon",
        "coordinates": [
             [
                 [-100.0, 34.0], [-101.0, 35.4], [-101.5, 34.4]
             ],
             # the hole is ignored in centroid computation
             [
                 [-100.2, 35.2], [-100.3, 34.4], [-100.1, 34.3]
             ]
        ]
     }
     # Expect no change
     expected = copy.deepcopy(fire)
     splitactivity._split(fire, False)
     assert fire == expected
Exemplo n.º 8
0
 def test_multi_point_no_area(self):
     fire = copy.deepcopy(BASE_FIRE_PRE_FUELBEDS_ONE_ACTIVITY)
     fire['activity'][0]['location']['geojson'] = {
         "type": "MultiPoint",
         "coordinates": [
             [-100.0, 34.0],
             [-101.0, 35.4]
         ]
     }
     expected = copy.deepcopy(BASE_FIRE_PRE_FUELBEDS_ONE_ACTIVITY)
     expected['activity'][0]['location']['area'] /= 2
     expected['activity'].append(copy.deepcopy(expected['activity'][0]))
     expected['activity'][0]['location']['geojson'] = {
         "type": "Point",
         "coordinates": [-100.0, 34.0]
     }
     expected['activity'][1]['location']['geojson'] = {
         "type": "Point",
         "coordinates": [-101.0, 35.4]
     }
     splitactivity._split(fire, False)
     assert fire == expected
Exemplo n.º 9
0
 def test_mixed_record_orig(self):
     fire = copy.deepcopy(FIRE_PRE_FUELBEDS_TWO_ACTIVITY)
     splitactivity._split(fire, True)
     expected = copy.deepcopy(EXPECTED_PRE_FUELBEDS_TWO_ACTIVITY)
     expected['original_activity'] = FIRE_PRE_FUELBEDS_TWO_ACTIVITY['activity']
     assert fire == expected
Exemplo n.º 10
0
 def test_mixed_dont_record_orig(self):
     fire = copy.deepcopy(FIRE_PRE_FUELBEDS_TWO_ACTIVITY)
     splitactivity._split(fire, False)
     assert fire == EXPECTED_PRE_FUELBEDS_TWO_ACTIVITY