mapnik / mapnik-support

Use the issues queue here to ask questions and offer help on using Mapnik (maybe if this works well we can retire the mailing list at http://mapnik.org/contact/?)
6 stars 6 forks source link

polygon pattern symbolizer and transform #129

Open HotPepperDaddy opened 4 years ago

HotPepperDaddy commented 4 years ago

Hi all,

I'm using 3.0.22 and transformations with polygon pattern symbolizer do not seem to have any effect. I'm using a png file and transformations are working fine using the point symbolizer. With polygon pattern symbolizer I don't get any error messages (logging is on), the pattern renders, but none of the transformations happen. I've tried scale, rotate, and translate.

Is there a known bug or are transformations not implemented for polygon pattern symbolizer?

Thanks!

talaj commented 4 years ago

Hi! There is a test for transforms and polygon patterns: https://github.com/mapnik/test-data-visual/blob/master/styles/geometry-transform-translate-patterns-svg.xml

Output seems to be affected by those transform params: https://github.com/mapnik/test-data-visual/blob/master/images/geometry-transform-translate-patterns-svg-200-200-1.0-agg-reference.png

HotPepperDaddy commented 4 years ago

Thanks, @talaj.

At least now I see that it's supposed to work. I just tried geometry-transform and can confirm that that's at least working for me. Now I'm trying to run that test myself to see if the test itself passes or fails. I have data and data-visual but when I run make test there's no output for the test in question and also nothing in the output images / html.

I tried running the test standalone but it doesn't seem to even be trying:

 ./test/visual/run --log debug --styles test/data-visual/styles/geometry-transform-translate-patterns-svg.xml -v
Mapnik LOG> 2019-11-01 10:21:03: registering: fonts/dejavu-fonts-ttf-2.37/ttf/DejaVuSerif-BoldItalic.ttf
Mapnik LOG> 2019-11-01 10:21:03: registering: fonts/dejavu-fonts-ttf-2.37/ttf/DejaVuSerif.ttf
Mapnik LOG> 2019-11-01 10:21:03: registering: fonts/dejavu-fonts-ttf-2.37/ttf/DejaVuSerifCondensed.ttf
Mapnik LOG> 2019-11-01 10:21:03: registering: fonts/dejavu-fonts-ttf-2.37/ttf/DejaVuSansMono-Oblique.ttf
Mapnik LOG> 2019-11-01 10:21:03: registering: fonts/dejavu-fonts-ttf-2.37/ttf/DejaVuMathTeXGyre.ttf
Mapnik LOG> 2019-11-01 10:21:03: registering: fonts/dejavu-fonts-ttf-2.37/ttf/DejaVuSansMono.ttf
Mapnik LOG> 2019-11-01 10:21:03: registering: fonts/dejavu-fonts-ttf-2.37/ttf/DejaVuSansCondensed-Bold.ttf
Mapnik LOG> 2019-11-01 10:21:03: registering: fonts/dejavu-fonts-ttf-2.37/ttf/DejaVuSerifCondensed-BoldItalic.ttf
Mapnik LOG> 2019-11-01 10:21:03: registering: fonts/dejavu-fonts-ttf-2.37/ttf/DejaVuSerif-Bold.ttf
Mapnik LOG> 2019-11-01 10:21:03: registering: fonts/dejavu-fonts-ttf-2.37/ttf/DejaVuSansMono-BoldOblique.ttf
Mapnik LOG> 2019-11-01 10:21:03: registering: fonts/dejavu-fonts-ttf-2.37/ttf/DejaVuSans-BoldOblique.ttf
Mapnik LOG> 2019-11-01 10:21:03: registering: fonts/dejavu-fonts-ttf-2.37/ttf/DejaVuSans-ExtraLight.ttf
Mapnik LOG> 2019-11-01 10:21:03: registering: fonts/dejavu-fonts-ttf-2.37/ttf/DejaVuSansMono-Bold.ttf
Mapnik LOG> 2019-11-01 10:21:03: registering: fonts/dejavu-fonts-ttf-2.37/ttf/DejaVuSansCondensed-BoldOblique.ttf
Mapnik LOG> 2019-11-01 10:21:03: registering: fonts/dejavu-fonts-ttf-2.37/ttf/DejaVuSans-Oblique.ttf
Mapnik LOG> 2019-11-01 10:21:03: registering: fonts/dejavu-fonts-ttf-2.37/ttf/DejaVuSerifCondensed-Bold.ttf
Mapnik LOG> 2019-11-01 10:21:03: registering: fonts/dejavu-fonts-ttf-2.37/ttf/DejaVuSansCondensed-Oblique.ttf
Mapnik LOG> 2019-11-01 10:21:03: registering: fonts/dejavu-fonts-ttf-2.37/ttf/DejaVuSansCondensed.ttf
Mapnik LOG> 2019-11-01 10:21:03: registering: fonts/dejavu-fonts-ttf-2.37/ttf/DejaVuSerifCondensed-Italic.ttf
Mapnik LOG> 2019-11-01 10:21:03: registering: fonts/dejavu-fonts-ttf-2.37/ttf/DejaVuSerif-Italic.ttf
Mapnik LOG> 2019-11-01 10:21:03: registering: fonts/dejavu-fonts-ttf-2.37/ttf/DejaVuSans-Bold.ttf
Mapnik LOG> 2019-11-01 10:21:03: registering: fonts/dejavu-fonts-ttf-2.37/ttf/DejaVuSans.ttf
Mapnik LOG> 2019-11-01 10:21:03: datasource_cache: Registered=gdal
Mapnik LOG> 2019-11-01 10:21:03: datasource_cache: Registered=shape
Mapnik LOG> 2019-11-01 10:21:03: datasource_cache: Registered=pgraster
Mapnik LOG> 2019-11-01 10:21:03: datasource_cache: Registered=raster
Mapnik LOG> 2019-11-01 10:21:03: datasource_cache: Registered=ogr
Mapnik LOG> 2019-11-01 10:21:03: datasource_cache: Registered=postgis
Mapnik LOG> 2019-11-01 10:21:03: datasource_cache: Registered=sqlite

Visual rendering: 0 failed / 0 passed / 0 overwritten / 0 errors

Any ideas? Thanks!

HotPepperDaddy commented 4 years ago

Update... I'm debugging using the python tests. It turns out my csv input plugin isn't working!

./visual.py geometry-transform-translate-patterns-svg
running test: render(geometry-transform-translate-patterns-svg.xml, {'status': True, 'grid': True, 'scales': [1.0, 2.0], 'agg': True, 'cairo': False, 'sizes': [(500, 100)]}, 1.0, <__main__.Reporting instance at 0xc626c8>)
Could not create datasource for type: 'csv' (searched for datasource plugins in '/opt/mapnik-3.0.20/lib/mapnik/input')  encountered during parsing of layer 'polygon' in Layer at line 54 of './data-visual/styles/geometry-transform-translate-patterns-svg.xml'
running test: render(geometry-transform-translate-patterns-svg.xml, {'status': True, 'grid': True, 'scales': [1.0, 2.0], 'agg': True, 'cairo': False, 'sizes': [(500, 100)]}, 2.0, <__main__.Reporting instance at 0xc626c8>)
Could not create datasource for type: 'csv' (searched for datasource plugins in '/opt/mapnik-3.0.20/lib/mapnik/input')  encountered during parsing of layer 'polygon' in Layer at line 54 of './data-visual/styles/geometry-transform-translate-patterns-svg.xml'

All 0 visual tests passed: ✓

I'll report back after fixing.

HotPepperDaddy commented 4 years ago

My problem with the csv input plugin was due to an outdated boost library on CentOS 7, which was 1.53. Luckily there's a 1.69 package available but that meant I had to rebuild mapnik and the python bindings. Good, those tests work now and I was able to run them and examine the output. I expected them to fail but they are the same as you posted.

What I've since discovered is that transform of scale, rotate, or translate has no effect with my png image with either global or local alignment. Geometry-transform works with translate but rotate and scale both look broken (that part doesn't matter to me).

