本文整理了Java中org.geotools.data.Query.getTypeName
方法的一些代码示例,展示了Query.getTypeName
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query.getTypeName
方法的具体详情如下:
包路径:org.geotools.data.Query
类名称:Query
方法名:getTypeName
[英]Get the name of the feature type to be queried.
[中]获取要查询的要素类型的名称。
代码示例来源: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 FeatureReader<SimpleFeatureType, SimpleFeature> getFeatureReader(
Query query, Transaction transaction) throws IOException {
FeatureTypeMap map = getTypeMapBackwards(query.getTypeName(), true);
updateMap(map, false);
FeatureReader<SimpleFeatureType, SimpleFeature> reader;
reader = wrapped.getFeatureReader(retypeQuery(query, map), transaction);
if (map.isUnchanged()) return reader;
return new RetypingFeatureCollection.RetypingFeatureReader(
reader, map.getFeatureType(query));
}
代码示例来源:origin: geotools/geotools
public FeatureReader<SimpleFeatureType, SimpleFeature> getFeatureReader(
Query query, Transaction transaction) throws IOException {
PreGeneralizedFeatureSource fs = featureSources.get(query.getTypeName());
if (fs == null) throw new IOException(query.getTypeName() + " not found");
return fs.getFeatureReader(query, transaction);
}
代码示例来源:origin: geotools/geotools
/**
* Returns a feature reader for the specified query and transaction.
*
* <p>This method is not intended to be overridden and is marked final. This implementation
* delegates to {@link FeatureCollection} and wraps an iterator in a {@link FeatureReader}.
*/
public FeatureReader<SimpleFeatureType, SimpleFeature> getFeatureReader(
Query query, Transaction tx) throws IOException {
if (query.getTypeName() == null) {
throw new IllegalArgumentException("Query does not specify type.");
}
return getFeatureSource(query.getTypeName(), tx).getReader(query);
}
代码示例来源:origin: geotools/geotools
@Override
public FeatureReader<SimpleFeatureType, SimpleFeature> getFeatureReader(
Query query, Transaction transaction) throws IOException {
ensureNotDisposed();
if (this.typeName.equals(query.getTypeName())) {
return DataUtilities.reader(source.getFeatures());
}
throw new IOException(
"Not found: "
+ query.getTypeName()
+ " DataStoreAdaptor contains "
+ this.typeName);
}
}
代码示例来源:origin: geotools/geotools
private Query namedQuery(final Query query) {
final String localName = typeInfo.getFeatureTypeName();
final String typeName = query.getTypeName();
if (typeName != null && !localName.equals(typeName)) {
throw new IllegalArgumentException(
"Wrong type name: " + typeName + " (this is " + localName + ")");
}
Query namedQuery = new Query(query);
namedQuery.setTypeName(localName);
return namedQuery;
}
代码示例来源:origin: geotools/geotools
/**
* Return the name of the type that is queried.
*
* @param query
* @return Name constructed from the query.
*/
private Name getName(Query query) {
if (query.getNamespace() == null) {
return Types.typeName(query.getTypeName());
} else {
return Types.typeName(query.getNamespace().toString(), query.getTypeName());
}
}
代码示例来源:origin: geotools/geotools
public FeatureReader<SimpleFeatureType, SimpleFeature> getFeatureReader(
Query query, Transaction transaction) throws IOException {
String typeName = query.getTypeName();
return getDataStore(typeName).getFeatureReader(query, transaction);
}
代码示例来源:origin: geotools/geotools
/**
* Return a 'view' of the given {@code DataStore} constrained by a {@code Query}.
*
* @param store the data store
* @param query the query
* @return the constrained view
* @throws IOException if the data store cannot be accessed
* @throws SchemaException if the query is incompatible with the store's contents
*/
public static SimpleFeatureSource createView(final DataStore store, final Query query)
throws IOException, SchemaException {
return createView(store.getFeatureSource(query.getTypeName()), query);
}
代码示例来源:origin: geotools/geotools
public SimpleFeatureCollection getFeatures(Query query) throws IOException {
String schemaName = wrapped.getSchema().getName().getLocalPart();
if (query.getTypeName() != null && !schemaName.equals(query.getTypeName())) {
throw new DataSourceException(
"Typename mismatch, query asks for '"
+ query.getTypeName()
+ " but this feature source provides '"
+ schemaName
+ "'");
}
return getFeatureCollection(query, getEnvelope(query.getFilter()));
}
代码示例来源:origin: geotools/geotools
public PropertyFeatureWriter(
ContentFeatureSource source, ContentState contentState, Query query, boolean append)
throws IOException {
this.state = contentState;
this.featureSource = source;
PropertyDataStore store = (PropertyDataStore) contentState.getEntry().getDataStore();
String namespaceURI = store.getNamespaceURI();
String typeName = query.getTypeName();
File dir = store.dir;
read = new File(store.dir, typeName + ".properties");
write = File.createTempFile(typeName + System.currentTimeMillis(), null, dir);
// start reading
delegate = new PropertyFeatureReader(namespaceURI, read);
type = delegate.getFeatureType();
// open writer
writer = new BufferedWriter(new FileWriter(write));
// write header
writer.write("_=");
writer.write(DataUtilities.encodeType(type));
}
// constructor end
代码示例来源:origin: geotools/geotools
public void computeAggregateFunction(Query query, FeatureCalc function) throws IOException {
final Lock lock = rwLock.readLock();
try {
lock.lock();
checkStore();
SimpleFeatureSource fs = slicesIndexStore.getFeatureSource(query.getTypeName());
if (fs instanceof ContentFeatureSource)
((ContentFeatureSource) fs).accepts(query, function, null);
else {
final SimpleFeatureCollection collection = fs.getFeatures(query);
collection.accepts(function, null);
}
} finally {
lock.unlock();
}
}
代码示例来源:origin: geotools/geotools
@Override
public FeatureReader<SimpleFeatureType, SimpleFeature> getFeatureReader(
Query query, Transaction transaction) throws IOException {
SimpleFeatureSource fs = getFeatureSource(query.getTypeName());
if (fs == null) {
throw new IOException(
"Could not find feature type mentioned in query: '"
+ query.getTypeName()
+ "'");
}
if (fs instanceof SimpleFeatureStore) {
((SimpleFeatureStore) fs).setTransaction(transaction);
}
SimpleFeatureIterator iterator = fs.getFeatures().features();
return new DelegateFeatureReader<SimpleFeatureType, SimpleFeature>(
fs.getSchema(), iterator);
}
代码示例来源:origin: geotools/geotools
/**
* Hashcode based on all parameters other than the handle.
*
* @return hascode for this Query
*/
@Override
public int hashCode() {
String[] n = getPropertyNames();
return ((n == null) ? (-1) : ((n.length == 0) ? 0 : (n.length | n[0].hashCode())))
| getMaxFeatures()
| ((getFilter() == null) ? 0 : getFilter().hashCode())
| ((getTypeName() == null) ? 0 : getTypeName().hashCode())
| ((getVersion() == null) ? 0 : getVersion().hashCode())
| ((getCoordinateSystem() == null) ? 0 : getCoordinateSystem().hashCode())
| ((getCoordinateSystemReproject() == null)
? 0
: getCoordinateSystemReproject().hashCode())
| getStartIndex();
}
代码示例来源:origin: geotools/geotools
private Query setupBaseQuery(Query q) {
if (q == null) {
q = new Query();
} else {
q = new Query(q);
}
if (hints != null) {
q.setHints(hints);
}
if (q.getTypeName() == null) {
q.setTypeName(typeName);
}
return q;
}
代码示例来源:origin: geotools/geotools
/** Test of getTypeName method, of class org.geotools.data.Query. */
public void testTypeName() {
Query query = new Query();
assertNull(query.getTypeName());
query.setTypeName("foobar");
assertEquals("foobar", query.getTypeName());
query = new Query("mytype", Filter.EXCLUDE);
assertEquals("mytype", query.getTypeName());
}
代码示例来源:origin: geotools/geotools
@Override
public SimpleFeatureCollection getGranules(Query q) throws IOException {
Utilities.ensureNonNull("query", q);
q = mergeHints(q);
String typeName = q.getTypeName();
checkStore();
//
// Load tiles informations, especially the bounds, which will be
// reused
//
final SimpleFeatureSource featureSource = getTileIndexStore().getFeatureSource(typeName);
if (featureSource == null) {
throw new NullPointerException(
"The provided SimpleFeatureSource is null, it's impossible to create an index!");
}
return featureSource.getFeatures(q);
}
代码示例来源:origin: geotools/geotools
public void computeAggregateFunction(Query query, FeatureCalc function) throws IOException {
query = mergeHints(query);
checkStore();
SimpleFeatureSource fs = getTileIndexStore().getFeatureSource(query.getTypeName());
if (fs instanceof ContentFeatureSource)
((ContentFeatureSource) fs).accepts(query, function, null);
else {
final SimpleFeatureCollection collection = fs.getFeatures(query);
collection.accepts(function, null);
}
}
代码示例来源:origin: geotools/geotools
public SimpleFeatureType getQueryType(Query query) throws IOException {
final String typeName = query.getTypeName();
final String propertyNames[] = query.getPropertyNames();
final FeatureTypeInfo typeInfo = typeInfoCache.getFeatureTypeInfo(typeName);
final SimpleFeatureType completeSchema = typeInfo.getFeatureType();
SimpleFeatureType featureType = completeSchema;
if (!query.retrieveAllProperties() || query.getCoordinateSystem() != null) {
try {
featureType =
DataUtilities.createSubType(
featureType, propertyNames, query.getCoordinateSystem());
} catch (SchemaException e) {
LOGGER.log(Level.FINEST, e.getMessage(), e);
throw new DataSourceException("Could not create Feature Type for query", e);
}
}
return featureType;
}
代码示例来源:origin: geotools/geotools
/** Get features based on the query specified. */
@Override
public FeatureCollection<FeatureType, Feature> getFeatures(Query query) throws IOException {
GetFeatureRequest request = client.createGetFeatureRequest();
FeatureType schema = dataAccess.getSchema(typeName);
QName name = dataAccess.getRemoteTypeName(typeName);
request.setTypeName(new QName(query.getTypeName()));
request.setFullType(schema);
request.setFilter(query.getFilter());
request.setPropertyNames(query.getPropertyNames());
request.setSortBy(query.getSortBy());
String srsName = null;
request.setSrsName(srsName);
return new WFSContentComplexFeatureCollection(request, schema, name);
}
内容来源于网络,如有侵权,请联系作者删除!