<br><br><div class="gmail_quote">2011/2/18 Brett Henderson <span dir="ltr"><<a href="mailto:brett@bretth.com" target="_blank">brett@bretth.com</a>></span><br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">


Hi Egoitz,<br><br>Apologies for the slow reply, but better late than never :-)<br> </blockquote><div><br>Yes much better XD<br><br></div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<br><div class="gmail_quote"><div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">

<br>Using Ecuador osm file form Cloudmade at Feb 8, 2011 :<br>SEVERE: Thread for task 1-read-xml-0.6 failed<br>org.openstreetmap.osmosis.core.OsmosisRuntimeException: Unable to insert user with id 222199 into the database.<br>




Caused by: org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "users_display_name_idx"<br></blockquote><br>I haven't seen this before, but I suspect I know what is causing it.  I'm guessing that there are two entities (nodes, ways or relations) that have different user ids but the same display name in the file.  I haven't seen it before, but it's possible that a user has been renamed, then subsequently a separate user renamed to user the same name as the first user's original name.  That might cause the same username to appear with different user ids.<br>



<br>If you download a fresh planet all usernames will be aligned, and if you subsequently load that planet into a database and keep the database up-to-date with daily/hourly/minutely diffs the users will also be kept correctly named because users are stored in a separate users table eliminating duplication.  It's only a problem when applying diffs to XML files because only updated entities will have their usernames updated, any existing entities will continue to have the names from the input XML file.<br>



</div></div></blockquote><div><br>Thanks I'll extract Ecuador .osm file directly from the latest planet file. <br> </div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">


<div class="gmail_quote"><div> </div><div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><br>Using the osm file result of the extract sentence I've writed earlier :<br>

SEVERE: Thread for task 1-read-xml-0.6 failed<br>

org.openstreetmap.osmosis.core.OsmosisRuntimeException: Unable to load current way nodes.<br>

Caused by: org.postgresql.util.PSQLException: ERROR: insert or update on
 table "current_way_nodes" violates foreign key constraint 
"current_way_nodes_node_id_fkey"<br>
Detail: Key (node_id)=(490767853) is not present in table "current_nodes"<br></blockquote></div><div><br>These are usually caused by inconsistencies in the XML file you've downloaded.  In both cases ways are referring to nodes that don't exist in the file.  Without knowing the complete history of the files you've downloaded it's hard to know why this might be.<br>



<br>In the past, I've simply dropped the current_way_nodes_node_id_fkey constraint to make it work, but that could potentially cause other issues.<br> </div><div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">




<br>Using Spain osm file from Cloudmade at Feb 8, 2011 :<br>All ok. I can use JOSM to access ( and even change ) the data from the API DB.<br><br>The API BD is always new ( dropdb : createdb : rake db:migrate : rake test ) before the population senteces.<br>


</blockquote></div></div><br></blockquote></div><br>Lets use an example to explain the problem :<br><br>Using a osm file downloaded from Cloudmade that works correctly ( importing to APIDB and editing with JOSM ), if I extract a bounding box with this sentence ... :<br>
<br>bzcat spain.osm.bz2 | osmosis --read-xml file=/dev/stdin 
enableDateParsing=no --bounding-box top=43.5 left=-3.5 bottom=42.0 
right=-1.0 --write-xml file=- | bzip2 > extracted.osm.bz2<br>

<br>and try to populate de APIDB with the extracted file ... :<br><br>bzcat extracted.osm.bz2 | osmosis --read-xml-0.6 file=- populateCurrent=yes host="localhost" database="xxx" user="xxx" paasword="xxx" validateSchemaVersion=no<br>
<br>Ends with error, ( Detail: Key (node_id)=(490767853) is not present in table "current_nodes" ) that node is out of the extract bounding box and it thosen't appear at extracted.osm.bz2 but it appears at spain.osm.bz2 ( the node is part of a way that starts at the bounding box but ends outside the bounding box ).<br>

