From: Andrea A. <aa...@op...> - 2009-06-30 09:24:57
|
jericks ha scritto: > I am trying to sort a shapefile or ArcSDE layer by an attribute. I first > tried adding a SortBy to a DefaultQuery, but the shapefile throws an error > and the ArcSDE layer fails silently. Next, I tried reading my FeatureSource > into an ArrayList of SimpleFeatures, sorting them using a Comparator, and > then writing the ArrayList back to an output FeatureStore, but the order is > not preserved. What is the correct way of sorting a FeatureSource? Native sorting is not supported on all stores, in particular, only database backends do... not sure what goes on in SDE. You can check at runtime if a feature source supports sorting on a certain field by using FeatureSource.getQueryCapabilities.supportsSorting(SortBy[]). As for preserving order in writes, there is basically only shapefile that do support it, but it's just an accident of how the writing occurs. SDE is free to keep whatever order it wants storage wise, and when you retrieve data the order will be very much dependent on what indexes are used to execute the query. So I guess in the end what you need is sort support in SDE. By looking at the code in SDE it would seem sorting in never supported (the query capabilities seem to always return false to the above cited methos), but I may be wrong. I've cc'ed the module maintainer, he should know more. Cheers Andrea -- Andrea Aime OpenGeo - http://opengeo.org Expert service straight from the developers. |