1

I am trying to use the pgr_dijkstraCostMatrix function in pgRouting for PostgreSQL to find the shortest paths between points in a road network. However, I keep encountering an error indicating that the function is not found. Here is a simplified version of my query:

WITH incident_location AS (
    SELECT fire_id, wkb_geometry AS fire_location
    FROM fire_incident
    WHERE fire_id = 'Fire_00001'
)
SELECT
    incident_location.fire_id,
    fire_stations.station_id,
    ST_AsGeoJSON(incident_location.fire_location)::json->'coordinates' AS incident_coordinates,
    ST_AsGeoJSON(fire_stations.wkb_geometry)::json->'coordinates' AS station_coordinates,
    pgr_dijkstraCostMatrix(
        'SELECT road_edge_id as id, road_source as source, road_target as target, road_length as cost FROM road_network',
        incident_location.fire_location::geometry(Point, 4326),
        ARRAY(SELECT wkb_geometry::geometry(Point, 4326) FROM fire_stations),
        false
    ) AS cost
FROM
    incident_location
JOIN
    fire_stations ON incident_location.fire_id = fire_stations.station_id
ORDER BY cost[1] ASC
LIMIT 1;

The error message I'm receiving is:

ERROR: function pgr_dijkstracostmatrix(unknown, geometry, geometry[], boolean) does not exist
SQL state: 42883
Character: 439

1 Answer 1

4

According to docs pgr_dijkstraCostMatrix function has only three parameters, but you are giving it four.

In such a case PostgreSQL will complain that such function does not exist.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.