本文整理了Java中org.geotools.data.Query.getHints
方法的一些代码示例,展示了Query.getHints
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query.getHints
方法的具体详情如下:
包路径:org.geotools.data.Query
类名称:Query
方法名:getHints
[英]Specifies some hints to drive the query execution and results build-up. Hints examples can be the GeometryFactory to be used, a generalization distance to be applied right in the data store, to data store specific things such as the fetch size to be used in JDBC queries. The set of hints supported can be fetched by calling FeatureSource#getSupportedHints(). Depending on the actual values of the hints, the data store is free to ignore them. No mechanism is in place, at the moment, to figure out which hints where actually used during the query execution.
[中]指定一些提示以驱动查询执行和结果生成。提示示例可以是要使用的GeometryFactory、要在数据存储中应用的泛化距离,以及要在JDBC查询中使用的特定于数据存储的内容,例如获取大小。支持的提示集可以通过调用FeatureSource#GetSupportedHights()获取。根据提示的实际值,数据存储可以随意忽略它们。目前还没有机制来确定在查询执行期间实际使用了哪些提示。
代码示例来源:origin: geoserver/geoserver
if (userQuery.getHints() == null) {
result.setHints(securityQuery.getHints());
} else if (securityQuery.getHints() == null) {
result.setHints(userQuery.getHints());
} else {
Hints mix = userQuery.getHints();
mix.putAll(securityQuery.getHints());
result.setHints(mix);
代码示例来源:origin: geoserver/geoserver
boolean returnOnlyFirst =
Boolean.TRUE.equals(
renamedQuery.getHints().getOrDefault(QUERY_FIRST_BAND, false));
Set<String> queriesCoverages = new HashSet<>();
for (CoverageBand band : bands) {
代码示例来源:origin: geoserver/geoserver
query.getHints().put(Hints.LINEARIZATION_TOLERANCE, linearizationTolerance);
代码示例来源:origin: geoserver/geoserver
try {
ConfigurationMetadataKey key = ConfigurationMetadataKey.get(e.getKey());
newQuery.getHints().put(key, e.getValue());
} catch (IllegalArgumentException ignore) {
LOGGER.fine("Hint " + e.getKey() + ": " + ignore);
代码示例来源:origin: geotools/geotools
private Double getRequestedDistance(Query query) {
Double result = (Double) query.getHints().get(Hints.GEOMETRY_DISTANCE);
if (result == null) {
/*
* Check if hints GEOMETRY_SIMPLIFICATION is active, when both are supported (because the
* wrapper store supports simplification) only simplification is sent down, but we can use it to pick
* a starting geometry to simplify further.
*/
result = (Double) query.getHints().get(Hints.GEOMETRY_SIMPLIFICATION);
log.fine("Hint for geometry simplification in query, fallback to base feature");
}
if (result == null) {
log.fine("No hint for geometry distance in query, fallback to base feature");
} else {
if (log.isLoggable(Level.FINE)) {
log.fine("Hint geometry distance: " + result);
}
}
return result;
}
代码示例来源:origin: geotools/geotools
/**
* If the provided query has a filter of a where clause place holder exists it will be
* preserved.
*
* @param query the query to test
* @return a query hints map that will contain an entry specifying if the the where clause place
* holder should be keep or not
*/
public static Hints setKeepWhereClausePlaceHolderHint(Query query) {
Filter filter = query.getFilter();
return setKeepWhereClausePlaceHolderHint(
query.getHints(), filter != null && filter != Filter.INCLUDE);
}
代码示例来源:origin: geotools/geotools
/**
* Builds the most appropriate geometry factory depending on the available query hints
*
* @param query
* @return
*/
protected GeometryFactory getGeometryFactory(Query query) {
// if no hints, use the default geometry factory
if (query == null || query.getHints() == null) {
return new GeometryFactory();
}
// grab a geometry factory... check for a special hint
Hints hints = query.getHints();
GeometryFactory geometryFactory = (GeometryFactory) hints.get(Hints.JTS_GEOMETRY_FACTORY);
if (geometryFactory == null) {
// look for a coordinate sequence factory
CoordinateSequenceFactory csFactory =
(CoordinateSequenceFactory) hints.get(Hints.JTS_COORDINATE_SEQUENCE_FACTORY);
if (csFactory != null) {
geometryFactory = new GeometryFactory(csFactory);
}
}
if (geometryFactory == null) {
// fall back on the default one
geometryFactory = new GeometryFactory();
}
return geometryFactory;
}
代码示例来源:origin: geotools/geotools
@Override
protected FeatureReader<SimpleFeatureType, SimpleFeature> getReaderInternal(Query query)
throws IOException {
File file = new File(store.dir, typeName + ".properties");
PropertyFeatureReader reader =
new PropertyFeatureReader(store.getNamespaceURI(), file, getGeometryFactory(query));
Double tolerance = (Double) query.getHints().get(Hints.LINEARIZATION_TOLERANCE);
if (tolerance != null) {
reader.setWKTReader(new WKTReader2(tolerance));
}
return reader;
}
代码示例来源:origin: geotools/geotools
private GeometryFactory getGeometryFactory(Query query) {
Hints hints = query.getHints();
// grab a geometry factory... check for a special hint
GeometryFactory geometryFactory = (GeometryFactory) hints.get(Hints.JTS_GEOMETRY_FACTORY);
if (geometryFactory == null) {
// look for a coordinate sequence factory
CoordinateSequenceFactory csFactory =
(CoordinateSequenceFactory) hints.get(Hints.JTS_COORDINATE_SEQUENCE_FACTORY);
if (csFactory != null) {
geometryFactory = new GeometryFactory(csFactory);
} else {
geometryFactory = new GeometryFactory();
}
}
return geometryFactory;
}
代码示例来源:origin: geotools/geotools
/**
* Merges the wrapper hints with the query ones, making sure not to overwrite the query ones
*
* @param q
* @return
*/
protected Query mergeHints(Query q) {
if (this.hints == null || this.hints.isEmpty()) {
return q;
}
Query clone = new Query(q);
Hints hints = clone.getHints();
if (hints == null || hints.isEmpty()) {
clone.setHints(this.hints);
} else {
for (Entry<Object, Object> entry : this.hints.entrySet()) {
if (!hints.containsKey(entry.getKey())) {
hints.put(entry.getKey(), entry.getValue());
}
}
}
return clone;
}
代码示例来源:origin: geotools/geotools
/**
* Gets the max amount amount of features to keep in memory from the query and system hints
*
* @param query
* @return
*/
static int getMaxFeatures(Query query) {
Hints hints = null;
if (query != null) {
hints = query.getHints();
}
int maxFeatures = 1000;
if (hints != null && hints.get(Hints.MAX_MEMORY_SORT) != null) {
maxFeatures = (Integer) hints.get(Hints.MAX_MEMORY_SORT);
} else if (Hints.getSystemDefault(Hints.MAX_MEMORY_SORT) != null) {
maxFeatures = (Integer) Hints.getSystemDefault(Hints.MAX_MEMORY_SORT);
}
return maxFeatures;
}
代码示例来源:origin: geotools/geotools
throws SQLException {
encodeAliasedTableName(
featureType.getTypeName(), sql, query.getHints(), join.getPrimaryAlias());
代码示例来源:origin: geotools/geotools
.equals(other.getCoordinateSystemReproject()))
&& (getStartIndex() == other.getStartIndex())
&& (getHints() == null
? (other.getHints() == null)
: getHints().equals(other.getHints()));
代码示例来源:origin: geotools/geotools
public void testMixQueryAll() {
// mixing Query.ALL equivalents with extra hints did not work
Query firstQuery = new Query(Query.ALL);
Query secondQuery = new Query(Query.ALL);
firstQuery.setHints(new Hints(Hints.USE_PROVIDED_FID, Boolean.TRUE));
secondQuery.setHints(new Hints(Hints.FEATURE_2D, Boolean.TRUE));
Query mixed = DataUtilities.mixQueries(firstQuery, secondQuery, "mixer");
assertEquals(2, mixed.getHints().size());
assertTrue((Boolean) mixed.getHints().get(Hints.USE_PROVIDED_FID));
assertTrue((Boolean) mixed.getHints().get(Hints.FEATURE_2D));
}
代码示例来源:origin: geotools/geotools
Hints hints = targetQuery.getHints();
hints.put(Hints.GEOMETRY_DISTANCE, 0.0);
代码示例来源:origin: geotools/geotools
/**
* Copy contructor.
*
* @param query the query to copy
*/
public Query(Query query) {
this(
query.getTypeName(),
query.getNamespace(),
query.getFilter(),
query.getMaxFeatures(),
query.getProperties(),
query.getHandle());
this.sortBy = query.getSortBy();
this.coordinateSystem = query.getCoordinateSystem();
this.coordinateSystemReproject = query.getCoordinateSystemReproject();
this.version = query.getVersion();
this.hints = query.getHints();
this.startIndex = query.getStartIndex();
this.alias = query.getAlias();
this.joins = new ArrayList();
for (Join j : query.getJoins()) {
this.joins.add(new Join(j));
}
}
代码示例来源:origin: geotools/geotools
private void fillCache(Query query) throws IOException {
Query cloned = new DefaultQuery(query);
cloned.getHints().remove(Hints.GEOMETRY_DISTANCE);
FeatureCollection features = wrapped.getFeatures(cloned);
FeatureIterator fi = features.features();
index = null;
STRtree newIndex = new STRtree();
while (fi.hasNext()) {
// consider turning all geometries into packed ones, to save space
Feature f = fi.next();
newIndex.insert(ReferencedEnvelope.reference(f.getBounds()), f);
}
fi.close();
index = newIndex;
cachedQuery = query;
cachedBounds = getEnvelope(query.getFilter());
dirty = false;
}
代码示例来源:origin: geotools/geotools
/**
* Copy contructor, clones the state of a generic Query into a DefaultQuery
*
* @param query
*/
public DefaultQuery(Query query) {
this(
query.getTypeName(),
query.getNamespace(),
query.getFilter(),
query.getMaxFeatures(),
query.getProperties(),
query.getHandle());
this.sortBy = query.getSortBy();
this.coordinateSystem = query.getCoordinateSystem();
this.coordinateSystemReproject = query.getCoordinateSystemReproject();
this.version = query.getVersion();
this.hints = query.getHints();
this.startIndex = query.getStartIndex();
this.alias = query.getAlias();
this.joins = query.getJoins();
}
}
代码示例来源:origin: geotools/geotools
private Query namedQuery(Query query) {
Query namedQuery =
namedQuery(
query.getFilter(), query.getMaxFeatures(), query instanceof JoiningQuery);
namedQuery.setProperties(query.getProperties());
namedQuery.setCoordinateSystem(query.getCoordinateSystem());
namedQuery.setCoordinateSystemReproject(query.getCoordinateSystemReproject());
namedQuery.setHandle(query.getHandle());
namedQuery.setMaxFeatures(query.getMaxFeatures());
namedQuery.setStartIndex(query.getStartIndex());
namedQuery.setSortBy(query.getSortBy());
namedQuery.setHints(query.getHints());
if (query instanceof JoiningQuery) {
((JoiningQuery) namedQuery).setQueryJoins(((JoiningQuery) query).getQueryJoins());
((JoiningQuery) namedQuery).setRootMapping(((JoiningQuery) query).getRootMapping());
}
return namedQuery;
}
代码示例来源:origin: geotools/geotools
protected GetFeatureRequest createGetFeature(Query query, ResultType resultType)
throws IOException {
GetFeatureRequest request = client.createGetFeatureRequest();
final WFSDataStore dataStore = getDataStore();
final QName remoteTypeName = dataStore.getRemoteTypeName(getEntry().getName());
final SimpleFeatureType remoteSimpleFeatureType;
remoteSimpleFeatureType = dataStore.getRemoteSimpleFeatureType(remoteTypeName);
request.setTypeName(remoteTypeName);
request.setFullType(remoteSimpleFeatureType);
invertAxisInFilterIfNeeded(query, remoteSimpleFeatureType);
request.setFilter(query.getFilter());
request.setResultType(resultType);
request.setHints(query.getHints());
int maxFeatures = query.getMaxFeatures();
if (Integer.MAX_VALUE > maxFeatures) {
request.setMaxFeatures(maxFeatures);
}
// let the request decide request.setOutputFormat(outputFormat);
request.setPropertyNames(query.getPropertyNames());
request.setSortBy(query.getSortBy());
String srsName = getSupportedSrsName(request, query);
request.setSrsName(srsName);
return request;
}
内容来源于网络,如有侵权,请联系作者删除!