I guess we could recode it this way:

   public static boolean isWithInScale(final Rule r,final  double 
scaleDenominator) {
            return (scaleDenominator == -1)
            || ((r.getMinScaleDenominator() < scaleDenominator)
                && Math.abs(r.getMinScaleDenominator() - scaleDenominator) < 
BufferedImageLegendGraphicBuilder.TOLERANCE))
            && (r.getMaxScaleDenominator() > scaleDenominator);
   }

This should only match the rule that has the min scale set to 1000, maybe I 
need a coffee too :P

If we want to be very very (very) precise I guess we shoudl start using 
BigDecimal.

On 10/02/2017 02:02 PM, Andrea Aime wrote:
Hi Nuno,
say it was recoded the way you suggest, what would heppen if the are two rules 
using a max scale and min scale of 1000,
and someone asked exactly for a map at scale 1000?
It seems to me both rules would trigger anyways, which is not what we want... 
or do I need a coffee? :)

Cheers
Andrea


On Mon, Oct 2, 2017 at 2:53 PM, Nuno Oliveira <[email protected] 
<mailto:[email protected]>> wrote:

    Hi Andrea,

    I have a spend a couple of minutes looking at this expression:

        (((r.getMinScaleDenominator() - 
BufferedImageLegendGraphicBuilder.TOLERANCE) <= scaleDenominator)
        && ((r.getMaxScaleDenominator() + 
BufferedImageLegendGraphicBuilder.TOLERANCE) > scaleDenominator));

    In my point of view it only makes sense to use a tolerance value when 
checking for equality, does it make sense to use it
    for > and < operators ? I don't think so ...

    I always used tolerance for this kind of comparisons:

        boolean equal = Math.abs(r.getMinScaleDenominator() - scaleDenominator) 
< BufferedImageLegendGraphicBuilder.TOLERANCE;

    So as far I'm concerned the current usage of 
BufferedImageLegendGraphicBuilder.TOLERANCE is a bug and should be removed.

    Cheers,

    Nuno Oliveira


    On 10/01/2017 09:39 AM, Andrea Aime wrote:
    Hi,
    I was looking into this geoserver ticket:

    https://osgeo-org.atlassian.net/browse/GEOS-4923 
<https://osgeo-org.atlassian.net/browse/GEOS-4923>

    The reported correctly traces it to the logic used to decide is a rule is 
in scale range, and indeed the
    specification says:

    "The MinScaleDenominator and MaxScaleDenominator elements, as their names
    suggest, are simply the minimum and maximum ranges of scale (denominators) 
of maps
    for which a rule should apply. The minimum scale is inclusive and the 
maximum scale is
    exclusive"

    I checked if StreamingRenderer does the same, and indeed, it does. Went 
back with svn to
    the initial commit of "LiteRenderer" by yours truly in 2003 (I cannot find 
an older renderer package
    in there, we are talking about the original 2.0.x branch!) and the logic 
with tolerance was already there.

    Now... I can understand the tolerance, clients and servers are almost never 
computing
    the value with the exact same precision (think float vs double, or just 
slight variations in the expression
    setup), but indeed hitting a threshold scale exactly makes both rules to 
trigger...

    Soo... possible approaches:

      * Just remove the tolerances altoghether. Simple,clean, we'll get some 
users complaining that their client is stating a scale at which rules should 
trigger, and they don't
      * Remove it only from max scale denominator check? It's still possible to make the 
two rules trigger but getting at a value between target and "scale - tolerance"
      * Add some sophisticated logic that favours the min rules in case we have 
both? (but not fully sure how to write it)

    More ideas? Suggestions? Any takers?

    Cheers
    Andrea

    ==GeoServer Professional Services from the experts! Visit http://goo.gl/it488V for more 
information.==Ing. Andrea Aime @geowolfTechnical LeadGeoSolutions S.A.S.Via di Montramito 3/A55054  
Massarosa (LU)phone: +39 0584 962313 <tel:+39%200584%20962313>fax: +39 0584 1660272 
<tel:+39%200584%20166%200272>mob: +39  339 8844549 
<tel:+39%20339%20884%204549>http://www.geo-solutions.ithttp://twitter.com/geosolutions_it 
<http://twitter.com/geosolutions_it>

    AVVERTENZE AI SENSI DEL D.Lgs. 196/2003

    Le informazioni contenute in questo messaggio di posta elettronica e/o 