<br>So tried the drop constraint solution :<br>psql -d openstreetmap -c "ALTER TABLE current_way_nodes DROP CONSTRAINT current_way_node_id_fkey CASCADE;"<br><br>It solved the populating problems ( no errors ), but using JOSM to see the APIBD information causes error if I try to view any way related with the ways that created the previous importing error ( it works if I view a zone with no ways related with the "outside of the bounding box" ):<br>
Log of the API server :<br><br>Processing ApiController#map (for 192.168.3.111 at XXX) [GET]<br>Parameters: {"bbox"=>"-3.0308533,43.3311716,-3.0116272,43.345155"}<br>Node Load (5.5ms) SELECT * FROM "current_nodes" WHERE ("current_nodes"."visible" = 't' ) AND (( tile BETWEEN 1878255232 AND 1878255251 OR tile BETWEEN 1878255256 AND 1878255259 ) AND latitude BETWEEN 433311716 AND 433451550 AND longitude BETWEEN -30308533 AND -30116272) LIMIT 50001<br>
NodeTag Load (12130.7ms) SELECT "current_node_tags".* FROM "current_node_tags" WHERE ("current_node_tags".id IN (3085055...<lot of numbers>..))<br>WayNode Load (4.8ms) SELECT * FROM "current_way_nodes" WHERE ("current_way_nodes"."node_id" IN (<lot of numbers>))<br>
Way Load (1.5ms) SELECT * FROM "current_ways" WHERE ("current_ways"."id" IN (<lot of numbers>))<br>WayNode Load (4.0ms) SELECT "current_way_nodes".* FROM "current_way_nodes" WHERE ("current_way_nodes".id IN (<lot of numbers>))<br>
WayTag Load (1.7ms) SELECT "current_way_tags".* FROM "current_way_tags" WHERE ("current_way_tags".id IN (<lot of numbers>))<br>Node Load (7.2ms) SELECT * FROM "current_nodes" WHERE ("current_nodes"."id" IN (<lot of numbers>))<br>
NodeTag Load (11976ms) SELECT "current_node_tags".* FROM "current_node_tags" WHERE ("current_node_tags".id IN (<lot of numbers>))<br><br>Completed in 24544ms (View: 1, DB: 24133) | 404 Not Found [<a href="http://192.168.2.173/api/0.6/map?bbox=-3.0308533,43.3311716,-3.0116272,43.345155">http://192.168.2.173/api/0.6/map?bbox=-3.0308533,43.3311716,-3.0116272,43.345155</a>]<br>

<div style="padding: 0px; margin-left: 0px; margin-top: 0px; overflow: hidden; word-wrap: break-word; color: black; font-size: 10px; text-align: left; line-height: 130%;">
</div>
<div style="padding: 0px; margin-left: 0px; margin-top: 0px; overflow: hidden; word-wrap: break-word; color: black; font-size: 10px; text-align: left; line-height: 130%;">
</div>
<div style="visibility: hidden; left: -5000px; position: absolute; z-index: 9999; padding: 0px; margin-left: 0px; margin-top: 0px; overflow: hidden; word-wrap: break-word; color: black; font-size: 10px; text-align: left; line-height: 130%;" id="avg_ls_inline_popup">
</div><br>JOSM error ( I donīt have the JOSM in English so this is a "homemade translation"  of the error message ) :<br>The OSM server "<a href="http://192.168.2.173:3000/api/0.6/">http://192.168.2.173:3000/api/0.6/</a>" doesnīt know about an object you tried to read, update or delete. Maybe the object dosenīt exist at the server or you are using a non valid URL to access to it. Please confirm the server URL "<a href="http://192.168.2.173:3000/api/0.6/">http://192.168.2.173:3000/api/0.6/</a>"<br>
<br><br>PD: I downloaded the new osm file for Spain from Cloudmade, It gives me the same importing error, the previous file ( Feb 8 ) worked with no error. I must have done some noob/strange/silly error because no one is complaining about the files from Cloudmade.<br>