giggls / openstreetmap-carto-de

OpenStreetMap german style (a fork of openstreetmap-carto)
Other
52 stars 19 forks source link

Rendering tiles with English labels when they are available #43

Closed EricG-Personal closed 5 years ago

EricG-Personal commented 5 years ago

I am trying to get openstreetmap-carto-de setup in the context of the default tile server instructions ( https://switch2osm.org/manually-building-a-tile-server-18-04-lts/ ).

What I am thinking should work is to follow the default instructions, but replace openstreetmap-carto-de with openstreetmap-carto. Is this generally correct?

I followed the instructions down to the Loading Data section.

In the openstreetmap-carto-de instructions, I read:

To get this style running it is also required to add the l10n code to the postgresql database.

I do have mapnik-german-l10n installed and all the tests (tests/runtests_in_virtualenv.sh) pass.

In the openstreetmap-carto-de instructions, I read

These views have to be created after the initial osm2pgsql data import

So, I used the following command to import the data:

osm2pgsql -d gis --flat-nodes ~/nodes.cache --create -G -S ~/src/openstreetmap-carto-de/hstore-only.style --hstore --tag-transform-script ~/src/openstreetmap-carto-de/openstreetmap-carto.lua ~/data/iraq-latest.osm.pbf -p planet_osm_hstore

According to the default instructions, the database name is gis. The instructions for openstreetmap-carto-de seem to assume the database name is osm.

To create the views, I tried:

./views_osmde/apply-views.sh gis en

However, this step generated some errors:

    > ./views_osmde/apply-views.sh gis en

    using database: gis
    using language: en
    psql:/tmp/view-line.sql:1: NOTICE:  view "planet_osm_line" does not exist, skipping
    DROP VIEW
    psql:/tmp/view-line.sql:56: ERROR:  function osm_tag2num(text) does not exist
    LINE 44: osm_tag2num(tags->'width') as "num_width",
             ^
    HINT:  No function matches the given name and argument types. You might need to add explicit type casts.
    psql:/tmp/view-line.sql:58: ERROR:  relation "planet_osm_line" does not exist
    psql:/tmp/view-point.sql:1: NOTICE:  view "planet_osm_point" does not exist, skipping
    DROP VIEW
    psql:/tmp/view-point.sql:58: ERROR:  function osm_tag2num(text) does not exist
    LINE 17: osm_tag2num(tags->'ele') as "num_ele",
             ^
    HINT:  No function matches the given name and argument types. You might need to add explicit type casts.
    psql:/tmp/view-point.sql:60: ERROR:  relation "planet_osm_point" does not exist
    psql:/tmp/view-polygon.sql:1: NOTICE:  view "planet_osm_polygon" does not exist, skipping
    DROP VIEW
    psql:/tmp/view-polygon.sql:62: ERROR:  function osm_tag2num(text) does not exist
    LINE 49: osm_tag2num(tags->'width') as "num_width",
             ^
    HINT:  No function matches the given name and argument types. You might need to add explicit type casts.
    psql:/tmp/view-polygon.sql:64: ERROR:  relation "planet_osm_polygon" does not exist
    psql:/tmp/view-roads.sql:1: NOTICE:  view "planet_osm_roads" does not exist, skipping
    DROP VIEW
    CREATE VIEW
    GRANT

What did I miss?

giggls commented 5 years ago

I am trying to get openstreetmap-carto-de setup in the context of the default tile server instructions ( https://switch2osm.org/manually-building-a-tile-server-18-04-lts/ ).

I never had a look at this manual so I can not help with this one.

What I am thinking should work is to follow the default instructions, but replace openstreetmap-carto-de with openstreetmap-carto. Is this generally correct?

This will work, but you will end up with an unchanged version of openstreetmap-carto and no l10n.

If you want to have openstreetmap-carto + l10n you will need to use the upstream+l10n branch of this repository.

This branch is not very well documented, but if you have a setup which works with German style master the style in this branch will be a drop-in replacement.

Did you even read [INSTALL-de.md](https://github.com/giggls/openstreetmap-carto-de/blob/master/INSTALL-de.md?

I do not think so because if so you would not have missed to apply osm_tag2num.sql.

Sven

giggls commented 5 years ago

Oh, apart from support only stuff I found a real bug :( The convenience script apply-views.sh did not apply osm_tag2num.sql. This should be fixed now.

EricG-Personal commented 5 years ago

Oh, apart from support only stuff I found a real bug :( The convenience script apply-views.sh did not apply osm_tag2num.sql. This should be fixed now.

I am glad you fixed the script which the documentation indicated would apply all of the commands. It is good to regularly test the documentation for such bugs and something you might want to consider in the future.

I will try the upstream+l10n branch and see if my results differ. Has the fix you applied to apply-views.sh been pushed to that branch as well?

giggls commented 5 years ago

AFAIK the script is not part of this branch. Which is really just a spin of from German Style and has not been tested for more than it works for me with my German style setup.

EricG-Personal commented 5 years ago

There still seems to be a problem with the script. I am not sure what I a missing. I think I am also getting lost between the branches and determining exactly where I need to flip back and forth between the install documents and branches.

  1. git checkout upstream+l10n

  2. scripts/get-shapefiles.py

  3. git checkout master

  4. osm2pgsql -d gis --flat-nodes ~/nodes.cache --create -G -S ~/src/openstreetmap-carto-de/hstore-only.style --hstore --tag-transform-script ~/src/openstreetmap-carto-de/openstreetmap-carto.lua ~/data/iraq-latest.osm.pbf -p planet_osm_hstore

  5. ./views_osmde/apply-views.sh gis en

using database: gis using language: en psql: FATAL: database "../osm_tag2num.sql" does not exist psql:/tmp/view-line.sql:1: NOTICE: view "planet_osm_line" does not exist, skipping DROP VIEW psql:/tmp/view-line.sql:56: ERROR: function osm_tag2num(text) does not exist LINE 44: osm_tag2num(tags->'width') as "num_width", ^ HINT: No function matches the given name and argument types. You might need to add explicit type casts. psql:/tmp/view-line.sql:58: ERROR: relation "planet_osm_line" does not exist psql:/tmp/view-point.sql:1: NOTICE: view "planet_osm_point" does not exist, skipping DROP VIEW psql:/tmp/view-point.sql:58: ERROR: function osm_tag2num(text) does not exist LINE 17: osm_tag2num(tags->'ele') as "num_ele", ^ HINT: No function matches the given name and argument types. You might need to add explicit type casts. psql:/tmp/view-point.sql:60: ERROR: relation "planet_osm_point" does not exist psql:/tmp/view-polygon.sql:1: NOTICE: view "planet_osm_polygon" does not exist, skipping DROP VIEW psql:/tmp/view-polygon.sql:62: ERROR: function osm_tag2num(text) does not exist LINE 49: osm_tag2num(tags->'width') as "num_width", ^ HINT: No function matches the given name and argument types. You might need to add explicit type casts. psql:/tmp/view-polygon.sql:64: ERROR: relation "planet_osm_polygon" does not exist psql:/tmp/view-roads.sql:1: NOTICE: view "planet_osm_roads" does not exist, skipping DROP VIEW CREATE VIEW GRANT ~/s/openstreetmap-carto-de (master|✔) $ git log ./views_osmde/apply-views.sh commit ddb20a57588d072ffba9125fd1f29a10676d08cd (HEAD -> master, origin/master, origin/HEAD) Author: Sven Geggus sven-osm@geggus.net Date: Tue Sep 10 16:45:42 2019 +0200

GERMAN STYLE: fix convenience script to also apply osm_tag2num.sql

commit 5a56c63540c3442de2f6a8c67f3698fb6eea3cc3 (tag: v4.11.0-de1) Author: Sven Geggus sven-git@geggus.net Date: Fri May 11 16:40:03 2018 +0200

GERMAN STYLE: Add script to apply views to the database in a language
specified as a commandline option.

6. Running functions separately...

~/s/openstreetmap-carto-de (master|✔) $ psql -d gis -f osm_tag2num.sql CREATE FUNCTION

~/s/openstreetmap-carto-de (master|✔) $ psql -d gis -f views_osmde/view-line.sql

psql:views_osmde/view-line.sql:1: NOTICE: view "planet_osm_line" does not exist, skipping DROP VIEW CREATE VIEW GRANT

~/s/openstreetmap-carto-de (master|✔) $ psql -d gis -f views_osmde/view-point.sql

psql:views_osmde/view-point.sql:1: NOTICE: view "planet_osm_point" does not exist, skipping DROP VIEW CREATE VIEW GRANT

~/s/openstreetmap-carto-de (master|✔) $ psql -d gis -f views_osmde/view-polygon.sql

psql:views_osmde/view-polygon.sql:1: NOTICE: view "planet_osm_polygon" does not exist, skipping DROP VIEW CREATE VIEW GRANT

~/s/openstreetmap-carto-de (master|✔) $ psql -d gis -f views_osmde/view-roads.sql

DROP VIEW CREATE VIEW GRANT

giggls commented 5 years ago

OK broke it even more this afternoon instead of fixing it, but hopefully it will work now.

This is really a very simple shell script. Writing bug reports here is likely way more costly than looking inside the script and fixing it. This is just a convenience function after all.

EricG-Personal commented 5 years ago

Thank you for fixing it for me and others who will try to use it in the future.

Are those NOTICE's I got when running the commands individually not actually problems? If they are problems, what did I miss?

giggls commented 5 years ago

No problem with this at all. Changed it in a way that the warnings will not appear anymore anyway.

EricG-Personal commented 5 years ago

Excellent. Thank you for clearing up that confusion.

EricG-Personal commented 5 years ago

Confirmed. The script appears to be working now. Onto the next problem...

EricG-Personal commented 5 years ago

You may want to document that those NOTICE's when running the commands individually are to be expected.

giggls commented 5 years ago

NACK, I changed the SQL scripts in commit 17cc1c9, they will no longer appear (at least with PostgreSQL11).

EricG-Personal commented 5 years ago

I am getting very close to being able to integrate this project with the default setup for a OSM tile server. The problem seems to stem from the assumption that the database should be called osm and the default instructions assume it is gis.

It looks like it may be possible (and perhaps easier) to alter the default instructions to use a database called osm, but I wanted to get your thoughts on this matter and to see if I have the steps correct about when to switch between branches and what files should be used from which branch.

  1. git checkout master

  2. cp hstore-only.style ~/Desktop/

  3. git checkout upstream+l10n

  4. scripts/get-shapefiles.py

  5. osm2pgsql --create -d gis --flat-nodes ~/nodes.cache -G -S ~/Desktop/hstore-only.style --hstore --tag-transform-script openstreetmap-carto.lua -p planet_osm_hstore ~/data/iraq-latest.osm.pbf

  6. git checkout master

  7. ./views_osmde/apply-views.sh gis en

  8. git checkout upstream+l10n

  9. make DBSCHEME=upstream

  10. Finish setting up according to default instructions

Setting up your webserver

[renderd]
num_threads=4
tile_dir=/var/lib/mod_tile
stats_file=/var/run/renderd/renderd.stats

[mapnik]
plugins_dir=/usr/lib/mapnik/3.0/input
font_dir=/usr/share/fonts/truetype
font_dir_recurse=1

[ajt]
URI=/hot/
TILEDIR=/var/lib/mod_tile
XML=/home/renderaccount/src/openstreetmap-carto-de/osm.xml
HOST=localhost
TILESIZE=256
MAXZOOM=20
CORS=*
  1. renderd -f -c /usr/local/etc/renderd.conf
renderd[18002]: An error occurred while loading the map layer 'ajt': Postgis Plugin: FATAL:  database "osm" does not exist
Connection string: ' dbname=osm connect_timeout=4'
  encountered during parsing of layer 'landcover-low-zoom' in Layer at line 765 of '/home/renderaccount/src/openstreetmap-carto-de/osm.xml'
renderd[18002]: An error occurred while loading the map layer 'ajt': Postgis Plugin: FATAL:  database "osm" does not exist
Connection string: ' dbname=osm connect_timeout=4'
  encountered during parsing of layer 'landcover-low-zoom' in Layer at line 765 of '/home/renderaccount/src/openstreetmap-carto-de/osm.xml'
renderd[18002]: An error occurred while loading the map layer 'ajt': Postgis Plugin: FATAL:  database "osm" does not exist
Connection string: ' dbname=osm connect_timeout=4'
  encountered during parsing of layer 'landcover-low-zoom' in Layer at line 765 of '/home/renderaccount/src/openstreetmap-carto-de/osm.xml'
renderd[18002]: An error occurred while loading the map layer 'ajt': Postgis Plugin: FATAL:  database "osm" does not exist
Connection string: ' dbname=osm connect_timeout=4'
  encountered during parsing of layer 'landcover-low-zoom' in Layer at line 765 of '/home/renderaccount/src/openstreetmap-carto-de/osm.xml'
giggls commented 5 years ago

Either change the database name in osm2pgsql import to "osm" or change the corresponding line in project.mml to gis. I'm am not the nanny for OSM beginners trying to set up a tileserver :P

This is not an issue at all! Please come back again here only if you have real issues with this stuff. If you just have questions, then next time please do not again abuse github issues for this but use the mailing-list or osm help.

EricG-Personal commented 5 years ago

I am having real issues with this stuff. It is not working. I am not sure where the issue might be. I have an idea it may be only with the database name, but as I have found multiple bugs in this stuff already it remains possible that the reason why it is not working is that there a bug in your stuff. I am willing to be a tester for you and continue to work until I get a functioning system. If you do not want that help, I will move on.

giggls commented 5 years ago

You have found one f*** bug in a convenience script that nobody cared about enough to report it here and you where confused about a harmless message from postgresql. That is what this "issues" look like to me.

Frankly you need to understand better what you are doing instead of bothering me with every single step you are trying to do

This "gis" vs. "osm" database name stuff is not something we need to discuss in an issue. This is just different defaults. Upstream uses "gis" while German sytle uses "osm".