Skip to content

Documentation instructions for routing no longer work (pgrouting >=4) #408

Closed

Description

@travishathaway

What version of PgOSM Flex are you using?

1.1.1

Docker image

1.1.1

What operating system, osm2pgsql, and PostgreSQL/PostGIS versions are you using?

Using Docker

What did you do exactly?

I was following the instructions for setting up routing here: https://pgosm-flex.com/routing.html and ran into the problem that all of the functions have been removed in version 4.0.0.

What did you expect to happen?

I expected the demo to work correctly.

What did happen instead?

Please see the error below:

pgosm=# SELECT pgr_nodeNetwork('routing.road_line', 0.1, 'id', 'geom');
SELECT pgr_createTopology('routing.road_line_noded', 0.1, 'geom');
SELECT pgr_analyzeGraph('routing.road_line_noded', 0.1, 'geom');
ERROR:  function pgr_nodenetwork(unknown, numeric, unknown, unknown) does not exist
LINE 1: SELECT pgr_nodeNetwork('routing.road_line', 0.1, 'id', 'geom...
               ^
HINT:  No function matches the given name and argument types. You might need to add explicit type casts.
ERROR:  function pgr_createtopology(unknown, numeric, unknown) does not exist
LINE 1: SELECT pgr_createTopology('routing.road_line_noded', 0.1, 'g...
               ^
HINT:  No function matches the given name and argument types. You might need to add explicit type casts.
ERROR:  function pgr_analyzegraph(unknown, numeric, unknown) does not exist
LINE 1: SELECT pgr_analyzeGraph('routing.road_line_noded', 0.1, 'geo...
               ^

What did you do to try analyzing the problem?

I read the release notes and documentation of pgrouting. It looks like the workaround is a bit cumbersome, so I think the solution for me is to just downgrade to a version pgsom-flex that uses a version of pgrouting <4.

Do you have any plans to update the docs to work with the latest pgrouting version?

Activity

  1. changed the title [-]Documentation instructions for pgrouting no longer work[/-] [+]Documentation instructions for pgrouting no longer work (pgrouting >=4)[/+] on Dec 7, 2025
  2. changed the title [-]Documentation instructions for pgrouting no longer work (pgrouting >=4)[/-] [+]Documentation instructions for routing no longer work (pgrouting >=4)[/+] on Dec 7, 2025
  3. rustprooflabs commented on Dec 13, 2025

    @rustprooflabs
    Owner

    Thanks for the heads up, @travishathaway! I'll start playing around with it. I hadn't realized I accidentally bundled a big upgrade on the pgrouting side. It's worth updating docs to keep up with the times.

  4. added
    documentationImprovements or additions to documentation
    bugSomething isn't working
    on Dec 13, 2025
  5. rustprooflabs commented on Dec 13, 2025

    @rustprooflabs
    Owner

    Breadcrumbs to follow:

  6. added this to the 1.1.2 milestone on Dec 13, 2025
  7. rustprooflabs commented on Dec 14, 2025

    @rustprooflabs
    Owner

    Updated 1.1.1 release notes so hopefully anyone else who looks before the docs are updated have a heads up.

    See #411 for PR that will add the new documentation.

    Image
  8. rustprooflabs commented on Dec 14, 2025

    @rustprooflabs
    Owner

    The initial version of pgRouting 4.0 docs are live on this page. This uses the common starting point for both new and old.

    If you have a chance to test and verify if this works for you that'd be fantastic. I'll do more thorough testing soon. I am pondering of a few new examples to add too.

  9. travishathaway commented on Dec 15, 2025

    @travishathaway
    Author

    I should have some free time to test this out in the coming week. I will post my feedback here.

  10. travishathaway commented on Dec 19, 2025

    @travishathaway
    Author

    @rustprooflabs,

    I had the chance to try this out. I first attempted the Brandenburg dataset. I waited about 24 hours until I canceled it. After that I, I tried just Berlin and gave up after about 8 hours. So, I was unfortunately unable to finish.

    This all got me thinking that it might be nice to have tips on how to reduce the graph size in the documentation. For example, I'm only interested in pedestrian routes, so maybe I just need to limit my network even further? I'll keep poking around at this and re-read your documentation to see if there's anything obvious about this in there I missed.

    Based on what I come up with, I would be happy to submit a pull request to add more to the documentation with any tips or tricks that I discover.

  11. rustprooflabs commented on Dec 20, 2025

    @rustprooflabs
    Owner

    An observation - pgr_separateTouching() takes a LOT longer to get the job done compared to the legacy pgr_nodeNetwork() function. Scaling from D.C. road network to Colorado road network goes from ~1 hour to ??? hours (21 hours and counting).

    Using dryrun shows the CTE query it's running, so I'm digging into that direction. I hadn't looked too closely at the legacy function, so might do some comparison to see what changed.

    SELECT *
    FROM pgr_separateTouching('SELECT id, geom FROM routing.osm_road_intermediate', dryrun => true)
    ;

    This portion seems likely to be the bottleneck.

    get_touching AS (
          SELECT e1.id id1, e2.id id2, ST_Snap(e1.geom, e2.geom, 0.01) AS geom, e1.geom AS g1, e2.geom AS g2
          FROM edges_table e1, edges_table e2
          WHERE e1.id != e2.id AND ST_DWithin(e1.geom, e2.geom, 0.01) AND NOT(
            ST_StartPoint(e1.geom) = ST_StartPoint(e2.geom) OR ST_StartPoint(e1.geom) = ST_EndPoint(e2.geom)
            OR ST_EndPoint(e1.geom) = ST_StartPoint(e2.geom) OR ST_EndPoint(e1.geom) = ST_EndPoint(e2.geom))
        ),
  12. rustprooflabs commented on Dec 20, 2025

    @rustprooflabs
    Owner

    @rustprooflabs,

    I had the chance to try this out. I first attempted the Brandenburg dataset. I waited about 24 hours until I canceled it. After that I, I tried just Berlin and gave up after about 8 hours. So, I was unfortunately unable to finish.

    This all got me thinking that it might be nice to have tips on how to reduce the graph size in the documentation. For example, I'm only interested in pedestrian routes, so maybe I just need to limit my network even further? I'll keep poking around at this and re-read your documentation to see if there's anything obvious about this in there I missed.

    Based on what I come up with, I would be happy to submit a pull request to add more to the documentation with any tips or tricks that I discover.

    @travishathaway Yeah, performance has unfortunately tanked in the step to create the noded network using these new functions. I'll keep digging into that side of things, per my other comment it's unusable for the region I want too, and I don't want it limited!

    For pedestrian routes you can adjust your input query with filters on the boolean columns, e.g. route_foot. I'd do that in the first routing.osm_road_intermediate step and it should cascade through the process from there. Note that the route_foot logic includes a variety of motorized roads in it's access controls. Depending on your area and how much dedicated footway infrastructure you have, you might want to include AND NOT route_motor, or be more specific with specific osm_type filters.

    CREATE TABLE routing.osm_road_intermediate AS
    WITH a AS (
    -- Remove as many multi-linestrings as possible with ST_LineMerge() 
    SELECT osm_id, osm_type, maxspeed, oneway, layer,
            route_foot, route_cycle, route_motor, access,
            ST_LineMerge(geom) AS geom
        FROM osm.road_line
        WHERE route_foot  --<---------------------Add this filter to limit to lines that are foot-routable
    ), extra_cleanup AS (
    -- Pull out those that are still multi, use ST_Dump() to pull out parts
    SELECT osm_id, osm_type, maxspeed, oneway, layer,
            route_foot, route_cycle, route_motor, access,
            (ST_Dump(geom)).geom AS geom
        FROM a 
        WHERE ST_GeometryType(geom) = 'ST_MultiLineString'
    ), combined AS (
    -- Combine two sources
    SELECT osm_id, osm_type, maxspeed, oneway, layer,
            route_foot, route_cycle, route_motor, access,
            geom
        FROM a
        WHERE ST_GeometryType(geom) != 'ST_MultiLineString'
    UNION
    SELECT osm_id, osm_type, maxspeed, oneway, layer,
            route_foot, route_cycle, route_motor, access,
            geom
        FROM extra_cleanup
        -- Some data may be lost here if multi-linestring somehow
        -- persists through the extra_cleanup query
        WHERE ST_GeometryType(geom) != 'ST_MultiLineString'
    )
    -- Calculate a new surrogate ID for key
    SELECT ROW_NUMBER() OVER (ORDER BY geom) AS id, *
        FROM combined
        ORDER BY geom
    ;
  13. rustprooflabs commented on Dec 20, 2025

    @rustprooflabs
    Owner

    @travishathaway Here's what I'm doing for testing with a tiny dataset, limiting the roads to a single neighborhood. I add a join to the first query in the CTE to return under 200 road segments but still with a routeable data set..

    SELECT r.osm_id, r.osm_type, r.maxspeed, r.oneway, r.layer,
            r.route_foot, r.route_cycle, r.route_motor, r.access,
            ST_LineMerge(r.geom) AS geom
        FROM osm.road_line r
        INNER JOIN osm.place_polygon p
            ON p.osm_id = -4633701
            AND ST_intersects(r.geom, p.geom)
  14. rustprooflabs commented on Dec 20, 2025

    @rustprooflabs
    Owner

    Sorry for all the noise -- but good news! I got the D.C. query down from 45 minutes to under 2 seconds. I'm going to try running this on the Colorado data, if it scales up well I'll publish a better version of the docs.

    This query is the slow step from the pgr function, note all the ST_StartPoint()/ST_EndPoint() in the OR clause. No wonder this doesn't perform well.

    CREATE TEMP TABLE get_touching AS
    SELECT e1.id id1, e2.id id2, ST_Snap(e1.geom, e2.geom, 0.01) AS geom, e1.geom AS g1, e2.geom AS g2
    FROM edges_table e1, edges_table e2
    WHERE e1.id != e2.id AND ST_DWithin(e1.geom, e2.geom, 0.01) AND NOT(
        ST_StartPoint(e1.geom) = ST_StartPoint(e2.geom) OR ST_StartPoint(e1.geom) = ST_EndPoint(e2.geom)
        OR ST_EndPoint(e1.geom) = ST_StartPoint(e2.geom) OR ST_EndPoint(e1.geom) = ST_EndPoint(e2.geom))
    ;
    
    SELECT 73258
    Time: 2685600.856 ms (44:45.601)

    This version doesn't show the changes that happened upstream, but the geom_start and geom_end columns are indexed geometries instead of on-the-fly calculations.

    CREATE TEMP TABLE get_touching_new AS
    SELECT e1.id AS id1, e2.id AS id2
            , ST_Snap(e1.geom, e2.geom, 0.01) AS geom
            , e1.geom AS g1
            , e2.geom AS g2
        FROM routing.osm_road_intermediate e1
            , routing.osm_road_intermediate e2
        WHERE
            -- we could use < Instead of != to only report intersections.
            -- The != results in two rows, e.g.  1, 2;  and;  2, 1
            -- Not doing that right now, causes other queries to be rewritten.
            -- Hoping the ST_StartPoint()/ST_EndPOint() changes are enough to matter.
            e1.id != e2.id
            AND ST_DWithin(e1.geom, e2.geom, 0.1)
            AND NOT (
                e1.geom_start = e2.geom_start OR  e1.geom_start = e2.geom_end
                OR e1.geom_end = e2.geom_start OR e1.geom_end = e2.geom_end
            )
    ;
    SELECT 73268
    Time: 1455.432 ms (00:01.455)
  15. rustprooflabs commented on Dec 20, 2025

    @rustprooflabs
    Owner

    Continuing to work on this under #413.

  16. rustprooflabs commented on Dec 21, 2025

    @rustprooflabs
    Owner

    @travishathaway New docker image pushed, see #413 (comment) for the notes on instructions, long term the docs are more important. I'd expect your regions to process in reasonable times now. 🤞

  17. travishathaway commented on Dec 22, 2025

    @travishathaway
    Author

    @rustprooflabs,

    This works for me on the Berlin dataset. Only takes 3 minutes and 20 seconds now. Thanks for the improvements!

    Just FYI, I wasn't able to pull this image as it couldn't be found, so I built it locally:

    $ docker pull rustprooflabs/pgosm-flex:1.1.2 
    Error response from daemon: failed to resolve reference "docker.io/rustprooflabs/pgosm-flex:1.1.2": docker.io/rustprooflabs/pgosm-flex:1.1.2: not found
    
  18. rustprooflabs commented on Dec 23, 2025

    @rustprooflabs
    Owner

    @travishathaway Thanks for the validation! Sorry, I should have been more clear about the Docker image, I had only pushed to the :latest tag not an officially tagged version. I think this is enough of an improvement that I'll get started on the official 1.1.2 release.

    I'm going to close this issue as I think the initially reported problem is resolved. If you detect any future issues please either re-open this or create a new issue. Thanks again for your help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingdocumentationImprovements or additions to documentation

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions