Oh wow - thanks so much for the response and the encouraging information! So
it sounds like if I want to start writing angled text now I'll have to be
brave and try building the Mapnik 2 trunk source? ;) 
This just leads me to make two further comments:

Firstly, thanks so much to everyone who is obviously putting so much work
into improving Mapnik - I'm delighted with the quality of the map images I
can produce in Mapnik 0.7.1 already, so with more features in v2 can only
make it even better. In fact, I have already seen several other features
which I think are in v2 that will make my life easier - namely SVG
symbolisers and "first-match" style rule matching. 
When I get a bit more proficient, I hope to be able to contribute back to
the Mapnik community myself (for one thing, when I finish my stylesheet for
the OS MM dataset I'll be happy to release that!). I'm still continuing my
attempts to make Mapnik talk to SQL Server via OGR, and if I ever find out
the solution, I'll be sure to share that too.

Secondly, just as a quick observation as a Mapnik newbie: the relative
status of Mapnik 2 and the current Mapnik 0.7.1 is a bit hazy. I think this
is perhaps caused by a number of factors: 
 - If v2.x is the successor to v0.7, what happened to the version 1.x
branch? Will there be any more changes going into the v0.7 branch, or is all
new development now happening against trunk? (I'm thinking of the Drupal
model that maintains two active branches at any time).
 - Most examples/build instructions etc. relate to the v0.7 branch (although
they might not explicitly say so) as being the current stable branch.
However, some applications seem to already be using the v2.0 branch in a
"production" environment (e.g. TileMill), suggesting that is already stable
for use.

So, (apart from the fact that there are no pre-compiled distributions, less
documentation available, etc.), would you recommend that any new developers
think about using the v2 trunk now? Presumeably, the more people are using
trunk, the faster any bugs can be found, and the quicker it will be to get a
v2 release?

Thanks again,
a.

-----Original Message-----
From: Dane Springmeyer [mailto:[email protected]] 
Sent: 04 August 2011 12:25 AM
To: Alastair Aitchison
Cc: [email protected]
Subject: Re: [Mapnik-users] TextSymbolizer - drawing text at an angle
relative to a point?


On Aug 2, 2011, at 1:47 PM, Alastair Aitchison wrote:

> Hi list,
>  
> I'm trying to plot OS Mastermap data using Mapnik, and am having a bit of
trouble with the placement of the cartographic labels.
> Rather than having the labels sourced from shape attributes, the dataset
defines all label text as separate features with:
> - a point location
> - the anchor location of the text relative to the point (i.e. Top left,
Middle bottom etc.)
> - the angle at which the text should be oriented (rather curiously,
measured as an integer value in 10ths of a degree from 0 - 3599)
>  
> If I use a TextSymbolizer with placement=point, then I can place the
labels at the correct position relative to the point using a combination of
the vertical_alignment and dx/dy properties, but there doesn't seem to be
any way to specify the angle at which the text should be drawn. (i.e.
there's no equivalent to MapServer's ANGLE property)

Mapnik2/trunk does support angles, and reading them from a database field.
So, this will be available in the next release.

Also Hermann Krauses recent work, also just in the trunk development code,
has support for anchors:
http://mapnik.org/news/2011/jul/13/new_text_placement_system/

>  
> So, instead, I've been applying some old-school trigonmetry to
artificially create lines at the appropriate angle, either starting or
ending at the anchor point in question, and drawing the text on the line
using a TextSymbolizer with the placement=line model instead. It's a lot
slower, since it's probably invoking lots of clever "wrapping text to wiggly
lines" computations that aren't required for my single line segment
scenario, but it does (nearly) get the results I want.
> The problem I now have is that, by using the placement=line model, I
appear to have sacrificed the ability to specify whereabouts along the line
the label gets placed - there is no horizontal-alignment attribute when
using a TextSymbolizer on a line as far as I can tell - the label is always
placed in the centre of the line.

Yes, unfortunately horizontal-alignment is not yet implemented for line
placement.

> That means the only way I can get the label drawn in the right place is if
I create the line to be exactly of the right length for the label to fit. If
I create it too big, the label is effectively "padded" away from its anchor
point (which lies at one end of the line) and misplaced. But, if I create
the line too small, the TextSymbolizer label attached to it won't be
rendered at all. The problem is that, seeing as I'm using a non-fixed width
font, the length of the text string (and therefore the offset) is different
for every individual label - I've tried computing an approximate line length
per length of label, but it's not reliable enough to be used.
>  
> Does anybody have any smart workarounds (or perhaps, a magical text-angle
property that I'm unaware of!) as to how to create angled text anchored to a
point?

See above! :)

>  
> Thanks!
> _______________________________________________
> Mapnik-users mailing list
> [email protected]
> https://lists.berlios.de/mailman/listinfo/mapnik-users

-----
No virus found in this message.
Checked by AVG - www.avg.com
Version: 10.0.1390 / Virus Database: 1518/3807 - Release Date: 08/03/11

_______________________________________________
Mapnik-users mailing list
[email protected]
https://lists.berlios.de/mailman/listinfo/mapnik-users

Reply via email to