in reply to Re^2: OpenStreetMap API : Worker and Plugins architecture
in thread OpenStreetMap API : Worker and Plugins architecture

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; }

Replies are listed 'Best First'.
Re^4: OpenStreetMap API : Worker and Plugins architecture
by bliako (Abbot) on May 16, 2019 at 10:36 UTC

    that's great thanks. I am currently working on what I proposed above but I see it being easily extended for including local files and DB (via GDAL). The main feature will be it operating on a higher level and via 3rd party plugins - in order to encourage independent development.

    I will let you know when I have something working, if you want to test it or have some suggestion about features. Thanks for your help.