<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">

<head>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">
<meta name=Generator content="Microsoft Word 12 (filtered medium)">
<style>
<!--
 /* Font Definitions */
 @font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
        {font-family:Consolas;
        panose-1:2 11 6 9 2 2 4 3 2 4;}
@font-face
        {font-family:Verdana;
        panose-1:2 11 6 4 3 5 4 4 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
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
pre
        {mso-style-priority:99;
        mso-style-link:"HTML Preformatted Char";
        margin:0in;
        margin-bottom:.0001pt;
        font-size:10.0pt;
        font-family:"Courier New";}
span.HTMLPreformattedChar
        {mso-style-name:"HTML Preformatted Char";
        mso-style-priority:99;
        mso-style-link:"HTML Preformatted";
        font-family:Consolas;}
p.msochpdefault, li.msochpdefault, div.msochpdefault
        {mso-style-name:msochpdefault;
        mso-margin-top-alt:auto;
        margin-right:0in;
        mso-margin-bottom-alt:auto;
        margin-left:0in;
        font-size:10.0pt;
        font-family:"Times New Roman","serif";}
span.htmlpreformattedchar0
        {mso-style-name:htmlpreformattedchar;
        font-family:Consolas;}
span.emailstyle19
        {mso-style-name:emailstyle19;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
span.EmailStyle22
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page Section1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.Section1
        {page:Section1;}
-->
</style>
<!--[if gte mso 9]><xml>
 <o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
 <o:shapelayout v:ext="edit">
  <o:idmap v:ext="edit" data="1" />
 </o:shapelayout></xml><![endif]-->
</head>

<body lang=EN-US link=blue vlink=purple>

<div class=Section1>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>I believe that the cartoweb precompiled binary is for 8.1 of
PostgreSQL. <o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p> </o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>Download the source code for PostgreSQL 8.2 and the source for
the dijkstra lib and recompile using MinGW.<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'> Install the new DLL in the <postgresql install>/lib
directory <o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>Then try and use the provided script.<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p> </o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>That should take care of your problems.<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p> </o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>Rob.<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p> </o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p> </o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p> </o:p></span></p>

<div>

<div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in'>

<p class=MsoNormal><b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>From:</span></b><span
style='font-size:10.0pt;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> Tuesday, April 03, 2007 6:45 AM<br>
<b>To:</b> PostGIS Users Discussion<br>
<b>Subject:</b> Re: [postgis-users] dijkstra.sql<o:p></o:p></span></p>

</div>

</div>

<p class=MsoNormal><o:p> </o:p></p>

<div>

<div>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Verdana","sans-serif"'>This
is sql file in dijkstra.sql, i'm using lib with the package in <br>
<a href="http://cartoweb.org/downloads.html#pgdijkstra" target="_blank">http://cartoweb.org/downloads.html#pgdijkstra</a><br>
i'm using mapserver ms4w, postgresql 8.2 and postgis 1.2.0-1 in windows system <o:p></o:p></span></p>

<p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><o:p> </o:p></p>

<p class=MsoNormal style='margin-bottom:12.0pt'><span style='font-size:10.0pt;
font-family:"Verdana","sans-serif"'><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>
<o:p></o:p></span></p>

<div>

<p class=MsoNormal style='margin-bottom:12.0pt'>----- 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<o:p></o:p></p>

<div>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>What version of the lib did you install? Was it built against
Postgre 8.1?</span><o:p></o:p></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'> </span><o:p></o:p></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>I would download the source and rebuild it against 8.2 then try
to install it again.</span><o:p></o:p></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'> </span><o:p></o:p></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'> </span><o:p></o:p></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'> </span><o:p></o:p></p>

<div>

<div style='border:none;border-top:solid windowtext 1.0pt;padding:3.0pt 0in 0in 0in;
border-color:-moz-use-text-color -moz-use-text-color'>

<p class=MsoNormal><b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>From:</span></b><span
style='font-size:10.0pt;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><o:p></o:p></p>

</div>

</div>

<p class=MsoNormal> <o:p></o:p></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?<o:p></o:p></pre></div>

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

</div>

<div>

<p class=MsoNormal>_______________________________________________<br>
postgis-users mailing list<br>
postgis-users@postgis.refractions.net<br>
<a href="http://postgis.refractions.net/mailman/listinfo/postgis-users"
target="_blank">http://postgis.refractions.net/mailman/listinfo/postgis-users</a><o:p></o:p></p>

</div>

</div>

<p class=MsoNormal><span style='font-size:10.0pt;font-family:"Verdana","sans-serif"'><o:p> </o:p></span></p>

</div>

</div>

<p class=MsoNormal><br>
Send instant messages to your online friends http://uk.messenger.yahoo.com <o:p></o:p></p>

</div>

</body>

</html>