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

Alternative for comp-op="darken" #3653

Closed
Klaus-Tockloth opened this Issue Jan 21, 2019 · 19 comments

Comments

Projects
None yet
6 participants
@Klaus-Tockloth
Copy link

Klaus-Tockloth commented Jan 21, 2019

The current style (4.19) uses the feature 'comp-op="darken"' three times:

<Style name="admin-low-zoom" filter-mode="first" comp-op="darken" opacity="0.4">
<Style name="admin-mid-zoom" filter-mode="first" comp-op="darken" opacity="0.5">
<Style name="admin-high-zoom" filter-mode="first" comp-op="darken" opacity="0.5">

Question: Is there an alternative to achieve a similar result?

Background: "comp-op" prevents mapnik/carto to create a svg file with "proper" vector data.
Instead a svg file with an (huge) embedded png map (base64 encoded) will be created. Same problem for pdf.

@kocio-pl kocio-pl added the code label Jan 21, 2019

@kocio-pl kocio-pl added this to the Bugs and improvements milestone Jan 21, 2019

@kocio-pl

This comment has been minimized.

Copy link
Collaborator

kocio-pl commented Jan 21, 2019

I have heard complaints about SVG export at least 2 times on forum and on help.osm.org, I would be happy if this problem could be fixed. Anybody interested in fixing this?

@Klaus-Tockloth

This comment has been minimized.

Copy link
Author

Klaus-Tockloth commented Jan 21, 2019

More details are here: mapnik/mapnik#3749

@imagico

This comment has been minimized.

Copy link
Collaborator

imagico commented Jan 21, 2019

To my knowledge the only other way to get consistent rendering of admin boundaries with semi-transparency is by preprocessing the data. This is a workable approach but not necessarily a desirable one here.

@sommerluk

This comment has been minimized.

Copy link
Collaborator

sommerluk commented Jan 23, 2019

Does mapnik/mapnik#4012 help here? Is part of the newest Mapnik release 3.0.22…

@talaj

This comment has been minimized.

Copy link

talaj commented Feb 8, 2019

It seems like comp-op is only available in Cairo SVG surface for SVG version >= 1.2, see behdad/cairo@5336cf5. Since Mapnik outputs SVG with version="1.1", I think this is the culprit.

On the other hand PDF with comp-op="darken" should be rendered correctly. I tried that with Mapnik 3.0.x and Cairo 1.15.

@talaj

This comment has been minimized.

Copy link

talaj commented Feb 8, 2019

Yes, SVG 1.1 is the default standard for Cairo SVG Surface. How I could overlook that 😠!

https://github.com/behdad/cairo/blob/7a923b1ff5bf3e2b79ce4f2fe14d352faef5bccb/src/cairo-svg-surface.c#L276

@talaj

This comment has been minimized.

Copy link

talaj commented Feb 8, 2019

Is this ancient script still being used for export to PDF and SVG?
https://trac.openstreetmap.org/browser/sites/tile.openstreetmap.org/cgi-bin/export

If yes, to allow comp-op in SVG, this has to be put after line 120 of the script:

surface.restrict_to_version(cairo.SVG_VERSION_1_2)

At least PyCairo 1.12.0 is needed: https://pycairo.readthedocs.io/en/latest/reference/surfaces.html#cairo.SVGSurface.restrict_to_version

Or is that script somewhere in git?

@kocio-pl

This comment has been minimized.

Copy link
Collaborator

kocio-pl commented Feb 8, 2019

Thanks for investigating the issue!

OSM website has its own repository, I guess this is where the export might be coded or called from:

https://github.com/openstreetmap/openstreetmap-website

@talaj

This comment has been minimized.

Copy link

talaj commented Feb 8, 2019

The website redirects to /cgi-bin/export, but I cannot find the export script in that repository:
https://github.com/openstreetmap/openstreetmap-website/blob/master/app/controllers/export_controller.rb#L23

@kocio-pl

This comment has been minimized.

Copy link
Collaborator

kocio-pl commented Feb 8, 2019

Hm, I am not sure where people get vector exports from, since by default it's just .osm file format. I opened a ticket here: openstreetmap/operations#270.

@tomhughes

This comment has been minimized.

Copy link

tomhughes commented Feb 8, 2019

This is mapnik/mapnik#3749 which has a PR opened today in mapnik/mapnik#4029.

@tomhughes

This comment has been minimized.

Copy link

tomhughes commented Feb 8, 2019

The script is https://github.com/openstreetmap/chef/blob/master/cookbooks/tile/templates/default/export.erb by the way, and as we're actually creating the surface ourselves in python I guess we can fix this in the script by setting the version on the surface?

@talaj

This comment has been minimized.

Copy link

talaj commented Feb 8, 2019

Yes @tomhughes, Ubuntu Bionic has python-cairo 1.16.2, so we can just call surface.restrict_to_version(cairo.SVG_VERSION_1_2) there.

@tomhughes

This comment has been minimized.

Copy link

tomhughes commented Feb 8, 2019

@kocio-pl

This comment has been minimized.

Copy link
Collaborator

kocio-pl commented Feb 8, 2019

Nice! When this change will became operational and how to make a simple test if this really works?

@tomhughes

This comment has been minimized.

Copy link

tomhughes commented Feb 8, 2019

It already is, and I already tested it.

@kocio-pl

This comment has been minimized.

Copy link
Collaborator

kocio-pl commented Feb 8, 2019

So can we just safely close this ticket now? Because as I understand the reporter, his aim was to allow vector exports, not a code change in itself.

@talaj

This comment has been minimized.

Copy link

talaj commented Feb 8, 2019

Also PDF seems OK to me now.

@kocio-pl

This comment has been minimized.

Copy link
Collaborator

kocio-pl commented Feb 8, 2019

Oh, I was thinking about "Export" button on top, while this function is available from "Share" button on the right... It's a small usability glitch for me. However both PDF and SVG work for me, so I'm closing it now. If there will be further problems to discuss, it can be reopened.

Thanks, guys!

@kocio-pl kocio-pl closed this Feb 8, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment