本文整理汇总了Java中org.geotools.data.Query.getFilter方法的典型用法代码示例。如果您正苦于以下问题:Java Query.getFilter方法的具体用法?Java Query.getFilter怎么用?Java Query.getFilter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.geotools.data.Query
的用法示例。
在下文中一共展示了Query.getFilter方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: makeDefinitionQuery
import org.geotools.data.Query; //导入方法依赖的package包/类
/**
* Takes a query and adapts it to match re definitionQuery filter
* configured for a feature type.
*
* @param query Query against this DataStore
* @param schema TODO
*
* @return Query restricted to the limits of definitionQuery
*
* @throws IOException See DataSourceException
* @throws DataSourceException If query could not meet the restrictions of
* definitionQuery
*/
protected Query makeDefinitionQuery(Query query, SimpleFeatureType schema) throws IOException {
if ((query == Query.ALL) || query.equals(Query.ALL)) {
return query;
}
try {
String[] propNames = extractAllowedAttributes(query, schema);
Filter filter = query.getFilter();
filter = makeDefinitionFilter(filter);
Query defQuery = new Query(query);
defQuery.setFilter(filter);
defQuery.setPropertyNames(propNames);
// set sort by
if (query.getSortBy() != null) {
defQuery.setSortBy(query.getSortBy());
}
// tell the data sources about the default linearization tolerance for curved
// geometries they might be reading
if (linearizationTolerance != null) {
query.getHints().put(Hints.LINEARIZATION_TOLERANCE, linearizationTolerance);
}
return defQuery;
} catch (Exception ex) {
throw new DataSourceException(
"Could not restrict the query to the definition criteria: " + ex.getMessage(), ex);
}
}
示例2: getReaderInternal
import org.geotools.data.Query; //导入方法依赖的package包/类
@Override
protected FeatureReader<SimpleFeatureType, SimpleFeature> getReaderInternal(Query query) throws IOException {
LOGGER.fine("getReaderInternal");
FeatureReader<SimpleFeatureType, SimpleFeature> reader = null;
try {
final ElasticDataStore dataStore = getDataStore();
final String docType = dataStore.getDocType(entry.getName());
final boolean scroll = !useSortOrPagination(query) && dataStore.getScrollEnabled();
final ElasticRequest searchRequest = prepareSearchRequest(query, scroll);
final ElasticResponse sr = dataStore.getClient().search(dataStore.getIndexName(), docType, searchRequest);
if (LOGGER.isLoggable(Level.FINE)) {
LOGGER.fine("Search response: " + sr);
}
if (!scroll) {
reader = new ElasticFeatureReader(getState(), sr);
} else {
reader = new ElasticFeatureReaderScroll(getState(), sr, getSize(query));
}
if (!filterFullySupported) {
reader = new FilteringFeatureReader<SimpleFeatureType, SimpleFeature>(reader, query.getFilter());
}
} catch (Exception e) {
LOGGER.log(Level.SEVERE, e.getMessage(), e);
throw new IOException("Error executing query search", e);
}
return reader;
}
示例3: equals
import org.geotools.data.Query; //导入方法依赖的package包/类
/**
* Equality based on propertyNames, maxFeatures, filter, typeName and
* version.
*
* <p>
* Changing the handle does not change the meaning of the Query.
* </p>
*
* @param obj
* Other object to compare against
*
* @return <code>true</code> if <code>obj</code> matches this filter
*/
@Override
public boolean equals(final Object obj) {
if ((obj == null) || !(obj instanceof Query)) {
return false;
}
if (this == obj) {
return true;
}
final Query other = (Query) obj;
return Arrays.equals(getPropertyNames(), other.getPropertyNames())
&& (retrieveAllProperties() == other.retrieveAllProperties())
&& (getMaxFeatures() == other.getMaxFeatures())
&& ((getFilter() == null) ? (other.getFilter() == null)
: getFilter().equals(other.getFilter()))
&& ((getTypeName() == null) ? (other.getTypeName() == null)
: getTypeName().equals(other.getTypeName()))
&& ((getVersion() == null) ? (other.getVersion() == null)
: getVersion().equals(other.getVersion()))
&& ((getCoordinateSystem() == null) ? (other
.getCoordinateSystem() == null) : getCoordinateSystem()
.equals(other.getCoordinateSystem()))
&& ((getCoordinateSystemReproject() == null) ? (other
.getCoordinateSystemReproject() == null)
: getCoordinateSystemReproject().equals(
other.getCoordinateSystemReproject()));
}
示例4: getCountInternal
import org.geotools.data.Query; //导入方法依赖的package包/类
@Override
protected int getCountInternal(Query query) throws IOException {
// TODO: support query filter
Filter filter = query.getFilter();
if (filter != null) {
//LOGGER.severe("Unhandled filter in getCountInternal" + query.getFilter());
LOGGER.warning("Unable handler filter in getCountInternal" + query.getFilter().getClass().getName());
}
int count = -1;
try {
Statement q = getDataStore().getConnection().createStatement();
ResultSet res = q.executeQuery("SELECT COUNT(*) FROM " + typeName);
count = res.getInt(1);
res.close();
q.close();
} catch (SQLException e) {
throw new IOException(e);
}
if (checkLimitOffset(query)) {
final int limit = query.getMaxFeatures();
if (limit > count) {
count = limit;
}
}
System.out.println("FeatureCount: " + count);
return count;
}
示例5: buildSqlQuery
import org.geotools.data.Query; //导入方法依赖的package包/类
protected String buildSqlQuery(Query query) throws IOException {
StringBuilder sql = new StringBuilder("SELECT ");
//column names
selectColumns(getSchema(), null, query, sql);
sql.setLength(sql.length() - 1);
// from
sql.append(" FROM ");
sql.append(typeName);
//filtering
Filter filter = query.getFilter();
if (filter != null && !Filter.INCLUDE.equals(filter)) {
sql.append(" WHERE ");
//encode filter
CoordinateReferenceSystem queryCrs = (query.getCoordinateSystem() != null) ? query.getCoordinateSystem() : query.getCoordinateSystemReproject();
filter(getSchema(), filter, sql, queryCrs);
}
//sorting
sort(getSchema(), query.getSortBy(), null, sql);
// finally encode limit/offset, if necessary
applyLimitOffset(sql, query);
return sql.toString();
}
示例6: getFilter
import org.geotools.data.Query; //导入方法依赖的package包/类
private Filter getFilter(
final Query query ) {
final Filter filter = query.getFilter();
if (filter instanceof BBOXImpl) {
final BBOXImpl bbox = ((BBOXImpl) filter);
final String propName = bbox.getPropertyName();
if ((propName == null) || propName.isEmpty()) {
bbox.setPropertyName(getSchema(
reader,
query).getGeometryDescriptor().getLocalName());
}
}
return filter;
}
示例7: reprojectFilter
import org.geotools.data.Query; //导入方法依赖的package包/类
private Query reprojectFilter(Query query) throws IOException {
SimpleFeatureType nativeFeatureType = source.getSchema();
final GeometryDescriptor geom = nativeFeatureType.getGeometryDescriptor();
// if no geometry involved, no reprojection needed
if(geom == null)
return query;
try {
// default CRS: the CRS we can assume geometry and bbox elements in filter are
// that is, usually the declared one, but the native one in the leave case
CoordinateReferenceSystem defaultCRS = null;
// we need to reproject all bbox and geometries to a target crs, which is
// the native one usually, but it's the declared on in the force case (since in
// that case we completely ignore the native one)
CoordinateReferenceSystem targetCRS = null;
CoordinateReferenceSystem nativeCRS = geom.getCoordinateReferenceSystem();
if(srsHandling == ProjectionPolicy.FORCE_DECLARED) {
defaultCRS = declaredCRS;
targetCRS = declaredCRS;
nativeFeatureType = FeatureTypes.transform(nativeFeatureType, declaredCRS);
} else if(srsHandling == ProjectionPolicy.REPROJECT_TO_DECLARED) {
defaultCRS = declaredCRS;
targetCRS = nativeCRS;
} else { // FeatureTypeInfo.LEAVE
defaultCRS = nativeCRS;
targetCRS = nativeCRS;
}
// now we apply a default to all geometries and bbox in the filter
ISODefaultCRSFilterVisitor defaultCRSVisitor = new ISODefaultCRSFilterVisitor(ff, defaultCRS);
Filter filter = query.getFilter() != null ? query.getFilter() : Filter.INCLUDE;
Filter defaultedFilter = (Filter) filter.accept(defaultCRSVisitor, null);
// and then we reproject all geometries so that the datastore receives
// them in the native projection system (or the forced one, in case of force)
ISOReprojectingFilterVisitor reprojectingVisitor = new ISOReprojectingFilterVisitor(ff, nativeFeatureType);
Filter reprojectedFilter = (Filter) defaultedFilter.accept(reprojectingVisitor, null);
Query reprojectedQuery = new Query(query);
reprojectedQuery.setFilter(reprojectedFilter);
return reprojectedQuery;
} catch(Exception e) {
throw new DataSourceException("Had troubles handling filter reprojection...", e);
}
}