waymarkedtrails / waymarkedtrails-backend

Database backend and rendering styles for waymarkedtrails website.
GNU General Public License v3.0
15 stars 6 forks source link

Error on xml file generation for hiking layer #15

Open doubotis opened 2 weeks ago

doubotis commented 2 weeks ago

Hello,

I'm on the process to build the .xml files to feed to Mapnik. I succeed to build the slopes.xml file, but I get an error when trying to build the file for hiking layer :

$ wmt-makedb hiking mapstyle > hiking.xml
Traceback (most recent call last):
  File "/home/wmtenv/bin/wmt-makedb", line 251, in <module>
    exit(action())
  File "/home/wmtenv/bin/wmt-makedb", line 167, in mapstyle
    print(env.get_template(f'{self.mapdb.site_config.MAPTYPE}.xml.jinja').render())
  File "/usr/local/lib/python3.7/dist-packages/jinja2/environment.py", line 989, in render
    return self.environment.handle_exception(exc_info, True)
  File "/usr/local/lib/python3.7/dist-packages/jinja2/environment.py", line 754, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/local/lib/python3.7/dist-packages/jinja2/_compat.py", line 37, in reraise
    raise value.with_traceback(tb)
  File "/home/wmtenv/lib/python3.7/site-packages/wmt_db/data/map-styles/routes.xml.jinja", line 2, in top-level template code
    {% extends "base_map.xml.jinja" %}
  File "/home/wmtenv/lib/python3.7/site-packages/wmt_db/data/map-styles/base_map.xml.jinja", line 57, in top-level template code
    {% block content %}{% endblock %}
  File "/home/wmtenv/lib/python3.7/site-packages/wmt_db/data/map-styles/routes.xml.jinja", line 5, in block "content"
    {% include "inc/routes-worldview.jinja" %}
  File "/home/wmtenv/lib/python3.7/site-packages/wmt_db/data/map-styles/inc/routes-worldview.jinja", line 4, in top-level template code
    {{ style.line(color.INT, width="1.3") }}
  File "/usr/local/lib/python3.7/dist-packages/jinja2/environment.py", line 408, in getattr
    return getattr(obj, attribute)
jinja2.exceptions.UndefinedError: 'style' is undefined

I got a hiking.xml file at the end of execution, but the contents if empty.

Do you have any ideas about this error ? It seems to reference the style property in routes-worldview.jinja, but I have no idea why the style is undefined in my case.

lonvia commented 1 week ago

This works fine for me. Here is what I did:

virtualenv -p python3 --system-site-packages wmtenv
. wmtenv/bin/activate

pip install -U osmium PyCairo \
               SQLAlchemy GeoAlchemy2 \
               git+https://github.com/waymarkedtrails/osgende@master \
               git+https://github.com/waymarkedtrails/waymarkedtrails-shields@master
               git+https://github.com/waymarkedtrails/waymarkedtrails-backend@master
mkdir symbols
wmt-makedb hiking mapstyle > hiking.xml

Can you describe your installation environment?

doubotis commented 4 days ago

I checked the code (I made some light changes in waymarkedtrails-shields to handle a specific case for me) but nothing seems wrong. It's probably a dependency issue with newer versions of Python. I'm still in 3.7-3.1 with Debian 10.

I'll update the issue when my environment is updated to the same as yours (=Debian 12) and I rested it.

lonvia commented 4 days ago

Yes, that would definitely be an issue. Likely the old jinja2 version. But you'd also run into trouble with the Python version sooner or later. Currently 3.8 is required (soon to be 3.10).