0

I have created a web based GIS application using Django, Mapnik, Mapproxy, OpenLayers 6. Now I need to develop a shortest path(road distance) between two points selected by the user. What is the best solution for the development? I have installed PostgreSQL and created a network topology by added two columns namely source and target then executed the select query with function pgr_createTopology.

I am using SRID 32643 and data in UTM format. Then to find route between two point I have executed the below query:

SELECT seq, node, edge, cost as cost, agg_cost, ST_AsText(the_geom)
FROM pgr_dijkstra( 'SELECT gid as id, source, target, st_length(the_geom) as cost FROM
gistrack_roads', (
    SELECT source
    FROM gistrack_roads
    ORDER BY ST_Distance(
                    ST_StartPoint(the_geom),
                    ST_SetSRID(ST_MakePoint(715511.9, 938165.3), 32643)
                ) ASC
            LIMIT 1
        ), (
            SELECT source
            FROM gistrack_roads
            ORDER BY ST_Distance(
                    ST_StartPoint(the_geom),
                    ST_SetSRID(ST_MakePoint(717022.4, 938451.4), 32643)
                ) ASC
            LIMIT 1
        )
    ) as pt
    JOIN gistrack_roads rd ON pt.edge = rd.gid;

but not getting the correct result.Getting empty records.

I have followed the tutorial https://blog.daftcode.pl/find-your-way-with-the-power-of-postgis-pgrouting-66d620ef201b

3
  • Welcome to GIS SE! We're a little different from other sites; this isn't a discussion forum but a Q&A site. Your questions should as much as possible describe not just what you want to do, but precisely what you have tried and where you are stuck trying that. Please check out our short tour for more about how the site works.
    – Ian Turton
    Oct 13 '20 at 10:48
  • 1
    Please Edit the question to contain an indication of what a "correct result" would contain, what you actually received, and how what you did receive did not meet expectations. "Best" questions are vulnerable to closure as being opinion-based and questions with multiple quesion marks are vulnerable to not being sufficienly focused.
    – Vince
    Oct 13 '20 at 11:34
  • Better use the GIST (K)NN operator <-> to find the closest point.
    – geozelot
    Oct 13 '20 at 12:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.