|
| 1 | +import shutil |
| 2 | + |
1 | 3 | import dataclasses
|
2 | 4 | import json
|
3 | 5 | import math
|
@@ -3691,6 +3693,47 @@ def test_apply_polygon(api):
|
3691 | 3693 | assert params["spatial_extent"] == {"west": 1.0, "south": 5.0, "east": 12.0, "north": 16.0, "crs": "EPSG:4326"}
|
3692 | 3694 |
|
3693 | 3695 |
|
| 3696 | +def test_apply_polygon_with_vector_cube(api, tmp_path): |
| 3697 | + shutil.copy(get_path("geojson/FeatureCollection01.json"), tmp_path / "geometry.json") |
| 3698 | + with ephemeral_fileserver(tmp_path) as fileserver_root: |
| 3699 | + url = f"{fileserver_root}/geometry.json" |
| 3700 | + |
| 3701 | + pg = { |
| 3702 | + "load_raster": { |
| 3703 | + "process_id": "load_collection", |
| 3704 | + "arguments": {"id": "S2_FOOBAR"}, |
| 3705 | + }, |
| 3706 | + "load_vector": { |
| 3707 | + "process_id": "load_url", |
| 3708 | + "arguments": {"url": str(url), "format": "GeoJSON"}, |
| 3709 | + }, |
| 3710 | + "apply_polygon": { |
| 3711 | + "process_id": "apply_polygon", |
| 3712 | + "arguments": { |
| 3713 | + "data": {"from_node": "load_raster"}, |
| 3714 | + "polygons": {"from_node": "load_vector"}, |
| 3715 | + "process": { |
| 3716 | + "process_graph": { |
| 3717 | + "constant": { |
| 3718 | + "process_id": "constant", |
| 3719 | + "arguments": {"x": {"from_parameter": "x"}}, |
| 3720 | + "result": True, |
| 3721 | + } |
| 3722 | + } |
| 3723 | + }, |
| 3724 | + }, |
| 3725 | + "result": True, |
| 3726 | + }, |
| 3727 | + } |
| 3728 | + _ = api.check_result(pg) |
| 3729 | + dummy = dummy_backend.get_collection("S2_FOOBAR") |
| 3730 | + assert dummy.apply_polygon.call_count == 1 |
| 3731 | + polygons = dummy.apply_polygon.call_args.kwargs["polygons"] |
| 3732 | + # TODO #288 instead of MultPolygon, this should actually be a vector cube, feature collection or something equivalent |
| 3733 | + assert isinstance(polygons, shapely.geometry.MultiPolygon) |
| 3734 | + assert polygons.bounds == (4.45, 51.1, 4.52, 51.2) |
| 3735 | + |
| 3736 | + |
3694 | 3737 | def test_fit_class_random_forest(api):
|
3695 | 3738 | res = api.check_result("fit_class_random_forest.json")
|
3696 | 3739 |
|
|
0 commit comments