Libosmium binding for php or perl?

Hi,

is there a language binding to php or perl for libosmium on Ubuntu?

I have no exprience in C and can’t use the C-Version.

Found the python version and i may use that if there is no other solution. (php prefered)

regards
walter aka wambacher

what i want to do:

  • get live data of ONE relation using the osm api (solved)
  • convert the xml-data to geojson using libosmium (open)
  • display the geojson on a map using leaflet (solved)

No, the Python bindings are the only available and maintained bindings.

On other suggestion: Have a look at osm2pgsql, more specifically the flex output. It might be overkill for you, but creating GeoJSON from OSM data in a PostgreSQL database is quite easy.

If you’re brave, you might try accessing it via FFI in PHP. Been doing something similar on an old project of mine. As long as you don’t need dozens of calls wrapped, it’s a viable option for PHP. If you need help with that, I might have some time to look into it this weekend.

Update: dealing with objects returned from functions doesn’t seem to be supported properly, so maybe not a good idea

I don’t want to stop you from anything, but wrapping libosmium is really difficult, much more so than for many other C libraries. And libosmium is C++, not C. There is a reason there are no other wrappers available.

Hi, i’m using osm2pgsql since 2010 and the flex output since 2020, iirc.

And i can’t use osm2pgsql or "osmium export … " because calling external programs from javascript is not the best way (for me).

But isn’t that the whole point of an API?

You have data (in this case xml data of a postcode boundary relation), call the appropriate API and process its results.

And that’s supposed to cause problems?
Well then, I’ll get started with the Python lib.

Not an answer to your question, but an answer to your use case:

You might want to have a look at leaflet-osm. It can show your downloaded relation xml on a leaflet map directly. No need to convert it to geojson first.

1 Like

Hi Ionvia,

that sounds great. Will try it asap.

Great, this plugin solved my problems :slight_smile:

After some minor changes tomorrow, my Leaflet based postcode map should do what i wanted.

Thanks
walter