feat(collectors): add ArcGIS landing points and cable-landing relation collectors

- Add ArcGISLandingPointCollector for FeatureServer/1 (landing points)
- Add ArcGISCableLandingRelationCollector for FeatureServer/3 (cable-landing relations)
- Register new collectors in __init__.py
- Fix earth cables.js with cable_id grouping for highlight
This commit is contained in:
rayd1o
2026-03-12 16:37:18 +08:00
parent ceb1b728d5
commit 14d11cd99d
4 changed files with 133 additions and 0 deletions

View File

@@ -0,0 +1,58 @@
from typing import Dict, Any, List
from datetime import datetime
from app.services.collectors.base import BaseCollector
class ArcGISCableLandingRelationCollector(BaseCollector):
name = "arcgis_cable_landing_relation"
priority = "P1"
module = "L2"
frequency_hours = 168
data_type = "cable_landing_relation"
base_url = "https://services.arcgis.com/6DIQcwlPy8knb6sg/arcgis/rest/services/SubmarineCables/FeatureServer/3/query"
async def fetch(self) -> List[Dict[str, Any]]:
import httpx
params = {"where": "1=1", "outFields": "*", "returnGeometry": "true", "f": "geojson"}
async with httpx.AsyncClient(timeout=60.0) as client:
response = await client.get(self.base_url, params=params)
response.raise_for_status()
return self.parse_response(response.json())
def parse_response(self, data: Dict[str, Any]) -> List[Dict[str, Any]]:
result = []
features = data.get("features", [])
for feature in features:
props = feature.get("properties", {})
try:
entry = {
"source_id": f"arcgis_relation_{props.get('OBJECTID', props.get('id', ''))}",
"name": f"{props.get('cable_name', 'Unknown')} - {props.get('landing_point_name', 'Unknown')}",
"country": props.get("country", ""),
"city": props.get("landing_point_name", ""),
"latitude": str(props.get("latitude", "")) if props.get("latitude") else "",
"longitude": str(props.get("longitude", "")) if props.get("longitude") else "",
"value": "",
"unit": "",
"metadata": {
"objectid": props.get("OBJECTID"),
"cable_id": props.get("cable_id"),
"cable_name": props.get("cable_name"),
"landing_point_id": props.get("landing_point_id"),
"landing_point_name": props.get("landing_point_name"),
"facility": props.get("facility"),
"status": props.get("status"),
},
"reference_date": datetime.utcnow().strftime("%Y-%m-%d"),
}
result.append(entry)
except (ValueError, TypeError, KeyError):
continue
return result