I am trying to figure out what is the conversion formula between scale and resolution used by GeoServer, specifically when creating a new gridset for Tile Caching. One would expect that the conversion formula for a given resolution expressed in m/px would be:
ScaleDenominator = Resolution * (PPI / 0.0254)
However, I have discovered that the following formula gives exactly the correlation between scale and resolution found in GeoServer:
ScaleDenominator = Resolution * (90 / 0.0252)
The value of 90 for PPI is understandable because you can find in GeoServer's documentation (here) that
The OGC standard output resolution is 90 DPI.
However, I can't understand the value 0.0252. From my point of view there are 2 possibilities:
- Either there's a bug in GeoServer because 0.0252 is used for conversion between meters and inches, instead of 0.0254.
- Or GeoServer is correctly using a conversion ratio of 0.0254 between meters and inches, but it is using a PPI of 90.71428571428571, which doesn't make much sense to me either.
Can someone help with this? I am using GeoServer 2.13.1, and similar results have consistently been obtained when using different coordinate systems.
Answer
Looking at the code seems to indicate that GeoTools (and hence GeoServer) uses 0.0254 in the scale calculation.
public static double calculatePixelsPerMeterRatio(double scaleDenominator, Map hints) {
if (scaleDenominator <= 0.0)
throw new IllegalArgumentException("The scale denominator must be positive.");
double scale = 1.0 / scaleDenominator;
return scale * (getDpi(hints) / 0.0254);
}
and unless you have set a hint for the DPI you will be using 90.714 which is possibly to do with US vs International Inches.
public static double getDpi(Map hints) {
if (hints != null && hints.containsKey("dpi")) {
return ((Number) hints.get("dpi")).doubleValue();
} else {
return 25.4 / 0.28; // 90 = OGC standard
}
}
No comments:
Post a Comment