Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error on xml file generation for hiking layer #15

Open
doubotis opened this issue Nov 7, 2024 · 3 comments
Open

Error on xml file generation for hiking layer #15

doubotis opened this issue Nov 7, 2024 · 3 comments

Comments

@doubotis
Copy link

doubotis commented Nov 7, 2024

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
Copy link
Contributor

lonvia commented Nov 11, 2024

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
Copy link
Author

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
Copy link
Contributor

lonvia commented Nov 18, 2024

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants