org.geotools.data.Query.getSortBy()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(9.4k)|赞(0)|评价(0)|浏览(385)

本文整理了Java中org.geotools.data.Query.getSortBy方法的一些代码示例,展示了Query.getSortBy的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query.getSortBy方法的具体详情如下:
包路径:org.geotools.data.Query
类名称:Query
方法名:getSortBy

Query.getSortBy介绍

[英]SortBy results according to indicated property and order.

SortBy is part of the Filter 1.1 specification, it is referenced by WFS1.1 and Catalog 2.0.x specifications and is used to organize results. The SortBy's are ment to be applied in order:

  • SortBy( year, ascending )
  • SortBy( month, decsending )
    Would produce something like:
  1. [year=2002 month=4],[year=2002 month=3],[year=2002 month=2],
  2. [year=2002 month=1],[year=2003 month=12],[year=2002 month=4],

SortBy should be considered at the same level of abstraction as Filter, and like Filter you may sort using properties not listed in getPropertyNames.

At a technical level the interface SortBy2 is used to indicate the additional requirements of a GeoTools implementation. The pure WFS 1.1 specification itself is limited to SortBy.
[中]根据指定的属性和顺序排序结果。
SortBy是过滤器1.1规范的一部分,由WFS1引用。1和目录2.0。x规范,用于组织结果。SortBy的申请顺序如下:
*SortBy(年份,升序)
*SortBy(月,12月)
将产生如下内容:

  1. [year=2002 month=4],[year=2002 month=3],[year=2002 month=2],
  2. [year=2002 month=1],[year=2003 month=12],[year=2002 month=4],

SortBy应该与Filter处于同一抽象级别,与Filter一样,您可以使用getPropertyNames中未列出的属性进行排序。
在技术层面上,接口SortBy2用于指示GeoTools实现的附加要求。纯WFS 1.1规范本身仅限于SortBy。

代码示例

