[mapserver-commits] r12733 - trunk/mapserver
svn at osgeo.org
svn at osgeo.org
Tue Nov 1 10:10:11 EDT 2011
Author: tbonfort
Date: 2011-11-01 07:10:11 -0700 (Tue, 01 Nov 2011)
New Revision: 12733
Modified:
trunk/mapserver/maprendering.c
Log:
add anchorpoint support for symbols along lines (#4071)
Modified: trunk/mapserver/maprendering.c
===================================================================
--- trunk/mapserver/maprendering.c 2011-11-01 13:57:20 UTC (rev 12732)
+++ trunk/mapserver/maprendering.c 2011-11-01 14:10:11 UTC (rev 12733)
@@ -267,16 +267,18 @@
int i,j;
pointObj point;
double original_rotation = style->rotation;
- double symbol_width;
+ double symbol_width,symbol_height;
int ret = MS_FAILURE;
- if(symbol->type != MS_SYMBOL_TRUETYPE)
+ if(symbol->type != MS_SYMBOL_TRUETYPE) {
symbol_width = MS_MAX(1,symbol->sizex*style->scale);
- else {
+ symbol_height = MS_MAX(1,symbol->sizey*style->scale);
+ } else {
rectObj rect;
if(MS_SUCCESS != renderer->getTruetypeTextBBox(renderer,symbol->full_font_path,style->scale,
symbol->character,&rect,NULL))
return MS_FAILURE;
symbol_width=rect.maxx-rect.minx;
+ symbol_height=rect.maxy-rect.miny;
}
for(i=0; i<p->numlines; i++)
{
@@ -311,6 +313,24 @@
point.x = p->line[i].point[j - 1].x + current_length * rx;
point.y = p->line[i].point[j - 1].y + current_length * ry;
+ if(symbol->anchorpoint_x != 0.5 || symbol->anchorpoint_y != 0.5) {
+ double ox, oy;
+ ox = (0.5 - symbol->anchorpoint_x) * symbol_width;
+ oy = (0.5 - symbol->anchorpoint_y) * symbol_height;
+ if(style->rotation != 0) {
+ double sina,cosa;
+ double rox,roy;
+ sina = sin(-style->rotation);
+ cosa = cos(-style->rotation);
+ rox = ox * cosa - oy * sina;
+ roy = ox * sina + oy * cosa;
+ point.x += rox;
+ point.y += roy;
+ } else {
+ point.x += ox;
+ point.y += oy;
+ }
+ }
switch (symbol->type) {
case MS_SYMBOL_PIXMAP:
ret = renderer->renderPixmapSymbol(image, point.x, point.y, symbol, style);
More information about the mapserver-commits
mailing list