I mentioned GDAL in case it is of use, as it covers a huge number of formats (and thus has a correspondingly large code base). You might be able to glean something from its source code for the OSM driver.

A quick download of one feature type might be possible, but to be honest I've never tried either a full or partial download of these data (hence my answer did not have any code examples). If you do download all features for a region then you should not need to set up a database, though, as you can access the contents of the file directly using Geo::GDAL::FFI::Dataset and Geo::GDAL::FFI::Layer methods, including running SQL queries over the data (see ExecuteSQL in the Geo::GDAL::Dataset::Dataset docs). The Synopsis for Geo::GDAL::FFI has an example of how to load the data, copied below.

I would definitely be interested in seeing something implemented in Perl to access these data, and can help with testing if you need it.

# from the Geo::GDAL::FFI synopsis, # it should detect the file type automatically (untested) use Geo::GDAL::FFI qw/Open/; my $layer = Open('test.shp')->GetLayer; $layer->ResetReading; while (my $feature = $layer->GetNextFeature) { my $value = $feature->GetField('name'); my $geom = $feature->GetGeomField; say $value, ' ', $geom->AsText; }

In reply to Re^3: OpenStreetMap API : Worker and Plugins architecture by swl
in thread OpenStreetMap API : Worker and Plugins architecture by bliako

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.