<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:verdana,helvetica,sans-serif;font-size:10pt"><div style="font-family: verdana,helvetica,sans-serif; font-size: 10pt;">This is sql file in dijkstra.sql, i'm using lib with the package in <br><span><a target="_blank" href="http://cartoweb.org/downloads.html#pgdijkstra">http://cartoweb.org/downloads.html#pgdijkstra</a></span><br>i'm using mapserver ms4w, postgresql 8.2 and postgis 1.2.0-1 in windows system<span style="font-size: 11pt; font-family: "Calibri","sans-serif"; color: rgb(31, 73, 125);"></span> 

<p class="MsoNormal"><span style="font-size: 11pt; font-family: "Calibri","sans-serif"; color: rgb(31, 73, 125);"><br></span></p><br><br>--<br>-- Shortest path algorithm for PostgreSQL<br>--<br>-- Copyright (c) 2005 Sylvain Pasche<br>--<br>-- This program is free software; you can redistribute it and/or modify<br>-- it under the terms of the GNU General Public License as published by<br>-- the Free Software Foundation; either version 2 of the License, or<br>-- (at your option) any later version.<br>--<br>-- This program is distributed in the hope that it will be useful,<br>-- but WITHOUT ANY WARRANTY; without even the implied warranty of<br>-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the<br>-- GNU General Public License for more details.<br>--<br>-- You should have received a copy of the GNU General Public License<br>-- along with this program; if not, write to the Free Software<br>-- Foundation, Inc., 59 Temple Place - Suite 330,
 Boston, MA 02111-1307, USA.<br>--<br><br><br>CREATE TYPE path_result AS (step integer, vertex_id integer, edge_id integer, cost float8);<br><br>-----------------------------------------------------------------------<br>-- Core function for shortest_path computation<br>-- See README for description<br>-----------------------------------------------------------------------<br>CREATE OR REPLACE FUNCTION shortest_path(sql text, source_id integer, target_id integer, <br>                                         directed boolean, has_reverse_cost boolean)<br>        RETURNS SETOF path_result<br>        AS '$libdir/libdijkstra.dll'<br>        LANGUAGE 'C' IMMUTABLE
 STRICT;<br><br><br>-----------------------------------------------------------------------<br>-- Drops the vertices and edges tables related to the given geom_table<br>-----------------------------------------------------------------------<br>CREATE OR REPLACE FUNCTION drop_graph_tables(geom_table varchar) RETURNS void AS<br>$$<br>DECLARE <br>        vertices_table varchar := quote_ident(geom_table) || '_vertices';<br>        edges_table varchar := quote_ident(geom_table) || '_edges';<br>BEGIN<br><br>        BEGIN<br>                EXECUTE 'DROP TABLE ' || vertices_table;<br>        EXCEPTION <br>                WHEN UNDEFINED_TABLE THEN<br>       
 END;<br>        BEGIN<br>                EXECUTE 'DROP TABLE ' || edges_table;<br>        EXCEPTION <br>                WHEN UNDEFINED_TABLE THEN<br>        END;<br>        RETURN;<br>END;<br>$$<br>LANGUAGE 'plpgsql' VOLATILE STRICT; <br><br>-----------------------------------------------------------------------<br>-- This function should not be used directly. Use create_graph_tables instead<br>--<br>-- Insert a vertex into the vertices table if not already there, and<br>--  return the id of the newly inserted or already existing element<br>-----------------------------------------------------------------------<br>CREATE OR REPLACE FUNCTION insert_vertex(vertices_table varchar,
 geom_id anyelement) RETURNS int AS<br>$$<br>DECLARE<br>        vertex_id int;<br>        myrec record;<br>BEGIN<br>        LOOP<br>                FOR myrec IN EXECUTE 'SELECT id FROM ' || quote_ident(vertices_table) || <br>                                     ' WHERE geom_id = ' || quote_literal(geom_id)  LOOP<br>                        IF myrec.id IS NOT NULL
 THEN<br>                                RETURN myrec.id;<br>                        END IF;<br>                END LOOP; <br>                EXECUTE 'INSERT INTO ' || quote_ident(vertices_table) || ' (geom_id) VALUES (' || quote_literal(geom_id) || ')';<br>        END LOOP;<br>END;<br>$$<br>LANGUAGE 'plpgsql' VOLATILE STRICT; <br><br>-----------------------------------------------------------------------<br>-- Create the vertices and edges tables from a table matching the <br>--  geometry schema described
 above.<br>-----------------------------------------------------------------------<br>CREATE OR REPLACE FUNCTION create_graph_tables(geom_table varchar, column_type varchar)<br>        RETURNS void AS<br>$$<br>DECLARE<br>        geom record;<br>        edge_id int;<br>        myrec record;<br>        source_id int;<br>        target_id int;<br>        vertices_table varchar := quote_ident(geom_table) || '_vertices';<br>        edges_table varchar := quote_ident(geom_table) || '_edges';<br>BEGIN<br><br>        EXECUTE 'CREATE TABLE ' || vertices_table || ' (id serial, geom_id '
 <br>                                || quote_ident(column_type) || '  NOT NULL UNIQUE)';<br>        EXECUTE 'CREATE INDEX ' || vertices_table || '_id_idx on ' || vertices_table || ' (id)';<br><br>        EXECUTE 'CREATE TABLE ' || edges_table || ' (id serial, source int, target int, ' <br>                                || 'cost float8, reverse_cost float8, UNIQUE (source, target))';<br>        EXECUTE 'CREATE INDEX ' || edges_table || '_source_target_idx on ' || edges_table || ' (source, target)';<br><br>        FOR geom IN
 EXECUTE 'SELECT gid as id, ' || ' source_id AS source, ' || <br>                                    ' target_id AS target FROM ' || quote_ident(geom_table) LOOP<br><br>                SELECT INTO source_id insert_vertex(vertices_table, geom.source);<br>                SELECT INTO target_id insert_vertex(vertices_table, geom.target);<br><br><br>                edge_id := nextval(edges_table || '_id_seq');<br>                EXECUTE 'INSERT INTO ' || edges_table || ' (id, source, target) VALUES ('
 <br>                     || edge_id || ', '<br>                     || quote_literal(source_id) || ', '<br>                     || quote_literal(target_id) || ')';<br>                <br>                EXECUTE 'UPDATE ' || quote_ident(geom_table) || ' SET edge_id = '<br>                                  || edge_id || ' WHERE gid = ' ||
 quote_literal(geom.id);<br><br>        END LOOP;<br>        RETURN;<br>END;<br>$$<br>LANGUAGE 'plpgsql' VOLATILE STRICT; <br><br><br><br><div style="font-family: times new roman,new york,times,serif; font-size: 12pt;">----- Original Message ----<br>From: Rob Tester <robtester@gmail.com><br>To: PostGIS Users Discussion <postgis-users@postgis.refractions.net><br>Sent: Tuesday, April 3, 2007 8:22:01 PM<br>Subject: RE: [postgis-users] dijkstra.sql<br><br>


 
 
