hello dear perlmonks


new to openstreetmap and - of course also fairly new to perl
i wanto t play with openstreetmap - and to options.
at them moment i have a mysql db where i have created the table with the columns (field names)

id lat lon name amenity operator vending .


see the corresponding SQL-Script


CREATE DATABASE `db123` DEFAULT CHARACTER SET latin1 COLLATE latin1_ge +rman2_ci; USE hans; CREATE TABLE `pois` ( `id` BIGINT(20) UNSIGNED NOT NULL, `lat` FLOAT(10,7) NOT NULL, `lon` FLOAT(10,7) NOT NULL, `name` VARCHAR(255) COLLATE utf8_bin NOT NULL, `amenity` VARCHAR(255) COLLATE utf8_bin NOT NULL, `operator` VARCHAh einR(255) COLLATE utf8_bin NOT NULL, `vending` VARCHAR(255) COLLATE utf8_bin NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin;


now i want to fetch some data from the planet
note;: all i want is to work with the POI - that means i have no interest to rebuild the maps again - all i am interested in is to get the text based data of the POI -

so here is my approach:

osm\planet\schleswig-holstein.osm -all-to-nodes >"c:\osm\planet\pois.o +sm"


#!/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?

In reply to from osm to mysql by Perlbeginner1

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.