#include <TeQuerierDBStr3.h>

Definition at line 47 of file TeQuerierDBStr3.h.
| bool | initPortal (TeTSEntry *ent=0) |
Public Member Functions | |
| void | clear () |
| Empties querier instances. | |
| bool | fetchInstance (TeSTInstance &sto) |
| Returns each loaded STO. | |
| TeGeomRep | geometryRep () |
| Returns the geometry representation of the theme. | |
| TeAttributeList | getAttrList () |
| Gets the attribute list from querier. | |
| int | getNumTimeFrames () |
| Gets the number of generated time frames. | |
| bool | getTS (TeTemporalSeries &ts) |
| Gets the full temporal serie. | |
| bool | getTSEntry (TeTSEntry &tsEntry, int frame) |
| Gets each temporal serie entry, for each time frame. | |
| TeTSParams & | getTSParams () |
| Returns the temporal serie params. | |
| TeLayer * | layer () |
| Returns the pointer to the layer. | |
| virtual bool | loadGeometries (TeMultiGeometry &geometries) |
| Loads all geometries. | |
| virtual bool | loadGeometries (TeMultiGeometry &geometries, unsigned int &index) |
| Loads all geometries of the index-th geometry representation. | |
| bool | loadInstances (TeTSEntry *ent=0) |
| Loads the instances. | |
| bool | loadTimeFrameInstances (int frame=-1) |
| Loads the STOs. | |
| int | numElemInstances () |
| Returns the number of instances. | |
| string | objectId () |
| Returns the object identifier. | |
| TeQuerierParams * | params () |
| Returns the querier parameters. | |
| TeQuerierDBStr3 (TeQuerierParams *params) | |
| Constructor. | |
| TeTheme * | theme () |
| Returns the pointer to the theme. | |
Static Public Member Functions | |
| static TeQuerierImpl * | DefaultObject (const TeQuerierParams &) |
| Returns a default object. | |
Protected Member Functions | |
| void | clearVectors () |
| clear internal vectors | |
| string | sqlFrom (string geomTable="") |
| Build the sql from clause. | |
| virtual string | sqlWhereRestrictions (TeRepresentation *rep=0) |
| Return a where clause in SQL that represent the querier restrictions. | |
Protected Attributes | |
| int | attrIndex1_ |
| index in the first portal of the first attribute | |
| int | attrIndex2_ |
| index in the first portal of the last attribute | |
| TeSharedPtr < TeAttributeList > | attrList_ |
| this flag indicates if the temporal serie was filled | |
| TeTable | attrTable_ |
| internal information used to fill the stos | |
| bool | filledSerie_ |
| temporal series | |
| bool | flagPortal_ |
| flag to control the portal | |
| vector< int > | geomIndex1_ |
| index where the geometry information begin in each portal in the vector "portals_" | |
| vector< int > | geomIndex2_ |
| index where the geometry information finish in each portal in the vector "portals_" | |
| vector < TeRepresentation > | geomRepr_ |
| keep the geometry representation of each portal | |
| int | groupIndex_ |
| index in the first portal of the group, if there is collection table | |
| map< int, int > | legendIdGroup_ |
| map from legend identifier to group number | |
| vector< int > | linkIndex_ |
| index of the link attributes in each portal in the vector "portals_" | |
| TeQuerierParams * | params_ |
| querier parameters that define the used querier strategy | |
| vector < TeDatabasePortal * > | portals_ |
| a portal to each geometry representation | |
| vector< int > | timeIndex1_ |
| index of the initial time in each portal in the vector "portals_" | |
| vector< int > | timeIndex2_ |
| index of the final time in each portal in the vector "portals_" | |
| TeTemporalSeries * | ts_ |
| map< int, vector< int > > | uniqueIndex_ |
| map FROM each portal in the vector "portals_" TO the indexes of the unique attributes | |
Private Member Functions | |
| bool | fillSTO (TeSTInstance &sto) |
| Internal function to fill STO. | |
Private Attributes | |
| string | fromClause_ |
| TeGeomRep | rep_ |
| int | timeFramePortal_ |
| TeTSEntry | TSEntry_ |
| string | whereClause_ |
| TeQuerierDBStr3::TeQuerierDBStr3 | ( | TeQuerierParams * | params | ) | [inline] |
Definition at line 67 of file TeQuerierDBStr3.h.
00067 : 00068 TeQuerierDB(params), 00069 timeFramePortal_(-1), 00070 fromClause_(""), 00071 whereClause_("") 00072 {}
| void TeQuerierDB::clear | ( | void | ) | [virtual, inherited] |
Reimplemented from TeQuerierImpl.
Definition at line 285 of file TeQuerierDB.cpp.
References TeQuerierDB::clearVectors().
00286 { 00287 clearVectors(); 00288 }
| void TeQuerierDB::clearVectors | ( | ) | [protected, inherited] |
Definition at line 269 of file TeQuerierDB.cpp.
References TeQuerierDB::flagPortal_, TeQuerierDB::geomRepr_, and TeQuerierDB::portals_.
Referenced by TeQuerierDB::clear(), TeQuerierDBStr1::fetchInstance(), fillSTO(), TeQuerierDBStr2::fillSTO(), initPortal(), TeQuerierDBStr2::initPortal(), TeQuerierDBStr1::initPortal(), and TeQuerierDBStr1::loadInstances().
00270 { 00271 vector<TeDatabasePortal*>::iterator itPortal = portals_.begin(); 00272 while(itPortal!=portals_.end()) 00273 { 00274 TeDatabasePortal* portal = *itPortal; 00275 delete portal; 00276 ++itPortal; 00277 } 00278 00279 portals_.clear(); 00280 geomRepr_.clear(); 00281 flagPortal_ = false; 00282 }
| static TeQuerierImpl* TeQuerierImpl::DefaultObject | ( | const TeQuerierParams & | ) | [inline, static, inherited] |
| bool TeQuerierDBStr3::fetchInstance | ( | TeSTInstance & | sto | ) | [virtual] |
Implements TeQuerierDB.
Definition at line 363 of file TeQuerierDBStr3.cpp.
References TeQuerierParams::box(), TeSTInstance::clear(), TeQuerierImpl::filledSerie_, fillSTO(), TeMultiGeometry::getBox(), TeBaseSTInstance< GeometryType, TimeType >::getGeometries(), TeBaseSTInstance< GeometryType, TimeType >::getPropertyValue(), TeQuerierImpl::params_, TeTemporalSeries::setTSEntryValue(), TeDATA, TeTSEntry::timeFrame_, TeQuerierImpl::ts_, TSEntry_, and updateBox().
00364 { 00365 sto.clear(); 00366 00367 if(!fillSTO(sto)) 00368 return false; 00369 00370 //build a temporal serie to one object 00371 string val; 00372 sto.getPropertyValue(val, 0); 00373 if((ts_) && (ts_->setTSEntryValue(TSEntry_.timeFrame_, atof(val.c_str()), TeDATA))) 00374 filledSerie_ = true; 00375 00376 updateBox(params_->box(), sto.getGeometries().getBox()); 00377 return true; 00378 }
| bool TeQuerierDBStr3::fillSTO | ( | TeSTInstance & | sto | ) | [private] |
Definition at line 237 of file TeQuerierDBStr3.cpp.
References TeSTInstance::addGeometry(), TeBaseSTInstance< GeometryType, TimeType >::addPropertyValue(), TeBaseSTInstance< GeometryType, TimeType >::addUniqueId(), TeQuerierDB::attrIndex1_, TeQuerierDB::attrIndex2_, TeQuerierImpl::attrList_, TeTime::chronon(), TeQuerierDB::clearVectors(), TeDatabasePortal::fetchGeometry(), TeDatabasePortal::fetchRow(), TeQuerierDB::flagPortal_, TeQuerierDB::geomIndex1_, TeDatabasePortal::getData(), TeDatabasePortal::getDate(), TeDatabasePortal::getInt(), TeQuerierDB::groupIndex_, TeQuerierParams::hasSpatialRes(), TeQuerierDB::legendIdGroup_, TeQuerierDB::linkIndex_, TeBaseSTInstance< GeometryType, TimeType >::objectId(), TeQuerierImpl::params_, TeQuerierDB::portals_, rep_, TeBaseSTInstance< GeometryType, TimeType >::setAttrList(), TeBaseSTInstance< GeometryType, TimeType >::setSlice(), TePOINTS, TeTSEntry::time_, TeTSEntry::timeFrame_, timeFramePortal_, TeQuerierDB::timeIndex1_, TeSTInstance::timeInterval(), and TSEntry_.
Referenced by fetchInstance().
00238 { 00239 if(portals_.empty()) 00240 return false; 00241 00242 TeDatabasePortal* portal = portals_[0]; 00243 if(!portal) 00244 return false; 00245 00246 if(!flagPortal_) //end of portal 00247 { 00248 clearVectors(); 00249 return false; 00250 } 00251 00252 00253 // first : verify the time 00254 if(TSEntry_.timeFrame_ > -1) 00255 { 00256 TeTime t1 = portal->getDate(timeIndex1_[0]); 00257 t1.chronon ((TSEntry_.time_).intervalChronon()); 00258 00259 //if the time is before the requested interval 00260 while ( (TSEntry_.time_).before(t1) && flagPortal_) 00261 { 00262 flagPortal_ = portal->fetchRow(); 00263 t1 = portal->getDate(timeIndex1_[0]); 00264 t1.chronon ((TSEntry_.time_).intervalChronon()); 00265 } 00266 00267 if(!(TSEntry_.time_).during(t1)) 00268 return false; 00269 00270 TeTimeInterval interval(t1, t1); 00271 sto.timeInterval(interval); 00272 00273 timeFramePortal_ = (TSEntry_.timeFrame_)+1; //next time frame 00274 } 00275 00276 //if there is spatial restriction, it groups all instances of all objects 00277 if(!params_->hasSpatialRes()) 00278 { 00279 // get object_id 00280 string objId = string(portal->getData(linkIndex_[0])); // 0: object_id 00281 sto.objectId (objId); 00282 sto.addUniqueId (objId); 00283 00284 //get the group index 00285 if(groupIndex_!=-1) 00286 { 00287 int gIndex = portal->getInt(groupIndex_); 00288 sto.setSlice(legendIdGroup_[gIndex]); 00289 } 00290 } 00291 00292 sto.setAttrList(attrList_); 00293 00294 //get property 00295 for(int s=attrIndex1_; s<=attrIndex2_; ++s) 00296 sto.addPropertyValue(portal->getData(s)); 00297 00298 // get geometry 00299 if(rep_ == TePOINTS) 00300 { 00301 TePoint point; 00302 flagPortal_ = portal->fetchGeometry(point,geomIndex1_[0]); 00303 sto.addGeometry (point); 00304 } 00305 else 00306 { 00307 TeCell cell; 00308 flagPortal_ = portal->fetchGeometry(cell, geomIndex1_[0]); 00309 sto.addGeometry (cell); 00310 } 00311 00312 return true; 00313 }
| TeGeomRep TeQuerierDB::geometryRep | ( | ) | [inherited] |
Definition at line 291 of file TeQuerierDB.cpp.
References TeTheme::layer(), TeQuerierImpl::params_, and TeQuerierParams::theme().
| TeAttributeList TeQuerierImpl::getAttrList | ( | ) | [inline, inherited] |
Definition at line 84 of file TeQuerierImpl.h.
Referenced by TeQuerier::getAttrList().
00084 { return (*attrList_); }
| int TeQuerierImpl::getNumTimeFrames | ( | ) | [inherited] |
Definition at line 121 of file TeQuerierImpl.cpp.
References TeTemporalSeries::numTimeFrames(), and TeQuerierImpl::ts_.
Referenced by TeQuerier::getNumTimeFrames().
00122 { 00123 if(!ts_) 00124 return 0; 00125 00126 return (ts_->numTimeFrames()); 00127 }
| bool TeQuerierImpl::getTS | ( | TeTemporalSeries & | ts | ) | [inherited] |
Definition at line 130 of file TeQuerierImpl.cpp.
References TeQuerierImpl::ts_.
Referenced by TeQuerier::getTS().
00131 { 00132 if(!ts_) 00133 return false; 00134 00135 ts = (*ts_); 00136 return true; 00137 }
Definition at line 112 of file TeQuerierImpl.cpp.
References TeTemporalSeries::getTSEntry(), and TeQuerierImpl::ts_.
Referenced by TeQuerier::getTSEntry(), and TeQuerierImpl::loadTimeFrameInstances().
00113 { 00114 if(!ts_) 00115 return false; 00116 00117 return(ts_->getTSEntry(tsEntry, frame)); 00118 }
| TeTSParams & TeQuerierImpl::getTSParams | ( | ) | [inherited] |
Definition at line 140 of file TeQuerierImpl.cpp.
References TeQuerierImpl::ts_, and TeTemporalSeries::TSparams_.
Referenced by TeQuerier::getTSParams().
Definition at line 33 of file TeQuerierDBStr3.cpp.
References TeTable::attInitialTime(), TeQuerierDB::attrIndex1_, TeQuerierDB::attrIndex2_, TeQuerierDB::attrTable_, TeTheme::attrTables(), TeQuerierParams::chronon(), TeQuerierDB::clearVectors(), TeTheme::collectionTable(), db, TeDatabasePortal::fetchRow(), TeQuerierDB::flagPortal_, fromClause_, TeQuerierDB::geomIndex1_, TeRepresentation::geomRep_, TeDatabase::getAttributeList(), TeDatabasePortal::getData(), TeDatabase::getPortal(), TeDatabase::getSQLStatistics(), TeDatabase::getSQLTemporalFunction(), TeQuerierParams::groupAttr(), TeQuerierDB::groupIndex_, TeQuerierParams::hasSpatialRes(), TeTheme::layer(), TeAbstractTheme::legend(), TeQuerierDB::legendIdGroup_, TeQuerierDB::linkIndex_, TeTable::linkName(), TeTable::name(), TeQuerierParams::objId(), TeQuerierImpl::params_, TeQuerierDB::portals_, TeDatabasePortal::query(), rep_, TeQuerierDB::sqlWhereRestrictions(), TeRepresentation::tableName_, TeTable::tableType(), TeAttrEvent, TeCELLS, TeConvertToUpperCase(), TeFixedGeomDynAttr, TePOINTS, TeQuerierParams::theme(), TeQuerierDB::timeIndex1_, TeQuerierDB::timeIndex2_, TeTable::uniqueName(), and whereClause_.
Referenced by loadInstances().
00034 { 00035 string selectClause, fromClause, whereClause, groupByClause; 00036 string initialTime, finalTime; 00037 linkIndex_.clear(); 00038 linkIndex_.push_back(-1); 00039 attrIndex1_=-1; 00040 attrIndex2_=-1; 00041 timeIndex1_.clear(); 00042 timeIndex1_.push_back(-1); 00043 timeIndex2_.clear(); 00044 timeIndex2_.push_back(-1); 00045 geomIndex1_.clear(); 00046 geomIndex1_.push_back(-1); 00047 groupIndex_=-1; 00048 00049 TeDatabase* db = params_->theme()->layer()->database(); 00050 00051 if(params_->groupAttr().empty()) 00052 return false; 00053 00054 //get the table name 00055 string tableName; 00056 TeGroupingAttr groupAttr = params_->groupAttr(); 00057 TeGroupingAttr::iterator it = groupAttr.begin(); 00058 size_t pos = (it->first.name_).find(".", 0, 1); 00059 if (pos != string::npos) 00060 tableName = (it->first.name_).substr(0,pos); 00061 00062 //group information 00063 legendIdGroup_.clear(); 00064 legendIdGroup_[0]=0; 00065 TeLegendEntryVector& legVec = params_->theme()->legend(); 00066 for(unsigned int l=0; l<legVec.size(); ++l) 00067 legendIdGroup_[legVec[l].id()]=legVec[l].group(); 00068 00069 clearVectors(); 00070 00071 // --------------------------------------------- Monut SQL 00072 00073 //------- Select and Group By clause 00074 00075 //load the attribute table 00076 int index = -1; 00077 unsigned int i=0; 00078 TeAttrTableVector attr = params_->theme()->attrTables(); 00079 for(i=0; i<attr.size(); ++i) 00080 { 00081 if(TeConvertToUpperCase(attr[i].name()) == TeConvertToUpperCase(tableName)) 00082 { 00083 index = i; 00084 attrTable_ = attr[i]; 00085 break; 00086 } 00087 } 00088 00089 //not find the table 00090 if(index<0) 00091 return false; 00092 00093 //verify the attribute table 00094 if((ent) && (attrTable_.tableType()!=TeAttrEvent) && (attrTable_.tableType()!=TeFixedGeomDynAttr)) 00095 return false; 00096 00097 //geometric Table 00098 TeAttributeList geomTableAttrs; 00099 string geomTable; 00100 if(params_->theme()->layer()->hasGeometry(TePOINTS)) 00101 { 00102 geomTable = params_->theme()->layer()->tableName(TePOINTS); 00103 if(!db->getAttributeList(geomTable, geomTableAttrs)) 00104 return false; 00105 rep_ = TePOINTS; 00106 } 00107 else if (params_->theme()->layer()->hasGeometry(TeCELLS)) 00108 { 00109 geomTable = params_->theme()->layer()->tableName(TeCELLS); 00110 if(!db->getAttributeList(geomTable, geomTableAttrs)) 00111 return false; 00112 rep_ = TeCELLS; 00113 } 00114 else 00115 return false; //this strategy is valid only for cells and point geometry 00116 00117 //object_id 00118 string linkName = attrTable_.name() +"."+ attrTable_.linkName(); //geomTable.name()+ ".object_id "; 00119 string uniqueIdName = attrTable_.name() +"."+ attrTable_.uniqueName(); 00120 00121 if(params_->hasSpatialRes()) 00122 selectClause = " MIN("+ linkName +")"; 00123 else 00124 selectClause = linkName; 00125 linkIndex_[0]=0; 00126 00127 if(ent) 00128 { 00129 //date 00130 initialTime = attrTable_.name() +"."+ attrTable_.attInitialTime(); 00131 00132 groupByClause = db->getSQLTemporalFunction(params_->chronon(), initialTime); 00133 if(!params_->hasSpatialRes()) 00134 groupByClause += ","+ linkName; 00135 00136 selectClause += ", MAX("+ initialTime +")"; 00137 timeIndex1_[0]=1; 00138 timeIndex2_[0]=1; 00139 } 00140 else if(!params_->hasSpatialRes()) 00141 groupByClause = linkName; 00142 00143 //statistic 00144 selectClause += ","+ db->getSQLStatistics(groupAttr); 00145 if(timeIndex1_[0]<0) 00146 attrIndex1_=1; 00147 else 00148 attrIndex1_=2; 00149 attrIndex2_ = attrIndex1_+(params_->groupAttr().size()-1); 00150 00151 //group index 00152 selectClause += ", MIN("+ params_->theme()->collectionTable()+".c_legend_id )"; 00153 groupIndex_ = attrIndex2_+1; 00154 00155 //----- insert geometrical information in the select clause 00156 for(i=0; i<geomTableAttrs.size(); ++i) 00157 selectClause += ", MIN( "+ geomTable +"."+ geomTableAttrs[i].rep_.name_ +" ) AS "+ geomTableAttrs[i].rep_.name_; 00158 geomIndex1_[0] = attrIndex2_+2; 00159 //----- 00160 00161 //------- From clause 00162 fromClause = this->sqlFrom(geomTable); 00163 if(fromClause.empty()) 00164 return false; 00165 00166 //where clause 00167 if(!params_->objId().empty()) 00168 whereClause = linkName +" = '"+ params_->objId() +"'"; 00169 00170 //---------- querier restriction 00171 TeRepresentation rep; 00172 rep.tableName_ = geomTable; 00173 rep.geomRep_ = rep_; 00174 00175 string sqlQuerierRest = sqlWhereRestrictions(&rep); 00176 if(!whereClause.empty()) 00177 whereClause += " AND "; 00178 00179 whereClause += sqlQuerierRest; 00180 00181 //---------- 00182 fromClause_ = fromClause; 00183 whereClause_ = whereClause; 00184 00185 string sql = " SELECT "+ selectClause; 00186 sql += " FROM "+ fromClause; 00187 if(!whereClause.empty()) 00188 sql += " WHERE "+ whereClause; 00189 if(!groupByClause.empty()) 00190 sql += " GROUP BY "+ groupByClause; 00191 00192 // --------------------------------------------- Submit the query 00193 00194 portals_.clear(); 00195 TeDatabasePortal* portal = db->getPortal(); 00196 00197 if(!portal) 00198 return false; 00199 00200 if(!portal->query(sql)) 00201 { 00202 delete (portal); 00203 flagPortal_ = false; 00204 return false; 00205 } 00206 00207 if(!portal->fetchRow()) 00208 { 00209 delete (portal); 00210 flagPortal_ = false; 00211 return false; 00212 } 00213 00214 string id = portal->getData(linkIndex_[0]); //object_Id 00215 bool flag = true; 00216 while(id.empty() && flag) 00217 { 00218 flag = portal->fetchRow(); 00219 if(flag) 00220 id = portal->getData(linkIndex_[0]); //object_Id 00221 } 00222 00223 if(id.empty() || (!flag)) 00224 { 00225 delete (portal); 00226 flagPortal_ = false; 00227 return false; 00228 } 00229 00230 portals_.push_back (portal); 00231 flagPortal_ = true; 00232 return true; 00233 }
| TeLayer* TeQuerierDB::layer | ( | ) | [inline, inherited] |
| bool TeQuerierDB::loadGeometries | ( | TeMultiGeometry & | geometries | ) | [virtual, inherited] |
Implements TeQuerierImpl.
Definition at line 523 of file TeQuerierDB.cpp.
References TeQuerierParams::loadGeom(), TeQuerierDB::loadGeometries(), TeQuerierImpl::params_, and TeQuerierDB::portals_.
00524 { 00525 bool flag = false; 00526 00527 if(!params_->loadGeom()) 00528 return flag; 00529 00530 for(unsigned int i=0; i<portals_.size(); ++i) 00531 flag = loadGeometries(geometries, i); 00532 00533 return flag; 00534 }
| bool TeQuerierDB::loadGeometries | ( | TeMultiGeometry & | geometries, | |
| unsigned int & | index | |||
| ) | [virtual, inherited] |
Implements TeQuerierImpl.
Definition at line 507 of file TeQuerierDB.cpp.
References addGeometry(), TeRepresentation::geomRep_, TeQuerierDB::geomRepr_, and TeQuerierDB::portals_.
Referenced by TeQuerierDB::loadGeometries().
00508 { 00509 if((portals_.size()<(index+1)) || (geomRepr_.size()<(index+1))) 00510 return false; 00511 00512 TeDatabasePortal* portal = portals_[index]; 00513 TeRepresentation rep = geomRepr_[index]; 00514 if(!portal) 00515 return false; 00516 00517 bool flag = addGeometry(portal, rep.geomRep_, geometries); 00518 00519 return flag; 00520 }
Implements TeQuerierDB.
Definition at line 317 of file TeQuerierDBStr3.cpp.
References TeQuerierImpl::attrList_, TeQuerierParams::box(), TeQuerierParams::groupAttr(), initPortal(), TeQuerierImpl::params(), TeQuerierImpl::params_, TeAttribute::rep_, TeQuerierParams::theme(), TeTSEntry::timeFrame_, timeFramePortal_, and TSEntry_.
00318 { 00319 if(!params_->theme()) 00320 return false; 00321 00322 //set a invalid box 00323 TeBox box; 00324 params_->box(box); 00325 00326 if(ent) 00327 { 00328 //if the portal was not initialised (timeFramePortal_==-1) or 00329 //if the time frame requested is lesser than the time frame appointed by the portal 00330 if((timeFramePortal_<0) || (ent->timeFrame_<timeFramePortal_)) 00331 { 00332 if(!initPortal(ent)) 00333 return false; 00334 00335 timeFramePortal_ = 0; 00336 } 00337 TSEntry_ = (*ent); 00338 } 00339 else // no chronon 00340 { 00341 if(!initPortal()) 00342 return false; 00343 00344 timeFramePortal_ = -1; 00345 } 00346 00347 attrList_->clear(); 00348 TeAttribute at; 00349 TeGroupingAttr::iterator it = params()->groupAttr().begin(); 00350 while(it!=params()->groupAttr().end()) 00351 { 00352 TeAttribute at; 00353 at.rep_ = it->first; 00354 attrList_->push_back (at); 00355 ++it; 00356 } 00357 00358 return true; 00359 }
| bool TeQuerierImpl::loadTimeFrameInstances | ( | int | frame = -1 |
) | [inherited] |
Definition at line 97 of file TeQuerierImpl.cpp.
References TeQuerierImpl::getTSEntry(), and TeQuerierImpl::loadInstances().
Referenced by TeQuerier::loadInstances().
00098 { 00099 if(frame>-1) 00100 { 00101 TeTSEntry ent; 00102 if(!getTSEntry(ent, frame)) 00103 return false; 00104 00105 return(loadInstances(&ent)); 00106 } 00107 else 00108 return(loadInstances()); 00109 }
| int TeQuerierDBStr3::numElemInstances | ( | ) | [virtual] |
Reimplemented from TeQuerierImpl.
Definition at line 381 of file TeQuerierDBStr3.cpp.
References TeDatabasePortal::fetchRow(), fromClause_, TeTheme::getAttTables(), TeTheme::layer(), TeDatabasePortal::numRows(), TeQuerierImpl::params_, TeDatabasePortal::query(), TeQuerierParams::theme(), and whereClause_.
00382 { 00383 //load the attribute tables 00384 TeAttrTableVector atts; 00385 params_->theme()->getAttTables(atts); 00386 if(atts.empty()) 00387 return 0; 00388 00389 string selectClause = " DISTINCT "; 00390 for(unsigned int i=0; i<atts.size(); ++i) 00391 { 00392 if(i>0) 00393 selectClause+= ","; 00394 selectClause+= atts[i].name() +"."+ atts[i].linkName(); 00395 00396 if(atts[i].linkName()!=atts[i].uniqueName()) 00397 selectClause+= ","+ atts[i].name() +"."+ atts[i].uniqueName(); 00398 } 00399 00400 string sql = "SELECT "+ selectClause + fromClause_; 00401 if(!whereClause_.empty()) 00402 sql += " WHERE "+ whereClause_; 00403 00404 TeDatabasePortal* portal = params_->theme()->layer()->database()->getPortal(); 00405 if(!portal) 00406 return 0; 00407 00408 if(!portal->query(sql) || !portal->fetchRow()) 00409 { 00410 delete (portal); 00411 return 0; 00412 } 00413 int result = portal->numRows(); 00414 delete portal; 00415 return result; 00416 }
| string TeQuerierImpl::objectId | ( | ) | [inline, inherited] |
Definition at line 63 of file TeQuerierImpl.h.
Referenced by TeQuerierDBStr1::initGeomPortal(), and TeQuerierDBStr1::initPortal().
| TeQuerierParams* TeQuerierImpl::params | ( | ) | [inline, inherited] |
Definition at line 90 of file TeQuerierImpl.h.
Referenced by TeQuerierDBStr1::fillSTONoGrouped(), TeQuerier::getBox(), loadInstances(), TeQuerierDBStr2::loadInstances(), TeQuerierDBStr1::loadInstances(), TeQuerier::operator=(), TeQuerier::params(), and TeQuerier::TeQuerier().
00090 { return params_; }
join with collection table
join with geometry table
join with collection table
join with geometry table
Definition at line 391 of file TeQuerierDB.cpp.
References TeQuerierDB::attrTable_, TeTheme::attrTables(), TeTheme::collectionAuxTable(), TeTheme::collectionTable(), TeRepresentation::geomRep_, TeQuerierParams::hasSpatialRes(), TeTheme::layer(), TeTable::linkName(), TeTable::name(), TeQuerierImpl::params_, TeQuerierParams::selectedObjs(), TeTable::tableType(), Te2String(), TeAll, TeAttrEvent, TeAttrExternal, TeAttrStatic, TeFixedGeomDynAttr, TeQuerierDB::theme(), TeQuerierParams::theme(), and TeTable::uniqueName().
Referenced by TeQuerierDBStr2::initPortal().
00392 { 00393 string fromPar = ""; 00394 string fromClause = ""; 00395 00396 //get collection tables 00397 string collAuxTable = params_->theme()->collectionAuxTable(); 00398 string collTable = params_->theme()->collectionTable(); 00399 00400 if(collAuxTable.empty() || collTable.empty()) 00401 return attrTable_.name(); 00402 00403 if(attrTable_.name().empty()) 00404 return ""; 00405 00406 string uniqueIdName = attrTable_.name() +"."+ attrTable_.uniqueName(); 00407 string objectIdName = attrTable_.name() +"."+ attrTable_.linkName(); 00408 string linkName; 00409 if(attrTable_.tableType() != TeAttrExternal) 00410 linkName = attrTable_.name() +"."+ attrTable_.linkName(); 00411 else 00412 linkName = collTable +".c_object_id "; 00413 00414 //load geometry table if there is spatial restriction 00415 if(geomTable.empty() && params_->hasSpatialRes()) 00416 { 00417 TeRepresentation* rep = (theme()->layer()->vectRepres())[0]; 00418 geomTable = theme()->layer()->tableName(rep->geomRep_); 00419 } 00420 00421 //get the extern table position 00422 int posExtern = -1; 00423 TeAttrTableVector attr = params_->theme()->attrTables(); 00424 for(unsigned int i=0; i<attr.size(); ++i) 00425 { 00426 if(attr[i].tableType() == TeAttrExternal) 00427 ++posExtern; 00428 } 00429 00430 //if the table is temporal 00431 if((attrTable_.tableType()==TeAttrEvent) || (attrTable_.tableType()==TeFixedGeomDynAttr)) 00432 { 00433 fromPar += "(("; 00434 fromClause = attrTable_.name()+" RIGHT JOIN "+ collAuxTable; 00435 00436 if(attrTable_.tableType()==TeFixedGeomDynAttr) 00437 { 00438 fromClause += " ON "+ uniqueIdName +" = "; 00439 fromClause += collAuxTable +".aux0"; 00440 fromClause += ")"; 00441 } 00442 else 00443 { 00444 fromClause += " ON "+ objectIdName +" = "; 00445 fromClause += collAuxTable +".object_id"+ ")"; 00446 } 00447 00448 fromClause += " LEFT JOIN "+ collTable; 00449 fromClause += " ON "+ collAuxTable +".object_id = "+ collTable +".c_object_id )"; 00450 00451 if(!geomTable.empty()) 00452 { 00453 fromPar += "("; 00454 fromClause += " LEFT JOIN "+ geomTable +" ON "; 00455 fromClause += collAuxTable +".object_id = "+ geomTable +".object_id )"; 00456 } 00457 00458 if(params_->selectedObjs() != TeAll) //! join with collection table 00459 { 00460 fromPar += "("; 00461 fromClause += " LEFT JOIN "+ collTable +" ON "; 00462 fromClause += collAuxTable +".object_id = "+ collTable +".c_object_id )"; 00463 } 00464 } 00465 00466 else if (attrTable_.tableType()==TeAttrStatic) 00467 { 00468 fromPar += "("; 00469 fromClause = attrTable_.name()+" RIGHT JOIN "+ collTable; 00470 fromClause += " ON "+ linkName +" = "+ collTable +".c_object_id)"; 00471 00472 if(!geomTable.empty()) //! join with geometry table 00473 { 00474 fromPar += "("; 00475 fromClause += " LEFT JOIN "+ geomTable +" ON "; 00476 fromClause += collTable +".c_object_id = "+ geomTable +".object_id )"; 00477 } 00478 00479 if(params_->selectedObjs() != TeAll) //! join with collection table 00480 { 00481 fromPar += "("; 00482 fromClause += " LEFT JOIN "+ collAuxTable +" ON "; 00483 fromClause += collTable +".c_object_id = "+ collAuxTable +".object_id )"; 00484 } 00485 } 00486 else if (attrTable_.tableType()==TeAttrExternal) 00487 { 00488 fromPar += "(("; 00489 fromClause = collAuxTable +" RIGHT JOIN "+ collTable; 00490 fromClause += " ON "+ collAuxTable +".object_id = "+ collTable +".c_object_id )"; 00491 fromClause += " LEFT JOIN "+ attrTable_.name() +" ON "; 00492 fromClause += collAuxTable +".aux"+ Te2String(posExtern) +" = "; 00493 fromClause += uniqueIdName +" )"; 00494 00495 if(!geomTable.empty()) //! join with geometry table 00496 { 00497 fromPar += "("; 00498 fromClause += " LEFT JOIN "+ geomTable +" ON "; 00499 fromClause += collTable +".c_object_id = "+ geomTable +".object_id )"; 00500 } 00501 } 00502 00503 return (fromPar+fromClause); 00504 }
| string TeQuerierDB::sqlWhereRestrictions | ( | TeRepresentation * | rep = 0 |
) | [protected, virtual, inherited] |
Definition at line 295 of file TeQuerierDB.cpp.
References TeQuerierParams::boxRest(), db, TeRepresentation::geomRep_, TeQuerierParams::geomRepRest(), TeQuerierParams::geomRest(), TeDatabase::getSQLBoxWhere(), TeQuerierParams::hasSpatialRes(), TeSingleton< TePrecision >::instance(), TeBox::isValid(), TeTheme::layer(), TeQuerierImpl::params_, TeQuerierParams::selectedObjs(), TePrecision::setPrecision(), TeQuerierParams::spatialRelation(), TeDatabase::spatialRelation(), TeRepresentation::tableName_, TeAll, TeGetPrecision(), TeGrouped, TeNotGrouped, TeNotSelectedByPointing, TeNotSelectedByQuery, TeSelectedByPointing, TeSelectedByPointingAndQuery, TeSelectedByPointingOrQuery, TeSelectedByQuery, and TeQuerierParams::theme().
Referenced by TeQuerierDBStr1::initGeomPortal(), initPortal(), TeQuerierDBStr2::initPortal(), and TeQuerierDBStr1::initPortal().
00296 { 00297 TeKeys objs; 00298 string whereClause= " 1 = 1 "; 00299 TeDatabase* db = params_->theme()->layer()->database(); 00300 if(!db) 00301 return ""; 00302 00303 // load the first representation 00304 if(!rep) 00305 rep = (params_->theme()->layer()->vectRepres())[0]; 00306 00307 // spatial restriction with other geometry representation 00308 if (params_->hasSpatialRes() && rep) 00309 { 00310 if(params_->boxRest().isValid()) 00311 { 00312 TeBox b = params_->boxRest(); 00313 TeGeomRep gRep = rep->geomRep_; 00314 string geomTableRest = params_->theme()->layer()->tableName(params_->geomRepRest()); 00315 whereClause += " AND "+ db->getSQLBoxWhere(b, gRep, geomTableRest); 00316 } 00317 else if(params_->geomRest()) 00318 { 00319 string geomTableRest = params_->theme()->layer()->tableName(params_->geomRepRest()); 00320 TePrecision::instance().setPrecision(TeGetPrecision(params_->theme()->layer()->projection())); 00321 00322 if((db->spatialRelation(geomTableRest, params_->geomRepRest(), params_->geomRest(), 00323 objs, params_->spatialRelation())) && (!objs.empty())) 00324 { 00325 string obs; 00326 for(unsigned int i=0; i<objs.size(); i++) 00327 { 00328 if(i!=0) 00329 obs += ","; 00330 obs += "'"+ objs[i] +"'"; 00331 } 00332 00333 whereClause += " AND "+ rep->tableName_ +".object_id IN ("+ obs +")"; 00334 } 00335 else 00336 whereClause += " AND 1 <> 1 "; // no geometry was found 00337 00338 } 00339 } 00340 00341 //selected objects 00342 switch (params_->selectedObjs()) 00343 { 00344 case TeAll: 00345 break; 00346 00347 case TeSelectedByPointing: 00348 whereClause += " AND (grid_status = 1 OR grid_status = 3"; 00349 whereClause += " OR (grid_status IS NULL AND (c_object_status = 1 OR c_object_status = 3)))"; 00350 break; 00351 00352 case TeNotSelectedByPointing: 00353 whereClause += " AND (grid_status = 0 OR grid_status = 2"; 00354 whereClause += " OR (grid_status is null AND (c_object_status = 0 OR c_object_status = 2)))"; 00355 break; 00356 00357 case TeSelectedByQuery: 00358 whereClause += " AND (grid_status = 2 OR grid_status = 3"; 00359 whereClause += " OR (grid_status is null AND (c_object_status = 2 OR c_object_status = 3)))"; 00360 break; 00361 00362 case TeNotSelectedByQuery: 00363 whereClause += " AND (grid_status = 0 OR grid_status = 1"; 00364 whereClause += " OR (grid_status is null AND (c_object_status = 0 OR c_object_status = 1)))"; 00365 break; 00366 00367 case TeGrouped: 00368 whereClause += " AND c_legend_id <> 0"; 00369 break; 00370 00371 case TeNotGrouped: 00372 whereClause += " AND c_legend_id = 0"; 00373 break; 00374 00375 case TeSelectedByPointingAndQuery: 00376 whereClause += " AND grid_status = 3"; 00377 whereClause += " OR (grid_status is null AND c_object_status = 3)"; 00378 break; 00379 00380 case TeSelectedByPointingOrQuery: 00381 whereClause += " AND (grid_status = 1 OR grid_status = 2 OR grid_status = 3)"; 00382 whereClause += " OR (grid_status is null AND (c_object_status = 3 OR c_object_status = 1 OR c_object_status = 2))"; 00383 break; 00384 } 00385 00386 return whereClause; 00387 }
| TeTheme* TeQuerierDB::theme | ( | ) | [inline, inherited] |
Reimplemented from TeQuerierImpl.
Definition at line 98 of file TeQuerierDB.h.
Referenced by TeQuerierDB::sqlFrom().
int TeQuerierDB::attrIndex1_ [protected, inherited] |
Definition at line 63 of file TeQuerierDB.h.
Referenced by fillSTO(), TeQuerierDBStr2::fillSTO(), TeQuerierDBStr1::fillSTOGrouped(), TeQuerierDBStr1::fillSTONoGrouped(), initPortal(), TeQuerierDBStr2::initPortal(), and TeQuerierDBStr1::initPortal().
int TeQuerierDB::attrIndex2_ [protected, inherited] |
Definition at line 65 of file TeQuerierDB.h.
Referenced by fillSTO(), TeQuerierDBStr2::fillSTO(), TeQuerierDBStr1::fillSTOGrouped(), TeQuerierDBStr1::fillSTONoGrouped(), initPortal(), TeQuerierDBStr2::initPortal(), and TeQuerierDBStr1::initPortal().
TeSharedPtr<TeAttributeList> TeQuerierImpl::attrList_ [protected, inherited] |
Definition at line 47 of file TeQuerierImpl.h.
Referenced by TeQuerierSHP::fetchInstance(), fillSTO(), TeQuerierDBStr2::fillSTO(), TeQuerierDBStr1::fillSTOGrouped(), TeQuerierDBStr1::fillSTONoGrouped(), TeQuerierSHP::loadInstances(), loadInstances(), TeQuerierDBStr2::loadInstances(), TeQuerierDBStr1::loadInstances(), TeQuerierImpl::operator=(), and TeQuerierImpl::TeQuerierImpl().
TeTable TeQuerierDB::attrTable_ [protected, inherited] |
Definition at line 52 of file TeQuerierDB.h.
Referenced by TeQuerierDBStr1::fillSTONoGrouped(), TeQuerierDBStr1::initGeomPortal(), initPortal(), TeQuerierDBStr2::initPortal(), TeQuerierDBStr1::initPortal(), and TeQuerierDB::sqlFrom().
bool TeQuerierImpl::filledSerie_ [protected, inherited] |
Definition at line 46 of file TeQuerierImpl.h.
Referenced by fetchInstance(), TeQuerierDBStr2::fetchInstance(), TeQuerierImpl::operator=(), and TeQuerierImpl::TeQuerierImpl().
bool TeQuerierDB::flagPortal_ [protected, inherited] |
Definition at line 54 of file TeQuerierDB.h.
Referenced by TeQuerierDB::clearVectors(), TeQuerierDBStr1::fetchInstance(), TeQuerierDBStr1::fillGeomSTO(), fillSTO(), TeQuerierDBStr2::fillSTO(), TeQuerierDBStr1::fillSTOGrouped(), TeQuerierDBStr1::fillSTONoGrouped(), initPortal(), TeQuerierDBStr2::initPortal(), and TeQuerierDBStr1::initPortal().
string TeQuerierDBStr3::fromClause_ [private] |
Definition at line 54 of file TeQuerierDBStr3.h.
Referenced by initPortal(), and numElemInstances().
vector<int> TeQuerierDB::geomIndex1_ [protected, inherited] |
Definition at line 69 of file TeQuerierDB.h.
Referenced by TeQuerierDBStr1::fillGeomSTO(), fillSTO(), TeQuerierDBStr1::fillSTOGrouped(), TeQuerierDBStr1::fillSTONoGrouped(), TeQuerierDBStr1::initGeomPortal(), initPortal(), and TeQuerierDBStr1::initPortal().
vector<int> TeQuerierDB::geomIndex2_ [protected, inherited] |
Definition at line 71 of file TeQuerierDB.h.
Referenced by TeQuerierDBStr1::initGeomPortal(), and TeQuerierDBStr1::initPortal().
vector<TeRepresentation> TeQuerierDB::geomRepr_ [protected, inherited] |
Definition at line 50 of file TeQuerierDB.h.
Referenced by TeQuerierDB::clearVectors(), TeQuerierDBStr1::fillGeomSTO(), TeQuerierDBStr1::fillSTOGrouped(), TeQuerierDBStr1::fillSTONoGrouped(), TeQuerierDBStr1::initGeomPortal(), TeQuerierDBStr1::initPortal(), TeQuerierDB::loadGeometries(), and TeQuerierDB::~TeQuerierDB().
int TeQuerierDB::groupIndex_ [protected, inherited] |
Definition at line 67 of file TeQuerierDB.h.
Referenced by fillSTO(), TeQuerierDBStr2::fillSTO(), TeQuerierDBStr1::fillSTOGrouped(), TeQuerierDBStr1::fillSTONoGrouped(), initPortal(), TeQuerierDBStr2::initPortal(), and TeQuerierDBStr1::initPortal().
map<int, int> TeQuerierDB::legendIdGroup_ [protected, inherited] |
Definition at line 78 of file TeQuerierDB.h.
Referenced by fillSTO(), TeQuerierDBStr2::fillSTO(), TeQuerierDBStr1::fillSTOGrouped(), TeQuerierDBStr1::fillSTONoGrouped(), initPortal(), TeQuerierDBStr2::initPortal(), and TeQuerierDBStr1::initPortal().
vector<int> TeQuerierDB::linkIndex_ [protected, inherited] |
Definition at line 60 of file TeQuerierDB.h.
Referenced by TeQuerierDBStr1::fillGeomSTO(), fillSTO(), TeQuerierDBStr2::fillSTO(), TeQuerierDBStr1::fillSTOGrouped(), TeQuerierDBStr1::fillSTONoGrouped(), TeQuerierDBStr1::initGeomPortal(), initPortal(), TeQuerierDBStr2::initPortal(), and TeQuerierDBStr1::initPortal().
TeQuerierParams* TeQuerierImpl::params_ [protected, inherited] |
Definition at line 44 of file TeQuerierImpl.h.
Referenced by fetchInstance(), TeQuerierDBStr1::fetchInstance(), TeQuerierSHP::fileName(), fillSTO(), TeQuerierDBStr2::fillSTO(), TeQuerierDBStr1::fillSTOGrouped(), TeQuerierDBStr1::fillSTONoGrouped(), TeQuerierDB::geometryRep(), TeQuerierDBStr1::initGeomPortal(), initPortal(), TeQuerierDBStr2::initPortal(), TeQuerierDBStr1::initPortal(), TeQuerierDB::loadGeometries(), TeQuerierSHP::loadInstances(), loadInstances(), TeQuerierDBStr2::loadInstances(), TeQuerierDBStr1::loadInstances(), numElemInstances(), TeQuerierDBStr1::numElemInstances(), TeQuerierImpl::operator=(), TeQuerierDB::sqlFrom(), TeQuerierDB::sqlWhereRestrictions(), TeQuerierImpl::TeQuerierImpl(), and TeQuerierImpl::~TeQuerierImpl().
vector<TeDatabasePortal*> TeQuerierDB::portals_ [protected, inherited] |
Definition at line 48 of file TeQuerierDB.h.
Referenced by TeQuerierDB::clearVectors(), TeQuerierDBStr1::fetchInstance(), TeQuerierDBStr1::fillGeomSTO(), fillSTO(), TeQuerierDBStr2::fillSTO(), TeQuerierDBStr1::fillSTOGrouped(), TeQuerierDBStr1::fillSTONoGrouped(), TeQuerierDBStr1::initGeomPortal(), initPortal(), TeQuerierDBStr2::initPortal(), TeQuerierDBStr1::initPortal(), TeQuerierDB::loadGeometries(), TeQuerierDBStr2::numElemInstances(), TeQuerierDBStr1::numElemInstances(), and TeQuerierDB::~TeQuerierDB().
TeGeomRep TeQuerierDBStr3::rep_ [private] |
int TeQuerierDBStr3::timeFramePortal_ [private] |
vector<int> TeQuerierDB::timeIndex1_ [protected, inherited] |
Definition at line 73 of file TeQuerierDB.h.
Referenced by TeQuerierDBStr1::fillGeomSTO(), fillSTO(), TeQuerierDBStr2::fillSTO(), TeQuerierDBStr1::fillSTOGrouped(), TeQuerierDBStr1::fillSTONoGrouped(), TeQuerierDBStr1::initGeomPortal(), initPortal(), TeQuerierDBStr2::initPortal(), and TeQuerierDBStr1::initPortal().
vector<int> TeQuerierDB::timeIndex2_ [protected, inherited] |
Definition at line 75 of file TeQuerierDB.h.
Referenced by TeQuerierDBStr1::fillGeomSTO(), TeQuerierDBStr1::fillSTOGrouped(), TeQuerierDBStr1::fillSTONoGrouped(), TeQuerierDBStr1::initGeomPortal(), initPortal(), TeQuerierDBStr2::initPortal(), and TeQuerierDBStr1::initPortal().
TeTemporalSeries* TeQuerierImpl::ts_ [protected, inherited] |
Definition at line 45 of file TeQuerierImpl.h.
Referenced by fetchInstance(), TeQuerierDBStr2::fetchInstance(), TeQuerierImpl::getNumTimeFrames(), TeQuerierImpl::getTS(), TeQuerierImpl::getTSEntry(), TeQuerierImpl::getTSParams(), TeQuerierImpl::operator=(), TeQuerierImpl::TeQuerierImpl(), and TeQuerierImpl::~TeQuerierImpl().
TeTSEntry TeQuerierDBStr3::TSEntry_ [private] |
Definition at line 51 of file TeQuerierDBStr3.h.
Referenced by fetchInstance(), fillSTO(), and loadInstances().
map<int, vector<int> > TeQuerierDB::uniqueIndex_ [protected, inherited] |
Definition at line 57 of file TeQuerierDB.h.
Referenced by TeQuerierDBStr1::fillSTOGrouped(), TeQuerierDBStr1::initGeomPortal(), and TeQuerierDBStr1::initPortal().
string TeQuerierDBStr3::whereClause_ [private] |
Definition at line 55 of file TeQuerierDBStr3.h.
Referenced by initPortal(), and numElemInstances().
1.5.3