本文整理了Java中org.geotools.data.Query.<init>
方法的一些代码示例,展示了Query.<init>
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query.<init>
方法的具体详情如下:
包路径:org.geotools.data.Query
类名称:Query
方法名:<init>
[英]Default constructor. Use setter methods to configure the Query before use (the default Query will retrieve all features).
[中]默认构造函数。使用setter方法在使用前配置查询(默认查询将检索所有功能)。
代码示例来源:origin: geoserver/geoserver
public FeatureCollection<T, F> getFeatures(Filter filter) throws IOException {
return getFeatures(new Query(null, filter));
}
代码示例来源:origin: geoserver/geoserver
public int lockFeatures(Filter filter) throws IOException {
return lockDelegate.lockFeatures(new Query(null, filter));
}
代码示例来源:origin: geoserver/geoserver
public void unLockFeatures(Filter filter) throws IOException {
unLockFeatures(new Query(null, filter));
}
代码示例来源:origin: geoserver/geoserver
public SimpleFeatureCollection getFeatures(Filter filter) throws IOException {
return getFeatures(new Query(typeMap.getName(), filter));
}
代码示例来源:origin: geoserver/geoserver
public SimpleFeatureCollection getFeatures(Filter filter) throws IOException {
return getFeatures(new Query(schema.getTypeName(), filter));
}
代码示例来源:origin: opentripplanner/OpenTripPlanner
/**
* Setup the WFS data source and add the DynamicStreetNotesSource to the graph
*/
@Override
public void setup(Graph graph) throws IOException, FactoryException {
LOG.info("Setup WFS polling updater");
HashMap<String, Object> connectionParameters = new HashMap<>();
connectionParameters.put(WFSDataStoreFactory.URL.key, url);
WFSDataStore data = (new WFSDataStoreFactory()).createDataStore(connectionParameters);
query = new Query(featureType); // Read only single feature type from the source
query.setCoordinateSystem(CRS.decode("EPSG:4326", true)); // Get coordinates in WGS-84
featureSource = data.getFeatureSource(featureType);
graph.streetNotesService.addNotesSource(notesSource);
}
代码示例来源:origin: geoserver/geoserver
/** Returns a GeoTools query build with the provided attributes and filters */
private Query buildQuery(List<PropertyName> attributes, Filter filter) {
if (attributes == null && (filter == null || filter == Filter.INCLUDE)) {
return Query.ALL;
} else {
Query q = new Query();
q.setFilter(filter);
// TODO: switch this to property names when possible
q.setPropertyNames(flattenNames(attributes));
return q;
}
}
代码示例来源:origin: stackoverflow.com
Query query = new Query("__BlobInfo__");
query.addFilter("filename", FilterOperator.EQUAL, filename);
DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();
PreparedQuery pq = datastore.prepare(query);
List<Entity> entList = pq.asList(FetchOptions.Builder.withLimit(1));
String name = entList.get(0).getKey().getName();
代码示例来源:origin: geoserver/geoserver
/** Builds the write query based on the access limits class */
public static Query getWriteQuery(WrapperPolicy policy) {
if (policy.getAccessLevel() != AccessLevel.READ_WRITE) {
return new Query(null, Filter.EXCLUDE);
} else if (policy.getLimits() == null) {
return Query.ALL;
} else if (policy.getLimits() instanceof VectorAccessLimits) {
VectorAccessLimits val = (VectorAccessLimits) policy.getLimits();
return val.getWriteQuery();
} else {
throw new IllegalArgumentException(
"SecureFeatureStore has been fed "
+ "with unexpected AccessLimits class "
+ policy.getLimits().getClass());
}
}
代码示例来源:origin: geoserver/geoserver
/**
* Retrieves the total extent of this FeatureSource.
*
* <p>Please note this extent will reflect the provided definitionQuery.
*
* @return Extent of this FeatureSource, or <code>null</code> if no optimizations exist.
* @throws IOException If bounds of definitionQuery
*/
public ReferencedEnvelope getBounds() throws IOException {
// since CRS is at most forced, we don't need to change this code
if (definitionQuery == Filter.INCLUDE) {
return source.getBounds();
} else {
Query query = new Query(getSchema().getTypeName(), definitionQuery);
return source.getBounds(query);
}
}
代码示例来源:origin: geoserver/geoserver
public SimpleFeatureCollection getFeatures(Query query) throws IOException {
if (query.getTypeName() == null) {
query = new Query(query);
((Query) query).setTypeName(typeMap.getName());
} else if (!typeMap.getName().equals(query.getTypeName())) {
throw new IOException(
"Cannot query this feature source with "
+ query.getTypeName()
+ " since it serves only "
+ typeMap.getName());
}
// GEOS-3210, if the query specifies a subset of property names we need to take that into
// account
SimpleFeatureType target = typeMap.getFeatureType(query);
return new RetypingFeatureCollection(
wrapped.getFeatures(store.retypeQuery(query, typeMap)), target);
}
代码示例来源:origin: geoserver/geoserver
public void removeFeatures(Filter filter) throws IOException {
// are we limiting anything?
Query writeQuery = getWriteQuery(policy);
if (writeQuery == Query.ALL) {
storeDelegate.removeFeatures(filter);
} else if (writeQuery.getFilter() == Filter.EXCLUDE
|| writeQuery.getPropertyNames() == Query.NO_NAMES) {
throw unsupportedOperation();
}
// get the mixed filter
final Query local = new Query(null, filter);
Query mixed = mixQueries(local, writeQuery);
storeDelegate.removeFeatures(mixed.getFilter());
}
代码示例来源:origin: geoserver/geoserver
@Test
public void testDelete() throws Exception {
final Query queryAll = new Query(RENAMED);
SimpleFeatureStore store;
store = (SimpleFeatureStore) rts.getFeatureSource(RENAMED);
int count = store.getCount(queryAll);
store.removeFeatures(fidFilter);
assertEquals(count - 1, store.getCount(queryAll));
}
代码示例来源:origin: geoserver/geoserver
@Test
public void testDelete() throws Exception {
final Query queryAll = new Query(RENAMED);
SimpleFeatureStore store;
store = (SimpleFeatureStore) rts.getFeatureSource(RENAMED);
int count = store.getCount(queryAll);
store.removeFeatures(fidFilter);
assertEquals(count - 1, store.getCount(queryAll));
}
代码示例来源:origin: geoserver/geoserver
@Test
public void testGetFeaturesReader() throws Exception {
FeatureReader<SimpleFeatureType, SimpleFeature> fr;
fr = rts.getFeatureReader(new Query(RENAMED), Transaction.AUTO_COMMIT);
SimpleFeature sf = fr.next();
fr.close();
assertEquals(primitive, sf.getFeatureType());
// check the feature ids have been renamed as well
assertTrue(
"Feature id has not been renamed, it's still " + sf.getID(),
sf.getID().startsWith(RENAMED));
}
代码示例来源:origin: geoserver/geoserver
@Test
public void testGetFeaturesReader() throws Exception {
FeatureReader<SimpleFeatureType, SimpleFeature> fr;
fr = rts.getFeatureReader(new Query(RENAMED), Transaction.AUTO_COMMIT);
SimpleFeature sf = fr.next();
fr.close();
assertEquals(RENAMED, sf.getFeatureType().getName().getLocalPart());
// check the feature ids have been renamed as well
assertTrue(
"Feature id has not been renamed, it's still " + sf.getID(),
sf.getID().startsWith(RENAMED));
}
代码示例来源:origin: geoserver/geoserver
@Test
public void testFeatureReaderFidFilter() throws Exception {
FeatureReader<SimpleFeatureType, SimpleFeature> fr;
fr = rts.getFeatureReader(new Query(RENAMED, fidFilter), Transaction.AUTO_COMMIT);
assertEquals(primitive, fr.getFeatureType());
assertTrue(fr.hasNext());
SimpleFeature sf = fr.next();
assertFalse(fr.hasNext());
fr.close();
assertEquals(fid, sf.getID());
}
代码示例来源:origin: geoserver/geoserver
@Test
public void testFeautureReaderFidFilter() throws Exception {
FeatureReader<SimpleFeatureType, SimpleFeature> fr;
fr = rts.getFeatureReader(new Query(RENAMED, fidFilter), Transaction.AUTO_COMMIT);
assertEquals(RENAMED, fr.getFeatureType().getName().getLocalPart());
assertTrue(fr.hasNext());
SimpleFeature sf = fr.next();
assertFalse(fr.hasNext());
fr.close();
assertEquals(fid, sf.getID());
}
代码示例来源:origin: geoserver/geoserver
@Test
public void testModify() throws Exception {
final Query queryAll = new Query(RENAMED);
SimpleFeatureStore store;
store = (SimpleFeatureStore) rts.getFeatureSource(RENAMED);
SimpleFeature original = store.getFeatures(fidFilter).features().next();
String newAddress = ((String) original.getAttribute("ADDRESS")) + " xxx";
store.modifyFeatures(
original.getFeatureType().getDescriptor("ADDRESS"), newAddress, fidFilter);
SimpleFeature modified = store.getFeatures(fidFilter).features().next();
assertEquals(newAddress, modified.getAttribute("ADDRESS"));
}
代码示例来源:origin: geoserver/geoserver
@Test
public void testQueryWithPropertyNames() throws Exception {
// check the schemas in feature source and feature collection
SimpleFeatureSource fs = rts.getFeatureSource(RENAMED);
Query q = new Query(RENAMED, Filter.INCLUDE, new String[] {"ADDRESS"});
FeatureCollection<SimpleFeatureType, SimpleFeature> fc = fs.getFeatures(q);
assertEquals(1, fc.getSchema().getAttributeCount());
// make sure the feature schema is good as well
FeatureIterator<SimpleFeature> it = fc.features();
SimpleFeature sf = it.next();
it.close();
assertEquals(1, sf.getAttributeCount());
assertNull(sf.getAttribute("FID"));
assertNotNull(sf.getAttribute("ADDRESS"));
}
}
内容来源于网络,如有侵权,请联系作者删除!