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

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

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

Query.setStartIndex介绍

[英]Set the index of the first feature to retrieve. This can be used in conjuction with #setMaxFeatures(int) to 'page' through a feature data source.
[中]设置要检索的第一个要素的索引。这可以与#setMaxFeatures(int)结合使用,通过功能数据源“分页”。

代码示例

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

query.getMaxFeatures() == Integer.MAX_VALUE ? null : query.getMaxFeatures();
  query.setStartIndex(null);
  query.setMaxFeatures(Query.DEFAULT_MAX);
} else {
      query.getMaxFeatures() == Integer.MAX_VALUE ? null : query.getMaxFeatures();
  query.setStartIndex(null);
  query.setMaxFeatures(Query.DEFAULT_MAX);

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

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

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

/**
 * Builds next query for execute in data source
 *
 * @return
 */
private Query getNextSourceQuery() {
  Query nextQuery = new Query(query);
  Filter idInFilter = IndexQueryUtils.buildIdInExpression(getNextSourceIdList(), mapping);
  nextQuery.setFilter(idInFilter);
  nextQuery.setStartIndex(0);
  nextQuery.setMaxFeatures(Integer.MAX_VALUE);
  return nextQuery;
}

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

private Query queryWithLimits(int lower, int upper) {
  Query query = new Query(tname("buildings"));
  query.setStartIndex(lower);
  query.setMaxFeatures(upper);
  return query;
}

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

public void testCountWithOffsetLimit() throws Exception {
  Query query = new Query();
  query.setStartIndex(1);
  query.setMaxFeatures(1);
  assertEquals(1, featureSource.getCount(query));
}

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

/**
 * Build the query for execute on index source partial Implementation manages pagination by
 * itself, so remove bounds from query
 *
 * @return Query
 */
@Override
protected Query transformQueryToIdsOnly() {
  Query idsQuery = new Query(unrollIndexes(partialIQM.getIndexQuery()));
  idsQuery.setProperties(getIndexQueryProperties());
  idsQuery.setTypeName(mapping.getIndexSource().getSchema().getTypeName());
  idsQuery.setStartIndex(null);
  idsQuery.setMaxFeatures(Integer.MAX_VALUE);
  return idsQuery;
}

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

public void testPaginationWithPlaceHolder() throws Exception {
    Query query = new Query("riverFullPlaceHolder");
    query.setStartIndex(1);
    query.setMaxFeatures(2);
    int count = dataStore.getFeatureSource("riverFullPlaceHolder").getCount(query);
    assertTrue(count == 1);
  }
}

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

/**
 * Test the second page of one feature per page.
 *
 * @throws IOException
 */
@Test
public void oneFeatureSecondPage() throws IOException {
  Query query = new Query();
  query.setMaxFeatures(1);
  query.setStartIndex(1);
  SimpleFeatureSource fs = store.getFeatureSource(TYPENAME);
  SimpleFeature[] features = (SimpleFeature[]) fs.getFeatures(query).toArray();
  Assert.assertEquals(1, fs.getCount(query));
  Assert.assertEquals("mock.2", features[0].getID());
}

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

/**
 * Test the first page of one feature per page.
 *
 * @throws IOException
 */
@Test
public void oneFeatureFirstPage() throws IOException {
  Query query = new Query();
  query.setMaxFeatures(1);
  query.setStartIndex(0);
  SimpleFeatureSource fs = store.getFeatureSource(TYPENAME);
  SimpleFeature[] features = (SimpleFeature[]) fs.getFeatures(query).toArray();
  Assert.assertEquals(1, fs.getCount(query));
  Assert.assertEquals("mock.1", features[0].getID());
}

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

/**
 * Test the third page of one feature per page.
 *
 * @throws IOException
 */
@Test
public void oneFeatureThirdPage() throws IOException {
  Query query = new Query();
  query.setMaxFeatures(1);
  query.setStartIndex(2);
  SimpleFeatureSource fs = store.getFeatureSource(TYPENAME);
  SimpleFeature[] features = (SimpleFeature[]) fs.getFeatures(query).toArray();
  Assert.assertEquals(1, fs.getCount(query));
  Assert.assertEquals("mock.3", features[0].getID());
}

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

/**
 * Test a page of two features that only contains one because startindex is too close to the
 * end.
 *
 * @throws IOException
 */
@Test
public void twoFeaturesReturnOne() throws IOException {
  Query query = new Query();
  query.setMaxFeatures(2);
  query.setStartIndex(2);
  SimpleFeatureSource fs = store.getFeatureSource(TYPENAME);
  SimpleFeature[] features = (SimpleFeature[]) fs.getFeatures(query).toArray();
  Assert.assertEquals(1, fs.getCount(query));
  Assert.assertEquals("mock.3", features[0].getID());
}

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

/**
 * Test the first page of one feature per page with natural sorting.
 *
 * @throws IOException
 */
@Test
public void naturalSortedOneFeatureFirstPage() throws IOException {
  Query query = new Query();
  query.setSortBy(new SortBy[] {SortBy.NATURAL_ORDER});
  query.setMaxFeatures(1);
  query.setStartIndex(0);
  SimpleFeatureSource fs = store.getFeatureSource(TYPENAME);
  SimpleFeature[] features = (SimpleFeature[]) fs.getFeatures(query).toArray();
  Assert.assertEquals(1, fs.getCount(query));
  Assert.assertEquals("mock.1", features[0].getID());
}

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

/**
 * Test the third page of one feature per page with natural sorting.
 *
 * @throws IOException
 */
@Test
public void naturalSortedOneFeatureThirdPage() throws IOException {
  Query query = new Query();
  query.setSortBy(new SortBy[] {SortBy.NATURAL_ORDER});
  query.setMaxFeatures(1);
  query.setStartIndex(2);
  SimpleFeatureSource fs = store.getFeatureSource(TYPENAME);
  SimpleFeature[] features = (SimpleFeature[]) fs.getFeatures(query).toArray();
  Assert.assertEquals(1, fs.getCount(query));
  Assert.assertEquals("mock.3", features[0].getID());
}

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

/**
 * Test the first page of one feature per page with reverse sorting.
 *
 * @throws IOException
 */
@Test
public void reverseSortedOneFeatureFirstPage() throws IOException {
  Query query = new Query();
  query.setSortBy(new SortBy[] {SortBy.REVERSE_ORDER});
  query.setMaxFeatures(1);
  query.setStartIndex(0);
  SimpleFeatureSource fs = store.getFeatureSource(TYPENAME);
  SimpleFeature[] features = (SimpleFeature[]) fs.getFeatures(query).toArray();
  Assert.assertEquals(1, fs.getCount(query));
  Assert.assertEquals("mock.3", features[0].getID());
}

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

/**
 * Test the second page of one feature per page with reverse sorting.
 *
 * @throws IOException
 */
@Test
public void reverseSortedOneFeatureSecondPage() throws IOException {
  Query query = new Query();
  query.setSortBy(new SortBy[] {SortBy.REVERSE_ORDER});
  query.setMaxFeatures(1);
  query.setStartIndex(1);
  SimpleFeatureSource fs = store.getFeatureSource(TYPENAME);
  SimpleFeature[] features = (SimpleFeature[]) fs.getFeatures(query).toArray();
  Assert.assertEquals(1, fs.getCount(query));
  Assert.assertEquals("mock.2", features[0].getID());
}

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

/**
 * Test the first page of two features per page.
 *
 * @throws IOException
 */
@Test
public void twoFeaturesFirstPage() throws IOException {
  Query query = new Query();
  query.setMaxFeatures(2);
  query.setStartIndex(0);
  SimpleFeatureSource fs = store.getFeatureSource(TYPENAME);
  SimpleFeature[] features = (SimpleFeature[]) fs.getFeatures(query).toArray();
  Assert.assertEquals(2, fs.getCount(query));
  Assert.assertEquals("mock.1", features[0].getID());
  Assert.assertEquals("mock.2", features[1].getID());
}

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

public void testUniqueWithLimitOffset() throws Exception {
  if (!dataStore.getSQLDialect().isLimitOffsetSupported()
      || !dataStore.getSQLDialect().isAggregatedSortSupported("distinct")) {
    return;
  }
  FilterFactory ff = dataStore.getFilterFactory();
  PropertyName p = ff.property(aname("stringProperty"));
  UniqueVisitor v = new MyUniqueVisitor(p);
  Query q = new Query(tname("ft1"));
  q.setStartIndex(0);
  q.setMaxFeatures(2);
  dataStore.getFeatureSource(tname("ft1")).accepts(q, v, null);
  assertFalse(visited);
  Set result = v.getResult().toSet();
  assertEquals(2, result.size());
}

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

public void testMaxWithLimitOffset() throws Exception {
  if (!dataStore.getSQLDialect().isLimitOffsetSupported()) {
    return;
  }
  FilterFactory ff = dataStore.getFilterFactory();
  PropertyName p = ff.property(aname("doubleProperty"));
  MaxVisitor v = new MyMaxVisitor(p);
  Query q = new Query(tname("ft1"));
  q.setStartIndex(0);
  q.setMaxFeatures(2);
  dataStore.getFeatureSource(tname("ft1")).accepts(q, v, null);
  assertFalse(visited);
  assertEquals(1.1, v.getResult().toDouble(), 0.01);
}

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

public void testSumWithLimitOffset() throws Exception {
  if (!dataStore.getSQLDialect().isLimitOffsetSupported()) {
    return;
  }
  FilterFactory ff = dataStore.getFilterFactory();
  PropertyName p = ff.property(aname("doubleProperty"));
  SumVisitor v = new MySumVisitor(p);
  Query q = new Query(tname("ft1"));
  q.setStartIndex(0);
  q.setMaxFeatures(2);
  dataStore.getFeatureSource(tname("ft1")).accepts(q, v, null);
  assertFalse(visited);
  assertEquals(1.1, v.getResult().toDouble(), 0.01);
}

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

public void testMinWithLimitOffset() throws Exception {
  if (!dataStore.getSQLDialect().isLimitOffsetSupported()) {
    return;
  }
  FilterFactory ff = dataStore.getFilterFactory();
  PropertyName p = ff.property(aname("doubleProperty"));
  MinVisitor v = new MyMinVisitor(p);
  Query q = new Query(tname("ft1"));
  q.setStartIndex(0);
  q.setMaxFeatures(2);
  dataStore.getFeatureSource(tname("ft1")).accepts(q, v, null);
  assertFalse(visited);
  assertEquals(0.0, v.getResult().toDouble(), 0.01);
}

相关文章