nel/i file/s allegato/i sono da considerarsi strettamente riservate. Il loro 
utilizzo è consentito esclusivamente al destinatario del messaggio, per le 
finalità indicate nel messaggio stesso. Qualora riceviate questo messaggio 
senza esserne il destinatario, Vi preghiamo cortesemente di darcene notizia via 
e-mail e di procedere alla distruzione del messaggio stesso, cancellandolo dal 
Vostro sistema. Conservare il messaggio stesso, divulgarlo anche in parte, 
distribuirlo ad altri soggetti, copiarlo, od utilizzarlo per finalità diverse, 
costituisce comportamento contrario ai principi dettati dal D.Lgs. 196/2003.

    The information in this message and/or attachments, is intended solely for 
the attention and use of the named addressee(s) and may be confidential or 
proprietary in nature or covered by the provisions of privacy act (Legislative 
Decree June, 30 2003, no.196 - Italy's New Data Protection Code).Any use not in 
accord with its purpose, any disclosure, reproduction, copying, distribution, 
or either dissemination, either whole or partial, is strictly forbidden except 
previous formal approval of the named addressee(s). If you are not the intended 
recipient, please contact immediately the sender by telephone, fax or e-mail 
and delete the information in this message that has been received in error. The 
sender does not give any warranty or accept liability as the content, accuracy 
or completeness of sent messages and accepts no responsibility  for changes 
made after they were sent or for other risks which arise as a result of e-mail 
transmission, viruses, etc.



    
------------------------------------------------------------------------------
    Check out the vibrant tech community on one of the world's most
    engaging tech sites, Slashdot.org!http://sdm.link/slashdot


    _______________________________________________
    Geoserver-devel mailing list
    [email protected] 
<mailto:[email protected]>
    https://lists.sourceforge.net/lists/listinfo/geoserver-devel 
<https://lists.sourceforge.net/lists/listinfo/geoserver-devel>

-- Regards,
    Nuno Oliveira
    ==
    GeoServer Professional Services from the experts! Visithttp://goo.gl/it488V 
 for more information.
    ==

    Nuno Miguel Carvalho Oliveira
    @nmcoliveira
    Software Engineer

    GeoSolutions S.A.S.
    Via di Montramito 3/A
    55054  Massarosa (LU)
    Italy
    phone:+39 0584 962313 <tel:+39%200584%20962313>
    fax:+39 0584 1660272 <tel:+39%200584%20166%200272>

    http://www.geo-solutions.it
    http://twitter.com/geosolutions_it <http://twitter.com/geosolutions_it>

    -------------------------------------------------------
    AVVERTENZE AI SENSI DEL D.Lgs. 196/2003
    Le informazioni contenute in questo messaggio di posta elettronica e/o 
nel/i file/s allegato/i sono da considerarsi strettamente riservate. Il loro 
utilizzo è consentito esclusivamente al destinatario del messaggio, per le 
finalità indicate nel messaggio stesso. Qualora riceviate questo messaggio 
senza esserne il destinatario, Vi preghiamo cortesemente di darcene notizia via 
e-mail e di procedere alla distruzione del messaggio stesso, cancellandolo dal 
Vostro sistema. Conservare il messaggio stesso, divulgarlo anche in parte, 
distribuirlo ad altri soggetti, copiarlo, od utilizzarlo per finalità diverse, 
costituisce comportamento contrario ai principi dettati dal D.Lgs. 196/2003.
The information in this message and/or attachments, is intended solely for the attention and use of the named addressee(s) and may be confidential or proprietary in nature or covered by the provisions of privacy act (Legislative Decree June, 30 2003, no.196 - Italy's New Data Protection Code).Any use not in accord with its purpose, any disclosure, reproduction, copying, distribution, or either dissemination, either whole or partial, is strictly forbidden except previous formal approval of the named addressee(s). If you are not the intended recipient, please contact immediately the sender by telephone, fax or e-mail and delete the information in this message that has been received in error. The sender does not give any warranty or accept liability as the content, accuracy or completeness of sent messages and accepts no responsibility for changes made after they were sent or for other risks which arise as a result of e-mail transmission, viruses, etc.


    
------------------------------------------------------------------------------
    Check out the vibrant tech community on one of the world's most
    engaging tech sites, Slashdot.org! http://sdm.link/slashdot
    _______________________________________________
    Geoserver-devel mailing list
    [email protected] 
<mailto:[email protected]>
    https://lists.sourceforge.net/lists/listinfo/geoserver-devel 
<https://lists.sourceforge.net/lists/listinfo/geoserver-devel>




--

Regards,

Andrea Aime

==GeoServer Professional Services from the experts! Visit http://goo.gl/it488V 
for more information.==Ing. Andrea Aime @geowolfTechnical LeadGeoSolutions 
S.A.S.Via di Montramito 3/A55054  Massarosa (LU)phone: +39 0584 962313fax: +39 
0584 1660272mob: +39  339 
8844549http://www.geo-solutions.ithttp://twitter.com/geosolutions_it

AVVERTENZE AI SENSI DEL D.Lgs. 196/2003

Le informazioni contenute in questo messaggio di posta elettronica e/o nel/i 
file/s allegato/i sono da considerarsi strettamente riservate. Il loro utilizzo 
è consentito esclusivamente al destinatario del messaggio, per le finalità 
indicate nel messaggio stesso. Qualora riceviate questo messaggio senza esserne 
il destinatario, Vi preghiamo cortesemente di darcene notizia via e-mail e di 
procedere alla distruzione del messaggio stesso, cancellandolo dal Vostro 
sistema. Conservare il messaggio stesso, divulgarlo anche in parte, 
distribuirlo ad altri soggetti, copiarlo, od utilizzarlo per finalità diverse, 
costituisce comportamento contrario ai principi dettati dal D.Lgs. 196/2003.

The information in this message and/or attachments, is intended solely for the 
attention and use of the named addressee(s) and may be confidential or 
proprietary in nature or covered by the provisions of privacy act (Legislative 
Decree June, 30 2003, no.196 - Italy's New Data Protection Code).Any use not in 
accord with its purpose, any disclosure, reproduction, copying, distribution, 
or either dissemination, either whole or partial, is strictly forbidden except 
previous formal approval of the named addressee(s). If you are not the intended 
recipient, please contact immediately the sender by telephone, fax or e-mail 
and delete the information in this message that has been received in error. The 
sender does not give any warranty or accept liability as the content, accuracy 
or completeness of sent messages and accepts no responsibility  for changes 
made after they were sent or for other risks which arise as a result of e-mail 
transmission, viruses, etc.


--
Regards,
Nuno Oliveira
==
GeoServer Professional Services from the experts! Visit http://goo.gl/it488V 
for more information.
==

Nuno Miguel Carvalho Oliveira
@nmcoliveira
Software Engineer

GeoSolutions S.A.S.
Via di Montramito 3/A
55054  Massarosa (LU)
Italy
phone: +39 0584 962313
fax:      +39 0584 1660272

http://www.geo-solutions.it
http://twitter.com/geosolutions_it

-------------------------------------------------------
AVVERTENZE AI SENSI DEL D.Lgs. 196/2003
Le informazioni contenute in questo messaggio di posta elettronica e/o nel/i 
file/s allegato/i sono da considerarsi strettamente riservate. Il loro utilizzo 
è consentito esclusivamente al destinatario del messaggio, per le finalità 
indicate nel messaggio stesso. Qualora riceviate questo messaggio senza esserne 
il destinatario, Vi preghiamo cortesemente di darcene notizia via e-mail e di 
procedere alla distruzione del messaggio stesso, cancellandolo dal Vostro 
sistema. Conservare il messaggio stesso, divulgarlo anche in parte, 
distribuirlo ad altri soggetti, copiarlo, od utilizzarlo per finalità diverse, 
costituisce comportamento contrario ai principi dettati dal D.Lgs. 196/2003.
The information in this message and/or attachments, is intended solely for the attention and use of the named addressee(s) and may be confidential or proprietary in nature or covered by the provisions of privacy act (Legislative Decree June, 30 2003, no.196 - Italy's New Data Protection Code).Any use not in accord with its purpose, any disclosure, reproduction, copying, distribution, or either dissemination, either whole or partial, is strictly forbidden except previous formal approval of the named addressee(s). If you are not the intended recipient, please contact immediately the sender by telephone, fax or e-mail and delete the information in this message that has been received in error. The sender does not give any warranty or accept liability as the content, accuracy or completeness of sent messages and accepts no responsibility for changes made after they were sent or for other risks which arise as a result of e-mail transmission, viruses, etc.

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Geoserver-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geoserver-devel

Reply via email to