Skip to content

Commit

Permalink
remove cap: prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
RoryPTB committed Sep 2, 2024
1 parent 011e6cf commit 8b681b3
Showing 1 changed file with 26 additions and 26 deletions.
52 changes: 26 additions & 26 deletions src/cap2geojson/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,29 +11,29 @@ def get_properties(alert):
Returns:
dict: The formatted properties object.
"""
info = alert["cap:info"]
info = alert["info"]
return {
"identifier": alert["cap:identifier"],
"sender": alert["cap:sender"],
"sent": alert["cap:sent"],
"status": alert["cap:status"],
"msgType": alert["cap:msgType"],
"scope": alert["cap:scope"],
"category": info["cap:category"],
"event": info["cap:event"],
"urgency": info["cap:urgency"],
"severity": info["cap:severity"],
"certainty": info["cap:certainty"],
"effective": info["cap:effective"],
"onset": info["cap:onset"],
"expires": info["cap:expires"],
"senderName": info["cap:senderName"],
"headline": info["cap:headline"],
"description": info["cap:description"],
"instruction": info["cap:instruction"],
"web": info["cap:web"],
"contact": info["cap:contact"],
"areaDesc": get_area_desc(info["cap:area"]),
"identifier": alert["identifier"],
"sender": alert["sender"],
"sent": alert["sent"],
"status": alert["status"],
"msgType": alert["msgType"],
"scope": alert["scope"],
"category": info["category"],
"event": info["event"],
"urgency": info["urgency"],
"severity": info["severity"],
"certainty": info["certainty"],
"effective": info["effective"],
"onset": info["onset"],
"expires": info["expires"],
"senderName": info["senderName"],
"headline": info["headline"],
"description": info["description"],
"instruction": info["instruction"],
"web": info["web"],
"contact": info["contact"],
"areaDesc": get_area_desc(info["area"]),
}


Expand All @@ -47,8 +47,8 @@ def get_area_desc(area):
str: The formatted area description.
"""
if isinstance(area, dict):
return area["cap:areaDesc"]
return ", ".join([a["cap:areaDesc"] for a in area])
return area["areaDesc"]
return ", ".join([a["areaDesc"] for a in area])


def get_circle_coord(theta, x_center, y_center, radius):
Expand Down Expand Up @@ -97,7 +97,7 @@ def get_multi_coordinates(area):
Returns:
list: The formatted multi-polygon coordinates.
"""
# Idea: loop over each area object and check if it's "cap:circle" or "cap:polygon"
# Idea: loop over each area object and check if it's "circle" or "polygon"
# If it's a circle, calculate the circle coordinates and add them to the list
# If it's a polygon, add the polygon coordinates to the list

Expand All @@ -112,7 +112,7 @@ def to_geojson(xml):
dict: The final GeoJSON object.
"""
data = xmltodict.parse(xml)
alert = data["cap:alert"]
alert = data["alert"]

alert_properties = get_properties(alert)
multi_polygon_coordinates = get_multi_coordinates(alert)
Expand Down

0 comments on commit 8b681b3

Please sign in to comment.