safe.gis.test.test_polygon module

class safe.gis.test.test_polygon.TestPolygon(methodName='runTest')[source]

Bases: unittest.case.TestCase

setUp()[source]
tearDown()[source]
test_all_inside_polygon()[source]

Corner case where all points are inside polygon works

test_all_outside_polygon()[source]

Corner case where all points are outside polygon works

test_clip_composite_lines_by_polygon()[source]

Composite lines are clipped and classified by polygon

test_clip_grid_by_polygon()[source]

Regular grids can be clipped by polygons (with holes)

test_clip_line_by_polygon_already_inside()[source]

Polygon line clipping works for special cases

test_clip_line_by_polygon_simple()[source]

Simple lines are clipped and classified by polygon

test_clip_lines_by_multiple_polygons()[source]

Multiple composite lines are clipped by multiple polygons

test_clip_lines_by_polygon_multi()[source]

Multiple composite lines are clipped and classified by polygon

test_clip_lines_by_polygon_real_data()[source]

Real roads are clipped by complex polygon

test_clip_points_by_polygons_with_holes()[source]

Points can be separated by polygons with holes

test_duplicate_points_being_ok()[source]

Polygons can have duplicate points without problems

test_in_and_outside_polygon_main()[source]

Set of points is correctly separated according to polygon (2)

test_inside_polygon_main2()[source]

Points can be classified as either inside or outside polygon (2)

test_inside_polygon_vector_version()[source]

Indices of points inside polygon are correct

test_intersection1()[source]

Intersection of two simple lines works

test_intersection2()[source]

Intersection point is independent of direction

test_intersection3()[source]

Intersection point is independent of direction (2)

test_intersection_direction_invariance()[source]

Intersection is direction invariant

This runs through a number of examples and checks that direction of lines don’t matter.

test_intersection_endpoints()[source]

Intersection of lines with coinciding endpoints works

Test that coinciding endpoints are picked up

test_intersection_parallel()[source]

Parallel lines are correctly detected in intersection code

test_is_inside_polygon_main1()[source]

Points are classified as either inside polygon or not

test_join_segments()[source]

Consecutive line segments can be joined into continuous line

test_large_convoluted_example()[source]

Large convoluted polygon clipping example works

test_large_convoluted_example_random()[source]

Large convoluted polygon clipping example works (random points)

test_large_example()[source]

Large polygon clipping example works

test_no_intersection()[source]

Lines that don’t intersect return None as expected

test_outside_polygon()[source]

Points are classified as either outside polygon or not

test_outside_polygon2()[source]

Points are classified as either outside polygon or not (2)

test_point_on_line()[source]

Points coinciding with lines are correctly detected

test_point_on_line_vector()[source]

Points coinciding with lines are correctly detected (vector version)

Vectorised version

test_polygon_clipping_error_handling()[source]

Polygon clipping checks input as expected

test_populate_polygon()[source]

Polygon can be populated by random points

test_populate_polygon_with_exclude()[source]

Polygon with hole can be populated by random points

test_populate_polygon_with_exclude2()[source]

Polygon with hole can be populated by random points (2)

test_separate_points_by_polygon0()[source]

Points can be separated by polygon

test_separate_points_by_polygon1()[source]

Set of points is correctly separated according to polygon

test_separate_points_by_polygon_characterisation()[source]

Numpy version of polygon clipping agrees with python version

test_separate_points_by_polygon_edge()[source]

Points on polygon edge correctly detected

test_separate_points_by_polygon_empty_points()[source]

Separate points by polygon ok when no points in bbox

test_vectorised_intersection1()[source]

Vectorised intersection of multiple lines works 1

test_vectorised_intersection2()[source]

Vectorised intersection of multiple lines works 2