Esempio n. 1
0
 def test_get_field_for_area_outside_data(self):
     """
     In this test, area_to_get is defined as being somewhere in the arctic.
     The get_field_for_area should return a string indicating that there is
     no data in that area.
     """
     area_to_get_got = GEOSGeometry("MUlTIPOLYGON(((-51.0 81.0, -52.0 81.0," "-52.0 82.0, -51.0 82.0, -51.0 81.0)))")
     self.assertEqual(get_field_for_area(area_to_get_got, "B19058_002E", Census), None)
Esempio n. 2
0
 def test_get_field_for_area_inside(self):
     """
     In this test, area_to_get_got is completely inside bound two and
     is equal to 1/25 of bound two's area. Bound two has a population
     of 1000 in the field we are getting. Therefore, the expected
     result is equal to (1/25)* 1000 = 40
     """
     area_to_get_got = GEOSGeometry(
         "MUlTIPOLYGON(((-95.9 36.15, -95.8 36.15," "-95.8 36.25, -95.9 36.25, -95.9 36.15)))"
     )
     self.assertEqual(get_field_for_area(area_to_get_got, "B19058_002E", Census), 40)
Esempio n. 3
0
 def test_get_field_for_area_intersection(self):
     """
     Two areas, bound one (500 in field being tested) and bound two(1000 in
     field being tested.) 1/25 of bound one is inside area_to_get_got, and
     9/25ths of bound two is inside area_to_get_got. Therefore, the expcted
     result is ((1/25) * 500) + ((9/25) * 1000) = 380
     """
     area_to_get_got = GEOSGeometry(
         "MUlTIPOLYGON(((-95.95 36.15, -95.45 36.15," "-95.45 36.35,-95.95 36.35, -95.95 36.15)))"
     )
     self.assertEqual(get_field_for_area(area_to_get_got, "B19058_002E", Census), 380)
Esempio n. 4
0
 def test_get_field_for_area_partially_outside(self):
     """
     In this test, 2/3 of area_to_get_got is inside bound two, taking
     up 2/25ths of bound two's total area, while the last 1/3 of
     area_to_get_got is outside of it.  The algorithm will ignore this
     overlap in to areas that don't contain any of the data we're looking
     for, so we need only concern ourselves with the area inside bound two.
     Expected Result: (2/25) * 1000 = 80
     """
     area_to_get_got = GEOSGeometry(
         "MUlTIPOLYGON(((-96.1 36.15, -95.8 36.15," "-95.8 36.25, -96.1 36.25, -96.1 36.15)))"
     )
     self.assertEqual(get_field_for_area(area_to_get_got, "B19058_002E", Census), 80)