in reply to from osm to mysql
Looks pretty good to me. Might want to add 'use warnings;' after your 'use strict;'. Have to assume that 'use OSM::osm;' is a module you got from somewhere? I did not see it on CPAN, though I did see a number of GEO::OSM::* modules that look like they might be useful to you, including what appears to be a parser -> Here.
Am thinking that you will want to include the DBD::mysql and company when you start pumping those variable into your database.
Not exactly sure what you are looking for,(what is the question specifically)? 'Does this fit?' is a little bit open ended...
Hope there is something here you find useful..Insanity: Doing the same thing over and over again and expecting different results...
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: from osm to mysql
by Perlbeginner1 (Scribe) on May 24, 2014 at 13:12 UTC | |
great to hear from you: see the source of the perlmodule: http://svn.openstreetmap.org/applications/utils/gary68/OSM/osm.pm wHAT IS AIMED: aimed is to transform POI out of German osm-pbf-files - in order to get the data (not to creat maps again) see the source (s)= http://download.geofabrik.de/europe/germany.html ranging form 10 MB (Bremen) to 390 MB (Nordrhein Westfalen) the osm.pbf-files are not too big; Question: which method is the best the most appropiate? - to store the results in a mysql-db or just have big calc-sheets (with csv-data) - only straightforward from files that - no backimport of data to OSM from a .csv file btw: see here - a similar approach of a guy - he only looks for a list of brides see the full overview: A self-updating OpenStreetMap database of US bridges – a step-by-step guide. http://oegeo.wordpress.com/2012/03/06/a-self-updating-openstreetmap-database-of-us-bridges-a-step-by-step-guide/ well i am pretty sure that the link to cpan gives back some very nice tools - update: by the way - one last question update. which method fits if i want to store the output of this request to a mysql database:
see the output here
how can this be done? note we have the fild names and all the set of the datbase is clear. the question is - how to put the data into the database.....? <br look forward to hear from you | [reply] [d/l] [select] |
by erix (Prior) on May 24, 2014 at 13:33 UTC | |
Just FYI: OpenStreetMap switched from Mysql to PostgreSQL (postgresql), a few years ago. You mention (link 1):
and in link 2: "I want all bridges in the US that are mapped in OpenStreetMap in a PostGIS database" So, of the two links you gave, one is from before that database switch to postgres, and the other explicitly mentions part of the postgres ecosystem (PostGIS: http://postgis.org/). No doubt, it is possible to use a database other than postgres but it might be something to be aware of (esp. when using some of the osm tools). | [reply] [d/l] [select] |
by poj (Abbot) on May 24, 2014 at 15:06 UTC | |
Read more... (3 kB)
I hope this answers your question.poj | [reply] [d/l] [select] |
by Perlbeginner1 (Scribe) on May 24, 2014 at 15:37 UTC | |
many many thanks for all your ideas and help regarding the connection of the database!!! this is great! of course - i know that postgresql is THE mandantory standard i am willing to do all in postgresql. i have some experience in MySQL - and i am now willing to do all what is needed to do work with postgres note; i do not need the spatial - featuees (the options of creating maps.) i only want to export POI from the planet file. later the weekend i will have a closer look at the codesnippets and will come back and report all my experiecne Again - many many thanks greetings ps - i am very very happy about this great forums - it rocks and you do a superb work !!!! Community at its best"!! | [reply] |
by Perlbeginner1 (Scribe) on May 29, 2014 at 15:05 UTC | |
again many many thanks - well - very convincing - since i want to put all the data ( that i have in a xml-file) into the mysql db - i need to have a INSERT-Statement. where to place this INSERT-statement!? look forward to hear from you | [reply] |
by poj (Abbot) on May 29, 2014 at 15:31 UTC | |
by Perlbeginner1 (Scribe) on May 29, 2014 at 15:59 UTC | |
by Perlbeginner1 (Scribe) on Jun 01, 2014 at 07:54 UTC | |
the script we discussed (see above) was written for windows - see the corresponding line with the paths...
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 ... 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 | [reply] [d/l] [select] |
by poj (Abbot) on Jun 01, 2014 at 14:07 UTC | |
by Perlbeginner1 (Scribe) on Jun 01, 2014 at 18:11 UTC | |
by wjw (Priest) on May 24, 2014 at 14:39 UTC | |
This is interesting, thanks for the background. I have only looked as OSM from the point of view of end user apps at this point(android), so the links and info you provide are appreciated. In answer to your first question: My preference is to use a database if at all possible. For smaller projects I like SQLite, as it is very portable, with the whole data base stored in one file. That limits it in size, but not terribly. I have no porblem sticking 500k records in an SQLite database. If it is likely that your going to have a much larger database, the MySQL is my preference. As erix pointed out, it looks like osm is leaning toward Postres. Postgres is fine, but I worked with it only once years ago, so I am somewhat abivilant towards it. I am sure it would work fine.As far as methodology goes: You already have your parser pretty much worked out as close as I can tell. I would take the script that you already have, add the DBI/DBD for your chosen database(does not matter from the Perl/DBI standpoint), and then write the rather short code to take your parsed data and insert it to the database. You are really already half done. You can use SuperSearch and the POD for your chosen database driver, to come up with examples. In simplistic psudo-code it looks a bit like the following:
Again, I hope you find this somewhat helpful...
...the majority is always wrong, and always the last to know about it...
Insanity: Doing the same thing over and over again and expecting different results...
| [reply] [d/l] |
by Perlbeginner1 (Scribe) on May 29, 2014 at 15:08 UTC | |
again many many thanks for all your hints; first of all i like the idea of sqlite i have to digg deeper into that next time your explanations were very convincing At the moment i am willing to store all the data into the MySQL-DB. Well - since i want to put all the data ( that i have in a xml-file) into the mysql db - i need to have a INSERT-Statement. where to place this INSERT-statement!? look forward to hear from you | [reply] |
by marto (Cardinal) on May 29, 2014 at 15:30 UTC | |
|
Re^2: from osm to mysql
by Perlbeginner1 (Scribe) on May 31, 2014 at 06:54 UTC | |
the script we discussed was written for windows - see the corresponding line with the paths...
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 ... 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 | [reply] [d/l] [select] |