Hi Andreas, On Thu, Sep 27, 2012 at 1:59 PM, Andreas Neumann <[email protected]> wrote: > Hi, > > At the qgis-user list someone has asked on how to create road-shield labels. > > I came across http://linfiniti.com/2011/08/shield-labels-for-qgis/ > > but in current master I can't find a way to define a background shape or > background color (rectangular and not buffer). > > Did this never make it into master? > > I think that we should offer a way to create road shields in QGIS. > > Another option would be to user marker lines and allow SVG markers to > dynamically replace text in an SVG shield for more complex US-style road > shields ... > > Any ideas on how to accomplish this?
I am looking at implementing this as an addition to the new labeling engine (inside QgsPalLabeling, not inside of the PAL engine, per se). Basically, I think we can have a SVG 'shield' centered behind a label. (I'm thinking SVG Background, not shield, even though that's what it would be widely used for) That SVG background can also be scaled to match the size of the label text and its rotation. If there was an X and Y 'scale buffer' figured in, the shield would be scaled to the size of the label plus those buffers. Example: US Interstate Shield with a buffers of X = 10 and Y=4 would scale horizontally (before being rotated) to the width of the label + the 10 units (mm or map) on each side; while height-wise, there only needs to be enough buffer to ensure the top and bottom of the shield would be appropriately visible outside the text. The buffers would of course be relative to the SVG background chosen. Other options could include X/Y Offsets (offsetting the background so the label text is over a particular 'location' in the SVG) and Rotation (whether to rotate background with the label, or always stay upright or at particular angle while the label text still rotates). With the SVG as a background to the label (e.g. integrated with QgsLabelPosition), the label manipulation tools can be used to show/pin/move/rotate the label and background together. If the SVG background had its own data defined values for offset and rotation, it could be manipulated with new label background manipulation tools (though not sure how much use that tool would be to users). Lastly, it might be possible to also change the color of some SVG icons (say ones with specific elements that have a known id). This would allow the background to match other symbology colors, without requiring the creation of a separate SVG for each color. All of those options could be data defined as well. I was going to start in on this project after finishing what I can with the current updates to Advanced Labeling I have been doing. In my opinion, SVG backgrounds would be the last need-to-have feature in labeling before moving the entire labeling options setup to one based upon 'styles chosen by rules'. In that scenario, all separate labeling option groups could be saved as styles (e.g. Text, Buffer, Placement, etc.), then rules could be defined to select which groups of styles are applied to what features. Then, the labeling setup could be an extension of the rule-based symbology setup, or at least share some of its already-defined rules. (Integrating the symbology and labeling rule-based setups might be easier after a separate labeling rule-based setup exists.) Once the label styles system is available, styles can be saved/loaded from project to project. If anyone would like to collaborate with me, or possibly mentor my work, I would appreciate it. I understand the inner workings of the labeling engine pretty well now (enough to attempt the SVG backgrounds), but my C++ skills are quite new. I should be able to start in a couple of weeks. Regards, Larry > > Other blog posts on the topic: > http://underdark.wordpress.com/2011/10/10/interstate-shield-styles-in-qgis/ > - but without the dynamic SVG parameter style text replacement the road > nr is sort of hard-coded ... > > Andreas > _______________________________________________ > Qgis-developer mailing list > [email protected] > http://lists.osgeo.org/mailman/listinfo/qgis-developer _______________________________________________ Qgis-developer mailing list [email protected] http://lists.osgeo.org/mailman/listinfo/qgis-developer
