[OSM-talk] Using OSM with PostGIS

Johnny Doe uucp1 at yahoo.com
Sat Apr 15 20:14:08 BST 2006


Here is the corrected and tested version of the script
that creates two layers - nodes and segments.
Lars, you can also try to run
ogr2ogr -f "esri shapefile" -spat 7 55 20 62
nodes_sverige.shp nodes.mif
ogr2ogr -f "esri shapefile" -spat 7 55 20 62
segments_sverige.shp segments.mif
qgis nodes_sverige.shp segments_sverige.shp
and feel the rendering speed :)

---
awk -F\" 'BEGIN{
 i=-1;j=-1; 
 system("rm -f planet.mi? nodes.mi? segments.mi?");
printf("version 300\ncharset \"utf-8\"\n\
coordsys earth projection 1, 104\n\
delimiter \",\"\n\
columns 1\n\
cat integer\n\
data\n\n") >"planet.mif";
 system("cp planet.mif nodes.mif; cp planet.mif
segments.mif");
}
{
        if ($1 == "  <node id=") 
         {
          nodes[i++]=$2; nodelat[$2]=$4;
          nodelon[$2]=$6;
         } 
        if ($1 == "  <segment id=") 
         {
          seg[j++]=$2; seg_start[j]=$4;
          seg_end[j]=$6;
         } 
}
END{
for(k=0;k<i;k++)
{
 print "point",nodelon[nodes[k]],nodelat[nodes[k]] >>
"planet.mif"
 print nodes[k] >> "planet.mid"
}
system("cp planet.mif nodes.mif; cp planet.mid
nodes.mid");
for(k=0;k<j;k++)
{
 print
"line",nodelon[seg_start[k]],nodelat[seg_start[k]],nodelon[seg_end[k]],nodelat[seg_end[k]]
>>"planet.mif"
 print seg[k] >> "planet.mid"
 print
"line",nodelon[seg_start[k]],nodelat[seg_start[k]],nodelon[seg_end[k]],nodelat[seg_end[k]]
>>"segments.mif"
 print seg[k] >> "segments.mid"
}
system("rm -f nodes.shp nodes.shx nodes.dbf nodes.prj;
ogr2ogr -f \"esri shapefile\" nodes.shp nodes.mif");
system("rm -f segments.shp segments.shx segments.dbf
segments.prj; ogr2ogr -f \"esri shapefile\"
segments.shp segments.mif");
}' planet.osm

---


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 




More information about the talk mailing list