def test_user_defined_extent(self): """Test that analysis honours user defined extents. Note that when testing on a desktop system this will overwrite your user defined analysis extent. """ settings = QtCore.QSettings() extent = ('POLYGON ((' '106.772279 -6.237576, ' '106.772279 -6.165415, ' '106.885165 -6.165415, ' '106.885165 -6.237576, ' '106.772279 -6.237576' '))') settings.setValue('inasafe/user_extent', extent) settings.setValue('inasafe/user_extent_crs', 'EPSG:4326') self.dock.read_settings() setup_scenario(self.dock, hazard='Continuous Flood', exposure='Population', aggregation_layer=u'D\xedstr\xedct\'s of Jakarta', aggregation_enabled_flag=True) self.dock.extent.show_rubber_bands = True expected_vertex_count = 2 # 4326 with disabled on-the-fly reprojection set_canvas_crs(GEOCRS, True) # User extent should override this set_small_jakarta_extent(self.dock) self.dock.extent.display_user_extent() user_band = self.dock.extent._user_analysis_rubberband self.assertEqual(expected_vertex_count, user_band.numberOfVertices())
def test_user_defined_extent(self): """Test that analysis honours user defined extents. Note that when testing on a desktop system this will overwrite your user defined analysis extent. """ settings = QtCore.QSettings() extents = '106.772279, -6.237576, 106.885165, -6.165415' settings.setValue('inasafe/analysis_extent', extents) settings.setValue('inasafe/analysis_extent_crs', 'EPSG:4326') DOCK.read_settings() setup_scenario(DOCK, hazard='A flood in Jakarta like in 2007', exposure='People', function='Need evacuation', function_id='Flood Evacuation Function', aggregation_layer='kabupaten jakarta singlepart', aggregation_enabled_flag=True) DOCK.extent.show_rubber_bands = True expected_vertex_count = 5 # 4326 with disabled on-the-fly reprojection set_canvas_crs(GEOCRS, True) # User extent should override this set_small_jakarta_extent(DOCK) DOCK.extent.show_user_analysis_extent() user_band = DOCK.extent.user_analysis_rubberband self.assertEqual(expected_vertex_count, user_band.numberOfVertices())
def test_issue581(self): """Test issue #581 in github - Humanize can produce IndexError : list index out of range """ # See https://github.com/AIFDR/inasafe/issues/581 result, message = setup_scenario( DOCK, hazard='A flood in Jakarta like in 2007', exposure='People', function='Need evacuation', function_id='Flood Evacuation Function') self.assertTrue(result, message) # Enable on-the-fly reprojection set_canvas_crs(GEOCRS, True) set_small_jakarta_extent(DOCK) # Press RUN DOCK.accept() result = DOCK.wvResults.page().currentFrame().toPlainText() message = 'Result not as expected: %s' % result self.assertTrue('IndexError' not in result, message) self.assertTrue( 'It appears that no People are affected by A flood in ' 'Jakarta like in 2007. You may want to consider:' in result)
def test_issue581(self): """Test issue #581 in github - Humanize can produce IndexError : list index out of range """ # See https://github.com/AIFDR/inasafe/issues/581 result, message = setup_scenario( self.dock, hazard='Continuous Flood', exposure='Population', function='Need evacuation', function_id='FloodEvacuationRasterHazardFunction') self.assertTrue(result, message) # Enable on-the-fly reprojection set_canvas_crs(GEOCRS, True) set_small_jakarta_extent(self.dock) # Press RUN self.dock.accept() result = self.dock.wvResults.page().currentFrame().toPlainText() message = 'Result not as expected: %s' % result self.assertTrue('IndexError' not in result, message) self.assertTrue( 'It appears that no Population are affected by Continuous Flood.' in result, message)
def test_user_defined_extent(self): """Test that analysis honours user defined extents. Note that when testing on a desktop system this will overwrite your user defined analysis extent. """ settings = QtCore.QSettings() extents = '106.772279, -6.237576, 106.885165, -6.165415' settings.setValue('inasafe/analysis_extent', extents) settings.setValue('inasafe/analysis_extent_crs', 'EPSG:4326') self.dock.read_settings() setup_scenario( self.dock, hazard='Continuous Flood', exposure='Population', function='Need evacuation', function_id='FloodEvacuationRasterHazardFunction', aggregation_layer=u'D\xedstr\xedct\'s of Jakarta', aggregation_enabled_flag=True) self.dock.extent.show_rubber_bands = True expected_vertex_count = 2 # 4326 with disabled on-the-fly reprojection set_canvas_crs(GEOCRS, True) # User extent should override this set_small_jakarta_extent(self.dock) self.dock.extent.show_user_analysis_extent() user_band = self.dock.extent.user_analysis_rubberband self.assertEqual(expected_vertex_count, user_band.numberOfVertices())
def test_user_defined_extent(self): """Test that analysis honours user defined extents. Note that when testing on a desktop system this will overwrite your user defined analysis extent. """ settings = QtCore.QSettings() extents = '106.772279, -6.237576, 106.885165, -6.165415' settings.setValue('inasafe/analysis_extent', extents) settings.setValue('inasafe/analysis_extent_crs', 'EPSG:4326') DOCK.read_settings() setup_scenario( DOCK, hazard='A flood in Jakarta like in 2007', exposure='People', function='Need evacuation', function_id='Flood Evacuation Function', aggregation_layer='kabupaten jakarta singlepart', aggregation_enabled_flag=True) DOCK.extent.show_rubber_bands = True expected_vertex_count = 5 # 4326 with disabled on-the-fly reprojection set_canvas_crs(GEOCRS, True) # User extent should override this set_small_jakarta_extent(DOCK) DOCK.extent.show_user_analysis_extent() user_band = DOCK.extent.user_analysis_rubberband self.assertEqual(expected_vertex_count, user_band.numberOfVertices())
def test_rubber_bands(self): """Test that the rubber bands get updated.""" setup_scenario(DOCK, hazard='A flood in Jakarta like in 2007', exposure='People', function='Need evacuation', function_id='Flood Evacuation Function', aggregation_layer='kabupaten jakarta singlepart', aggregation_enabled_flag=True) DOCK.extent.show_rubber_bands = True expected_vertex_count = 5 # 4326 with enabled on-the-fly reprojection - check next set_canvas_crs(GEOCRS, True) set_small_jakarta_extent(DOCK) DOCK.show_next_analysis_extent() next_band = DOCK.extent.next_analysis_rubberband self.assertEqual(expected_vertex_count, next_band.numberOfVertices()) # 4326 with disabled on-the-fly reprojection - check next set_canvas_crs(GEOCRS, False) set_small_jakarta_extent(DOCK) DOCK.show_next_analysis_extent() next_band = DOCK.extent.next_analysis_rubberband self.assertEqual(expected_vertex_count, next_band.numberOfVertices()) # 900913 with enabled on-the-fly reprojection - check next set_canvas_crs(GOOGLECRS, True) set_jakarta_google_extent(DOCK) next_band = DOCK.extent.next_analysis_rubberband self.assertEqual(expected_vertex_count, next_band.numberOfVertices()) # 900913 with enabled on-the-fly reprojection - check last set_canvas_crs(GOOGLECRS, True) set_jakarta_google_extent(DOCK) # Press RUN # noinspection PyCallByClass,PyTypeChecker DOCK.accept() # DOCK.show_extent() last_band = DOCK.extent.last_analysis_rubberband geometry = last_band.asGeometry().exportToWkt() expected = ( 'LINESTRING(11876228.33329810947179794 -695807.82839082507416606, ' '11908350.67106631398200989 -695807.82839082507416606, ' '11908350.67106631398200989 -678083.54461829655338079, ' '11876228.33329810947179794 -678083.54461829655338079, ' '11876228.33329810947179794 -695807.82839082507416606)') expected_list = self.wkt_to_coordinates(expected) actual_list = self.wkt_to_coordinates(geometry) for item in xrange(0, len(expected_list)): print item, expected_list[item], actual_list[item] self.assertAlmostEqual(expected_list[item][0], actual_list[item][0]) self.assertAlmostEqual(expected_list[item][1], actual_list[item][1]) self.assertEqual(expected_vertex_count, last_band.numberOfVertices())
def test_rubber_bands(self): """Test that the rubber bands get updated.""" setup_scenario(DOCK, hazard='Continuous Flood', exposure='Population', function='Need evacuation', function_id='FloodEvacuationRasterHazardFunction', aggregation_layer=u'D\xedstr\xedct\'s of Jakarta', aggregation_enabled_flag=True) DOCK.extent.show_rubber_bands = True expected_vertex_count = 5 # 4326 with enabled on-the-fly reprojection - check next set_canvas_crs(GEOCRS, True) set_small_jakarta_extent(DOCK) DOCK.show_next_analysis_extent() next_band = DOCK.extent.next_analysis_rubberband self.assertEqual(expected_vertex_count, next_band.numberOfVertices()) # 4326 with disabled on-the-fly reprojection - check next set_canvas_crs(GEOCRS, False) set_small_jakarta_extent(DOCK) DOCK.show_next_analysis_extent() next_band = DOCK.extent.next_analysis_rubberband self.assertEqual(expected_vertex_count, next_band.numberOfVertices()) # 900913 with enabled on-the-fly reprojection - check next set_canvas_crs(GOOGLECRS, True) set_jakarta_google_extent(DOCK) next_band = DOCK.extent.next_analysis_rubberband self.assertEqual(expected_vertex_count, next_band.numberOfVertices()) # 900913 with enabled on-the-fly reprojection - check last set_canvas_crs(GOOGLECRS, True) set_jakarta_google_extent(DOCK) # Press RUN # noinspection PyCallByClass,PyTypeChecker DOCK.accept() # DOCK.show_extent() last_band = DOCK.extent.last_analysis_rubberband geometry = last_band.asGeometry().exportToWkt() expected = ( 'LINESTRING(11889533.87392097897827625 -691251.80866545776370913, ' '11893986.65355271473526955 -691251.80866545776370913, ' '11893986.65355271473526955 -686773.02196401008404791, ' '11889533.87392097897827625 -686773.02196401008404791, ' '11889533.87392097897827625 -691251.80866545776370913)') expected_list = self.wkt_to_coordinates(expected) actual_list = self.wkt_to_coordinates(geometry) for item in xrange(0, len(expected_list)): print item, expected_list[item], actual_list[item] self.assertAlmostEqual(expected_list[item][0], actual_list[item][0]) self.assertAlmostEqual(expected_list[item][1], actual_list[item][1]) self.assertEqual(expected_vertex_count, last_band.numberOfVertices())
def test_rubber_bands(self): """Test that the rubber bands get updated.""" setup_scenario( self.dock, hazard='Continuous Flood', exposure='Population', function='Need evacuation', function_id='FloodEvacuationRasterHazardFunction', aggregation_layer=u'D\xedstr\xedct\'s of Jakarta', aggregation_enabled_flag=True) self.dock.extent.show_rubber_bands = True expected_vertex_count = 5 # 4326 with enabled on-the-fly reprojection - check next set_canvas_crs(GEOCRS, True) set_small_jakarta_extent(self.dock) self.dock.show_next_analysis_extent() next_band = self.dock.extent.next_analysis_rubberband self.assertEqual(expected_vertex_count, next_band.numberOfVertices()) # 4326 with disabled on-the-fly reprojection - check next set_canvas_crs(GEOCRS, False) set_small_jakarta_extent(self.dock) self.dock.show_next_analysis_extent() next_band = self.dock.extent.next_analysis_rubberband self.assertEqual(expected_vertex_count, next_band.numberOfVertices()) # 900913 with enabled on-the-fly reprojection - check next set_canvas_crs(GOOGLECRS, True) set_jakarta_google_extent(self.dock) next_band = self.dock.extent.next_analysis_rubberband self.assertEqual(expected_vertex_count, next_band.numberOfVertices()) # 900913 with enabled on-the-fly reprojection - check last set_canvas_crs(GOOGLECRS, True) set_jakarta_google_extent(self.dock) # Press RUN # noinspection PyCallByClass,PyTypeChecker self.dock.accept() # self.dock.show_extent() last_band = self.dock.extent.last_analysis_rubberband geometry = last_band.asGeometry().exportToWkt() expected = ( 'LINESTRING(11889533.87392097897827625 -691251.80866545776370913, ' '11893986.65355271473526955 -691251.80866545776370913, ' '11893986.65355271473526955 -686773.02196401008404791, ' '11889533.87392097897827625 -686773.02196401008404791, ' '11889533.87392097897827625 -691251.80866545776370913)') expected_list = self.wkt_to_coordinates(expected) actual_list = self.wkt_to_coordinates(geometry) for item in xrange(0, len(expected_list)): print item, expected_list[item], actual_list[item] self.assertAlmostEqual( expected_list[item][0], actual_list[item][0]) self.assertAlmostEqual( expected_list[item][1], actual_list[item][1]) self.assertEqual( expected_vertex_count, last_band.numberOfVertices() )
def test_rubber_bands(self): """Test that the rubber bands get updated.""" setup_scenario( DOCK, hazard='A flood in Jakarta like in 2007', exposure='People', function='Need evacuation', function_id='Flood Evacuation Function', aggregation_layer='kabupaten jakarta singlepart', aggregation_enabled_flag=True) DOCK.extent.show_rubber_bands = True expected_vertex_count = 5 # 4326 with enabled on-the-fly reprojection - check next set_canvas_crs(GEOCRS, True) set_small_jakarta_extent(DOCK) DOCK.show_next_analysis_extent() next_band = DOCK.extent.next_analysis_rubberband self.assertEqual(expected_vertex_count, next_band.numberOfVertices()) # 4326 with disabled on-the-fly reprojection - check next set_canvas_crs(GEOCRS, False) set_small_jakarta_extent(DOCK) DOCK.show_next_analysis_extent() next_band = DOCK.extent.next_analysis_rubberband self.assertEqual(expected_vertex_count, next_band.numberOfVertices()) # 900913 with enabled on-the-fly reprojection - check next set_canvas_crs(GOOGLECRS, True) set_jakarta_google_extent(DOCK) next_band = DOCK.extent.next_analysis_rubberband self.assertEqual(expected_vertex_count, next_band.numberOfVertices()) # 900913 with enabled on-the-fly reprojection - check last set_canvas_crs(GOOGLECRS, True) set_jakarta_google_extent(DOCK) # Press RUN # noinspection PyCallByClass,PyTypeChecker DOCK.accept() # DOCK.show_extent() last_band = DOCK.extent.last_analysis_rubberband geometry = last_band.asGeometry().exportToWkt() expected = ( 'LINESTRING(11876228.33329810947179794 -695807.82839082507416606, ' '11908350.67106631398200989 -695807.82839082507416606, ' '11908350.67106631398200989 -678083.54461829655338079, ' '11876228.33329810947179794 -678083.54461829655338079, ' '11876228.33329810947179794 -695807.82839082507416606)') expected_list = self.wkt_to_coordinates(expected) actual_list = self.wkt_to_coordinates(geometry) for item in xrange(0, len(expected_list)): print item, expected_list[item], actual_list[item] self.assertAlmostEqual( expected_list[item][0], actual_list[item][0]) self.assertAlmostEqual( expected_list[item][1], actual_list[item][1]) self.assertEqual( expected_vertex_count, last_band.numberOfVertices() )