コード例 #1
0
ファイル: test_api.py プロジェクト: YouQam/geoextent
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)
コード例 #2
0
ファイル: test_api.py プロジェクト: o2r-project/geoextent
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"
コード例 #3
0
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"] == []
コード例 #4
0
ファイル: test_api_csv.py プロジェクト: YouQam/geoextent
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
コード例 #5
0
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']
コード例 #6
0
ファイル: test_api_csv.py プロジェクト: YouQam/geoextent
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']
コード例 #7
0
ファイル: test_api_csv.py プロジェクト: YouQam/geoextent
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']
コード例 #8
0
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']
コード例 #9
0
ファイル: test_api.py プロジェクト: o2r-project/geoextent
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"
コード例 #10
0
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)
コード例 #11
0
ファイル: test_api_csv.py プロジェクト: YouQam/geoextent
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']
コード例 #12
0
ファイル: test_api_csv.py プロジェクト: YouQam/geoextent
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']
コード例 #13
0
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"
コード例 #14
0
ファイル: test_api.py プロジェクト: o2r-project/geoextent
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"
コード例 #15
0
ファイル: test_api.py プロジェクト: o2r-project/geoextent
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"
コード例 #16
0
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
コード例 #17
0
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']
コード例 #18
0
ファイル: test_api.py プロジェクト: YouQam/geoextent
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
コード例 #19
0
ファイル: test_api.py プロジェクト: o2r-project/geoextent
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']
コード例 #20
0
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
コード例 #21
0
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']
コード例 #22
0
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"
コード例 #23
0
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']
コード例 #24
0
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']
コード例 #25
0
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"
コード例 #26
0
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"
コード例 #27
0
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
コード例 #28
0
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
    ]
コード例 #29
0
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']
コード例 #30
0
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']