本文整理了Java中org.geotools.data.Query.getMaxFeatures
方法的一些代码示例,展示了Query.getMaxFeatures
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query.getMaxFeatures
方法的具体详情如下:
包路径:org.geotools.data.Query
类名称: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
query.getMaxFeatures() == Integer.MAX_VALUE ? null : query.getMaxFeatures();
offset = query.getStartIndex();
maxFeatures =
query.getMaxFeatures() == Integer.MAX_VALUE ? null : query.getMaxFeatures();
代码示例来源:origin: geotools/geotools
private String getNextFromVisitor() {
// if max features reached, no more items.
if (counter >= idQuery.getMaxFeatures()) return null;
if (visitorIterator.hasNext()) {
counter++;
return (String) visitorIterator.next();
} else {
// if next current visitor start is into bounds
int nextStart = currentVisitorStart + STEP_LOAD;
if (nextStart <= (start + max - 1)) {
// init new visitor, next bounds
currentVisitorStart = nextStart;
initVisitor();
// if don't have next value yet, no more data -> return null
if (!visitorIterator.hasNext()) return null;
// has next value, return it
counter++;
return (String) visitorIterator.next();
}
}
return null;
}
代码示例来源:origin: geotools/geotools
public JTSIndexVisitorAdapter(final GranuleCatalogVisitor adaptee, Query q) {
this.adaptee = adaptee;
this.filter = q == null ? Query.ALL.getFilter() : q.getFilter();
this.maxGranules = q.getMaxFeatures();
}
代码示例来源:origin: geotools/geotools
/**
* Applies the limit/offset elements to the query if they are specified and if the dialect
* supports them
*
* @param sql The sql to be modified
* @param the query that holds the limit and offset parameters
*/
public void applyLimitOffset(StringBuffer sql, Query query) {
applyLimitOffset(sql, query.getStartIndex(), query.getMaxFeatures());
}
代码示例来源:origin: geotools/geotools
public IndexUniqueVisitorIterator(
FeatureCollection<SimpleFeatureType, SimpleFeature> fc,
Query idQuery,
String idFieldName) {
super();
this.fc = fc;
this.idQuery = idQuery;
this.idFieldName = idFieldName;
this.start = idQuery.getStartIndex() != null ? idQuery.getStartIndex() : 0;
this.max = idQuery.getMaxFeatures();
currentVisitorStart = this.start;
initVisitor();
}
代码示例来源:origin: geotools/geotools
/**
* Hashcode based on all parameters other than the handle.
*
* @return hascode for this Query
*/
@Override
public int hashCode() {
String[] n = getPropertyNames();
return ((n == null) ? (-1) : ((n.length == 0) ? 0 : (n.length | n[0].hashCode())))
| getMaxFeatures()
| ((getFilter() == null) ? 0 : getFilter().hashCode())
| ((getTypeName() == null) ? 0 : getTypeName().hashCode())
| ((getVersion() == null) ? 0 : getVersion().hashCode())
| ((getCoordinateSystem() == null) ? 0 : getCoordinateSystem().hashCode())
| ((getCoordinateSystemReproject() == null)
? 0
: getCoordinateSystemReproject().hashCode())
| getStartIndex();
}
代码示例来源:origin: geotools/geotools
/** Test of getMaxFeatures method, of class org.geotools.data.Query. */
public void testMaxFeatures() {
// System.out.println("testMaxFeatures");
Query query = new Query();
assertEquals(Query.DEFAULT_MAX, query.getMaxFeatures());
query.setMaxFeatures(5);
assertEquals(5, query.getMaxFeatures());
}
代码示例来源: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
applyLimitOffset(sql, query.getStartIndex(), query.getMaxFeatures());
代码示例来源: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 (txQuery.getMaxFeatures() > query.getMaxFeatures()) {
transformed = new MaxFeaturesIterator(transformed, query.getMaxFeatures());
代码示例来源:origin: geotools/geotools
/**
* Retrieve a FeatureReader<SimpleFeatureType, SimpleFeature> for the geometry attributes only,
* designed for bounds computation
*/
protected FeatureReader<SimpleFeatureType, SimpleFeature> boundsReader() throws IOException {
List attributes = new ArrayList();
SimpleFeatureType schema = featureSource.getSchema();
for (int i = 0; i < schema.getAttributeCount(); i++) {
AttributeDescriptor at = schema.getDescriptor(i);
if (at instanceof GeometryDescriptorImpl) attributes.add(at.getLocalName());
}
DefaultQuery q = new DefaultQuery(query);
q.setPropertyNames(attributes);
FeatureReader<SimpleFeatureType, SimpleFeature> reader =
((DataStore) featureSource.getDataStore()).getFeatureReader(q, getTransaction());
int maxFeatures = query.getMaxFeatures();
if (maxFeatures == Integer.MAX_VALUE) {
return reader;
} else {
return new MaxFeatureReader<SimpleFeatureType, SimpleFeature>(reader, maxFeatures);
}
}
代码示例来源:origin: geotools/geotools
/**
* Retrieve a FeatureReader<SimpleFeatureType, SimpleFeature> for this Query
*
* @return FeatureReader<SimpleFeatureType, SimpleFeature> for this Query
* @throws IOException If results could not be obtained
*/
public FeatureReader<SimpleFeatureType, SimpleFeature> reader() throws IOException {
FeatureReader<SimpleFeatureType, SimpleFeature> reader;
reader =
((DataStore) featureSource.getDataStore())
.getFeatureReader(query, getTransaction());
int maxFeatures = query.getMaxFeatures();
if (maxFeatures != Integer.MAX_VALUE) {
reader = new MaxFeatureReader<SimpleFeatureType, SimpleFeature>(reader, maxFeatures);
}
if (transform != null) {
reader = new ReprojectFeatureReader(reader, getSchema(), transform);
}
return reader;
}
代码示例来源:origin: geotools/geotools
size -= query.getStartIndex();
return Math.min(size, query.getMaxFeatures());
代码示例来源:origin: geotools/geotools
int maxFeatures = query.getMaxFeatures();
return (count < maxFeatures) ? count : maxFeatures;
代码示例来源: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
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
if (sourceFeaturesCounter >= (start + query.getMaxFeatures())) {
return false;
代码示例来源: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
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;
}
内容来源于网络,如有侵权,请联系作者删除!