I see that data-visual/styles/geometry-transform-translate-patterns.xml only shows off geometry-transform for pngs.

This all leads me to believe that transform isn't meant to work for png images in the polygon pattern symbolizer. FWIW I've tried different pngs such as data/images/satellite.png.

Shall I create another test case or modify geometry-transform-translate-patterns.xml?

Thanks for your help.

HotPepperDaddy commented 4 years ago

@talaj or anyone?

talaj commented 4 years ago

I looked into the code and transforms are really not implemented for raster patterns. What kind of transform would you like? Scaling can be done by preprocessing the pattern image.

HotPepperDaddy commented 4 years ago

If I were to use polygon pattern symbolizer to do this I would use scale and translate. In fact, I don't want to "pattern" the image at all. I want to scale it to fit the bounds of the polygon and align it to the centre.

Another approach would be to modify polygon symbolizer to take a file attribute to fill the polygon with.

It's not out of the question to pre process my images - in fact I am doing that. Right now I'm using one image per polygon and scaling it based on the zoom level (in that case using point symbolizer).

talaj commented 4 years ago

If you want to show just one image in the center of the polygon then point or marker symbolizer should be right for that. Polygon pattern symbolizer has nothing like center of the polygon.

HotPepperDaddy commented 4 years ago

In this case I want to fill the entire polygon with my image, not just show it in the centre.

In polygon pattern symbolizer could translate be used to modify the local alignment?