<p><span style="background-color: rgb(255, 255, 51);">ERROR: duplicate key violates unique constraint "roadl_edges_source_key" <br></span></p><p><br><span style="background-color: rgb(255, 255, 51);"></span></p>
<p><span style="background-color: rgb(255, 255, 51);">This occurs because of duplicate edges in the graph. <br></span></p><p><br><span style="background-color: rgb(255, 255, 51);"></span></p><p><span style="background-color: rgb(255, 255, 51);">
So you do the following to clean it up.<br></span></p><p>The following lines are taken from <a href="http://www.cartoweb.org/doc/cw3.3/xhtml/user.install.html">http://www.cartoweb.org/doc/cw3.3/xhtml/user.install.html</a>
<br></p><p>
But if the data quality is poor, you need to delete the duplicates edges (they have the same
source-target pairs of vertices).
For example, to check that you have duplicated edges, you can type:
</p>
<pre class="screen">$ SELECT * FROM (SELECT source_id, target_id, count(*) AS c FROM roads_europe group by <br>source_id, target_id order by c)<br>AS foo where foo.c = 2;</pre>
<p>
If there is duplicated edges, to delete one of two rows, you can type:
</p>
<pre class="screen">$ CREATE TABLE doublons AS SELECT * FROM roads_europe WHERE gid in<br>(SELECT gid FROM (SELECT DISTINCT on (source_id, target_id) source_id, gid <br>FROM roads_europe) AS doublon);<br>
$ DELETE FROM roads_europe;<br>$ INSERT INTO roads_europe (SELECT * FROM doublons);<br>$ DROP TABLE doublons;</pre>Hope it helps.<br><br>Pradeep B V<br><a href="http://mapunity.org">http://mapunity.org</a><br><br><div><span class="gmail_quote">
On 12/16/06, <b class="gmail_sendername">Sasanka Gandavarapu</b> <<a href="mailto:horryglory@gmail.com">horryglory@gmail.com</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi all<br>
<br>
While using the Create_graph_tables function for integrating pgdijkstra with postgreSQL i am encountering the following error:<br>
I am directly using the demo datafiles(from cartoweb, hence i dont think there is any problem with the data). <br>
Also, before doing this, i created source and target fields in the
database by adding three new columns and using assign_vertex_id.<br>
<br>
can someone help, please...<br>
<br>
NOTICE: CREATE TABLE will create implicit sequence "roadl_vertices_id_seq" for serial column "roadl_vertices.id"<br>
CONTEXT: SQL statement "CREATE TABLE roadl_vertices (id serial, geom_id int4 NOT NULL UNIQUE)"<br>
PL/pgSQL function "create_graph_tables" line 11 at execute statement<br>
<br>
NOTICE: CREATE TABLE / UNIQUE will create implicit index "roadl_vertices_geom_id_key" for table "roadl_vertices"<br>
CONTEXT: SQL statement "CREATE TABLE roadl_vertices (id serial, geom_id int4 NOT NULL UNIQUE)"<br>
PL/pgSQL function "create_graph_tables" line 11 at execute statement<br>
<br>
NOTICE: CREATE TABLE will create implicit sequence "roadl_edges_id_seq" for serial column "roadl_edges.id"<br>
CONTEXT: SQL statement "CREATE TABLE roadl_edges (id serial,
source int, target int, cost float8, reverse_cost float8, UNIQUE
(source, target))"<br>
PL/pgSQL function "create_graph_tables" line 15 at execute statement<br>
<br>
NOTICE: CREATE TABLE / UNIQUE will create implicit index "roadl_edges_source_key" for table "roadl_edges"<br>
CONTEXT: SQL statement "CREATE TABLE roadl_edges (id serial,
source int, target int, cost float8, reverse_cost float8, UNIQUE
(source, target))"<br>
PL/pgSQL function "create_graph_tables" line 15 at execute statement<br>
<br style="background-color: rgb(255, 255, 51);">
<span style="background-color: rgb(255, 255, 51);">ERROR: duplicate key violates unique constraint "roadl_edges_source_key" </span><br>
CONTEXT: SQL statement "INSERT INTO roadl_edges (id, source, target) VALUES (91, '107', '109')"<br>
PL/pgSQL function "create_graph_tables" line 27 at execute statement<br>
<br>
Thanks in advance,<br>
Horry<br>
<br>_______________________________________________<br>postgis-users mailing list<br><a onclick="return top.js.OpenExtLink(window,event,this)" href="mailto:postgis-users@postgis.refractions.net">postgis-users@postgis.refractions.net
</a><br><a onclick="return top.js.OpenExtLink(window,event,this)" href="http://postgis.refractions.net/mailman/listinfo/postgis-users" target="_blank">http://postgis.refractions.net/mailman/listinfo/postgis-users</a><br><br>
<br></blockquote></div><br>