我需要根据其几何形状的区域遍历已经排序的SimpleFeatureCollection。
我发现经典的[[SimpleFeatureIterator未排序,并且存在一个[[SortedFeatureIterator(SimpleFeatureIterator iterator,SimpleFeatureType schema,SortBy [] sortBy,int maxFeatures)对象,我尝试使用它。
此sortBy对象需要一个PropertyName,我猜它必须由FilterFactory生成。这是我的问题:我找不到如何将此属性设置为与函数一起运行。我发现org.opengis.filter.expression.Function存在,例如org.opengis.filter.expression.Function.AreaFunction
将是合适的。但是随着PropertyName和AreaFunction都扩展了[[org.opengis.filter.expression.Expression接口,我找不到将函数放入SortBy对象的方法。我尝试了几件事,看了看,但没有找到解决方法。 有什么想法吗?我有正确的思维方式吗?我错过了救恩的方法吗?非常感谢你的帮助。 PS:Area不是我的收藏的属性(尽管这是肮脏的hack解决方案,但是我尝试避免使用它们...)代码示例: SimpleFeatureIterator sfcIt = sfc.features();
FilterFactory2 ff = FeatureUtilities.DEFAULT_FILTER_FACTORY;
Function function = new AreaFunction();
//first intention
SortBy[] s = {ff.sort(function.toString(), SortOrder.ASCENDING)};
//second intention
Expression expr = ff.function(function.toString(), ff.property("the_geom"));
//desperate intention
final PropertyName propertyName = (PropertyName) function; //utopic
final PropertyName propertyName = ff.arithmeticOperators(true, function); //that isn't the same function object...
SortBy[] sort = { new SortByImpl(expr, SortOrder.ASCENDING) };
SortBy[] sort = { new SortByImpl(propertyName, SortOrder.ASCENDING) };
SortedFeatureIterator sfcIter = new SortedFeatureIterator(sfcIter, sfc.getSchema(), sort, sfc.size());
感谢您的意见!马克西姆·科隆]
我需要按照其几何形状遍历已经排序的SimpleFeatureCollection。我发现经典的SimpleFeatureIterator未排序,而SortedFeatureIterator(...