| 262 | } |
| 263 | |
| 264 | int msImagePolylineMarkers(imageObj *image, shapeObj *p, symbolObj *symbol, |
| 265 | symbolStyleObj *style, double spacing, int auto_angle) { |
| 266 | rendererVTableObj *renderer = MS_IMAGE_RENDERER(image); |
| 267 | int i,j; |
| 268 | pointObj point; |
| 269 | double original_rotation = style->rotation; |
| 270 | double symbol_width; |
| 271 | int ret = MS_FAILURE; |
| 272 | if(symbol->type != MS_SYMBOL_TRUETYPE) |
| 273 | symbol_width = MS_MAX(1,symbol->sizex*style->scale); |
| 274 | else { |
| 275 | rectObj rect; |
| 276 | if(MS_SUCCESS != renderer->getTruetypeTextBBox(renderer,symbol->full_font_path,style->scale, |
| 277 | symbol->character,&rect,NULL)) |
| 278 | return MS_FAILURE; |
| 279 | symbol_width=rect.maxx-rect.minx; |
| 280 | } |
| 281 | for(i=0; i<p->numlines; i++) |
| 282 | { |
| 283 | int line_in = 0; |
| 284 | double current_length = (spacing+symbol_width)/2.0; // initial padding for each line |
| 285 | double line_length=0; |
| 286 | for(j=1; j<p->line[i].numpoints; j++) |
| 287 | { |
| 288 | double rx,ry,theta,length; |
| 289 | int in; |
| 290 | length = sqrt((pow((p->line[i].point[j].x - p->line[i].point[j-1].x),2) + pow((p->line[i].point[j].y - p->line[i].point[j-1].y),2))); |
| 291 | line_length += length; |
| 292 | if(length==0)continue; |
| 293 | rx = (p->line[i].point[j].x - p->line[i].point[j-1].x)/length; |
| 294 | ry = (p->line[i].point[j].y - p->line[i].point[j-1].y)/length; |
| 295 | |
| 296 | if (auto_angle) { |
| 297 | theta = asin(ry); |
| 298 | if(rx < 0) { |
| 299 | theta += MS_PI; |
| 300 | } |
| 301 | else theta = -theta; |
| 302 | style->rotation = original_rotation + theta; |
| 303 | } |
| 304 | in = 0; |
| 305 | while (current_length <= length) { |
| 306 | |
| 307 | point.x = p->line[i].point[j - 1].x + current_length * rx; |
| 308 | point.y = p->line[i].point[j - 1].y + current_length * ry; |
| 309 | switch (symbol->type) { |
| 310 | case MS_SYMBOL_PIXMAP: |
| 311 | ret = renderer->renderPixmapSymbol(image, point.x, point.y, symbol, style); |
| 312 | break; |
| 313 | case MS_SYMBOL_ELLIPSE: |
| 314 | ret = renderer->renderEllipseSymbol(image, point.x, point.y, symbol, style); |
| 315 | break; |
| 316 | case MS_SYMBOL_VECTOR: |
| 317 | ret = renderer->renderVectorSymbol(image, point.x, point.y, symbol, style); |
| 318 | break; |
| 319 | case MS_SYMBOL_TRUETYPE: |
| 320 | ret = renderer->renderTruetypeSymbol(image, point.x, point.y, symbol, style); |
| 321 | break; |
no test coverage detected