Hi,

I have a simple SQL query in postgis :

*"Select * from table1 order by filed1 desc, ABS(filed2 - 10) asc" *

in above query I order firstly based on the field1, and then absolute value
of field2 minus 10, which works fine in postgis.

I am going to simulate this using geotools but I can not implement ABS
function. Here is part of my code:

final SortBy sortByField1 = ff.sort("field1", SortOrder.DESCENDING);



*final SortBy sortByField2 = ff.sort("ABS(field2 -10)",
SortOrder.ASCENDING);*
The seconds statement throws an exception since sort only recognizes field
name not expression.
I had a look at documentation and I found that we can use expression to
handle this but I couldnt implement it :

       PropertyName name = *sortByField2*.getPropertyName();
     *  name.evaluate(object)*
        final SortBy newSort  = new SortByImpl(name, SortOrder.ASCENDING);

I know there are    *FilterFunction_ab*s  and *Add* functions in Geotools
but I dont know how I can use those to evaluate  ABS and subtract function.

It would be great if someone can help me to find a solution.

Thanks,
Ali
------------------------------------------------------------------------------
Slashdot TV.  
Video for Nerds.  Stuff that matters.
http://tv.slashdot.org/
_______________________________________________
GeoTools-GT2-Users mailing list
GeoTools-GT2-Users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to