文档首页 > > 开发指南> 开发GeoMesa应用> 样例代码说明> 查询数据

查询数据

分享
更新时间:2019/05/07 GMT+08:00

功能简介

根据指定时空条件查询数据。

样例代码

// construct a (E)CQL filter from the search parameters,
// and use that as the basis for the query
Filter cqlFilter = createFilter(geomField, x0, y0, x1, y1, dateField, t0, t1, attributesQuery);
Query query = new Query(simpleFeatureTypeName, cqlFilter);
List<String> properties = new LinkedList<>();
// submit the query, and get back an iterator over matching features
FeatureSource featureSource = dataStore.getFeatureSource(simpleFeatureTypeName);
FeatureCollection featureCollection = featureSource.getFeatures(query);
FeatureIterator featureItr = featureCollection.features();
// loop through all results
int n = 0;
while (featureItr.hasNext()) {
  Feature feature = featureItr.next();
  feature.getIdentifier().getID();
  System.out.println((++n) + "." +
    feature.getProperty("Who").getValue() + "|" +
    feature.getProperty("What").getValue() + "|" +
    feature.getProperty("When").getValue() + "|" +
    feature.getProperty("Where").getValue() + "|" +
    feature.getProperty("Why").getValue());
}
featureItr.close();
分享:

    相关文档

    相关产品

文档是否有解决您的问题?

提交成功!非常感谢您的反馈,我们会继续努力做到更好!
反馈提交失败,请稍后再试!

*必选

请至少选择或填写一项反馈信息

字符长度不能超过200

提交反馈 取消

如您有其它疑问,您也可以通过华为云社区问答频道来与我们联系探讨

智能客服提问云社区提问