def test_dissolve_multisinglepolygons(tmpdir): # Init tmp_dir = Path(tmpdir) tmp_dir.mkdir(parents=True, exist_ok=True) # Prepare test data + test for suffix in test_helper.get_test_suffix_list(): for crs_epsg in test_helper.get_test_crs_epsg_list(): # Write test file in the right format + crs print(f"Run test for suffix {suffix} and crs_epsg {crs_epsg}") test_gdf = gpd.GeoDataFrame(geometry=[ test_helper.TestData.polygon_with_island, test_helper.TestData.multipolygon ], crs=test_helper.TestData.crs_epsg) # Reproject if needed if test_helper.TestData.crs_epsg != crs_epsg: test_gdf = test_gdf.to_crs(epsg=crs_epsg) assert isinstance(test_gdf, gpd.GeoDataFrame) input_path = tmp_dir / f"polygons_{crs_epsg}{suffix}" gfo.to_file(test_gdf, input_path) output_path = tmp_dir / f"{input_path.stem}-output{suffix}" # Now run test basetest_dissolve_multisinglepolygons(input_path, output_path)
def test_union_circles(tmpdir): # Prepare test data + run tests tmp_dir = Path(tmpdir) tmp_dir.mkdir(parents=True, exist_ok=True) for suffix in test_helper.get_test_suffix_list(): for crs_epsg in test_helper.get_test_crs_epsg_list(): # If test input file is in wrong format, convert it input1_path = test_helper.prepare_test_file( path=test_helper.TestFiles.polygons_overlappingcircles_one_gpkg, tmp_dir=tmp_dir, suffix=suffix, crs_epsg=crs_epsg) # If test input file is in wrong format, convert it input2_path = test_helper.prepare_test_file( path=test_helper.TestFiles.polygons_overlappingcircles_twothree_gpkg, tmp_dir=tmp_dir, suffix=suffix, crs_epsg=crs_epsg) # Now run test output_path = tmp_dir / f"{input1_path.stem}-output{suffix}" print(f"Run test for suffix {suffix}, crs_epsg {crs_epsg}") basetest_union_circles(tmp_dir, input1_path, input2_path, output_path)
def test_export_by_distance(tmpdir): # Prepare test data + run tests tmp_dir = Path(tmpdir) tmp_dir.mkdir(parents=True, exist_ok=True) for suffix in test_helper.get_test_suffix_list(): for crs_epsg in test_helper.get_test_crs_epsg_list(): # If test input file is in wrong format, convert it input_to_select_from_path = test_helper.prepare_test_file( path=test_helper.TestFiles.polygons_parcels_gpkg, tmp_dir=tmp_dir, suffix=suffix, crs_epsg=crs_epsg) # If test input file is in wrong format, convert it input_to_compare_with_path = test_helper.prepare_test_file( path=test_helper.TestFiles.polygons_zones_gpkg, tmp_dir=tmp_dir, suffix=suffix, crs_epsg=crs_epsg) # Now run test output_path = tmp_dir / f"{input_to_select_from_path.stem}-output{suffix}" print(f"Run test for suffix {suffix}, crs_epsg {crs_epsg}") basetest_export_by_distance( input_to_select_from_path, input_to_compare_with_path, output_path)
def test_simplify(tmpdir): # Init tmp_dir = Path(tmpdir) tmp_dir.mkdir(parents=True, exist_ok=True) test_inputs = [] test_inputs.append({ "input_path": test_helper.TestFiles.polygons_parcels_gpkg, "geometrytype": GeometryType.MULTIPOLYGON}) test_inputs.append({ "input_path": test_helper.TestFiles.points_gpkg, "geometrytype": GeometryType.MULTIPOINT}) test_inputs.append({ "input_path": test_helper.TestFiles.linestrings_rows_of_trees_gpkg, "geometrytype": GeometryType.MULTILINESTRING}) # Prepare test data + run tests for suffix in test_helper.get_test_suffix_list(): for crs_epsg in test_helper.get_test_crs_epsg_list(): for test_input in test_inputs: # If test input file is in wrong format, convert it input_path = test_helper.prepare_test_file( path=test_input['input_path'], tmp_dir=tmp_dir, suffix=suffix, crs_epsg=crs_epsg) # Now run test output_path = tmp_dir / f"{input_path.stem}-output{suffix}" print(f"Run test for suffix {suffix}, crs_epsg {crs_epsg}, geometrytype {test_input['geometrytype']}") basetest_simplify(input_path, output_path, test_input['geometrytype'])
def test_dissolve_polygons_nogroupby(tmpdir): # Prepare test data + run tests tmp_dir = Path(tmpdir) tmp_dir.mkdir(parents=True, exist_ok=True) for suffix in test_helper.get_test_suffix_list(): for crs_epsg in test_helper.get_test_crs_epsg_list(): # If test input file is in wrong format, convert it input_path = test_helper.prepare_test_file( path=test_helper.TestFiles.polygons_parcels_gpkg, tmp_dir=tmp_dir, suffix=suffix, crs_epsg=crs_epsg) # Now run test output_path = tmp_dir / f"{input_path.stem}-output{suffix}" print(f"Run test for suffix {suffix}, crs_epsg {crs_epsg}") basetest_dissolve_polygons_groupby(input_path, output_path)
def test_buffer_ext(tmpdir): # Prepare test data + run tests tmp_dir = Path(tmpdir) tmp_dir.mkdir(parents=True, exist_ok=True) for suffix in test_helper.get_test_suffix_list(): # Buffer on not-projected data is weird, so not tested (at the moment) for crs_epsg in test_helper.get_test_crs_epsg_list(): # If test input file is in wrong format, convert it input_path = test_helper.prepare_test_file( path=test_helper.TestFiles.polygons_parcels_gpkg, tmp_dir=tmp_dir, suffix=suffix, crs_epsg=crs_epsg) # Now run test output_path = tmp_dir / f"{input_path.stem}-output{suffix}" print(f"Run test for suffix {suffix}, crs_epsg {crs_epsg}") basetest_buffer_ext(input_path, output_path)