On Thu, Aug 21, 2014 at 11:54 AM, Alireza Shamakhy <
alireza.shama...@gmail.com> wrote:
> 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 :
>
Don't know where you find the docs stating you can use an expression, but
they are wrong,
the SortBy interface has these two methods:
PropertyName getPropertyName();
/**
* The the sort order - one of {@link SortOrder#ASCENDING ASCENDING}
* or {@link SortOrder#DESCENDING DESCENDING}.
*/
SortOrder getSortOrder();
So only a PropertyName can be used for sorting, not a generic expression
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
-------------------------------------------------------
------------------------------------------------------------------------------
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