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

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

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

Query.setSortBy介绍

[英]Sets the sort by information.
[中]设置排序依据信息。

代码示例

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

@Test
public void testEmptySort() throws IOException, IllegalAccessException {
  SimpleFeatureSource fsp = getFeatureSource(SystemTestData.PRIMITIVEGEOFEATURE);
  Query q = new Query();
  q.setSortBy(SortBy.UNSORTED);
  SimpleFeatureCollection fc = fsp.getFeatures(q);
  // the above call used to add a SortedSimpleFeatureCollection wrapper that in turn killed
  // some visit optimizations
  while (fc instanceof DecoratingFeatureCollection) {
    assertThat(fc, not(instanceOf(SortedSimpleFeatureCollection.class)));
    Field field =
        FieldUtils.getDeclaredField(SortedSimpleFeatureCollection.class, "delegate");
    field.setAccessible(true);
    Object delegate = field.get(fc);
    fc = (SimpleFeatureCollection) delegate;
  }
}

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

defQuery.setSortBy(query.getSortBy());

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

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

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

if (sortBy != null && sortBy != SortBy.UNSORTED) {
  if (!source.getQueryCapabilities().supportsSorting(sortBy)) {
    query.setSortBy(null);

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

public SimpleFeatureCollection sort(org.opengis.filter.sort.SortBy sort) {
  Query query = new Query();
  query.setSortBy(new org.opengis.filter.sort.SortBy[] {sort});
  query = DataUtilities.mixQueries(this.query, query, null);
  return new ContentFeatureCollection(featureSource, query);
}

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

public SimpleFeatureCollection sort(SortBy order) {
  Query subQuery = new Query(getSchema().getTypeName());
  subQuery.setSortBy(new SortBy[] {order});
  CollectionFeatureSource temp = new CollectionFeatureSource(this);
  return temp.getFeatures(subQuery);
}

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

@Override
public SimpleFeatureCollection sort(SortBy order) {
  Query subQuery = new Query(getSchema().getTypeName());
  subQuery.setSortBy(new SortBy[] {order});
  CollectionFeatureSource temp = new CollectionFeatureSource(this);
  return temp.getFeatures(subQuery);
}

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

@Override
  public SimpleFeatureCollection sort(SortBy order) {
    Query q = new Query(getSchema().getTypeName());
    q.setSortBy(new SortBy[] {order});
    Query subQuery = DataUtilities.mixQueries(query, q, q.getHandle());
    return CollectionFeatureSource.this.getFeatures(subQuery);
  }
}

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

@Test
public void testRetypeCannotSortCovered() throws Exception {
  Query q = new Query();
  q.setPropertyNames(new String[] {"name", "z"});
  q.setSortBy(new SortBy[] {ff.sort("z", SortOrder.ASCENDING)});
  checkRetypeCannotSort(q, q);
}

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

void assertDatesMatch(Filter filter, String... dates) throws Exception {
  FilterFactory ff = dataStore.getFilterFactory();
  Query query = new Query(aname("dates"), filter);
  query.setSortBy(new SortBy[] {ff.sort(aname("dt"), SortOrder.ASCENDING)});
  assertDatesMatch(query, dates);
}

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

public void testNaturalSortingAsc() throws Exception {
  Query q = new Query(featureSource.getSchema().getTypeName());
  q.setSortBy(new SortBy[] {SortBy.NATURAL_ORDER});
  try (SimpleFeatureIterator features = featureSource.getFeatures(q).features()) {
    String prevId = null;
    while (features.hasNext()) {
      String currId = features.next().getID();
      if (prevId != null) assertTrue(prevId.compareTo(currId) <= 0);
      prevId = currId;
    }
  }
}

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

public void testNaturalSortingdesc() throws Exception {
  Query q = new Query(featureSource.getSchema().getTypeName());
  q.setSortBy(new SortBy[] {SortBy.REVERSE_ORDER});
  try (SimpleFeatureIterator features = featureSource.getFeatures(q).features()) {
    String prevId = null;
    while (features.hasNext()) {
      String currId = features.next().getID();
      if (prevId != null) assertTrue(prevId.compareTo(currId) >= 0);
      prevId = currId;
    }
  }
}

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

@Test
public void testRetypeCannotSortFullyCovered() throws Exception {
  Query q = new Query();
  q.setPropertyNames(
      new String[] {
        "name",
      });
  q.setSortBy(new SortBy[] {ff.sort("z", SortOrder.ASCENDING)});
  Query expected = new Query(q);
  expected.setPropertyNames(new String[] {"name", "z"});
  checkRetypeCannotSort(q, expected);
}

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

@Test
public void testRetypeCannotSortPartiallyCovered() throws Exception {
  Query q = new Query();
  q.setPropertyNames(
      new String[] {
        "name",
      });
  q.setSortBy(
      new SortBy[] {
        ff.sort("name", SortOrder.ASCENDING), ff.sort("z", SortOrder.ASCENDING)
      });
  Query expected = new Query(q);
  expected.setPropertyNames(new String[] {"name", "z"});
  checkRetypeCannotSort(q, expected);
}

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

public void testTemporalJoin() throws Exception {
  FilterFactory ff = dataStore.getFilterFactory();
  After after = ff.after(ff.property(aname("dt")), ff.property("other." + aname("dt")));
  Query q = new Query(tname("dates"));
  q.getJoins().add(new Join(tname("dates"), after).alias("other"));
  q.setSortBy(new SortBy[] {ff.sort(aname("dt"), SortOrder.ASCENDING)});
  assertDatesMatch(q, "2009-06-28 15:12:41", "2009-09-29 17:54:23", "2009-09-29 17:54:23");
}

代码示例来源: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 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 natural sorting.
 *
 * @throws IOException
 */
@Test
public void naturalSortedFeatures() throws IOException {
  Query query = new Query();
  query.setSortBy(new SortBy[] {SortBy.NATURAL_ORDER});
  SimpleFeatureSource fs = store.getFeatureSource(TYPENAME);
  SimpleFeature[] features = (SimpleFeature[]) fs.getFeatures(query).toArray();
  Assert.assertEquals(3, fs.getCount(query));
  Assert.assertEquals("mock.1", features[0].getID());
  Assert.assertEquals("mock.2", features[1].getID());
  Assert.assertEquals("mock.3", features[2].getID());
}

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

/**
 * Test reverse sorting.
 *
 * @throws IOException
 */
@Test
public void reverseSortedFeatures() throws IOException {
  Query query = new Query();
  query.setSortBy(new SortBy[] {SortBy.REVERSE_ORDER});
  SimpleFeatureSource fs = store.getFeatureSource(TYPENAME);
  SimpleFeature[] features = (SimpleFeature[]) fs.getFeatures(query).toArray();
  Assert.assertEquals(3, fs.getCount(query));
  Assert.assertEquals("mock.3", features[0].getID());
  Assert.assertEquals("mock.2", features[1].getID());
  Assert.assertEquals("mock.1", features[2].getID());
}

相关文章