更新时间:2021-03-18 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();
父主题: 样例代码说明
