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

Alternative for comp-op="darken" #3653

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

Alternative for comp-op="darken" #3653

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

Comments

@Klaus-Tockloth
Copy link

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

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

More details are here: mapnik/mapnik#3749

@imagico
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
Copy link
Collaborator

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

@talaj
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
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
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
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
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
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
Copy link

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

@tomhughes
Copy link

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

Fixed in openstreetmap/chef@d95ea79.

@kocio-pl
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
Copy link

It already is, and I already tested it.

@kocio-pl
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
Copy link

talaj commented Feb 8, 2019

Also PDF seems OK to me now.

@kocio-pl
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!

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

No branches or pull requests

6 participants