<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Sat, Mar 15, 2014 at 12:57 AM, Carsten Hogertz <span dir="ltr"><<a href="mailto:carsten.hogertz@gmail.com" target="_blank">carsten.hogertz@gmail.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">puh, not the simplest task for a non-developer....I mean the function.<div>to get a result with for one row is no problem (using whatever pg_*())</div>

</div></blockquote><div><br></div><div>Of course you don't need to write a plpgsql function.</div><div>You can also make n queries with your programming language of your choice.</div><div>But with pgRouting it's common that you always need to code at least a little bit.<br>

</div><div><br></div><div>Daniel</div><div><br></div><div><br></div><div><br></div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="gmail_extra">

<br><br><div class="gmail_quote">
2014-03-14 16:33 GMT+01:00 Stephen Woodbridge <span dir="ltr"><<a href="mailto:woodbri@swoodbridge.com" target="_blank">woodbri@swoodbridge.com</a>></span>:<div><div class="h5"><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">


Hi Carsten,<br>
<br>
I assume you can make a single pgRouting query from point A to B using pgr_astar() or pgr_trsp() or something similar.<br>
<br>
Work that out first. Read the Documentation and the workshop.<br>
<br>
Then you just want to write a simple procedure to query your table and for each row run the pgr_*() query and do something with the results.<br>
<br>
<a href="https://www.google.com/#newwindow=1&q=postgres%20plpgsql%20tutorial" target="_blank">https://www.google.com/#<u></u>newwindow=1&q=postgres%<u></u>20plpgsql%20tutorial</a><br>
<br>
Read these to get a basic understanding ot plpgsql sripting for stored procedures.<br>
<br>
If you table is big it will take a while. Get this working first and then we can talk about how to speed it up if you need that.<br>
<br>
-Steve<div><br>
<br>
On 3/14/2014 11:00 AM, Carsten Hogertz wrote:<br>
</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div>
lol. Now we're talking about the same issue!<br>
I could run n x n queries but this would not be very efficient as I'd<br>
like to have a more "automatic" solution.<br>
<br>
I already thought about function and looping but as being a complete<br>
newbie on looping and writing functions this seems quite hard to solve<br>
for myself.<br>
<br>
Maybe you've got a hint?<br>
<br>
thanks<br>
carsten<br>
<br>
<br>
<br>
2014-03-14 15:53 GMT+01:00 Daniel Kastl <<a href="mailto:daniel@georepublic.de" target="_blank">daniel@georepublic.de</a><br></div>
<mailto:<a href="mailto:daniel@georepublic.de" target="_blank">daniel@georepublic.de</a>><u></u>>:<div><br>
<br>
<br>
<br>
<br>
    On Fri, Mar 14, 2014 at 11:42 PM, Carsten Hogertz<br></div><div>
    <<a href="mailto:carsten.hogertz@gmail.com" target="_blank">carsten.hogertz@gmail.com</a> <mailto:<a href="mailto:carsten.hogertz@gmail.com" target="_blank">carsten.hogertz@gmail.<u></u>com</a>>> wrote:<br>



<br>
        Hi Daniel,<br>
        thanks for your eMail.<br>
        Well, I think it's not a 1-n calculation. IMHO it's a 1-1<br>
        calculation,right?<br>
        So I don't know how to calculate the distance for each row of<br>
        the routing_pair table.<br>
<br>
<br>
    Well, you need to run this query for each row. So with n rows you<br>
    need n queries.<br>
    If you use standard shortest path function you need to run "n x n"<br>
    queries.<br>
<br>
    You may want to write a custom function, which makes first a select<br>
    of all records in your table and then loops through these records.<br>
    Or don't I still understand the problem?<br>
<br>
    Daniel<br>
<br>
<br>
<br>
<br>
        Thanks<br>
        Carsten<br>
<br>
<br>
        2014-03-14 15:33 GMT+01:00 Daniel Kastl <<a href="mailto:daniel@georepublic.de" target="_blank">daniel@georepublic.de</a><br></div>
        <mailto:<a href="mailto:daniel@georepublic.de" target="_blank">daniel@georepublic.de</a>><u></u>>:<div><br>
<br>
<br>
<br>
<br>
            On Fri, Mar 14, 2014 at 11:26 PM, Carsten Hogertz<br>
            <<a href="mailto:carsten.hogertz@gmail.com" target="_blank">carsten.hogertz@gmail.com</a><br></div><div><div>
            <mailto:<a href="mailto:carsten.hogertz@gmail.com" target="_blank">carsten.hogertz@gmail.<u></u>com</a>>> wrote:<br>
<br>
                Maybe to clearify.<br>
<br>
                I've got the following two tables:<br>
<br>
                Table at_2po_4pgr with the columns:<br>
<br>
                   id integer NOT NULL,<br>
                   osm_id bigint,<br>
                   osm_name character varying,<br>
                   osm_meta character varying,<br>
                   osm_source_id bigint,<br>
                   osm_target_id bigint,<br>
                   clazz integer,<br>
                   flags integer,<br>
                   source integer,<br>
                   target integer,<br>
                   km double precision,<br>
                   kmh integer,<br>
                   cost2 double precision,<br>
                   reverse_cost double precision,<br>
                   x1 double precision,<br>
                   y1 double precision,<br>
                   x2 double precision,<br>
                   y2 double precision,<br>
                   geom_way geometry(LineString,4326)<br>
<br>
                and Table routing_pair with the columns:<br>
<br>
                   id integer,<br>
                   h_key integer,<br>
                   lat_htl double precision,<br>
                   lon_htl double precision,<br>
                   source integer,<br>
                   geom_htl geometry(Point,4326),<br>
                   lat_bhf double precision,<br>
                   lon_bhf double precision,<br>
                   target integer,<br>
                   geom_bhf geometry(Point,4326)<br>
