<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr">
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Helvetica,sans-serif;" dir="ltr">
<p>Looks like you need to use the polygon extent to compute the rotation angle but then should use the extent of the rotated polygon for the map extent.</p>
<br>
<br>
<div style="color: rgb(0, 0, 0);">
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>From:</b> Travis Kirstine <traviskirstine@gmail.com><br>
<b>Sent:</b> Friday, September 8, 2017 9:23 PM<br>
<b>To:</b> Carlos Ruiz; Lime, Steve D (MNIT)<br>
<b>Cc:</b> mapserver-users@lists.osgeo.org<br>
<b>Subject:</b> Re: [mapserver-users] rotate and fit based on polygon</font>
<div> </div>
</div>
<div>
<div dir="ltr">Thanks Carlos, we've employed the method you've suggested already but not getting the results we are looking for, perhaps the linked image will help illustrate my problem  
<div><br>
</div>
<div><a href="https://drive.google.com/file/d/0BwWJtNuZjvCUR1AtVEZVLTdCbk0/view?usp=sharing" id="LPlnk523406" previewremoved="true">https://drive.google.com/file/d/0BwWJtNuZjvCUR1AtVEZVLTdCbk0/view?usp=sharing</a>
<div id="LPBorder_GT_15051372291650.8727405353615698" style="margin-bottom: 20px; overflow: auto; width: 100%; text-indent: 0px;">
<table id="LPContainer_15051372291600.3603570827078566" role="presentation" cellspacing="0" style="width: 90%; background-color: rgb(255, 255, 255); position: relative; overflow: auto; padding-top: 20px; padding-bottom: 20px; margin-top: 20px; border-top: 1px dotted rgb(200, 200, 200); border-bottom: 1px dotted rgb(200, 200, 200);">
<tbody>
<tr valign="top" style="border-spacing: 0px;">
<td id="ImageCell_15051372291620.34624081815300767" colspan="1" style="width: 250px; position: relative; display: table-cell; padding-right: 20px;">
<div id="LPImageContainer_15051372291620.0011786231671879754" style="background-color: rgb(255, 255, 255); height: 131px; position: relative; margin: auto; display: table; width: 250px;">
<a id="LPImageAnchor_15051372291620.42150285347609273" href="https://drive.google.com/file/d/0BwWJtNuZjvCUR1AtVEZVLTdCbk0/view?usp=sharing" target="_blank" style="display: table-cell; text-align: center;"><img id="LPThumbnailImageID_15051372291630.7844189899813239" width="250" height="131" style="display: inline-block; max-width: 250px; max-height: 250px; height: 131px; width: 250px; border-width: 0px; vertical-align: bottom;" src="https://lh6.googleusercontent.com/MLd9NjXDV9xuCgkbcx5555cQIqdUGvnuzkGeZhP51pN3RsEHd2FO5g=w1200-h630-p"></a></div>
</td>
<td id="TextCell_15051372291630.9012695044566943" colspan="2" style="vertical-align: top; position: relative; padding: 0px; display: table-cell;">
<div id="LPRemovePreviewContainer_15051372291630.23095537724909931"></div>
<div id="LPTitle_15051372291630.38170051193667653" style="top: 0px; color: rgb(0, 114, 198); font-weight: normal; font-size: 21px; font-family: wf_segoe-ui_light, "Segoe UI Light", "Segoe WP Light", "Segoe UI", "Segoe WP", Tahoma, Arial, sans-serif; line-height: 21px;">
<a id="LPUrlAnchor_15051372291640.707561782893569" href="https://drive.google.com/file/d/0BwWJtNuZjvCUR1AtVEZVLTdCbk0/view?usp=sharing" target="_blank" style="text-decoration: none;">rotate_image.jpg</a></div>
<div id="LPMetadata_15051372291640.3063628651195516" style="margin: 10px 0px 16px; color: rgb(102, 102, 102); font-weight: normal; font-family: wf_segoe-ui_normal, "Segoe UI", "Segoe WP", Tahoma, Arial, sans-serif; font-size: 14px; line-height: 14px;">
drive.google.com</div>
</td>
</tr>
</tbody>
</table>
</div>
<br>
<br>
</div>
<div> </div>
<div><br>
</div>
</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">On 8 September 2017 at 16:25, Carlos Ruiz <span dir="ltr">
<<a href="mailto:boolean10001@yahoo.com" target="_blank">boolean10001@yahoo.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex; border-left:1px #ccc solid; padding-left:1ex">
<div>
<div style="font-family:Helvetica Neue,Helvetica,Arial,sans-serif; font-size:13px">
<div style="font-family:Helvetica Neue,Helvetica,Arial,sans-serif; font-size:13px">
<div>
<div>Travis,</div>
<div><br>
</div>
<div>Do you have the polygons in PostGIS ? Maybe you can get the extent by using st_extent(geom) and retrieve it on PHP/Python to set the map extent. You could also get a margin by multiplying extent b 1.1 (10%).</div>
<div><br>
</div>
<br>
</div>
<div><br>
</div>
</div>
<div id="m_1727125107000336384ydpe0229a2fyahoo_quoted_4918075102" class="m_1727125107000336384ydpe0229a2fyahoo_quoted">
<div style="font-family:'Helvetica Neue',Helvetica,Arial,sans-serif; font-size:13px; color:#26282a">
<span class="">
<div>On Thursday, September 7, 2017, 1:27:06 PM CDT, Travis Kirstine <<a href="mailto:traviskirstine@gmail.com" target="_blank">traviskirstine@gmail.com</a>> wrote:
</div>
<div><br>
</div>
<div><br>
</div>
</span>
<div><span class="">
<div id="m_1727125107000336384ydpe0229a2fyiv0111190909">
<div dir="ltr">I have a bunch of polygons that represent 8.5 x 11 printed map sheets.  I'd like to produce images for each sheet that best fits the polygon within the outputted image.  We've tried using mapscript by setting the map extent based on the bbox
 of the source polygon and rotation but results aren't great depending on the orientation of the source polygon.  Is there a way to set the "extent" based on a polygon? </div>
</div>
</span>______________________________<wbr>_________________<br>
mapserver-users mailing list<br>
<a href="mailto:mapserver-users@lists.osgeo.org" rel="nofollow" target="_blank">mapserver-users@lists.osgeo.<wbr>org</a><br>
<a href="https://lists.osgeo.org/mailman/listinfo/mapserver-users" rel="nofollow" target="_blank">https://lists.osgeo.org/<wbr>mailman/listinfo/mapserver-<wbr>users</a></div>
</div>
</div>
</div>
</div>
</blockquote>
</div>
<br>
</div>
</div>
</div>
</div>
</body>
</html>