Hi Egoitz,<br><br><div class="gmail_quote">On Thu, Feb 24, 2011 at 7:16 PM, Egoitz Ormaetxea <span dir="ltr"><<a href="mailto:egoitz.ormaetxea@gmail.com">egoitz.ormaetxea@gmail.com</a>></span> wrote:<br><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 class="im"><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></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" target="_blank">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="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><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/" target="_blank">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/" target="_blank">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>

</blockquote></div><br>Note that much of the following text is copy and paste from an email I sent yesterday ;-)  I think it's applicable here.<br><br>When
 you perform a bounding box extract, if nodes lie outside the bounding 
box, but are referenced by ways inside the bounding box they will not be
 included in the file.  This is due to the way Osmosis processing works 
because it finishes processing nodes before it sees the ways.<br>
<br>You have several options here:<br>1. Drop the constraint from the database.  This might lead to other issues.<br>2.
 Add the clipIncompleteEntities=true option to the --bounding-box task. 
 This will modify the ways so that they no longer reference the 
problematic ways.  Obviously they will no longer be identical to the 
original ways from the input planet file.<br>
3. Add the completeWays=true option to the --bounding-box task.  This 
will include the missing nodes, but will slow down processing 
enormously.<br><br>You've already tried option 1 which gives you errors in JOSM.  I suspect 3 will be too slow.  That leaves you with 2.  Note that 2 modifies the ways which may or may not be appropriate for you.<br>
<br>Brett<br><br>