Skip to main content

Correlation Routes

RESTful API endpoints for analyzing entity correlations and causal relationships between traffic, weather, and accidents using Neo4j graph analysis.

Base Pathโ€‹

/api/correlation

Endpoints Summaryโ€‹

MethodEndpointDescription
GET/accident-weatherWeather-accident correlation
GET/traffic-patternsTraffic pattern correlation
GET/entity-relationshipsEntity relationship graph
GET/causal-analysisCausal factor analysis

Endpointsโ€‹

GET /api/correlation/accident-weatherโ€‹

Analyze correlation between weather conditions and accidents.

Query Parameters:

ParameterTypeDescription
fromstringStart date
tostringEnd date
weatherTypestringWeather filter

Response:

{
"success": true,
"data": {
"correlations": [
{
"weatherCondition": "rain",
"accidentIncrease": 45,
"confidence": 0.87,
"sampleSize": 150
},
{
"weatherCondition": "fog",
"accidentIncrease": 62,
"confidence": 0.79,
"sampleSize": 45
}
],
"topFactors": [
{ "factor": "wet_road", "impact": 0.42 },
{ "factor": "visibility", "impact": 0.35 },
{ "factor": "wind_speed", "impact": 0.15 }
]
}
}

GET /api/correlation/entity-relationshipsโ€‹

Get relationship graph for an entity.

Query Parameters:

ParameterTypeRequiredDescription
entityIdstringYesEntity URN
depthnumberNoTraversal depth (default: 2)
typesstringNoRelationship types (comma-separated)

Response:

{
"success": true,
"data": {
"nodes": [
{ "id": "urn:ngsi-ld:RoadAccident:001", "type": "Accident" },
{ "id": "urn:ngsi-ld:Camera:nearby-001", "type": "Camera" },
{ "id": "urn:ngsi-ld:WeatherObserved:001", "type": "Weather" }
],
"edges": [
{ "source": "RoadAccident:001", "target": "Camera:nearby-001", "type": "NEAR_TO" },
{ "source": "RoadAccident:001", "target": "WeatherObserved:001", "type": "OCCURRED_DURING" }
]
}
}

Referencesโ€‹