in gemini/agents/research-multi-agents/ev_agent/api_handler/api_02_EV_Infra_StationAnalysis.py [0:0]
def analyze_accessibility(stations: List[Dict]) -> AccessibilityMetrics:
"""Analyze accessibility metrics from station data"""
metrics = AccessibilityMetrics()
total_stations = len(stations)
for station in stations:
# Access type analysis
access_time = (station.get("access_days_time") or "").lower()
access_code = (station.get("access_code") or "").lower()
if "24 hours" in access_time:
metrics.access_type["24_7_access"]["count"] += 1
if "restricted" in access_time:
metrics.access_type["restricted"]["count"] += 1
if access_code == "public":
metrics.access_type["public"]["count"] += 1
# print(station)
# Payment methods analysis based on network and other indicators
network = station.get("ev_network", "").lower()
# If it's a networked station (not Tesla and not Non-Networked)
if network and network not in ["tesla", "non-networked"]:
# Most charging networks support multiple payment methods
metrics.payment_methods["credit_card"]["count"] += 1
metrics.payment_methods["mobile_pay"]["count"] += 1
metrics.payment_methods["network_card"]["count"] += 1
elif "tesla" in network.lower():
# Tesla specific payment methods
metrics.payment_methods["mobile_pay"]["count"] += 1
elif any(keyword in access_time.lower() for keyword in ["pay", "fee", "paid"]):
# For non-networked stations that mention payment
metrics.payment_methods["credit_card"]["count"] += 1
# Operational status
if station.get("status_code") == "E":
metrics.operational_status["operational"]["count"] += 1
else:
metrics.operational_status["non_operational"]["count"] += 1
# Calculate percentages
if total_stations > 0:
for category in [
metrics.access_type,
metrics.payment_methods,
metrics.operational_status,
]:
for metric in category.values():
metric["percentage"] = round(
(metric["count"] / total_stations * 100), 2
)
return metrics