** Make sure extent fits image window to be created. Returns cellsize of output image. */
| 664 | ** Make sure extent fits image window to be created. Returns cellsize of output image. |
| 665 | */ |
| 666 | double msAdjustExtent(rectObj *rect, int width, int height) |
| 667 | { |
| 668 | double cellsize, ox, oy; |
| 669 | |
| 670 | cellsize = MS_MAX(MS_CELLSIZE(rect->minx, rect->maxx, width), MS_CELLSIZE(rect->miny, rect->maxy, height)); |
| 671 | |
| 672 | if(cellsize <= 0) /* avoid division by zero errors */ |
| 673 | return(0); |
| 674 | |
| 675 | ox = MS_MAX(((width-1) - (rect->maxx - rect->minx)/cellsize)/2,0); /* these were width-1 and height-1 */ |
| 676 | oy = MS_MAX(((height-1) - (rect->maxy - rect->miny)/cellsize)/2,0); |
| 677 | |
| 678 | rect->minx = rect->minx - ox*cellsize; |
| 679 | rect->miny = rect->miny - oy*cellsize; |
| 680 | rect->maxx = rect->maxx + ox*cellsize; |
| 681 | rect->maxy = rect->maxy + oy*cellsize; |
| 682 | |
| 683 | return(cellsize); |
| 684 | } |
| 685 | |
| 686 | /* |
| 687 | ** Rect must always contain a portion of bounds. If not, rect is |
no outgoing calls
no test coverage detected