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

contour style rework #567

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

contour style rework #567

wants to merge 1 commit into from

Conversation

quasart
Copy link
Contributor

@quasart quasart commented May 9, 2021

Hello,
Here is my try to improve contour lines style (#534) :

  • thinner and more yellowish to make confusion with path impossible
  • comp-op multiply to make them visible on both empty land, forest, or even hill shadow background,
  • less labels at mid-zoom
  • label glow is now white

I didn't manage to download elevation data, I simply drawn some lines by hand in JOSM for testing purpose...

Screen Shot 2021-05-10 at 10 08 20
Screen Shot 2021-05-10 at 10 08 50
Screen Shot 2021-05-10 at 10 10 22
Screen Shot 2021-05-10 at 10 10 52

@quasart quasart changed the title contour style rework #534 contour style rework May 9, 2021
@Phyks
Copy link
Member

Phyks commented May 15, 2021

@quasart Thanks! I really like it. It would be really nice to have an example in a dense area such as the Alps.

Regarding the contours, you might be interested in https://pub.phyks.me/osm/cyclosm/ (see https://github.com/cyclosm/cyclosm-cartocss-style/blob/master/CONTRIBUTING.md#kosmtik). If you cannot make this work, I can output some renders.

Waiting for @Florimondable advice on this one as well :)

@Florimondable
Copy link
Member

Hi, thanks for the work

* thinner and more yellowish to make confusion with path impossible

I prefer the previous colors. Did you try the ones from opentopomap ? They seems very good.

* comp-op multiply to make them visible on both empty land, forest, or even hill shadow background,

Need example if possible, not sure it's a good idea in terms of performance.

* less labels at mid-zoom

* label glow is now white

These seems good.

Like, Phyks if you can provide more examples.
I may try to look at it further too.

@quasart
Copy link
Contributor Author

quasart commented May 17, 2021

Did you try the ones from opentopomap ? They seems very good.

i like opentopomap colors too but it’s not that easy : in cyclosm there are brown ways in conflict with contour lines. And opentopomap forests color is more yellow-green than here

@Florimondable
Copy link
Member

I’m afraid of too deep modification, the current works pretty well I think.
So I think modification should be subtle.

On IGN topo map the level lines are strong too, but it’s the french reference topo map.

image

@quasart
Copy link
Contributor Author

quasart commented May 18, 2021

I don’t understand what bother you. The change I propose look pretty subtle.

Current style is ok but it has a big issue i’m trying to solve : it’s slightly too strong, especially when background is white. this is taking too much focus over ways.
in my proposal, it looks well balance, no ?

About IGN topo maps, forest shade is very light, and brown color is not in conflict with other elements of the map. Anyway paths are definitely bolder than contour lines, and that is what I’m expecting in cyclosm.

@Phyks
Copy link
Member

Phyks commented May 28, 2021

Thanks for this PR, I really like where we are going with contour lines here. However, I think we could probably dim them even further.

See screenshots:

https://www.cyclosm.org/#map=15/48.8470/1.9968/cyclosm
2021-05-28-215230

(contour lines are still very strong here)

https://www.cyclosm.org/#map=14/48.8603/1.8948/cyclosm
2021-05-28-215310

(same)

https://www.cyclosm.org/#map=13/45.0226/5.5694/cyclosm

2021-05-28-215333