代码示例来源:origin: geoserver/geoserver

  1. if (query.getSortBy() != null) {
  2. defQuery.setSortBy(query.getSortBy());

代码示例来源:origin: geoserver/geoserver

  1. result.setCoordinateSystemReproject(userQuery.getCoordinateSystemReproject());
  2. result.setStartIndex(userQuery.getStartIndex());
  3. result.setSortBy(userQuery.getSortBy());

代码示例来源:origin: geotools/geotools

  1. /**
  2. * Extracts List of Sort attributes names from Query
  3. *
  4. * @param query
  5. * @return List of Sort attributes names
  6. */
  7. public static List<String> getAttributesOnSort(Query query) {
  8. List<String> result = new ArrayList<>();
  9. if (query.getSortBy() == null) return result;
  10. for (int i = 0; i < query.getSortBy().length; i++) {
  11. result.add(query.getSortBy()[i].getPropertyName().getPropertyName());
  12. }
  13. return result;
  14. }

代码示例来源:origin: geoserver/geoserver

  1. SortBy[] sortBy = query.getSortBy();
  2. Integer offset = null, maxFeatures = null;
  3. if (sortBy != null && sortBy != SortBy.UNSORTED) {

代码示例来源:origin: geotools/geotools

  1. static SimpleFeatureReader getDelegateReader(SimpleFeatureReader reader, Query query)
  2. throws IOException {
  3. int maxFeatures = getMaxFeatures(query);
  4. return getDelegateReader(reader, query.getSortBy(), maxFeatures);
  5. }

代码示例来源:origin: geotools/geotools

  1. SortBy[] original = query.getSortBy();
  2. if (original == null) {
  3. return original;

代码示例来源:origin: geotools/geotools

  1. for (GranuleDescriptor g : features) {
  2. if (q.getSortBy() == null && maxGranules > 0 && numGranules >= maxGranules) break;
  3. final SimpleFeature originator = g.getOriginator();
  4. if (originator != null && filter.evaluate(originator)) filtered.add(originator);
  5. if (q.getSortBy() != null) {
  6. Comparator<SimpleFeature> comparator =
  7. SortedFeatureReader.getComparator(q.getSortBy());
  8. if (comparator != null) {
  9. Collections.sort(filtered, comparator);

代码示例来源:origin: geotools/geotools

  1. protected PreparedStatement selectJoinSQLPS(
  2. SimpleFeatureType featureType, JoinInfo join, Query query, Connection cx)
  3. throws SQLException, IOException {
  4. StringBuffer sql = new StringBuffer();
  5. sql.append("SELECT ");
  6. selectColumns(featureType, join.getPrimaryAlias(), query, sql);
  7. // joined columns
  8. for (JoinPart part : join.getParts()) {
  9. selectColumns(part.getQueryFeatureType(), part.getAlias(), query, sql);
  10. }
  11. sql.setLength(sql.length() - 1);
  12. dialect.encodePostSelect(featureType, sql);
  13. sql.append(" FROM ");
  14. // join clauses
  15. encodeTableJoin(featureType, join, query, sql);
  16. // filtering
  17. List<FilterToSQL> toSQLs = encodeWhereJoin(featureType, join, sql);
  18. // sorting
  19. sort(featureType, query.getSortBy(), join.getPrimaryAlias(), sql);
  20. // finally encode limit/offset, if necessary
  21. applyLimitOffset(sql, query.getStartIndex(), query.getMaxFeatures());
  22. LOGGER.fine(sql.toString());
  23. PreparedStatement ps =
  24. cx.prepareStatement(
  25. sql.toString(), ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
  26. ps.setFetchSize(fetchSize);
  27. setPreparedFilterValues(ps, toSQLs, cx);
  28. return ps;
  29. }

代码示例来源:origin: geotools/geotools

  1. sort(featureType, query.getSortBy(), null, sql);

代码示例来源:origin: geotools/geotools

  1. q.getSortBy() == null ? null : SortedFeatureReader.getComparator(q.getSortBy());
  2. if (comparator == null) {
  3. index.query(requestedBBox, new JTSIndexVisitorAdapter(visitor, q));

代码示例来源:origin: geotools/geotools

  1. sort(featureType, query.getSortBy(), null, sql);

代码示例来源:origin: geotools/geotools

  1. protected String selectJoinSQL(SimpleFeatureType featureType, JoinInfo join, Query query)
  2. throws IOException, SQLException {
  3. StringBuffer sql = new StringBuffer();
  4. sql.append("SELECT ");
  5. // column names
  6. selectColumns(featureType, join.getPrimaryAlias(), query, sql);
  7. // joined columns
  8. for (JoinPart part : join.getParts()) {
  9. selectColumns(part.getQueryFeatureType(), part.getAlias(), query, sql);
  10. }
  11. sql.setLength(sql.length() - 1);
  12. dialect.encodePostSelect(featureType, sql);
  13. // from
  14. sql.append(" FROM ");
  15. // join clauses
  16. encodeTableJoin(featureType, join, query, sql);
  17. // filtering
  18. encodeWhereJoin(featureType, join, sql);
  19. // TODO: sorting
  20. sort(featureType, query.getSortBy(), join.getPrimaryAlias(), sql);
  21. // finally encode limit/offset, if necessary
  22. applyLimitOffset(sql, query.getStartIndex(), query.getMaxFeatures());
  23. return sql.toString();
  24. }

代码示例来源:origin: geotools/geotools

  1. if (query.getSortBy() != null && txQuery.getSortBy() == null) {
  2. transformed =
  3. new SortedFeatureIterator(transformed, getSchema(), query.getSortBy(), -1);

代码示例来源:origin: geotools/geotools

  1. txQuery.setStartIndex(null);
  2. if (query.getSortBy() != null && !caps.supportsSorting(txQuery.getSortBy())) {
  3. txQuery.setSortBy(null);
  4. if (query.getSortBy() != null && txQuery.getSortBy() == null) {
  5. txQuery.setStartIndex(null);
  6. txQuery.setMaxFeatures(Query.DEFAULT_MAX);

代码示例来源:origin: geotools/geotools

  1. /**
  2. * Copy contructor.
  3. *
  4. * @param query the query to copy
  5. */
  6. public Query(Query query) {
  7. this(
  8. query.getTypeName(),
  9. query.getNamespace(),
  10. query.getFilter(),
  11. query.getMaxFeatures(),
  12. query.getProperties(),
  13. query.getHandle());
  14. this.sortBy = query.getSortBy();
  15. this.coordinateSystem = query.getCoordinateSystem();
  16. this.coordinateSystemReproject = query.getCoordinateSystemReproject();
  17. this.version = query.getVersion();
  18. this.hints = query.getHints();
  19. this.startIndex = query.getStartIndex();
  20. this.alias = query.getAlias();
  21. this.joins = new ArrayList();
  22. for (Join j : query.getJoins()) {
  23. this.joins.add(new Join(j));
  24. }
  25. }

代码示例来源:origin: geotools/geotools

  1. /** Get features based on the query specified. */
  2. @Override
  3. public FeatureCollection<FeatureType, Feature> getFeatures(Query query) throws IOException {
  4. GetFeatureRequest request = client.createGetFeatureRequest();
  5. FeatureType schema = dataAccess.getSchema(typeName);
  6. QName name = dataAccess.getRemoteTypeName(typeName);
  7. request.setTypeName(new QName(query.getTypeName()));
  8. request.setFullType(schema);
  9. request.setFilter(query.getFilter());
  10. request.setPropertyNames(query.getPropertyNames());
  11. request.setSortBy(query.getSortBy());
  12. String srsName = null;
  13. request.setSrsName(srsName);
  14. return new WFSContentComplexFeatureCollection(request, schema, name);
  15. }

代码示例来源:origin: geotools/geotools

  1. getQuerySchema(queryProperties, unsupportedFilter, fullSchema);
  2. final String sortByClause = buildSortByClause(fullSchema, query.getSortBy(), fidReader);
  3. final ArcSDEQuery sdeQuery;
  4. sdeQuery =

代码示例来源:origin: geotools/geotools

  1. /**
  2. * Copy contructor, clones the state of a generic Query into a DefaultQuery
  3. *
  4. * @param query
  5. */
  6. public DefaultQuery(Query query) {
  7. this(
  8. query.getTypeName(),
  9. query.getNamespace(),
  10. query.getFilter(),
  11. query.getMaxFeatures(),
  12. query.getProperties(),
  13. query.getHandle());
  14. this.sortBy = query.getSortBy();
  15. this.coordinateSystem = query.getCoordinateSystem();
  16. this.coordinateSystemReproject = query.getCoordinateSystemReproject();
  17. this.version = query.getVersion();
  18. this.hints = query.getHints();
  19. this.startIndex = query.getStartIndex();
  20. this.alias = query.getAlias();
  21. this.joins = query.getJoins();
  22. }
  23. }

代码示例来源:origin: geotools/geotools

  1. private Query namedQuery(Query query) {
  2. Query namedQuery =
  3. namedQuery(
  4. query.getFilter(), query.getMaxFeatures(), query instanceof JoiningQuery);
  5. namedQuery.setProperties(query.getProperties());
  6. namedQuery.setCoordinateSystem(query.getCoordinateSystem());
  7. namedQuery.setCoordinateSystemReproject(query.getCoordinateSystemReproject());
  8. namedQuery.setHandle(query.getHandle());
  9. namedQuery.setMaxFeatures(query.getMaxFeatures());
  10. namedQuery.setStartIndex(query.getStartIndex());
  11. namedQuery.setSortBy(query.getSortBy());
  12. namedQuery.setHints(query.getHints());
  13. if (query instanceof JoiningQuery) {
  14. ((JoiningQuery) namedQuery).setQueryJoins(((JoiningQuery) query).getQueryJoins());
  15. ((JoiningQuery) namedQuery).setRootMapping(((JoiningQuery) query).getRootMapping());
  16. }
  17. return namedQuery;
  18. }

代码示例来源:origin: geotools/geotools

  1. protected GetFeatureRequest createGetFeature(Query query, ResultType resultType)
  2. throws IOException {
  3. GetFeatureRequest request = client.createGetFeatureRequest();
  4. final WFSDataStore dataStore = getDataStore();
  5. final QName remoteTypeName = dataStore.getRemoteTypeName(getEntry().getName());
  6. final SimpleFeatureType remoteSimpleFeatureType;
  7. remoteSimpleFeatureType = dataStore.getRemoteSimpleFeatureType(remoteTypeName);
  8. request.setTypeName(remoteTypeName);
  9. request.setFullType(remoteSimpleFeatureType);
  10. invertAxisInFilterIfNeeded(query, remoteSimpleFeatureType);
  11. request.setFilter(query.getFilter());
  12. request.setResultType(resultType);
  13. request.setHints(query.getHints());
  14. int maxFeatures = query.getMaxFeatures();
  15. if (Integer.MAX_VALUE > maxFeatures) {
  16. request.setMaxFeatures(maxFeatures);
  17. }
  18. // let the request decide request.setOutputFormat(outputFormat);
  19. request.setPropertyNames(query.getPropertyNames());
  20. request.setSortBy(query.getSortBy());
  21. String srsName = getSupportedSrsName(request, query);
  22. request.setSrsName(srsName);
  23. return request;
  24. }

相关文章