<style>
<!--
 _filtered {font-family:Calibri;panose-1:2 15 5 2 2 2 4 3 2 4;}
 _filtered {font-family:Tahoma;panose-1:2 11 6 4 3 5 4 4 2 4;}
 _filtered {font-family:Consolas;panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;margin-bottom:.0001pt;font-size:12.0pt;font-family:"Times New Roman", "serif";}
a:link, span.MsoHyperlink
        {color:blue;text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {color:purple;text-decoration:underline;}
pre
        {margin:0in;margin-bottom:.0001pt;font-size:10.0pt;font-family:"Courier New";}
span.HTMLPreformattedChar
        {font-family:Consolas;}
span.EmailStyle19
        {font-family:"Calibri", "sans-serif";color:#1F497D;}
.MsoChpDefault
        {font-size:10.0pt;}
 _filtered {margin:1.0in 1.0in 1.0in 1.0in;}
div.Section1
        {}
-->
</style>



<div class="Section1">

<p class="MsoNormal"><span style="font-size: 11pt; font-family: "Calibri","sans-serif"; color: rgb(31, 73, 125);">What version of the lib did you install? Was it built against Postgre
8.1?</span></p> 

<p class="MsoNormal"><span style="font-size: 11pt; font-family: "Calibri","sans-serif"; color: rgb(31, 73, 125);">  </span></p> 

<p class="MsoNormal"><span style="font-size: 11pt; font-family: "Calibri","sans-serif"; color: rgb(31, 73, 125);">I would download the source and rebuild it against 8.2 then try
to install it again.</span></p> 

<p class="MsoNormal"><span style="font-size: 11pt; font-family: "Calibri","sans-serif"; color: rgb(31, 73, 125);">  </span></p> 

<p class="MsoNormal"><span style="font-size: 11pt; font-family: "Calibri","sans-serif"; color: rgb(31, 73, 125);">  </span></p> 

<p class="MsoNormal"><span style="font-size: 11pt; font-family: "Calibri","sans-serif"; color: rgb(31, 73, 125);">  </span></p> 

<div>

<div style="border-style: solid none none; border-color: rgb(181, 196, 223) -moz-use-text-color -moz-use-text-color; border-width: 1pt medium medium; padding: 3pt 0in 0in;">

<p class="MsoNormal"><b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">From:</span></b><span style="font-size: 10pt; font-family: "Tahoma","sans-serif";">
postgis-users-bounces@postgis.refractions.net
[mailto:postgis-users-bounces@postgis.refractions.net] <b>On Behalf Of </b>Bayu
Kurniawan<br>
<b>Sent:</b> Monday, April 02, 2007 6:39 PM<br>
<b>To:</b> postgis-users@postgis.refractions.net<br>
<b>Subject:</b> [postgis-users] dijkstra.sql</span></p> 

</div>

</div>

<p class="MsoNormal">  </p> 

<div><pre>I have some problems with installation of the pgdikstra. Running<br><br>dijkstra.sql gives this error message:<br><br> <br><br>psql:dijkstra.sql:32: ERROR:  incompatible library "C:/Program Files/PostgreSQL/<br><br>8.2/lib/libdjikstra.dll" : missing magic block<br><br>HINT : Extension libraries are required to use the PG_MODULE_MAGIC macro<br><br><br><br>Any solutions for this?</pre></div> 

<p class="MsoNormal"><br><span>
Send instant messages to your online friends <a target="_blank" href="http://uk.messenger.yahoo.com">http://uk.messenger.yahoo.com</a> </span></p> 

</div>

<div>_______________________________________________<br>postgis-users mailing list<br>postgis-users@postgis.refractions.net<br><a target="_blank" href="http://postgis.refractions.net/mailman/listinfo/postgis-users">http://postgis.refractions.net/mailman/listinfo/postgis-users</a><br></div></div><br></div></div><br>Send instant messages to your online friends http://uk.messenger.yahoo.com </body></html>