def test_folder_multiple_files(): assert [ 7.6016807556152335, 51.94881477206191, 7.647256851196289, 51.974624029877454 ] in geoextent.fromFile('/testdata/folder', bbox=True, tbox=True) assert [6.574722, 51.434444, 4.3175, 53.217222] in geoextent.fromFile('/testdata/folder', bbox=True) assert [ 292063.81225905, 5618144.09259115, 302531.3161606, 5631223.82854667 ] not in geoextent.fromFile('/testdata/folder', tbox=True)
def test_kml_extract_bbox(): result = geoextent.fromFile("tests/testdata/kml/aasee.kml", bbox=True) assert "bbox" in result assert "crs" in result assert result["bbox"] == pytest.approx( [7.594213, 51.942465, 7.618246, 51.957278], abs=tolerance) assert result["crs"] == "4326"
def test_shapefile_extract_time(): result = geoextent.fromFile( 'tests/testdata//shapefile/Abgrabungen_Kreis_Kleve_Shape.shp', bbox=False, tbox=True) assert "bbox" not in result assert result["temporal_extent"] == []
def test_empty_csv_file(): result = geoextent.fromFile('tests/testdata/csv/empty_csv.csv', bbox=True, tbox=True) assert "bbox" not in result assert "tbox" not in result assert "crs" not in result
def test_csv_extract_tbox(): result = geoextent.fromFile('tests/testdata/csv/cities_NL.csv', bbox=False, tbox=True) assert "bbox" not in result assert "tbox" in result assert result["tbox"] == ['2017-08-01', '2019-09-30']
def test_csv_extract_bbox_and_tbox_semicolon_delimiter(): result = geoextent.fromFile( 'tests/testdata/csv/csv_semicolon_delimiter.csv', bbox=True, tbox=True) assert "bbox" in result assert "tbox" in result assert result["bbox"] == [4.3175, 51.434444, 6.574722, 53.217222] assert result["tbox"] == ['01.08.2017', '30.09.2019']
def test_csv_extract_tbox(): result = geoextent.fromFile('tests/testdata/csv/cities_NL.csv', bbox=False, tbox=True) assert "bbox" not in result assert "tbox" in result assert result["tbox"] == ['01.08.2017', '30.09.2019']
def test_geojson_extract_only_time(): result = geoextent.fromFile( 'tests/testdata/geojson/muenster_ring_zeit.geojson', bbox=False, tbox=True) assert "bbox" not in result assert result["tbox"] == ['2018-11-14', '2018-11-14']
def test_gpkg_extract_bbox(): result = geoextent.fromFile("tests/testdata/nc/nc.gpkg", bbox=True) assert "bbox" in result assert "crs" in result assert result['bbox'] == pytest.approx( [-84.323835, 33.882102, -75.456585, 36.589757], abs=tolerance) assert result["crs"] == "4326"
def main(): # Check if there is no arguments, then print help if len(sys.argv[1:]) == 0: print_help_fun() argparser.exit() args = vars(argparser.parse_args()) logger.debug('Extracting from inputs %s', args['input=']) if (args['help']): print_help_fun() elif (args['formats']): print_supported_formats() else: # Check if file is exists happens in parser validation, see readable_file_or_dir if os.path.isfile(os.path.join(os.getcwd(), args['input='])): output = extent.fromFile(args['input='], bbox=args['bounding_box'], tbox=args['time_box']) if os.path.isdir(os.path.join(os.getcwd(), args['input='])): output = extent.fromDirectory(args['input='], bbox=args['bounding_box'], tbox=args['time_box']) if output is None: raise Exception("This file format is not supported") # print output if type(output) == list or type(output) == dict: print(str(output)) else: print(output)
def test_csv_extract_bbox_and_tbox_with_Datetime(): result = geoextent.fromFile('tests/testdata/csv/cities_NL_Datetime.csv', bbox=True, tbox=True) assert "bbox" in result assert "tbox" in result assert result["bbox"] == [4.3175, 51.434444, 6.574722, 53.217222] assert result["tbox"] == ['01.08.2017', '30.09.2019']
def test_csv_extract_bbox_and_tbox_with_cols_diff_order_and_alt_names3(): result = geoextent.fromFile('tests/testdata/csv/cities_NL_case5.csv', bbox=True, tbox=True) assert "bbox" in result assert "tbox" in result assert result["bbox"] == [4.3175, 51.434444, 6.574722, 53.217222] assert result["tbox"] == ['01.08.2017', '30.09.2019']
def test_geojson_extract_bbox(): result = geoextent.fromFile( 'tests/testdata/geojson/muenster_ring_zeit.geojson', bbox=True) assert "bbox" in result assert "crs" in result assert result["bbox"] == pytest.approx( [7.601680, 51.948814, 7.647256, 51.974624], abs=tolerance) assert result["crs"] == "4326"
def test_gpx_extract_bbox(): result = geoextent.fromFile( "tests/testdata/gpx/gpx1.1_with_all_fields.gpx", bbox=True) assert "bbox" in result assert "crs" in result assert result["bbox"] == pytest.approx([-20.2, 10.0, 46.7, 14.0], abs=tolerance) assert result["crs"] == "4326"
def test_gml_extract_bbox(): result = geoextent.fromFile("tests/testdata/gml/clc_1000_PT.gml", bbox=True) assert "bbox" in result assert "crs" in result assert result["bbox"] == pytest.approx( [-17.542069, 32.39669, -6.959389, 39.301139], abs=tolerance) assert result["crs"] == "4326"
def test_csv_extract_tbox_two_diff_time_formats(): result = geoextent.fromFile( 'tests/testdata/csv/3DCMTcatalog_TakemuraEPS_mixed_time_formats.csv', bbox=False, tbox=True) assert "bbox" not in result assert "tbox" not in result assert "crs" not in result
def test_csv_extract_tbox_month_abbr_dd_yyyy_time_formats(): result = geoextent.fromFile( 'tests/testdata/csv/3DCMTcatalog_TakemuraEPS_month_abbr_dd_yyyy_time_format.csv', bbox=False, tbox=True) assert "bbox" not in result assert "crs" not in result assert result["tbox"] == ['2017-04-09', '2017-07-20']
def test_defaults(): result = geoextent.fromFile("tests/testdata/nc/ECMWF_ERA-40_subset.nc") assert "bbox" in result assert "temporal_extent" in result assert "crs" in result result = geoextent.fromFile("tests/testdata/nc/ECMWF_ERA-40_subset.nc", bbox=False) assert "bbox" not in result assert "temporal_extent" in result assert "crs" not in result result = geoextent.fromFile("tests/testdata/nc/ECMWF_ERA-40_subset.nc", tbox=False) assert "bbox" not in result assert "temporal_extent" not in result assert "crs" not in result
def test_gml_extract_bbox_time(): result = geoextent.fromFile("tests/testdata/gml/clc_1000_PT.gml", bbox=True, tbox=True) assert result['bbox'] == pytest.approx( [-17.542069, 32.39669, -6.959389, 39.301139], abs=tolerance) assert result["crs"] == "4326" assert result['tbox'] == ['2005-12-31', '2013-11-30']
def test_shapefile_without_crs_extract_bbox(): result = geoextent.fromFile( 'tests/testdata/shapefile/Abgrabungen_Kreis_Kleve_Shape.shp', bbox=True, tbox=False) assert "tbox" not in result assert "bbox" not in result assert "crs" not in result
def test_shapefile_extract_time(): result = geoextent.fromFile('tests/testdata/shapefile/ifgi_denkpause.shp', bbox=False, tbox=True) assert "bbox" not in result assert "crs" not in result assert "tbox" in result assert result['tbox'] == ['2021-01-01', '2021-01-01']
def test_geotiff_extract_bbox(): result = geoextent.fromFile('tests/testdata/tif/wf_100m_klas.tif', bbox=True) assert "bbox" in result assert "crs" in result assert result["bbox"] == pytest.approx( [5.915300, 50.310251, 9.468398, 52.530775], abs=tolerance) assert result["crs"] == "4326"
def test_csv_extract_tbox_iso8601_time_format(): result = geoextent.fromFile( 'tests/testdata/csv/3DCMTcatalog_TakemuraEPS.csv', bbox=False, tbox=True) assert "bbox" not in result assert "crs" not in result assert "tbox" in result assert result["tbox"] == ['2017-04-08', '2020-02-06']
def test_csv_extract_tbox_dd_mm_yyyy_time_format(): result = geoextent.fromFile( 'tests/testdata/csv/3DCMTcatalog_TakemuraEPS_dd_mm_yyyy.csv', bbox=False, tbox=True) assert "bbox" not in result assert "crs" not in result assert "tbox" in result assert result["tbox"] == ['2017-04-19', '2018-01-31']
def test_shapefile_with_crs_extract_bbox(): result = geoextent.fromFile( 'tests/testdata/shapefile/gis_osm_buildings_a_free_1.shp', bbox=True, tbox=False) assert "temporal_extent" not in result assert result["bbox"] == pytest.approx( [-167.400123, -89.998844, 166.700078, -60.708069], abs=tolerance) assert result["crs"] == "4326"
def test_csv_extract_bbox(): result = geoextent.fromFile('tests/testdata/csv/cities_NL_lat&long.csv', bbox=True) assert "bbox" in result assert "crs" in result assert "tbox" not in result assert result["bbox"] == pytest.approx( [4.3175, 51.434444, 6.574722, 53.217222], abs=tolerance) assert result["crs"] == "4326"
def test_csv_extract_tbox_random_sample_invalid(): result = geoextent.fromFile( 'tests/testdata/csv/3DCMTcatalog_TakemuraEPS.csv', bbox=False, tbox=True, num_sample=-1) assert "bbox" not in result assert "crs" not in result assert "tbox" not in result
def test_shapefile_extract_bbox(): result = geoextent.fromFile( 'tests/testdata//shapefile/Abgrabungen_Kreis_Kleve_Shape.shp', bbox=True, tbox=False) assert "temporal_extent" not in result assert result["bbox"] == [ 295896.274870878, 5694747.64703736, 325999.79578122497, 5747140.98659967 ]
def test_csv_extract_bbox_and_tbox_semicolon_delimiter(): result = geoextent.fromFile( 'tests/testdata/csv/csv_semicolon_delimiter.csv', bbox=True, tbox=True) assert "bbox" in result assert "tbox" in result assert "crs" in result assert result["bbox"] == pytest.approx( [4.3175, 51.434444, 6.574722, 53.217222], abs=tolerance) assert result["crs"] == "4326" assert result["tbox"] == ['2017-08-01', '2019-09-30']
def test_csv_extract_tbox_random_sample_value_larger_than_data(): result = geoextent.fromFile( 'tests/testdata/csv/3DCMTcatalog_TakemuraEPS.csv', bbox=False, tbox=True, num_sample=1000000) assert "bbox" not in result assert "crs" not in result assert "tbox" in result assert result["tbox"] == ['2017-04-08', '2020-02-06']