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

Extend PointSymbolizer to support image scaling #155

Closed
artemp opened this issue Oct 11, 2011 · 15 comments
Closed

Extend PointSymbolizer to support image scaling #155

artemp opened this issue Oct 11, 2011 · 15 comments
Assignees
Labels
Milestone

Comments

@artemp
Copy link
Member

artemp commented Oct 11, 2011

This ticket is an enhancement request to look into new design options around adding more flexibility to or extending the PointSymbolizer.

Currently the behavior of the width and height parameters seems both redundant (see Ticket #60) and non-intuitive. Setting width and height to any dimensions other than the exact dimensions of the input graphic file crops the graphic rather than scaling the image (which would be my expected behavior).

Ideally support for scaling vector graphics could be added to allow things to be done with the PointSymbolizer related to thematic display of point data, similar to this request:
http://www.mail-archive.com/dev@openstreetmap.org/msg04395.html

@artemp
Copy link
Member Author

artemp commented Oct 11, 2011

[springmeyer] Also see Ticket #60

@artemp
Copy link
Member Author

artemp commented Oct 11, 2011

[tomh] Are you saying that the Agg renderer does scale symbols and the Cairo renderer doesn't? Is this a new feature in the Agg renderer? or something I missed when doing Cairo?

@artemp
Copy link
Member Author

artemp commented Oct 11, 2011

[springmeyer] Whoops, I didn't mean to tag that as only component cairo.

This enhancement, I assume, would affect both renderers.

@artemp
Copy link
Member Author

artemp commented Oct 11, 2011

[ajturner] I've started digging into this - but haven't yet figured out in Agg where to do the scaling transformation.

More generally it would be good to expose mechanisms similar to KML's styling support: scale, 'hotspot' location (where to center the image), color overlay.

@artemp
Copy link
Member Author

artemp commented Oct 11, 2011

[springmeyer] Another relevant thread relating to extending the PointSymbolizer:

@artemp
Copy link
Member Author

artemp commented Oct 11, 2011

[springmeyer] A few likely relevant sources:

  • source:trunk/include/mapnik/stroke.hpp
  • source:trunk/src/stroke.cpp
  • source:trunk/include/mapnik/point_symbolizer.hpp
  • source:trunk/src/point_symbolizer.cpp
  • source:trunk/src/symbolizer.cpp
  • source:trunk/include/mapnik/symbolizer.hpp
  • source:trunk/src/png_reader.cpp
  • source:trunk/src/graphics.cpp

@artemp
Copy link
Member Author

artemp commented Oct 11, 2011

[springmeyer] FYI: Recent vector label action here: http://trac.osgeo.org/mapserver/log/trunk/mapserver/mapagg.cpp

@artemp
Copy link
Member Author

artemp commented Oct 11, 2011

[ajturner] I have this somewhat working in my local copy. I'll try and clean up into a patch and submit

@artemp
Copy link
Member Author

artemp commented Oct 11, 2011

[semprebon] I've taken ajturner's changes and updated them for version 0.6.0.

@artemp
Copy link
Member Author

artemp commented Oct 11, 2011

[springmeyer] Fantastic,
Thanks for the patch.

One thing I noticed right off is that we'll also need property serialization added to source:trunk/src/save_map.cpp as well.

Nice job adding it to source:trunk/src/load_map.cpp

@artemp
Copy link
Member Author

artemp commented Oct 11, 2011

[springmeyer] Okay, so I've given the patch an initial review.

Overall I'm not sure, after thinking more about the PointSymbolizer as it is currently used, that scaling support should be added to the PointSymbolizer.

If the goal is scaling raster icons/graphics read from the filesystem then this is useful. However if the goal is proper proportional symbology (this is a feature I'd like to see and I'm assuming you are after, but correct me..) of graphics primitives (circles, rectangles, ellipses, etc) then it seems more logical to write this functionality into a new symbolizer that would accept arguments like:

{{{

}}}

Perhaps the actual arguments should stick to the svg spec: http://www.w3.org/TR/SVG11/shapes.html ?

Thoughts?

@artemp
Copy link
Member Author

artemp commented Oct 11, 2011

[springmeyer] Okay, if a full blown symbolizer that supports constructing graphics primitives is not what you are after, the existing patch still needs some improvement.

These things have been fixed in my revised patch:

  • Typo in 'opcity' in include/mapnik/point_symbolizer.hpp
  • 'color' parameter not exposed in python
  • 'color' parameter should be optional
  • fixed a few mixed tabs and spaces
  • because 'color' was not optional existing graphic symbols were made all white even if color param was not supplied

I've tested the revised patch with this sample XML and symbol:
http://mapnik-utils.googlecode.com/svn/sandbox/point_opacity/

It now renders original symbol correctly if the 'color' and 'scale' parameters are not used.

And it works to scale the symbol up or down and apply a color to it.

Problems:

  • overall design decision needed on approach (put more effort into PointSymbolizer or direct a new one)
  • placement finder is not sensitive to symbol size
  • Cairo bindings are crashing python
  • 'color' param should be called 'fill' throughout

@artemp
Copy link
Member Author

artemp commented Oct 11, 2011

[rcoup] This patch seems to have gone a little off-course. When Craig & I were looking at scaling in #320, the outcome was to:

  • make width & height optional, since the PNG/SVG readers are perfectly capable of figuring it out themselves.
  • if neither are specified, draw as "original size" (px for raster symbols, "document units" for SVG ones)
  • if one is specified, scale proportionally to fit in that size
  • if both are specified, scale un-proportionately.

Cairo helpfully supports internal scaling via it's matrix, agg needs to use the stuff in image_util.hpp.

The scale parameter seems redundant, since I can't figure out any use cases for cropping symbols (anyone?), and it'll require a user to calculate it from the desired image width & height anyway.

Adding color is a bit OT for this ticket and should probably be handled separately.

@artemp
Copy link
Member Author

artemp commented Oct 11, 2011

[springmeyer] rcoup - I fully agree.

@ghost ghost assigned artemp and springmeyer Jul 16, 2012
@springmeyer
Copy link
Member

solved by #1311 and #1361, closing.

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

2 participants