[Geoserver-users] Scalebar and scale ratio is wrong when using stateplane projection

Hello, all:
   We are using StatePlane 2927, whose unit is ft(US). When we used the map
decoration to display the scale line and scale ratio, we found that
Geoserver gave the wrong number and a wrong scale bar by default. The scale
bar is about 3.28 times longer than the length it should be. Obviously, the
map unit is somehow not picked up within Geoserver, although we have the
projection defined for the layer in the administration console.

   Any help appreciated!

Thanks!

Joe Liao

--
View this message in context: http://osgeo-org.1560.x6.nabble.com/Scalebar-and-scale-ratio-is-wrong-when-using-stateplane-projection-tp5155838.html
Sent from the GeoServer - User mailing list archive at Nabble.com.

Is it possible that your scale bar is in meters?

Ian

···

On 11 August 2014 18:59, joeliao <lxjiulxjiu@anonymised.com> wrote:

Hello, all:
We are using StatePlane 2927, whose unit is ft(US). When we used the map
decoration to display the scale line and scale ratio, we found that
Geoserver gave the wrong number and a wrong scale bar by default. The scale
bar is about 3.28 times longer than the length it should be. Obviously, the
map unit is somehow not picked up within Geoserver, although we have the
projection defined for the layer in the administration console.

Any help appreciated!

Thanks!

Joe Liao


View this message in context: http://osgeo-org.1560.x6.nabble.com/Scalebar-and-scale-ratio-is-wrong-when-using-stateplane-projection-tp5155838.html
Sent from the GeoServer - User mailing list archive at Nabble.com.



Geoserver-users mailing list
Geoserver-users@anonymised.comsts.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users


Ian Turton

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).
The calculation seems to be simple and I am still trying to figure out what
is the cause of this problem. Also, when using the Layer Preview in
GeoServer admin page, the map ratio shown on the lower left corner is wrong
too. By checking the source code, I found that the map unit is set to be
"m", which should be "ft". But the projection "EPSG:2927" is picked up
correctly. So, by default, there is something wrong with GeoServer code when
working with StatePlane projections (specifically 2927 here): the map unit
is not being read properly.

Thanks!

--
View this message in context: http://osgeo-org.1560.x6.nabble.com/Scalebar-and-scale-ratio-is-wrong-when-using-stateplane-projection-tp5155838p5156002.html
Sent from the GeoServer - User mailing list archive at Nabble.com.

What version of Geoserver are you using?

The next release of geoserver should have a big change about how scale is calculated - since there is a difference between the WMS scale calculation, and the scale you would expect when printed on a map.

It is not clear to me if this functionality is going to be in RC1. If we hit the button would you be available to test a nightly build?

···

Jody Garnett

On Mon, Aug 11, 2014 at 10:59 AM, joeliao <lxjiulxjiu@anonymised.com> wrote:

Hello, all:
We are using StatePlane 2927, whose unit is ft(US). When we used the map
decoration to display the scale line and scale ratio, we found that
Geoserver gave the wrong number and a wrong scale bar by default. The scale
bar is about 3.28 times longer than the length it should be. Obviously, the
map unit is somehow not picked up within Geoserver, although we have the
projection defined for the layer in the administration console.

Any help appreciated!

Thanks!

Joe Liao


View this message in context: http://osgeo-org.1560.x6.nabble.com/Scalebar-and-scale-ratio-is-wrong-when-using-stateplane-projection-tp5155838.html
Sent from the GeoServer - User mailing list archive at Nabble.com.



Geoserver-users mailing list
Geoserver-users@anonymised.comsts.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users

My GeoServer version is 2.4.1.

Sure, I would be more than happy to test the nightly build version.

Thanks!

--
View this message in context: http://osgeo-org.1560.x6.nabble.com/Scalebar-and-scale-ratio-is-wrong-when-using-stateplane-projection-tp5155838p5156027.html
Sent from the GeoServer - User mailing list archive at Nabble.com.

Yep, gap between WMS specification of scale and scale. I recall that WMS calculates scale based on the centre of the current map?

If you see that pull request - which will sadly be for the next release cycle - you should be able to build yourself a branch and let us know if the new scale calculation works for you?

···

Jody Garnett

On Tue, Aug 12, 2014 at 8:51 AM, 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).
The calculation seems to be simple and I am still trying to figure out what
is the cause of this problem. Also, when using the Layer Preview in
GeoServer admin page, the map ratio shown on the lower left corner is wrong
too. By checking the source code, I found that the map unit is set to be
“m”, which should be “ft”. But the projection “EPSG:2927” is picked up
correctly. So, by default, there is something wrong with GeoServer code when
working with StatePlane projections (specifically 2927 here): the map unit
is not being read properly.

Thanks!


View this message in context: http://osgeo-org.1560.x6.nabble.com/Scalebar-and-scale-ratio-is-wrong-when-using-stateplane-projection-tp5155838p5156002.html

Sent from the GeoServer - User mailing list archive at Nabble.com.



Geoserver-users mailing list
Geoserver-users@anonymised.comsts.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users

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

-------------------------------------------------------