roelderickx / ogr2osm

A tool for converting ogr-readable files like shapefiles into .pbf or .osm data
https://pypi.org/project/ogr2osm/
MIT License
59 stars 14 forks source link

Cannot fine translation file #5

Closed musuruan closed 3 years ago

musuruan commented 3 years ago

HI! I'm the Fedora package maintainer for ogr2osm.

I also performed a couple of OSM imports in the past using this tool.

I updated to your new v1.0.0 but I noticed the following issue.

For example, let's try to translate the shapefile shipped inside the zip file named "3026619toponimi141117.zip" available at: http://cartografia.provincia.biella.it/on-line/Home/Repertorio/Consultazione/articolo3000189.html

The translation file is available here: https://github.com/musuruan/osm_imports/tree/master/prov_bi

I run ogr2osm from the directory where there is the translation file, the shapefile is in a sub directory.

$ ogr2osm -e 32632 -t toponimi.py -f Toponimi/toponimi141117.shp Using default translations Preparing to convert 'Toponimi/toponimi141117.shp' to '/home/andrea/Dropbox/OpenStreetMap/osm_imports/prov_bi/toponimi141117.osm'. Splitting long ways Writing file header Writing nodes Writing ways Writing relations Writing file footer

As you can see, it doesn't find the translation file and it uses the default translation (i.e. no translation at all).

If I downgrade to pnorman's ogr2osm git commit f82e052 (which is the latest version I have publicly packaged) I have no issue:

$ ogr2osm -e 32632 -t toponimi.py -f Toponimi/toponimi141117.shp

The output is not verbose but the osm file has been created using the translation file.

roelderickx commented 3 years ago

Hi @musuruan Thanks for your report.

The translations are reworked a bit to make the code more maintainable, so this issue does not really come as a surprise. It is also a first step towards a more unified system of translation but I am still in the process of analyzing. For now it means you have to alter your translation file but don't worry, it is very straightforward.

If all goes well you will see the following output: $ ogr2osm -e 32632 -t toponimi.py -f Toponimi/toponimi141117.shp Found valid translation class ToponimiTranslation Preparing to convert 'Toponimi/toponimi141117.shp' to '/home/andrea/Dropbox/OpenStreetMap/osm_imports/prov_bi/toponimi141117.osm'. Splitting long ways Writing file header Writing nodes Writing ways Writing relations Writing file footer

Please let me know if you encounter any difficulties. It may be interesting to write a small documentation file on how to convert translation files from pnorman's version to this version, so your experience is valuable.

musuruan commented 3 years ago

Thanks Roel! I followed your notes and now the translation script works :-)

roelderickx commented 3 years ago

Glad to see that it works. I have added a conversion guide in the README file of ogr2osm-translations and added a link in the README file of ogr2osm. I will also add a clear warning when a translation file is passed as parameter, but when no TranslationBase derived class can be found (and thus falling back to the default translation). I hope these measures will prevent errors as much as possible.