(much lighter in the Alps, but still a bit too present, isn't it?)

I can provide contour lines extracts of the db if it can help you @quasart, let me know.

@quasart
Copy link
Contributor Author

quasart commented May 30, 2021

Regarding the contours, you might be interested in https://pub.phyks.me/osm/cyclosm/ (see https://github.com/cyclosm/cyclosm-cartocss-style/blob/master/CONTRIBUTING.md#kosmtik). If you cannot make this work, I can output some renders.

thank you for your help

i managed to load this into my db, but I could not render coutour lines

Same thing with hillshade, i managed to generate shade file, but I could not make it visible

Would your db extract work with unchanged project.mml ?

i like your screenshots by the way

@Phyks
Copy link
Member

Phyks commented May 31, 2021

i managed to load this into my db, but I could not render coutour lines
Would your db extract work with unchanged project.mml ?

Indeed, these "getting started data" got out of sync with the production ones. For the sake of reusing previously built data, we adapted the SQL queries to a database that pre-existed on our production server: https://github.com/cyclosm/cyclosm-cartocss-style/blob/master/project.mml#L205-L211.

You could use a view such as to seamlessly use them with current codebase (not tested on my side, I don't have my laptop at hand to give it a try):

DROP VIEW IF EXISTS contours;
CREATE VIEW contours AS
(
  SELECT
    way AS geometry, ele AS height
  FROM planet_osm_line
) AS data;

I'll update the doc accordingly.

Also note that contours lines are disabled by default so you should opt-in through a Kosmtik localconfig (latest code sample from https://github.com/cyclosm/cyclosm-cartocss-style/blob/master/docs/INSTALL.md#create-the-contour-lines-database).

Same thing with hillshade, i managed to generate shade file, but I could not make it visible

Same for hillshades, we reused previously built tiff tiles for hillshades. They should be usable by loading only one version (https://pub.phyks.me/osm/cyclosm/hillshade-90.tif for the higher available resolution for instance) and building a dem/shade.vrt around it: https://github.com/cyclosm/cyclosm-cartocss-style/blob/master/project.mml#L190-L197.

Note that here again, hillshades are optional so you should opt-in by using a Kosmtik localconfig.

Let me know if you need any more infos, I'm happy to double check everything works fine and as intended here and update the doc which might have slipped out of sync with the codebase.

@quasart
Copy link
Contributor Author

quasart commented Jun 26, 2021

Even with your help I could not make it work...

I enabled hillshades and contours rendering.

I had to patch dem/contours.style to add ele tag.

I loaded contours db this way :

psql -c 'drop database contours;'
createdb contours
psql -d contours -c 'CREATE EXTENSION postgis;'
psql -d contours -c 'CREATE EXTENSION hstore;'
osm2pgsql -c --slim --drop --hstore -d contours --cache 5000 --style ./dem/contours.style ./data/contours-K30K31L30L31M30M31M32.osm.pbf 
psql -d contours -c "DROP VIEW contour;"
psql -d contours -c "CREATE VIEW contours AS SELECT way AS geometry, tags->'ele' AS height FROM planet_osm_line;"

When I replace a geometry value with a way linestring extracted from osm db, it's well rendered.
So database looks well loaded, and I'm sure rendering and db view are ok.
Wrong coordinate system maybe ? I don't find how to display these coordinates as lat/long.

contours=# select height,st_astext(geometry) from contours limit 1;
 height |                                                                                                                            st_astext                                                                                                                             
--------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
   2850 | LINESTRING(-52408.3368414959 5268634.98865658,-52404.9972567721 5268631.65547286,-52388.3327290004 5268541.65995918,-52408.3368414959 5268521.66107312,-52463.7182881656 5268541.65995918,-52453.3321796746 5268631.65547286,-52408.3368414959 5268634.98865658)
(1 row)

osm=# select st_astext(way) from planet_osm_line limit 1;
                                                                                                                                                                                st_astext                                                                                                                                                                                
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 LINESTRING(-143014.699038458 5976238.99125391,-143059.850223923 5976217.98349912,-143121.087075809 5976131.26559785,-143164.00073951 5976111.14297347,-143230.603190851 5976088.34940554,-143300.790129796 5976042.30363111,-143331.180350783 5976000.28912307,-143349.95994888 5975945.31334773,-143497.914684093 5975869.77343073,-143591.523243901 5975792.93968538)

About hillshade, here is what I run, but nothing displayed, I have no clue :

rm dem/shade.vrt 
gdalwarp -s_srs EPSG:4269 -t_srs "+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs" -r bilinear data/hillshade-1000.tif data/PROJ.tif
gdaldem hillshade -co compress=lzw -compute_edges data/PROJ.tif data/HILLSHADE.tif
gdaldem color-relief data/HILLSHADE.tif -alpha dem/shade.ramp data/SEMI-TRANSPARENT-HILLSHADE.tif
gdalbuildvrt dem/shade.vrt data/SEMI-TRANSPARENT-HILLSHADE.tif

@Phyks
Copy link
Member

Phyks commented Jul 22, 2021

Regarding the hillshades, when you run

gdaldem hillshade -co compress=lzw -compute_edges data/PROJ.tif data/HILLSHADE.tif

you get an empty tif image.

Starting from the tif images from pub.phyks.me (hillshade-1000.tif), I think you just have to:

gdaldem color-relief data/hillshade-1000.tif -alpha dem/shade.ramp data/OUT.tif

and then build a VRT, enable the layer in project.mml and get the render.

@Phyks
Copy link
Member

Phyks commented Jul 22, 2021

Regarding contours, from our production database, we have lines such as

                       st_astext

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 LINESTRING(-5002265.007118847 -140967.57184044205,-5002234.085038071 -140984.34505399413,-5002213.470317553 -140923.3866528537,-5002234.085038071 -140905.712579947,-5002265.007118847 -140902.76690103734,-5002311.390240011 -140923.3866528537,-5002265.007118847 -140967.57184044205)

They are supposed to be in Mercator projection, so you should be able to project them to WGS84 (lat/lon) with ST_Transform http://www.postgis.net/docs/ST_Transform.html.

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

Successfully merging this pull request may close these issues.

3 participants