15 namespace MAKVRinTerra
17 template <
typename FS>
26 typedef boost::shared_ptr<DtIndexChooserFeatureSet>
Ptr;
28 static FS*
Make(FS* input, FS* mainIndex)
33 std::string
label()
const {
return myInput->label() +
" index chooser"; }
39 Mutex::scoped_lock lock(
myData->myMutex,
false);
41 tot += i->second->numberOfFeatures();
51 Mutex::scoped_lock lock(
myData->myMutex,
false);
53 if (!i->second->elided())
64 Mutex::scoped_lock lock(
myData->myMutex,
false);
66 if (!i->second->empty())
77 bool isCacheable(
const boost::optional<DtFeatureGeometry>& area)
const
82 void cacheEstimate(
double& time,
double&
size,
const boost::optional<DtFeatureGeometry>& area)
const
88 const boost::optional<DtFeatureGeometry>& area,
94 bool loaded(
double timeout=0.0)
const
96 tbb::tick_count start = tbb::tick_count::now();
101 Mutex::scoped_lock lock(
myData->myMutex,
false);
104 double whatsleft = timeout - (tbb::tick_count::now() - start).seconds();
108 if (!i->second->loaded(whatsleft))
134 : func(func), query(query)
157 const boost::optional<DtFeatureGeometry>& geometry,
164 return myMainIndex->filter(combined, geometry, load);
182 DtWarn <<
"Query = " << query << std::endl;
184 DtWarn <<
"Combined = " << combined << std::endl;
190 Mutex::scoped_lock lock(
myData->myMutex,
true);
192 if (i !=
myData->myIndexMap.end())
194 DtInfo <<
"Using feature attribute index on key " << attr->key() << std::endl;
195 return i->second->filter(combined, geometry, load);
199 typedef typename AttributeIndex::Config AttributeConfig;
201 std::auto_ptr<FS> set(AttributeIndex::Make(
202 new AttributeConfig(
myInput->filter(
true,
LOAD), attr->key())));
204 DtInfo <<
"Creating feature attribute index on key " << attr->key() << std::endl;
205 std::auto_ptr<FS> ret(set->filter(combined, geometry, load));
207 myData->myIndexMap.insert(attr->key(), set.release());
208 return ret.release();
211 return myMainIndex->filter(combined, geometry, load);
240 typedef tbb::queuing_rw_mutex
Mutex;
247 typedef boost::ptr_map<const DtFeature::Key, FS>
Map;
const_iterator begin() const
Definition: indexChooserFeatureSet.h:250
bool isCacheable(const boost::optional< DtFeatureGeometry > &area) const
Definition: indexChooserFeatureSet.h:77
void cacheEstimate(double &time, double &size, const boost::optional< DtFeatureGeometry > &area) const
Definition: indexChooserFeatureSet.h:82
const_iterator end() const
Definition: indexChooserFeatureSet.h:251
DetachCallback addLoadedCallback(const LoadedCallback &cb) const
Definition: indexChooserFeatureSet.h:120
Map myIndexMap
Definition: indexChooserFeatureSet.h:254
static FS * Make(FS *input, FS *mainIndex)
Definition: indexChooserFeatureSet.h:28
Definition: featureSet.h:48
void operator()(const Feature &feature) const
Definition: indexChooserFeatureSet.h:127
Load all features which may be in the feature set.
Definition: featureSet.h:39
const boost::shared_ptr< FS > myMainIndex
Definition: indexChooserFeatureSet.h:243
voidpf void uLong size
Definition: ioapi.h:39
Caller(const ForEachFunction &func, const DtQuery &query)
Definition: indexChooserFeatureSet.h:133
Do not initiate new loads, read whatever is currently loaded.
Definition: featureSet.h:45
FS * clone() const
Definition: indexChooserFeatureSet.h:115
std::string label() const
Definition: indexChooserFeatureSet.h:33
DtIndexChooserFeatureSet(const DtIndexChooserFeatureSet &from, const DtQuery &combined)
Definition: indexChooserFeatureSet.h:223
void cacheData(const boost::optional< DtFeatureGeometry > &area, DtFeatureCacheProgressCallback *progress) const
Definition: indexChooserFeatureSet.h:87
Definition: indexChooserFeatureSet.h:18
bool isIndexed() const
Definition: indexChooserFeatureSet.h:72
Matches features that have an attribute with a certain key.
Definition: query.h:295
Mutex myMutex
Definition: indexChooserFeatureSet.h:253
boost::ptr_map< const DtFeature::Key, FS > Map
Definition: indexChooserFeatureSet.h:247
FS * filter(const DtQuery &query, const boost::optional< DtFeatureGeometry > &geometry, DtLoadType load) const
Definition: indexChooserFeatureSet.h:155
FS::Feature Feature
Definition: indexChooserFeatureSet.h:21
Map::const_iterator const_iterator
Definition: indexChooserFeatureSet.h:248
unsigned numberOfFeatures() const
Definition: indexChooserFeatureSet.h:35
DtIndexChooserFeatureSet(FS *input, FS *mainIndex)
Definition: indexChooserFeatureSet.h:215
Represents a set of characeters a DtFeature object can have. DtQuery objects are the way to communica...
Definition: query.h:38
Definition: indexChooserFeatureSet.h:125
bool empty() const
Definition: indexChooserFeatureSet.h:59
DtQuery myFilteredAttributes
Definition: indexChooserFeatureSet.h:258
FS::DetachCallback DetachCallback
Definition: indexChooserFeatureSet.h:24
DtIndexChooserFeatureSet(const DtIndexChooserFeatureSet &from)
Definition: indexChooserFeatureSet.h:232
const boost::shared_ptr< Data > myData
Definition: indexChooserFeatureSet.h:257
Definition: indexChooserFeatureSet.h:245
Definition: attributeIndexingFeatureSet.h:29
bool DtIsElided(const FS &fs)
Helper functions using null pointers to feature sets to denote empty feature sets. This helps avoid dynamically allocating lots of empty feature sets.
Definition: featureSet.h:465
DtLoadType
Used to indicate whether to load features. See DtFeatureSetTemplate::filter.
Definition: featureSet.h:36
bool elided() const
Definition: indexChooserFeatureSet.h:46
tbb::queuing_rw_mutex Mutex
Definition: indexChooserFeatureSet.h:240
bool matches(const DtFeature &feature) const
Test a feature to see if it matches this query.
DtQuery query
Definition: indexChooserFeatureSet.h:140
const boost::shared_ptr< FS > myInput
Definition: indexChooserFeatureSet.h:242
bool loaded(double timeout=0.0) const
Definition: indexChooserFeatureSet.h:94
boost::shared_ptr< DtIndexChooserFeatureSet > Ptr
Definition: indexChooserFeatureSet.h:26
DetachCallback forEachFeatureAsync(const ForEachFunction &func) const
Definition: indexChooserFeatureSet.h:149
void forEachFeatureParallel(const ForEachFunction &func) const
Definition: indexChooserFeatureSet.h:143
ForEachFunction func
Definition: indexChooserFeatureSet.h:139
FS::ForEachFunction ForEachFunction
Definition: indexChooserFeatureSet.h:22
FS::LoadedCallback LoadedCallback
Definition: indexChooserFeatureSet.h:23