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

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

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

Query.getMaxFeatures介绍

[英]Get the maximum number of features that will be retrieved by this Query.

Note: This is the only method that is not directly out of the Query element in the WFS specification. It is instead a part of a GetFeature request, which can hold one or more queries. But each of those in turn will need a maxFeatures, so it is needed here.

If the value returned here is max integer then the number of features should not be limited.
[中]获取此查询将检索的最大功能数。
注意:这是WFS规范中唯一一个没有直接从查询元素中取出的方法。它是GetFeature请求的一部分,可以保存一个或多个查询。但每一个都需要一个maxFeatures,所以这里需要它。
如果此处返回的值为max integer,则不应限制功能的数量。

代码示例

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

  1. query.getMaxFeatures() == Integer.MAX_VALUE ? null : query.getMaxFeatures();
  2. offset = query.getStartIndex();
  3. maxFeatures =
  4. query.getMaxFeatures() == Integer.MAX_VALUE ? null : query.getMaxFeatures();

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

  1. private String getNextFromVisitor() {
  2. // if max features reached, no more items.
  3. if (counter >= idQuery.getMaxFeatures()) return null;
  4. if (visitorIterator.hasNext()) {
  5. counter++;
  6. return (String) visitorIterator.next();
  7. } else {
  8. // if next current visitor start is into bounds
  9. int nextStart = currentVisitorStart + STEP_LOAD;
  10. if (nextStart <= (start + max - 1)) {
  11. // init new visitor, next bounds
  12. currentVisitorStart = nextStart;
  13. initVisitor();
  14. // if don't have next value yet, no more data -> return null
  15. if (!visitorIterator.hasNext()) return null;
  16. // has next value, return it
  17. counter++;
  18. return (String) visitorIterator.next();
  19. }
  20. }
  21. return null;
  22. }

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

  1. public JTSIndexVisitorAdapter(final GranuleCatalogVisitor adaptee, Query q) {
  2. this.adaptee = adaptee;
  3. this.filter = q == null ? Query.ALL.getFilter() : q.getFilter();
  4. this.maxGranules = q.getMaxFeatures();
  5. }

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

  1. /**
  2. * Applies the limit/offset elements to the query if they are specified and if the dialect
  3. * supports them
  4. *
  5. * @param sql The sql to be modified
  6. * @param the query that holds the limit and offset parameters
  7. */
  8. public void applyLimitOffset(StringBuffer sql, Query query) {
  9. applyLimitOffset(sql, query.getStartIndex(), query.getMaxFeatures());
  10. }

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

  1. public IndexUniqueVisitorIterator(
  2. FeatureCollection<SimpleFeatureType, SimpleFeature> fc,
  3. Query idQuery,
  4. String idFieldName) {
  5. super();
  6. this.fc = fc;
  7. this.idQuery = idQuery;
  8. this.idFieldName = idFieldName;
  9. this.start = idQuery.getStartIndex() != null ? idQuery.getStartIndex() : 0;
  10. this.max = idQuery.getMaxFeatures();
  11. currentVisitorStart = this.start;
  12. initVisitor();
  13. }

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

  1. /**
  2. * Hashcode based on all parameters other than the handle.
  3. *
  4. * @return hascode for this Query
  5. */
  6. @Override
  7. public int hashCode() {
  8. String[] n = getPropertyNames();
  9. return ((n == null) ? (-1) : ((n.length == 0) ? 0 : (n.length | n[0].hashCode())))
  10. | getMaxFeatures()
  11. | ((getFilter() == null) ? 0 : getFilter().hashCode())
  12. | ((getTypeName() == null) ? 0 : getTypeName().hashCode())
  13. | ((getVersion() == null) ? 0 : getVersion().hashCode())
  14. | ((getCoordinateSystem() == null) ? 0 : getCoordinateSystem().hashCode())
  15. | ((getCoordinateSystemReproject() == null)
  16. ? 0
  17. : getCoordinateSystemReproject().hashCode())
  18. | getStartIndex();
  19. }

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

  1. /** Test of getMaxFeatures method, of class org.geotools.data.Query. */
  2. public void testMaxFeatures() {
  3. // System.out.println("testMaxFeatures");
  4. Query query = new Query();
  5. assertEquals(Query.DEFAULT_MAX, query.getMaxFeatures());
  6. query.setMaxFeatures(5);
  7. assertEquals(5, query.getMaxFeatures());
  8. }

代码示例来源: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. applyLimitOffset(sql, query.getStartIndex(), query.getMaxFeatures());

代码示例来源: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 (txQuery.getMaxFeatures() > query.getMaxFeatures()) {
  2. transformed = new MaxFeaturesIterator(transformed, query.getMaxFeatures());

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

  1. /**
  2. * Retrieve a FeatureReader<SimpleFeatureType, SimpleFeature> for the geometry attributes only,
  3. * designed for bounds computation
  4. */
  5. protected FeatureReader<SimpleFeatureType, SimpleFeature> boundsReader() throws IOException {
  6. List attributes = new ArrayList();
  7. SimpleFeatureType schema = featureSource.getSchema();
  8. for (int i = 0; i < schema.getAttributeCount(); i++) {
  9. AttributeDescriptor at = schema.getDescriptor(i);
  10. if (at instanceof GeometryDescriptorImpl) attributes.add(at.getLocalName());
  11. }
  12. DefaultQuery q = new DefaultQuery(query);
  13. q.setPropertyNames(attributes);
  14. FeatureReader<SimpleFeatureType, SimpleFeature> reader =
  15. ((DataStore) featureSource.getDataStore()).getFeatureReader(q, getTransaction());
  16. int maxFeatures = query.getMaxFeatures();
  17. if (maxFeatures == Integer.MAX_VALUE) {
  18. return reader;
  19. } else {
  20. return new MaxFeatureReader<SimpleFeatureType, SimpleFeature>(reader, maxFeatures);
  21. }
  22. }

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

  1. /**
  2. * Retrieve a FeatureReader<SimpleFeatureType, SimpleFeature> for this Query
  3. *
  4. * @return FeatureReader<SimpleFeatureType, SimpleFeature> for this Query
  5. * @throws IOException If results could not be obtained
  6. */
  7. public FeatureReader<SimpleFeatureType, SimpleFeature> reader() throws IOException {
  8. FeatureReader<SimpleFeatureType, SimpleFeature> reader;
  9. reader =
  10. ((DataStore) featureSource.getDataStore())
  11. .getFeatureReader(query, getTransaction());
  12. int maxFeatures = query.getMaxFeatures();
  13. if (maxFeatures != Integer.MAX_VALUE) {
  14. reader = new MaxFeatureReader<SimpleFeatureType, SimpleFeature>(reader, maxFeatures);
  15. }
  16. if (transform != null) {
  17. reader = new ReprojectFeatureReader(reader, getSchema(), transform);
  18. }
  19. return reader;
  20. }

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

  1. size -= query.getStartIndex();
  2. return Math.min(size, query.getMaxFeatures());

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

  1. int maxFeatures = query.getMaxFeatures();
  2. return (count < maxFeatures) ? count : maxFeatures;

代码示例来源: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. 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. if (sourceFeaturesCounter >= (start + query.getMaxFeatures())) {
  2. return false;

代码示例来源: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. 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. }

相关文章