<html><head><style>body{font-family:Helvetica,Arial;font-size:13px}</style></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;">There are a lot of non-scale preserving projections, I would think it would be difficult or impossible to accommodate them all and if you can't accommodate them all then it will be problematic to explain when the scaledenom is "correct" and when it isn't.  </div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;"><br></div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;">The scalebar rendered by MapServer does accurately reflect the ground scale as far as I know so I would think it would be possible to accurately compute the ground scale based on how the scalebar is rendered (independently of the projection perhaps).</div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;"><br></div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;">Another approach is to implement a great circle distance calculation like haversine or vicenty, reproject a point from the left and right edge in the center of the map to epsg:4326 and compute the real world distance across the pixel space, adjusting for the map's resolution.</div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;"><br></div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;">Cheers</div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;"><br></div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;">Paul</div> <div id="bloop_sign_1394156916800050944" class="bloop_sign"><span style="font-family:helvetica,arial;font-size:13px"></span>-- <br>Paul Spencer<br><span>Sent with Airmail</span></div> <div style="color:black"><br>From: <span style="color:black">Tamas Szekeres</span> <a href="mailto:szekerest@gmail.com">szekerest@gmail.com</a><br>Reply: <span style="color:black">Tamas Szekeres</span> <a href="mailto:szekerest@gmail.com">szekerest@gmail.com</a><br>Date: <span style="color:black">March 6, 2014 at 10:49:28 AM</span><br>To: <span style="color:black">mapserver-dev@lists.osgeo.org</span> <a href="mailto:mapserver-dev@lists.osgeo.org">mapserver-dev@lists.osgeo.org</a><br>Subject: <span style="color:black"> [mapserver-dev] Regarding to the scale calculation in MapServer <br></span></div><br> <blockquote type="cite" class="clean_bq"><span><div><div></div><div>



<title></title>


<div dir="ltr">Hi Devs,
<div><br></div>
<div>As far as I know certain projections require to modify the
scale regarding to the latitude of the given view. For latlong and
AFAIK for the web mercator (ie EPSG:3857, EPSG:900913) we might
require to use cos(latitude) as the correction factor. </div>
<div><br></div>
<div>With the current mapserver code, I don't see how this
requirement is taken into account. For the units=MS_DD, I can see
the following code fragment in the code in msInchesPerUnits (though
this is not compiled in by default)</div>
<div><br></div>
<div>
<pre style="font-family:Consolas,'Liberation Mono',Courier,monospace;font-size:12px;margin-top:0px;margin-bottom:0px;color:rgb(51,51,51);line-height:18px">
</pre>
<div class="" id="LC131" style="padding-left:10px"><span class="" style="color:rgb(153,153,153);font-weight:bold">#ifdef
ENABLE_VARIABLE_INCHES_PER_DEGREE</span></div>
<div class="" id="LC132" style="padding-left:10px">
      <span class="" style="font-weight:bold">if</span> <span class="" style="">(</span><span class="" style="">center_lat</span> <span class="" style="font-weight:bold">!=</span> <span class="" style="color:rgb(0,153,153)">0.0</span><span class="" style="">)</span>
<span class="" style="">{</span></div>
<pre>
</pre>
<div class="" id="LC133" style="padding-left:10px">
        <span class="" style="color:rgb(68,85,136);font-weight:bold">double</span>
<span class="" style="">cos_lat</span><span class="" style="">;</span></div>
<div class="" id="LC134" style="padding-left:10px">
        <span class="" style="">cos_lat</span> <span class="" style="font-weight:bold">=</span> <span class="" style="">cos</span><span class="" style="">(</span><span class="" style="">MS_PI</span><span class="" style="font-weight:bold">*</span><span class="" style="">center_lat</span><span class="" style="font-weight:bold">/</span><span class="" style="color:rgb(0,153,153)">180.0</span><span class="" style="">);</span></div>
<pre>
</pre>
<div class="" id="LC135" style="padding-left:10px">
        <span class="" style="">lat_adj</span> <span class="" style="font-weight:bold">=</span> <span class="" style="">sqrt</span><span class="" style="">(</span><span class="" style="color:rgb(0,153,153)">1</span><span class="" style="font-weight:bold">+</span><span class="" style="">cos_lat</span><span class="" style="font-weight:bold">*</span><span class="" style="">cos_lat</span><span class="" style="">)</span><span class="" style="font-weight:bold">/</span><span class="" style="">sqrt</span><span class="" style="">(</span><span class="" style="color:rgb(0,153,153)">2.0</span><span class="" style="">);</span></div>
<pre>
</pre>
<div class="" id="LC136" style="padding-left:10px">
      <span class="" style="">}</span></div>
<div class="" id="LC137" style="padding-left:10px"><span class="" style="color:rgb(153,153,153);font-weight:bold">#endif</span></div>
<pre>
</pre></div>
<div><br></div>
<div>Shouldn't the correction be applied for the web mercator
(units=MS_METERS) and probably for futher CRS-s as
well? </div>
<div><br></div>
<div>Should we anyway have <span style="color:rgb(153,153,153);font-family:Consolas,'Liberation Mono',Courier,monospace;font-size:12px;font-weight:bold;line-height:18px;white-space:pre">ENABLE_VARIABLE_INCHES_PER_DEGREE</span>
defined by default?</div>
<div><br></div>
<div>Best regards,</div>
<div><br></div>
<div>Tamas</div>
<div><br></div>
<div><br></div>
</div>


_______________________________________________
<br>mapserver-dev mailing list
<br>mapserver-dev@lists.osgeo.org
<br>http://lists.osgeo.org/mailman/listinfo/mapserver-dev</div></div></span></blockquote></body></html>