On Tue, Aug 12, 2014 at 5:51 PM, joeliao <lxjiulxjiu@anonymised.com> wrote:
I did not find any configuration for setting the units for the scale line.
I went into the code and found that the scaleDenominator is wrong, by which
I mean it is about 3.28 times bigger. I kept tracing the problem, and found
out that the scaleDenominator comes out from this calculation:
RendererUtilities.calculateOGCScale(getRenderingArea(),getRequest().getWidth(),hints).
I think you have simply found a bug that has been there for something like
10 years,
and that nobody every complained about.
The code is:
public static double calculateOGCScale(ReferencedEnvelope envelope, int
imageWidth, Map hints) {
// if it's geodetic, we're dealing with lat/lon unit measures
if(envelope.getCoordinateReferenceSystem() instanceof
GeographicCRS) {
return (envelope.getWidth() * OGC_DEGREE_TO_METERS) /
(imageWidth / getDpi(hints) * 0.0254);
} else {
return envelope.getWidth() / (imageWidth / getDpi(hints) *
0.0254);
}
}
Now, the geographic crs case is using a fixed conversion ratio that is
given by OGC,
and that ends up dividing:
(envelope.getWidth() * OGC_DEGREE_TO_METERS) -> meters
with:
imageWidth / getDpi(hints) * 0.0254 -> meters
However, in the case of projected CRS, we end up with:
envelope.getWidth() -> meters, feet, whatever the unit of measure of the
rendering is
over
(imageWidth / getDpi(hints) * 0.0254) -> meters
Which is obviously wrong for any CRS not expressed in meters, the scale
needs to be an adimensional number, and we end up with a value that's
expressed in feet over meters (or something else depending on the unit).
I'm going to fix this one right away but... I'll have to discuss how to
handle it.
The issue is, it has been there for such a long time, that just fixing it
will
ruin all scale dependent rules in existing SLD sheets, for those that do
upgrade.
Cheers
Andrea
--
GeoServer Professional Services from the experts! Visit
http://goo.gl/NWWaa2 for more information.
Ing. Andrea Aime
@geowolf
Technical Lead
GeoSolutions S.A.S.
Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy
phone: +39 0584 962313
fax: +39 0584 1660272
mob: +39 339 8844549
http://www.geo-solutions.it
http://twitter.com/geosolutions_it
-------------------------------------------------------