Skip to content

Commit 8575373

Browse files
Add link for Glide Collection
1 parent b221728 commit 8575373

File tree

5 files changed

+16
-33
lines changed

5 files changed

+16
-33
lines changed

pystac_monty/collections/__init__.py

Whitespace-only changes.

pystac_monty/collections/glide_events.py

Lines changed: 0 additions & 19 deletions
This file was deleted.

pystac_monty/sources/gdacs.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ def get_impact_category_from_sendai_a(
358358
def get_impact_category_from_sendai_b(
359359
sendainame: str,
360360
) -> MontyImpactExposureCategory:
361-
if sendainame == "rescued" or sendainame == "displaced":
361+
if sendainame == "rescued" or sendainame == "displaced" or sendainame == "affected":
362362
return MontyImpactExposureCategory.ALL_PEOPLE
363363
else:
364364
raise ValueError(f"Unknown sendai name {sendainame} for indicators B")
@@ -367,7 +367,7 @@ def get_impact_category_from_sendai_b(
367367
def get_impact_category_from_sendai_c(
368368
sendainame: str,
369369
) -> MontyImpactExposureCategory:
370-
if sendainame == "houses damaged":
370+
if sendainame == "houses damaged" or sendainame == "houses":
371371
return MontyImpactExposureCategory.BUILDINGS
372372
else:
373373
raise ValueError(f"Unknown sendai name {sendainame} for indicators C")
@@ -415,12 +415,14 @@ def get_impact_type_from_sendai_b(sendainame: str) -> MontyImpactType:
415415
return MontyImpactType.ASSISTED
416416
elif sendainame == "displaced":
417417
return MontyImpactType.RELOCATED
418+
elif sendainame == "affected":
419+
return MontyImpactType.TOTAL_AFFECTED
418420
else:
419421
raise ValueError(f"Unknown sendai name {sendainame} for indicators B")
420422

421423
@staticmethod
422424
def get_impact_type_from_sendai_c(sendainame: str) -> MontyImpactType:
423-
if sendainame == "houses damaged":
425+
if sendainame == "houses damaged" or sendainame == "houses":
424426
return MontyImpactType.DAMAGED
425427
else:
426428
raise ValueError(f"Unknown sendai name {sendainame} for indicators C")

pystac_monty/sources/glide.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
from datetime import datetime
33
from typing import Any
44

5+
import requests
56
from pystac import Collection, Item, Link
67
from shapely.geometry import Point, mapping
78

8-
from pystac_monty.collections.glide_events import glide_event_collection
99
from pystac_monty.extension import MontyExtension
1010
from pystac_monty.sources.common import MontyDataSource
1111

@@ -21,6 +21,10 @@ class GlideTransformer:
2121
Transforms Glide event data into STAC Items
2222
"""
2323

24+
glide_events_collection_url = (
25+
"https://github.com/IFRCGo/monty-stac-extension/raw/refs/heads/main/examples/glide-events/glide-events.json"
26+
)
27+
2428
def __init__(self, data: GlideDataSource) -> None:
2529
self.data = data
2630

@@ -56,9 +60,7 @@ def make_items(self) -> list[Item]:
5660
},
5761
)
5862

59-
item.properties["keywords"] = [data.get("location", "")]
60-
61-
item.set_collection(self.get_collection())
63+
item.set_collection(self.get_event_collection())
6264

6365
MontyExtension.add_to(item)
6466
monty = MontyExtension.ext(item)
@@ -82,9 +84,10 @@ def make_date(self, data: dict) -> datetime:
8284
date = datetime.fromisoformat(formatted_date.replace("Z", "+00:00"))
8385
return date
8486

85-
def get_collection(self) -> Collection:
86-
data = glide_event_collection
87-
return Collection.from_dict(data)
87+
def get_event_collection(self) -> Collection:
88+
response = requests.get(self.glide_events_collection_url)
89+
collection_dict = json.loads(response.text)
90+
return Collection.from_dict(collection_dict)
8891

8992
def check_and_get_glide_events(self) -> list[Any]:
9093
glideset: list[Any] = self.data.get_data()["glideset"]

tests/extensions/test_glide.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,7 @@
99
from parameterized import parameterized
1010

1111
from pystac_monty.extension import MontyExtension
12-
from pystac_monty.sources.glide import (
13-
GlideDataSource,
14-
GlideTransformer,
15-
)
12+
from pystac_monty.sources.glide import GlideDataSource, GlideTransformer
1613
from tests.conftest import get_data_file
1714
from tests.extensions.test_monty import CustomValidator
1815

0 commit comments

Comments
 (0)