<br>
<br>
                The routing_pair table hold three important information:<br>
                ID<br>
                SOURCE<br>
                TARGET<br>
<br>
                All columns are filled (source + target are calculated<br>
                from at_2po_4pgr.<br>
<br>
                The task seems to be quite simple: I want for each row<br>
                from the routing_pair the distance between soure +<br>
                target (and if possible its geom).<br>
                Could you please help me how to solve this?<br>
<br>
<br>
            Hi Carsten,<br>
<br>
            There is a function named kDijkstra and it allows you to<br>
            calculate all paths from one node to many:<br>
            <a href="http://docs.pgrouting.org/2.0/en/src/kdijkstra/doc/index.html#pgr-kdijkstra" target="_blank">http://docs.pgrouting.org/2.0/<u></u>en/src/kdijkstra/doc/index.<u></u>html#pgr-kdijkstra</a><br>
<br>
            If something is not clear with the page above, feel free to ask.<br>
<br>
            Daniel<br>
<br>
<br>
<br>
<br>
<br>
            --<br>
            Georepublic UG & Georepublic Japan<br>
            eMail: <a href="mailto:daniel.kastl@georepublic.de" target="_blank">daniel.kastl@georepublic.de</a><br></div></div>
            <mailto:<a href="mailto:daniel.kastl@georepublic.de" target="_blank">daniel.kastl@<u></u>georepublic.de</a>><div><br>
            Web: <a href="http://georepublic.info" target="_blank">http://georepublic.info</a><br>
<br>
            ______________________________<u></u>_________________<br>
            Pgrouting-users mailing list<br>
            <a href="mailto:Pgrouting-users@lists.osgeo.org" target="_blank">Pgrouting-users@lists.osgeo.<u></u>org</a><br></div>
            <mailto:<a href="mailto:Pgrouting-users@lists.osgeo.org" target="_blank">Pgrouting-users@lists.<u></u>osgeo.org</a>><div><br>
            <a href="http://lists.osgeo.org/mailman/listinfo/pgrouting-users" target="_blank">http://lists.osgeo.org/<u></u>mailman/listinfo/pgrouting-<u></u>users</a><br>
<br>
<br>
<br>
        ______________________________<u></u>_________________<br>
        Pgrouting-users mailing list<br>
        <a href="mailto:Pgrouting-users@lists.osgeo.org" target="_blank">Pgrouting-users@lists.osgeo.<u></u>org</a><br></div>
        <mailto:<a href="mailto:Pgrouting-users@lists.osgeo.org" target="_blank">Pgrouting-users@lists.<u></u>osgeo.org</a>><div><br>
        <a href="http://lists.osgeo.org/mailman/listinfo/pgrouting-users" target="_blank">http://lists.osgeo.org/<u></u>mailman/listinfo/pgrouting-<u></u>users</a><br>
<br>
<br>
<br>
<br>
    --<br>
    Georepublic UG & Georepublic Japan<br></div>
    eMail: <a href="mailto:daniel.kastl@georepublic.de" target="_blank">daniel.kastl@georepublic.de</a> <mailto:<a href="mailto:daniel.kastl@georepublic.de" target="_blank">daniel.kastl@<u></u>georepublic.de</a>><div>


<br>
    Web: <a href="http://georepublic.info" target="_blank">http://georepublic.info</a><br>
<br>
    ______________________________<u></u>_________________<br>
    Pgrouting-users mailing list<br></div>
    <a href="mailto:Pgrouting-users@lists.osgeo.org" target="_blank">Pgrouting-users@lists.osgeo.<u></u>org</a> <mailto:<a href="mailto:Pgrouting-users@lists.osgeo.org" target="_blank">Pgrouting-users@lists.<u></u>osgeo.org</a>><div>


<br>
    <a href="http://lists.osgeo.org/mailman/listinfo/pgrouting-users" target="_blank">http://lists.osgeo.org/<u></u>mailman/listinfo/pgrouting-<u></u>users</a><br>
<br>
<br>
<br>
<br>
______________________________<u></u>_________________<br>
Pgrouting-users mailing list<br>
<a href="mailto:Pgrouting-users@lists.osgeo.org" target="_blank">Pgrouting-users@lists.osgeo.<u></u>org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/pgrouting-users" target="_blank">http://lists.osgeo.org/<u></u>mailman/listinfo/pgrouting-<u></u>users</a><br>
<br>
</div></blockquote><div><div>
<br>
______________________________<u></u>_________________<br>
Pgrouting-users mailing list<br>
<a href="mailto:Pgrouting-users@lists.osgeo.org" target="_blank">Pgrouting-users@lists.osgeo.<u></u>org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/pgrouting-users" target="_blank">http://lists.osgeo.org/<u></u>mailman/listinfo/pgrouting-<u></u>users</a><br>
</div></div></blockquote></div></div></div><br></div>
<br>_______________________________________________<br>
Pgrouting-users mailing list<br>
<a href="mailto:Pgrouting-users@lists.osgeo.org">Pgrouting-users@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/pgrouting-users" target="_blank">http://lists.osgeo.org/mailman/listinfo/pgrouting-users</a><br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div dir="ltr">

<span style="font-family:arial,sans-serif;font-size:13px;border-collapse:collapse">Georepublic UG & Georepublic Japan<br>eMail: <a href="mailto:daniel.kastl@georepublic.de" style="color:rgb(66,99,171)" target="_blank">daniel.kastl@georepublic.de</a><br>

Web: <a href="http://georepublic.info" style="color:rgb(66,99,171)" target="_blank">http://georepublic.info</a></span></div>
</div></div>