Hi Go and Andrea

I would be happy to take on the task of implementing this fix if it would be of assistance - I need the practice getting my head around the submission process better and this would be a good way for me to do that.

Please could you both let me know if you would like me to do this.

BTW, my investigation suggests that the bug is actually in the org.geotools.filter.function.StaticGeometry class and is easily illustrated by:

    System.out.println(StaticGeometry.greaterEqualThan("2", "0"));
    System.out.println(StaticGeometry.greaterEqualThan("3", "0"));

which outputs

true
false

which is consistent with Go's original investigation. I suspect this is caused by a historic change to the compareTo method in java.lang.String.

Andrea's delegation suggestion would obviously bypass this completely, but I suggest it would also be worthwhile fixing the StaticGeometry class as well? Thoughts?

Again, both Go and Andrea please let me know if you would like me to take the task of creating a pull request for this and I will happily take this on.

Cheers
Iain


On 8/10/2016 1:52 a.m., Andrea Aime wrote:
Hi Go,
I would actually scrap the contents of those functions entirely and make them delegate to the same named filter objects, that do already have the logic you're looking for. This is the base class, it has many subclasses for each comparison implementation:
https://github.com/geotools/geotools/blob/master/modules/library/main/src/main/java/org/geotools/filter/CompareFilterImpl.java#L91

The devs are way beyond busy (too many users, too many suggestions/reports, not enough devs) any chance you can make a pull request?

Cheers
Andrea


On Fri, Oct 7, 2016 at 1:55 PM, Sato, Go <[email protected] <mailto:[email protected]>> wrote:

    Hello,

    This is my first post to this mailing list. My name is Go and I am
    working for a civil engineering firm developing web applications
    with GeoServer.

    Recently, I have bumped into an issue when building a SLD for
    GeoServer which is reported here in detail.

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

    Out of curiosity, I have attempted to debug geotools to get to the
    bottom by myself. The quickstart guide was very helpful.

    What I found was, in case of greaterEqualThan filter,
    org.geotools.filter.function.FilterFunction_greaterEqualThan.evaluate()
    receives expressions as strings and then evaluates them as strings
    and finally passes strings to
    org.geotools.filter.function.StaticGeometry.greaterEqualThan().

    So, no matter which I define numeric params as ogc:Literal or
    ogc:Function in the SLD, FilterFunction_greaterEqualThan always
    performs comparisons in lexicographical order. The same issue was
    found in greaterThan, lessEqualThan and lessThan filters.

    To make numeric comparisons happen in these filters, I would
    suggest to change their behaviours to make comparisons in
    lexicographic ordering only when either one of the expressions
    were non-numeric. Otherwise, I think there is very limited use for
    these comparison filters in layer styling.

    The patch will be like the following for all greaterEqualThan,
    greaterThan, lessEqualThan and lessThan

    Replace lines 46 – 60 of
    
geotools/modules/library/main/src/main/java/org/geotools/filter/function/FilterFunction_greaterEqualThan.java
    with

    try { // attempt to get values as numbers and perform conversion

    arg0 = (Object) getExpression(0).evaluate(feature,
    Long.class).longValue();

    arg1 = (Object) getExpression(1).evaluate(feature,
    Long.class).longValue();

     } catch (Exception wereNotNumbers) // probably a type error

    {

    try { // attempt to get value and perform conversion

    arg0 = (Object) getExpression(0).evaluate(feature);

    } catch (Exception e) // probably a type error

    {

    throw new IllegalArgumentException(

    "Filter Function problem for function greaterEqualThan argument #0
    - expected type Object");

    }

    try { // attempt to get value and perform conversion

    arg1 = (Object) getExpression(1).evaluate(feature);

    } catch (Exception e) // probably a type error

    {

    throw new IllegalArgumentException(

    "Filter Function problem for function greaterEqualThan argument #1
    - expected type Object");

    }

    }

    Thank you for your consideration in advance.

    *WSP_PB_Logo_RGB-192*

    **

    *Go Sato*

    GIS Developer | Smart Consulting

    WSP Parsons Brinckerhoff in the UK

    Email: [email protected] <mailto:[email protected]>

    www.wsp-pb.com <http://www.wsp-pb.com/>




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




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

Ing. Andrea Aime
@geowolf
Technical Lead

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

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.


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


This body part will be downloaded on demand.


This body part will be downloaded on demand.

--
Sent from my ZX80



---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most 
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
GeoTools-Devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-devel

Reply via email to