Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Round off on label on using SLD for GetLegendGraphic request on ncwms2 #128

Open
suman111sanjel opened this issue May 31, 2020 · 4 comments

Comments

@suman111sanjel
Copy link

Hi,

I am fetching GetLegendGraphic on thredds Data server 5 which uses ncWMS2. The problem is while fetching legend it round off 2.5 to 3.0 or so on on Legend i don't want to round off on legend.
rain

I want to label 1.0, 1.5, 2.0, 2.5, 3.0, 3.5 and so on
link:http://110.34.30.197:8080/thredds/wms/saldasforecast/monthly_std_ens3.ncml?REQUEST=GetLegendGraphic&SLD_BODY=%3C?xml%20version=%221.0%22%20encoding=%22ISO-8859-1%22?%3E%3CStyledLayerDescriptor%20version=%221.1.0%22%20xsi:schemaLocation=%22http://www.opengis.net/sldStyledLayerDescriptor.xsd%22%20xmlns=%22http://www.opengis.net/sld%22%20xmlns:ogc=%22http://www.opengis.net/ogc%22%20xmlns:se=%22http://www.opengis.net/se%22%20xmlns:xlink=%22http://www.w3.org/1999/xlink%22%20xmlns:xsi=%22http://www.w3.org/2001/XMLSchema-instance%22%3E%3CNamedLayer%3E%3Cse:Name%3ERainf_f_tavg%3C/se:Name%3E%3CUserStyle%3E%3Cse:Name%3EThesholded%20colour%20scheme%3C/se:Name%3E%3Cse:CoverageStyle%3E%3Cse:Rule%3E%3Cse:RasterSymbolizer%3E%3Cse:Opacity%3E1.0%3C/se:Opacity%3E%3Cse:ColorMap%3E%3Cse:Categorize%20fallbackValue=%22%2300000000%22%3E%3Cse:LookupValue%3ERasterdata%3C/se:LookupValue%3E%3Cse:Value%3E%2300000000%3C/se:Value%3E%3Cse:Threshold%3E-2.5%3C/se:Threshold%3E%3Cse:Value%3E%23C2523C%3C/se:Value%3E%3Cse:Threshold%3E-2%3C/se:Threshold%3E%3Cse:Value%3E%23FFAA01%3C/se:Value%3E%3Cse:Threshold%3E-1.5%3C/se:Threshold%3E%3Cse:Value%3E%23FFD380%3C/se:Value%3E%3Cse:Threshold%3E-1%3C/se:Threshold%3E%3Cse:Value%3E%23FEFF73%3C/se:Value%3E%3Cse:Threshold%3E-0.5%3C/se:Threshold%3E%3Cse:Value%3E%23E1E1E1%3C/se:Value%3E%3Cse:Threshold%3E0%3C/se:Threshold%3E%3Cse:Value%3E%23E1E1E1%3C/se:Value%3E%3Cse:Threshold%3E0.5%3C/se:Threshold%3E%3Cse:Value%3E%23E9FFBE%3C/se:Value%3E%3Cse:Threshold%3E1%3C/se:Threshold%3E%3Cse:Value%3E%237BED01%3C/se:Value%3E%3Cse:Threshold%3E1.5%3C/se:Threshold%3E%3Cse:Value%3E%2321DD00%3C/se:Value%3E%3Cse:Threshold%3E2%3C/se:Threshold%3E%3Cse:Value%3E%230ACC2E%3C/se:Value%3E%3Cse:Threshold%3E2.5%3C/se:Threshold%3E%3Cse:Value%3E%2317B568%3C/se:Value%3E%3Cse:Threshold%3E3%3C/se:Threshold%3E%3Cse:Value%3E%231E9B89%3C/se:Value%3E%3Cse:Threshold%3E3.5%3C/se:Threshold%3E%3Cse:Value%3E%231A828F%3C/se:Value%3E%3Cse:Threshold%3E4%3C/se:Threshold%3E%3Cse:Value%3E%23135784%3C/se:Value%3E%3Cse:Threshold%3E4.5%3C/se:Threshold%3E%3Cse:Value%3E%2300000000%3C/se:Value%3E%3C/se:Categorize%3E%3C/se:ColorMap%3E%3C/se:RasterSymbolizer%3E%3C/se:Rule%3E%3C/se:CoverageStyle%3E%3C/UserStyle%3E%3C/NamedLayer%3E%3C/StyledLayerDescriptor%3E&VERTICAL=false

Please Help me with this problem

Thank You
Suman Sanjel

@guygriffiths
Copy link
Contributor

Thanks for reporting this, it is a bug, I've just fixed it in c5dbe5c

@ghansham
Copy link

The above fix does not work in following case:

Assuming a range of 477 to 945.
The values for labels get calculated as 477, 594, 711, 828, 945.
sigfigs value gets calculated as 1. which rounds off 477 to 480 and 945 to 950.

int sigfigs = (int) Math.ceil(Math.log10(max / minDiff));

Can something be done to calculate it correctly?

@guygriffiths
Copy link
Contributor

If that's not accurate enough (and given a range of 500, a precision of 5 should be within the width of the label), you can add the colorBarOnly=true argument and create a legend client-side.

@ghansham
Copy link

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants