[Benchmarking] Scale and pixel resolution formulas

Andrea Aime aaime at opengeo.org
Thu Aug 12 10:50:23 EDT 2010

Daniel Morissette ha scritto:
> Andrea Aime wrote:
>> Hi,
>> scale computation this year is going to make a difference
>> in tests so I'd like to make sure we're all on the same page,
>> otherwise servers will do a different amount of work.
>> The SLD spec suggests the following formulas for scale
>> denominator computation:
>> sd_non_geographic = (bbox_width / image_width) * (DPI / 0.0254)
>> sd_geographic = (bbox_width / OGC_DEG_TO_METER) * (DPI / 0.0.254)
>> DPI = 25.4 / 0.28  --> 90.714
>> OGC_DEG_TO_METER = 6378137.0 * 2.0 * PI / 360
>> The above are actually the formulas used by GeoServer.
>> As far as I know OpenLayers and MapServer use the same, but with
>> DPI=75.
>> To get the servers make the same work we all need to have a similar
>> scale computation setup. Are we? :-)
> For the record, MapServer's default DPI is 72, not 75. 

Whoops, sorry. I guess I'm not much of a MapServer user :-p

> However this is a
> configurable parameter and can very easily be changed to 90.714 in a
> mapfile.
> I had a quick look at MapServer's scale calculation code and constants,
> and it uses a variant of the formulas above with the constants based on
> inches-per-unit. This gives essentially the same results within a small
> margin of error.
> For instance, in the non-geographic case (projected coordinates in
> meters), we use 39.3701 inches per meter which means 0.025399986 meters
> per inch, compared to your 0.0254... not a significant difference.
> However, in the geographic case, we use 4374754 inches per degree and
> using your OGC_DEG_TO_METER I'd get 4382659.48 inches per degree... a
> difference of 0.18% ... not very significant either, but I thought I'd
> mention it.
> Note that this is based on a quick review of the code... I hope I did
> not make a mistake that would mislead you.
> Another important thing to note when calculating scales is that OGC uses
> a pixel edge to pixel edge model when specifying a BBOX ... i.e. the
> BBOX correspond to the extents of the outside of the pixels of the
> image. However some software, including MapServer's native (non-OGC)
> interface, use a pixel-center to pixel-center model. There are logical
> reasons for choosing this pixel-center model and other packages may have
> chosen to use it too. However this can lead to some scale differences
> when serving OGC requests and MapServer has been "fixed" to take this
> difference into account and make sure its OGC interfaces do the right thing.
> Just mentioning it so that other software packages double-check to make
> sure they are using the right model for their BBOX and scale calculations.

Thanks for the summary. Once the DPI has been adjusted I guess the two
servers will be have substantially the same: I don't believe the small
differences you mentioned will change many responses (if any at all).


Andrea Aime
OpenGeo - http://opengeo.org
Expert service straight from the developers.

More information about the Benchmarking mailing list