Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re^4: from osm to mysql

by Perlbeginner1 (Scribe)
on Jun 01, 2014 at 07:54 UTC ( [id://1088164]=note: print w/replies, xml ) Need Help??


in reply to Re^3: from osm to mysql
in thread from osm to mysql

hello dear Poi- good morning ;<)

the script we discussed (see above) was written for windows - see the corresponding line with the paths...


#!/usr/bin/perl -w use strict ; use OSM::osm ; my $file ; my $nodeUser ; my @nodeTags ; my $nodeTags ; my $ref1 ; my $line ; my $tag; my $nodeName; my $id ="1" ; my $lat ; my $lon ; my $name ; my $amenity ; my $operator ; my $vending; $file = "c:/osm/planet/pois.osm" ; openOsmFile ($file) ; open(AUSGABE, ">c:/osm/planet/mysql.txt"); ($id, $lon, $lat, $nodeUser, $ref1) = getNode2 () ; while ($id != -1 ) { $name ="" ; $amenity ="" ; $operator ="" ; $vending ="" ; @nodeTags = @$ref1; foreach my $tag (@nodeTags) { if ($tag->[0] eq "name") { $name = scalar ($tag->[1] )}; if ($tag->[0] eq "amenity") { $amenity = scalar ($tag->[1] + )}; if ($tag->[0] eq "operator") { $operator = scalar ($tag->[ +1] )}; if ($tag->[0] eq "vending") { $vending = scalar ($tag->[1] + )} } if ($name ne "" | $amenity ne "" | $operator ne"" | $vendi +ng ne"") {print AUSGABE "$id^$lat^$lon^$name^$amenity^$operator^$ve +nding\n";} ($id, $lon, $lat, $nodeUser, $ref1) = getNode2 () ; } close(AUSGABE); closeOsmFile () ;


how would you say - does this fit for linux - no. We have to do some corrections first.

note; i run linux opensuse 13.1
- mysql is up and running
- the modules i have all



use DBI; use XML::Twig;
... and i guess that i need furthermore another "library" this library which is used in this line use OSM::osm ; which is inspired by this page note German language: url=http://wiki.openstreetmap.org/wiki/User:Brogo/OpenLayers_DatenbankanbindungUser:Brogo/OpenLayers Datenbankanbindung - OpenStreetMap Wiki/url

and this url=http://svn.openstreetmap.org/applications/utils/gary68/OSM/osm.pm", $title, "/url This module contains a lot of useful functions for working with osm files and data. it also includes functions for calculation and output. url=http://wiki.openstreetmap.org/wiki/User:Gary68User:Gary68 - OpenStreetMap Wiki/url

bquestions: /b

where to put this library: url=http://svn.openstreetmap.org/applications/utils/gary68/OSM/osm.pm", $title, "/url should i put it into the folder where i have the following perl scripts:

note: well what i have i have a folder

home/perl where i have the following perl code:

a. osm_to_db.pl
b. create_db.pl


bsecond question:/b - i am sure that i have to do some corrections;

in the code create_db.pl
a. the first correction:
at the line $file = "c:/osm/planet/pois.osm" ;

b the second correction:
at the line

 "open(AUSGABE, ">c:/osm/planet/mysql.txt"); "

...since i have no windows but a linux-system....:


look forward to hear from you

Replies are listed 'Best First'.
Re^5: from osm to mysql
by poj (Abbot) on Jun 01, 2014 at 14:07 UTC

    Just change the lines to

    $file = "pois.osm" ; open(AUSGABE, ">mysql.txt");

    and put the pois.osm file in with create_db.pl.

    While you are in the early stages of testing, create a folder /home/perl/OSM and put the osm.pm in it. Looks like you also need osmDB.pm in there too.

    You will also need to install Compress::Bzip2
    poj

      hello dear poi

      many many thanks for all the hints. Great to hear from you. you are very very supportive. That is so overwhelming,.

      many thanks again - greetings

      perlbeginner1

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1088164]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (3)
As of 2024-04-19 17:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found