diff --git a/covid_api/api/api_v1/endpoints/detections.py b/covid_api/api/api_v1/endpoints/detections.py index 075980a..669b29e 100644 --- a/covid_api/api/api_v1/endpoints/detections.py +++ b/covid_api/api/api_v1/endpoints/detections.py @@ -12,7 +12,7 @@ router = APIRouter() # TODO: unhardcoded types and dates -MLTypes = Enum("MLTypes", [(ml, ml) for ml in ["ship", "multiple", "plane"]]) # type: ignore +MLTypes = Enum("MLTypes", [(ml, ml) for ml in ["ship", "multiple", "plane", "vehicles"]]) # type: ignore @router.get( diff --git a/covid_api/api/utils.py b/covid_api/api/utils.py index 79c86c4..177164d 100644 --- a/covid_api/api/utils.py +++ b/covid_api/api/utils.py @@ -740,4 +740,6 @@ def site_date_to_scenes(site: str, date: str): json.loads(row["scene_id"].replace("'", '"')) ) - return site_date_to_scenes_dict[f"{site}-{date}"] + # deduplicate scene list (in case multiple datasets contains the same + # scene id) + return list(set(site_date_to_scenes_dict[f"{site}-{date}"])) diff --git a/covid_api/db/static/datasets/__init__.py b/covid_api/db/static/datasets/__init__.py index 92b1201..2952ae9 100644 --- a/covid_api/db/static/datasets/__init__.py +++ b/covid_api/db/static/datasets/__init__.py @@ -133,7 +133,11 @@ def _prep_output(self, output_datasets: dict, api_url: str): tile.replace("{api_url}", api_url) for tile in dataset.compare.source.tiles ] - if dataset.id in ["detections-ship", "detections-plane"]: + if dataset.id in [ + "detections-ship", + "detections-plane", + "detections-vehicles", + ]: dataset.source = GeoJsonSource( type=dataset.source.type, data=dataset.source.tiles[0] ) diff --git a/covid_api/db/static/datasets/agriculture.json b/covid_api/db/static/datasets/agriculture.json index e149122..37013fb 100644 --- a/covid_api/db/static/datasets/agriculture.json +++ b/covid_api/db/static/datasets/agriculture.json @@ -24,7 +24,8 @@ "water-chlorophyll", "water-spm", "detections-ship", - "detections-plane" + "detections-plane", + "detections-vehicles" ], "enabled": false, "swatch": { diff --git a/covid_api/db/static/datasets/co2-diff.json b/covid_api/db/static/datasets/co2-diff.json index ec64426..fd39573 100644 --- a/covid_api/db/static/datasets/co2-diff.json +++ b/covid_api/db/static/datasets/co2-diff.json @@ -24,7 +24,8 @@ "water-chlorophyll", "water-spm", "detections-ship", - "detections-plane" + "detections-plane", + "detections-vehicles" ], "enabled": false, "swatch": { diff --git a/covid_api/db/static/datasets/co2.json b/covid_api/db/static/datasets/co2.json index fbe16c3..c5f963f 100644 --- a/covid_api/db/static/datasets/co2.json +++ b/covid_api/db/static/datasets/co2.json @@ -23,7 +23,8 @@ "water-chlorophyll", "water-spm", "detections-ship", - "detections-plane" + "detections-plane", + "detections-vehicles" ], "enabled": false, "compare": { diff --git a/covid_api/db/static/datasets/detections-plane.json b/covid_api/db/static/datasets/detections-plane.json index df7ae64..8fb3fd3 100644 --- a/covid_api/db/static/datasets/detections-plane.json +++ b/covid_api/db/static/datasets/detections-plane.json @@ -8,7 +8,7 @@ "source": { "type": "geojson", "tiles": [ - "{api_url}/detections/plane/{spotlightId}/{date}.geojson" + "{api_url}/detections-plane/{spotlightId}/{date}.geojson" ] }, "background_source": { @@ -29,7 +29,8 @@ "detection-multi", "water-chlorophyll", "water-spm", - "detections-ship" + "detections-ship", + "detections-vehicles" ], "enabled": false, "swatch": { diff --git a/covid_api/db/static/datasets/detections-ship.json b/covid_api/db/static/datasets/detections-ship.json index 3e0cf96..75132aa 100644 --- a/covid_api/db/static/datasets/detections-ship.json +++ b/covid_api/db/static/datasets/detections-ship.json @@ -8,7 +8,7 @@ "source": { "type": "geojson", "tiles": [ - "{api_url}/detections/ship/{spotlightId}/{date}.geojson" + "{api_url}/detections-ship/{spotlightId}/{date}.geojson" ] }, "background_source": { @@ -29,7 +29,8 @@ "detection-multi", "water-chlorophyll", "water-spm", - "detections-plane" + "detections-plane", + "detections-vehicles" ], "enabled": false, "swatch": { diff --git a/covid_api/db/static/datasets/detections-vehicles.json b/covid_api/db/static/datasets/detections-vehicles.json new file mode 100644 index 0000000..56b29b2 --- /dev/null +++ b/covid_api/db/static/datasets/detections-vehicles.json @@ -0,0 +1,41 @@ +{ + "id": "detections-vehicles", + "name": "Vehicle", + "type": "inference-timeseries", + "s3_location": "detections-vehicles", + "is_periodic": false, + "time_unit": "day", + "source": { + "type": "geojson", + "tiles": [ + "{api_url}/detections-vehicles/{spotlightId}/{date}.geojson" + ] + }, + "background_source": { + "type": "raster", + "tiles": [ + "{api_url}/{z}/{x}/{y}@1x?url=s3://covid-eo-data/detections-vehicles/background/{spotlightId}/{date}.tif" + ] + }, + "exclusive_with": [ + "agriculture", + "no2", + "co2-diff", + "co2", + "gibs-population", + "car-count", + "nightlights-viirs", + "nightlights-hd", + "detection-multi", + "water-chlorophyll", + "water-spm", + "detections-ship", + "detections-plane" + ], + "enabled": false, + "swatch": { + "color": "#C0C0C0", + "name": "Grey" + }, + "info": "Vehicles detected each day in PlanetScope imagery are shown in orange." +} \ No newline at end of file diff --git a/covid_api/db/static/datasets/nightlights-hd.json b/covid_api/db/static/datasets/nightlights-hd.json index a44d25f..ceeb37a 100644 --- a/covid_api/db/static/datasets/nightlights-hd.json +++ b/covid_api/db/static/datasets/nightlights-hd.json @@ -23,7 +23,8 @@ "water-chlorophyll", "water-spm", "detections-ship", - "detections-plane" + "detections-plane", + "detections-vehicles" ], "swatch": { "color": "#C0C0C0", diff --git a/covid_api/db/static/datasets/nightlights-viirs.json b/covid_api/db/static/datasets/nightlights-viirs.json index ee00ca7..5b429e9 100644 --- a/covid_api/db/static/datasets/nightlights-viirs.json +++ b/covid_api/db/static/datasets/nightlights-viirs.json @@ -23,7 +23,8 @@ "water-chlorophyll", "water-spm", "detections-ship", - "detections-plane" + "detections-plane", + "detections-vehicles" ], "swatch": { "color": "#C0C0C0", diff --git a/covid_api/db/static/datasets/no2.json b/covid_api/db/static/datasets/no2.json index 962abd6..8f3f4b0 100644 --- a/covid_api/db/static/datasets/no2.json +++ b/covid_api/db/static/datasets/no2.json @@ -26,7 +26,8 @@ "water-chlorophyll", "water-spm", "detections-ship", - "detections-plane" + "detections-plane", + "detections-vehicles" ], "enabled": true, "compare": { diff --git a/covid_api/db/static/datasets/water-chlorophyll.json b/covid_api/db/static/datasets/water-chlorophyll.json index 146d09f..511a01b 100644 --- a/covid_api/db/static/datasets/water-chlorophyll.json +++ b/covid_api/db/static/datasets/water-chlorophyll.json @@ -23,7 +23,8 @@ "detection-multi", "water-spm", "detections-ship", - "detections-plane" + "detections-plane", + "detections-vehicles" ], "swatch": { "color": "#154F8D", diff --git a/covid_api/db/static/datasets/water-spm.json b/covid_api/db/static/datasets/water-spm.json index 46ed091..a0d0de0 100644 --- a/covid_api/db/static/datasets/water-spm.json +++ b/covid_api/db/static/datasets/water-spm.json @@ -23,7 +23,8 @@ "detection-multi", "water-chlorophyll", "detections-ship", - "detections-plane" + "detections-plane", + "detections-vehicles" ], "swatch": { "color": "#154F8D",