|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.geotools.caching.featurecache.AbstractFeatureCache
public abstract class AbstractFeatureCache
Abstract implementation of a feature cache.
This implementation uses envelopes to deal with determining what has been added to the cache already and what items need to be retrieved from the feature source.
Field Summary | |
---|---|
protected static org.opengis.filter.FilterFactory |
ff
|
protected FeatureSource |
fs
|
protected java.util.concurrent.locks.ReentrantReadWriteLock |
lock
|
protected static java.util.logging.Logger |
logger
|
protected int |
source_feature_reads
|
protected int |
source_hits
|
Constructor Summary | |
---|---|
AbstractFeatureCache(FeatureSource fs)
Creates a new feature cache from the given feature source. |
Method Summary | |
---|---|
protected FeatureCollection |
_getFeatures(org.opengis.filter.Filter filter)
Gets features with satisfy a given filter. |
void |
addFeatureListener(FeatureListener listener)
Adds a feature listener |
void |
changed(FeatureEvent event)
This event is fired when the features in the feature source have changed. |
FeatureCollection |
get(com.vividsolutions.jts.geom.Envelope e)
Get all features within a given envelope as a in memory feature collection. |
DataAccess |
getDataStore()
Returns the DataAccess of the underlying feature source |
FeatureCollection |
getFeatures()
Gets all features from that are contained within the feature source. |
FeatureCollection |
getFeatures(org.opengis.filter.Filter filter)
Get all features with satisfy a given filter. |
FeatureCollection |
getFeatures(Query query)
Gets all features which satisfy the given query. |
ResourceInfo |
getInfo()
Information describing the contents of this resoruce. |
org.opengis.feature.type.Name |
getName()
Returns the qualified name for the Features this FeatureSource serves. |
QueryCapabilities |
getQueryCapabilities()
Returns and indication of what query capabilities this FeatureSource supports natively. |
org.opengis.feature.simple.SimpleFeatureType |
getSchema()
Returns the feature schema of the underlying feature source. |
abstract java.lang.String |
getStats()
Gets the feature cache statistics |
protected abstract void |
isOversized(FeatureCollection fc)
Determines if the given feature collection is too big to put into the cache. |
protected abstract java.util.List<com.vividsolutions.jts.geom.Envelope> |
match(com.vividsolutions.jts.geom.Envelope e)
Returns a list of envelopes that are not in the cache but within the given bounds. |
void |
readLock()
Gets a read lock |
void |
readUnLock()
Unlocks the read lock |
protected void |
register(BBOXImpl f)
Registers a given bounding box filter with the cache. |
protected abstract void |
register(com.vividsolutions.jts.geom.Envelope e)
Registers a given envelope with the cache. |
void |
register(org.opengis.filter.Filter f)
Registers filter from the cache. |
void |
removeFeatureListener(FeatureListener listener)
Removes a feature listener. |
java.lang.String |
sourceAccessStats()
Returns a string containing statistics about data source reading. |
protected void |
unregister(BBOXImpl f)
Unregisters a given bounding box filter with the cache. |
protected abstract void |
unregister(com.vividsolutions.jts.geom.Envelope e)
Unregisters a given envelope with the cache. |
void |
unregister(org.opengis.filter.Filter f)
Unregisters filter from the cache. |
void |
writeLock()
Gets a write lock |
void |
writeUnLock()
unlocks the write lock |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface org.geotools.caching.featurecache.FeatureCache |
---|
clear, dispose, peek, put, put, remove |
Methods inherited from interface org.geotools.data.FeatureSource |
---|
getBounds, getBounds, getCount, getSupportedHints |
Field Detail |
---|
protected static java.util.logging.Logger logger
protected static org.opengis.filter.FilterFactory ff
protected FeatureSource fs
protected int source_hits
protected int source_feature_reads
protected java.util.concurrent.locks.ReentrantReadWriteLock lock
Constructor Detail |
---|
public AbstractFeatureCache(FeatureSource fs)
fs
- Method Detail |
---|
public void addFeatureListener(FeatureListener listener)
addFeatureListener
in interface FeatureSource
listener
- FeatureListenerpublic DataAccess getDataStore()
getDataStore
in interface FeatureSource
public FeatureCollection getFeatures() throws java.io.IOException
getFeatures
in interface FeatureSource
java.io.IOException
- For all data source errors.public FeatureCollection getFeatures(Query query) throws java.io.IOException
This version gets all the features from the cache and datastore and combines them in a memory feature collection.
This should probably be overwritten for any implementations.
getFeatures
in interface FeatureSource
query
- a datasource query object. It encapsulates requested
information, such as typeName, maxFeatures and filter.
java.io.IOException
- For all data source errors.Query
public FeatureCollection getFeatures(org.opengis.filter.Filter filter) throws java.io.IOException
This version gets all features from the cache and from memory and combines them in a memory feature collection.
This should probably be overwritten for any implementations.
getFeatures
in interface FeatureSource
filter
- An OpenGIS filter; specifies which features to retrieve.
null is not allowed, use Filter.INCLUDE instead.
java.io.IOException
- For all data source errors.protected FeatureCollection _getFeatures(org.opengis.filter.Filter filter) throws java.io.IOException
filter
- must be a BBOXImpl filter
java.io.IOException
public FeatureCollection get(com.vividsolutions.jts.geom.Envelope e) throws java.io.IOException
get
in interface FeatureCache
java.io.IOException
protected abstract java.util.List<com.vividsolutions.jts.geom.Envelope> match(com.vividsolutions.jts.geom.Envelope e)
e
-
protected void register(BBOXImpl f)
This informs the cache that it has data for the given area.
f
- protected abstract void register(com.vividsolutions.jts.geom.Envelope e)
This informs the cache that it has data for the given area.
e
- protected abstract void unregister(com.vividsolutions.jts.geom.Envelope e)
This informs the cache that there is no data for the given envelope or that the data is incomplete.
e
- protected void unregister(BBOXImpl f)
This informs the cache that there is no data for the given envelope or that the data is incomplete.
e
- public void unregister(org.opengis.filter.Filter f)
Filter needs to be an instance of BBOXImpl or a collection of BBOXImpls that are combined using or. Any other combination will result in a UnsupportedOperationException.
f
- protected abstract void isOversized(FeatureCollection fc) throws CacheOversizedException
fc
-
CacheOversizedException
- if feature collection is to big for cachepublic org.opengis.feature.simple.SimpleFeatureType getSchema()
getSchema
in interface FeatureSource
public void removeFeatureListener(FeatureListener listener)
removeFeatureListener
in interface FeatureSource
listener
- FeatureListenerpublic void changed(FeatureEvent event)
changed
in interface FeatureListener
event
- The FeatureEvent being firedpublic void register(org.opengis.filter.Filter f)
Filter needs to be an instance of BBOXImpl or a collection of BBOXImpls that are combined using or. Any other combination will result in a UnsupportedOperationException.
f
- public java.lang.String sourceAccessStats()
Stats include: Source hits and Feature Source Reads
public abstract java.lang.String getStats()
public void readLock()
public void readUnLock()
public void writeLock()
public void writeUnLock()
public ResourceInfo getInfo()
FeatureSource
Please note that for FeatureContent:
getInfo
in interface FeatureSource
public org.opengis.feature.type.Name getName()
FeatureSource
Note this is different from getSchema().getType().getName()
(that
is, the feature type name), this name specifies the
AttributeDescriptor name
for the
Features served by this source. So,
FeatureSoruce.getName() == FeatureSource.getFeatures().next().getAttributeDescriptor().getName()
.
Though it's a common practice when dealing with SimpleFeatureType
and SimpleFeature
to assume they're equal. There's no conflict
(as per the dynamic typing system the org.opengis.feature
package
defines) in a Feature and its type sharing the same name, as well as in a
GML schema an element declaration and a type definition may be named the
same. Yet, the distinction becomes important as we get rid of that
assumption and thus allow to reuse a type definition for different
FeatureSoruces, decoupling the descriptor (homologous to the Feature
element declaration in a GML schema) from its type definition.
So, even if implementors are allowed to delegate to
getSchema().getName()
if they want to call the fatures and their
type the same, client code asking a
DataAccess.getFeatureSource(Name)
shall use this name to request
for a FeatureSource, rather than the type name, as used in pre 2.5
versions of GeoTools. For example, if we have a FeatureSource named
Roads
and its type is named Roads_Type
, the
DataAccess
shall be queried through Roads
, not
Roads_Type
.
getName
in interface FeatureSource
public QueryCapabilities getQueryCapabilities()
FeatureSource
getQueryCapabilities
in interface FeatureSource
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |