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

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

本文整理了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:
[year=2002 month=4],[year=2002 month=3],[year=2002 month=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月)
将产生如下内容:

[year=2002 month=4],[year=2002 month=3],[year=2002 month=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

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

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

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

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

/**
 * Extracts List of Sort attributes names from Query
 *
 * @param query
 * @return List of Sort attributes names
 */
public static List<String> getAttributesOnSort(Query query) {
  List<String> result = new ArrayList<>();
  if (query.getSortBy() == null) return result;
  for (int i = 0; i < query.getSortBy().length; i++) {
    result.add(query.getSortBy()[i].getPropertyName().getPropertyName());
  }
  return result;
}

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

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

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

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

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

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

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

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

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

protected PreparedStatement selectJoinSQLPS(
    SimpleFeatureType featureType, JoinInfo join, Query query, Connection cx)
    throws SQLException, IOException {
  StringBuffer sql = new StringBuffer();
  sql.append("SELECT ");
  selectColumns(featureType, join.getPrimaryAlias(), query, sql);
  // joined columns
  for (JoinPart part : join.getParts()) {
    selectColumns(part.getQueryFeatureType(), part.getAlias(), query, sql);
  }
  sql.setLength(sql.length() - 1);
  dialect.encodePostSelect(featureType, sql);
  sql.append(" FROM ");
  // join clauses
  encodeTableJoin(featureType, join, query, sql);
  // filtering
  List<FilterToSQL> toSQLs = encodeWhereJoin(featureType, join, sql);
  // sorting
  sort(featureType, query.getSortBy(), join.getPrimaryAlias(), sql);
  // finally encode limit/offset, if necessary
  applyLimitOffset(sql, query.getStartIndex(), query.getMaxFeatures());
  LOGGER.fine(sql.toString());
  PreparedStatement ps =
      cx.prepareStatement(
          sql.toString(), ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
  ps.setFetchSize(fetchSize);
  setPreparedFilterValues(ps, toSQLs, cx);
  return ps;
}

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

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

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

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

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

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

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

protected String selectJoinSQL(SimpleFeatureType featureType, JoinInfo join, Query query)
    throws IOException, SQLException {
  StringBuffer sql = new StringBuffer();
  sql.append("SELECT ");
  // column names
  selectColumns(featureType, join.getPrimaryAlias(), query, sql);
  // joined columns
  for (JoinPart part : join.getParts()) {
    selectColumns(part.getQueryFeatureType(), part.getAlias(), query, sql);
  }
  sql.setLength(sql.length() - 1);
  dialect.encodePostSelect(featureType, sql);
  // from
  sql.append(" FROM ");
  // join clauses
  encodeTableJoin(featureType, join, query, sql);
  // filtering
  encodeWhereJoin(featureType, join, sql);
  // TODO: sorting
  sort(featureType, query.getSortBy(), join.getPrimaryAlias(), sql);
  // finally encode limit/offset, if necessary
  applyLimitOffset(sql, query.getStartIndex(), query.getMaxFeatures());
  return sql.toString();
}

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

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

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

txQuery.setStartIndex(null);
if (query.getSortBy() != null && !caps.supportsSorting(txQuery.getSortBy())) {
  txQuery.setSortBy(null);
if (query.getSortBy() != null && txQuery.getSortBy() == null) {
  txQuery.setStartIndex(null);
  txQuery.setMaxFeatures(Query.DEFAULT_MAX);

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

/**
 * Copy contructor.
 *
 * @param query the query to copy
 */
public Query(Query query) {
  this(
      query.getTypeName(),
      query.getNamespace(),
      query.getFilter(),
      query.getMaxFeatures(),
      query.getProperties(),
      query.getHandle());
  this.sortBy = query.getSortBy();
  this.coordinateSystem = query.getCoordinateSystem();
  this.coordinateSystemReproject = query.getCoordinateSystemReproject();
  this.version = query.getVersion();
  this.hints = query.getHints();
  this.startIndex = query.getStartIndex();
  this.alias = query.getAlias();
  this.joins = new ArrayList();
  for (Join j : query.getJoins()) {
    this.joins.add(new Join(j));
  }
}

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

/** Get features based on the query specified. */
@Override
public FeatureCollection<FeatureType, Feature> getFeatures(Query query) throws IOException {
  GetFeatureRequest request = client.createGetFeatureRequest();
  FeatureType schema = dataAccess.getSchema(typeName);
  QName name = dataAccess.getRemoteTypeName(typeName);
  request.setTypeName(new QName(query.getTypeName()));
  request.setFullType(schema);
  request.setFilter(query.getFilter());
  request.setPropertyNames(query.getPropertyNames());
  request.setSortBy(query.getSortBy());
  String srsName = null;
  request.setSrsName(srsName);
  return new WFSContentComplexFeatureCollection(request, schema, name);
}

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

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

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

/**
   * Copy contructor, clones the state of a generic Query into a DefaultQuery
   *
   * @param query
   */
  public DefaultQuery(Query query) {
    this(
        query.getTypeName(),
        query.getNamespace(),
        query.getFilter(),
        query.getMaxFeatures(),
        query.getProperties(),
        query.getHandle());
    this.sortBy = query.getSortBy();
    this.coordinateSystem = query.getCoordinateSystem();
    this.coordinateSystemReproject = query.getCoordinateSystemReproject();
    this.version = query.getVersion();
    this.hints = query.getHints();
    this.startIndex = query.getStartIndex();
    this.alias = query.getAlias();
    this.joins = query.getJoins();
  }
}

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

private Query namedQuery(Query query) {
  Query namedQuery =
      namedQuery(
          query.getFilter(), query.getMaxFeatures(), query instanceof JoiningQuery);
  namedQuery.setProperties(query.getProperties());
  namedQuery.setCoordinateSystem(query.getCoordinateSystem());
  namedQuery.setCoordinateSystemReproject(query.getCoordinateSystemReproject());
  namedQuery.setHandle(query.getHandle());
  namedQuery.setMaxFeatures(query.getMaxFeatures());
  namedQuery.setStartIndex(query.getStartIndex());
  namedQuery.setSortBy(query.getSortBy());
  namedQuery.setHints(query.getHints());
  if (query instanceof JoiningQuery) {
    ((JoiningQuery) namedQuery).setQueryJoins(((JoiningQuery) query).getQueryJoins());
    ((JoiningQuery) namedQuery).setRootMapping(((JoiningQuery) query).getRootMapping());
  }
  return namedQuery;
}

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

protected GetFeatureRequest createGetFeature(Query query, ResultType resultType)
    throws IOException {
  GetFeatureRequest request = client.createGetFeatureRequest();
  final WFSDataStore dataStore = getDataStore();
  final QName remoteTypeName = dataStore.getRemoteTypeName(getEntry().getName());
  final SimpleFeatureType remoteSimpleFeatureType;
  remoteSimpleFeatureType = dataStore.getRemoteSimpleFeatureType(remoteTypeName);
  request.setTypeName(remoteTypeName);
  request.setFullType(remoteSimpleFeatureType);
  invertAxisInFilterIfNeeded(query, remoteSimpleFeatureType);
  request.setFilter(query.getFilter());
  request.setResultType(resultType);
  request.setHints(query.getHints());
  int maxFeatures = query.getMaxFeatures();
  if (Integer.MAX_VALUE > maxFeatures) {
    request.setMaxFeatures(maxFeatures);
  }
  // let the request decide request.setOutputFormat(outputFormat);
  request.setPropertyNames(query.getPropertyNames());
  request.setSortBy(query.getSortBy());
  String srsName = getSupportedSrsName(request, query);
  request.setSrsName(srsName);
  return request;
}

相关文章