| 485 | } |
| 486 | |
| 487 | symbolObj* rotateVectorSymbolPoints(symbolObj *symbol, double angle_rad) { |
| 488 | double dp_x, dp_y, xcor, ycor; |
| 489 | double sin_a, cos_a; |
| 490 | double minx,miny,maxx,maxy; |
| 491 | symbolObj *newSymbol; |
| 492 | double TOL=0.00000000001; |
| 493 | int i; |
| 494 | |
| 495 | angle_rad = -angle_rad; |
| 496 | |
| 497 | newSymbol = (symbolObj *) msSmallMalloc(sizeof(symbolObj)); |
| 498 | msCopySymbol(newSymbol, symbol, NULL); |
| 499 | |
| 500 | sin_a = sin(angle_rad); |
| 501 | cos_a = cos(angle_rad); |
| 502 | |
| 503 | dp_x = symbol->sizex * .5; /* get the shift vector at 0,0 */ |
| 504 | dp_y = symbol->sizey * .5; |
| 505 | |
| 506 | /* center at 0,0 and rotate; then move back */ |
| 507 | for( i=0;i < symbol->numpoints;i++) { |
| 508 | /* don't rotate PENUP commands (TODO: should use a constant here) */ |
| 509 | if ((symbol->points[i].x == -99.0) && (symbol->points[i].x == -99.0) ) { |
| 510 | newSymbol->points[i].x = -99.0; |
| 511 | newSymbol->points[i].y = -99.0; |
| 512 | continue; |
| 513 | } |
| 514 | |
| 515 | newSymbol->points[i].x = dp_x + ((symbol->points[i].x-dp_x)*cos_a - (symbol->points[i].y-dp_y)*sin_a); |
| 516 | newSymbol->points[i].y = dp_y + ((symbol->points[i].x-dp_x)*sin_a + (symbol->points[i].y-dp_y)*cos_a); |
| 517 | } |
| 518 | |
| 519 | /* get the new bbox of the symbol, because we need it to get the new dimensions of the new symbol */ |
| 520 | get_bbox(newSymbol->points, newSymbol->numpoints, &minx, &miny, &maxx, &maxy); |
| 521 | if ( (fabs(minx)>TOL) || (fabs(miny)>TOL) ) { |
| 522 | xcor = minx*-1.0; /* symbols always start at 0,0 so get the shift vector */ |
| 523 | ycor = miny*-1.0; |
| 524 | for( i=0;i < newSymbol->numpoints;i++) { |
| 525 | if ((newSymbol->points[i].x == -99.0) && (newSymbol->points[i].x == -99.0)) |
| 526 | continue; |
| 527 | newSymbol->points[i].x = newSymbol->points[i].x + xcor; |
| 528 | newSymbol->points[i].y = newSymbol->points[i].y + ycor; |
| 529 | } |
| 530 | |
| 531 | /* update the bbox to get the final dimension values for the symbol */ |
| 532 | get_bbox(newSymbol->points, newSymbol->numpoints, &minx, &miny, &maxx, &maxy); |
| 533 | } |
| 534 | newSymbol->sizex = maxx; |
| 535 | newSymbol->sizey = maxy; |
| 536 | return newSymbol; |
| 537 | } |
| 538 | |
| 539 | int renderVectorSymbolGD(imageObj *img, double x, double y, symbolObj *symbol, symbolStyleObj *style) { |
| 540 | int bRotated = MS_FALSE; |
no test coverage detected