![]() |
TerraLib 4.1
|
00001 /************************************************************************************ 00002 TerraLib - a library for developing GIS applications. 00003 Copyright � 2001-2007 INPE and Tecgraf/PUC-Rio. 00004 00005 This code is part of the TerraLib library. 00006 This library is free software; you can redistribute it and/or 00007 modify it under the terms of the GNU Lesser General Public 00008 License as published by the Free Software Foundation; either 00009 version 2.1 of the License, or (at your option) any later version. 00010 00011 You should have received a copy of the GNU Lesser General Public 00012 License along with this library. 00013 00014 The authors reassure the license terms regarding the warranties. 00015 They specifically disclaim any warranties, including, but not limited to, 00016 the implied warranties of merchantability and fitness for a particular purpose. 00017 The library provided hereunder is on an "as is" basis, and the authors have no 00018 obligation to provide maintenance, support, updates, enhancements, or modifications. 00019 In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct, 00020 indirect, special, incidental, or consequential damages arising out of the use 00021 of this library and its documentation. 00022 *************************************************************************************/ 00023 00030 #ifndef TeComputeAttrStrategies_H 00031 #define TeComputeAttrStrategies_H 00032 00033 #include "TeAttribute.h" 00034 #include "TeBox.h" 00035 #include "TeUtils.h" 00036 #include "TeNetwork.h" 00037 #include "TeKdTree.h" 00038 #include "TeLayer.h" 00039 00040 typedef TeSAM::TeAdaptativeKdTreeNode<TeCoord2D, vector<TePoint>, TePoint> KDNODE; 00041 typedef TeSAM::TeAdaptativeKdTree<KDNODE> KDTREE; 00042 00043 class TeTheme; 00044 class TeRaster; 00045 class TeQuerier; 00046 00053 00054 template<class Iterator> 00055 class TeComputeAttrStrategy 00056 { 00057 public: 00059 TeProperty defaultValue () { return defaultValue_; } 00060 00062 /* 00063 \param first the first element of the Iterator 00064 \param last the last element of the Iterator 00065 \param columnName the attribute name to be generated in the TeProperty's 00066 */ 00067 virtual vector<TeProperty> compute (Iterator /*first*/, Iterator /*last*/, const string& /*columnName*/) 00068 { 00069 vector<TeProperty> result; 00070 result.push_back (defaultValue_); 00071 return result; 00072 } 00073 00075 virtual ~TeComputeAttrStrategy(){} 00076 00077 bool ComputeAttrIsDummy(double value, double dummy) 00078 { 00079 return (ABS(value - dummy) < 0.001); 00080 } 00081 00082 00083 protected: 00085 TeComputeAttrStrategy () {}; 00086 00088 TeProperty defaultValue_; 00089 }; 00090 00091 00093 template<class Iterator> 00094 class TeAverageStrategy: public TeComputeAttrStrategy<Iterator> 00095 { 00096 public: 00098 /* 00099 \param defaultValue the returned value of the compute method when the iterator is empty 00100 */ 00101 TeAverageStrategy (double dummyV = 0.0, double defaultV = 0.0) {this->defaultValue_.value_ = Te2String (defaultV); dummy = dummyV; } 00102 00104 virtual ~TeAverageStrategy() {} 00105 00107 /* 00108 \param first the first element of the Iterator 00109 \param last the last element of the Iterator 00110 \param columnName the attribute name to be generated in the TeProperty's 00111 */ 00112 virtual vector<TeProperty> compute (Iterator first, Iterator last, const string& columnName) 00113 { 00114 double tot_val = 0.0; 00115 int num = 0; 00116 00117 Iterator it = first; 00118 while (it != last) 00119 { 00120 if( !ComputeAttrIsDummy((*it), dummy) ) 00121 { 00122 tot_val += (*it); 00123 num++; 00124 } 00125 ++it; 00126 } 00127 00128 TeProperty prop; 00129 prop.attr_.rep_.name_ = columnName; 00130 prop.attr_.rep_.type_ = TeREAL; 00131 prop.attr_.rep_.numChar_ = 48; 00132 if (num > 0) 00133 { 00134 double val = tot_val/num; 00135 prop.value_ = Te2String (val); 00136 } 00137 else prop.value_ = this->defaultValue_.value_; 00138 00139 TePropertyVector result; 00140 result.push_back (prop); 00141 return result; 00142 } 00143 private: 00144 double dummy; 00145 }; 00146 00147 00149 template<class Iterator> 00150 class TeSTDevStrategy: public TeComputeAttrStrategy<Iterator> 00151 { 00152 public: 00154 /* 00155 \param defaultValue the returned value of the compute method when the iterator is empty 00156 */ 00157 TeSTDevStrategy (double dummyV = 0.0, double defaultV = 0.0) {this->defaultValue_.value_ = Te2String (defaultV); dummy = dummyV; } 00158 00160 virtual ~TeSTDevStrategy() {} 00161 00163 /* 00164 \param first the first element of the Iterator 00165 \param last the last element of the Iterator 00166 \param columnName the attribute name to be generated in the TeProperty's 00167 */ 00168 virtual vector<TeProperty> compute (Iterator first, Iterator last, const string& columnName) 00169 { 00170 double tot_val = 0.0; 00171 double stdev = 0.0; 00172 int num = 0; 00173 00174 Iterator it = first; 00175 while (it != last) 00176 { 00177 if( !ComputeAttrIsDummy((*it), dummy) ) 00178 { 00179 tot_val += (*it); 00180 num++; 00181 } 00182 ++it; 00183 } 00184 if(num > 0) 00185 { 00186 double mean = tot_val / num; 00187 it = first; 00188 while (it != last) 00189 { 00190 if( !ComputeAttrIsDummy((*it), dummy) ) stdev += pow((*it) - mean, 2); 00191 00192 ++it; 00193 } 00194 stdev = stdev / num; 00195 stdev = sqrt(stdev); 00196 } 00197 00198 TeProperty prop; 00199 prop.attr_.rep_.name_ = columnName; 00200 prop.attr_.rep_.type_ = TeREAL; 00201 prop.attr_.rep_.numChar_ = 48; 00202 00203 if (num > 0) prop.value_ = Te2String (stdev); 00204 else prop.value_ = this->defaultValue_.value_; 00205 00206 TePropertyVector result; 00207 result.push_back (prop); 00208 return result; 00209 } 00210 private: 00211 double dummy; 00212 }; 00213 00214 00216 template<class Iterator> 00217 class TeSumStrategy: public TeComputeAttrStrategy<Iterator> 00218 { 00219 public: 00221 /* 00222 \param defaultValue the returned value of the compute method when the iterator is empty 00223 */ 00224 TeSumStrategy (double dummyV = 0.0, double defaultV = 0.0) {this->defaultValue_.value_ = Te2String (defaultV); dummy = dummyV; } 00225 00227 virtual ~TeSumStrategy() {} 00228 00230 /* 00231 \param first the first element of the Iterator 00232 \param last the last element of the Iterator 00233 \param columnName the attribute name to be generated in the TeProperty's 00234 */ 00235 virtual vector<TeProperty> compute (Iterator first, Iterator last, const string& columnName) 00236 { 00237 double sum = 0.0; 00238 Iterator it = first; 00239 bool found = false; 00240 while (it != last) 00241 { 00242 if( !ComputeAttrIsDummy((*it), dummy) ) 00243 { 00244 sum += (*it); 00245 found = true; 00246 } 00247 ++it; 00248 } 00249 00250 TeProperty prop; 00251 00252 if (first == last || !found) prop = this->defaultValue_; 00253 else prop.value_ = Te2String (sum); 00254 00255 prop.attr_.rep_.name_ = columnName; 00256 prop.attr_.rep_.type_ = TeREAL; 00257 prop.attr_.rep_.numChar_ = 48; 00258 TePropertyVector result; 00259 result.push_back (prop); 00260 return result; 00261 } 00262 private: 00263 double dummy; 00264 }; 00265 00266 00268 template<class Iterator> 00269 class TeMinimumStrategy: public TeComputeAttrStrategy<Iterator> 00270 { 00271 public: 00273 /* 00274 \param defaultValue the returned value of the compute method when the iterator is empty 00275 */ 00276 TeMinimumStrategy (double dummyV = 0.0, double defaultV = 0.0) {this->defaultValue_.value_ = Te2String (defaultV); dummy = dummyV; } 00277 00279 virtual ~TeMinimumStrategy() {} 00280 00282 /* 00283 \param first the first element of the Iterator 00284 \param last the last element of the Iterator 00285 \param columnName the attribute name to be generated in the TeProperty's 00286 */ 00287 virtual vector<TeProperty> compute (Iterator first, Iterator last, const string& columnName) 00288 { 00289 double min = TeMAXFLOAT; 00290 Iterator it = first; 00291 while (it != last) 00292 { 00293 if( !ComputeAttrIsDummy((*it), dummy) ) 00294 { 00295 double val = (*it); 00296 if (val < min) min = val; 00297 } 00298 ++it; 00299 } 00300 00301 TeProperty prop; 00302 prop.attr_.rep_.name_ = columnName; 00303 prop.attr_.rep_.type_ = TeREAL; 00304 prop.attr_.rep_.numChar_ = 48; 00305 00306 if (first == last || min == TeMAXFLOAT) 00307 prop.value_ = this->defaultValue_.value_; 00308 else 00309 prop.value_ = Te2String (min); 00310 00311 TePropertyVector result; 00312 result.push_back (prop); 00313 return result; 00314 } 00315 private: 00316 double dummy; 00317 }; 00318 00319 00321 template<class Iterator> 00322 class TeMaximumStrategy: public TeComputeAttrStrategy<Iterator> 00323 { 00324 public: 00326 /* 00327 \param defaultValue the returned value of the compute method when the iterator is empty 00328 */ 00329 TeMaximumStrategy (double dummyV = 0.0, double defaultV = 0.0) {this->defaultValue_.value_ = Te2String (defaultV); dummy = dummyV; } 00330 00332 virtual ~TeMaximumStrategy() {} 00333 00335 /* 00336 \param first the first element of the Iterator 00337 \param last the last element of the Iterator 00338 \param columnName the attribute name to be generated in the TeProperty's 00339 */ 00340 virtual vector<TeProperty> compute (Iterator first, Iterator last, const string& columnName) 00341 { 00342 double max = TeMINFLOAT; 00343 Iterator it = first; 00344 while (it != last) 00345 { 00346 if( !ComputeAttrIsDummy((*it), dummy) ) 00347 { 00348 double val = (*it); 00349 if (val > max) max = val; 00350 } 00351 ++it; 00352 } 00353 00354 TeProperty prop; 00355 prop.attr_.rep_.name_ = columnName; 00356 prop.attr_.rep_.type_ = TeREAL; 00357 prop.attr_.rep_.numChar_ = 48; 00358 00359 if (first == last || max == TeMINFLOAT) 00360 prop.value_ = this->defaultValue_.value_; 00361 else 00362 prop.value_ = Te2String (max); 00363 00364 TePropertyVector result; 00365 result.push_back (prop); 00366 return result; 00367 } 00368 private: 00369 double dummy; 00370 }; 00371 00372 00374 template<class Iterator> 00375 class TeCategoryPercentageStrategy: public TeComputeAttrStrategy<Iterator> 00376 { 00377 public: 00379 /* 00380 \param defaultValue the returned value of the compute method when the iterator is empty 00381 \param classes classes for regrouping the values 00382 */ 00383 TeCategoryPercentageStrategy (map<string, string>& classes, double defaultValue = 0.0) 00384 { 00385 this->defaultValue_.value_ = Te2String (defaultValue); 00386 classesMap_ = classes; 00387 usingMap = true; 00388 } 00389 00391 /* 00392 \param defaultValue the returned value of the compute method when the iterator is empty 00393 \param dummyV the ignored value 00394 */ 00395 00396 TeCategoryPercentageStrategy(double defaultValue = 0.0, string dummyV = "") 00397 { 00398 usingMap = false; 00399 this->defaultValue_.value_ = Te2String (defaultValue); 00400 dummy = dummyV; 00401 } 00402 00404 virtual ~TeCategoryPercentageStrategy() {} 00405 00407 /* 00408 \param first the first element of the Iterator 00409 \param last the last element of the Iterator 00410 \param columnName the attribute name to be generated in the TeProperty's 00411 */ 00412 virtual vector<TeProperty> compute (Iterator first, Iterator last, const string& columnName) 00413 { 00414 TeProperty category; 00415 int num = 0; 00416 00417 // initialize count 00418 map<string, int> count; 00419 00420 if(usingMap) 00421 { 00422 map<string, string>::iterator itMap = classesMap_.begin(); 00423 while (itMap != classesMap_.end()) 00424 { 00425 count[(*itMap).second] = 0; 00426 ++itMap; 00427 } 00428 00429 Iterator it = first; 00430 while (it != last) 00431 { 00432 if (it.getProperty (category)) 00433 { 00434 count[classesMap_[category.value_]]++; 00435 num++; 00436 } 00437 ++it; 00438 } 00439 } 00440 else // use the data to initialize the counter 00441 { 00442 Iterator it = first; 00443 while (it != last) 00444 { 00445 if (it.getProperty (category) && category.value_ != dummy) 00446 count[category.value_] = 0; 00447 00448 ++it; 00449 } 00450 00451 it = first; 00452 while (it != last) 00453 { 00454 if (it.getProperty (category) && category.value_ != dummy) 00455 { 00456 count[category.value_]++; 00457 num++; 00458 } 00459 ++it; 00460 } 00461 } 00462 00463 TePropertyVector result; 00464 map <string, int>:: iterator count_it = count.begin(); 00465 00466 while(count_it != count.end()) 00467 { 00468 string value_ = (*count_it).first; 00469 for (unsigned i = 0; i < value_.size(); i++) 00470 if(value_[i] == '.' || value_[i] == '+' || value_[i] == '-') 00471 // remove them from value because they cant be part of a column name 00472 value_[i] = '_'; 00473 00474 TeProperty prop; 00475 prop.attr_.rep_.name_ = columnName + value_; 00476 prop.attr_.rep_.type_ = TeREAL; 00477 prop.attr_.rep_.numChar_ = 48; 00478 00479 double percent = 0.0; 00480 double value = (double)(*count_it).second; 00481 if (num != 0) percent = value/num; 00482 prop.value_ = Te2String (percent); 00483 result.push_back (prop); 00484 ++count_it; 00485 } 00486 return result; 00487 } 00488 00489 private: 00491 map<string, string> classesMap_; 00492 bool usingMap; 00493 string dummy; 00494 }; 00495 00496 00498 template<class Iterator> 00499 class TePresenceStrategy: public TeComputeAttrStrategy<Iterator> 00500 { 00501 public: 00503 /* 00504 \param defaultValue the returned value of the compute method when the iterator is empty 00505 */ 00506 TePresenceStrategy (bool defaultValue = 0) 00507 { 00508 this->defaultValue_.attr_.rep_.type_ = TeINT; 00509 this->defaultValue_.value_ = Te2String (defaultValue); 00510 this->defaultValue_.attr_.rep_.numChar_ = 48; 00511 } 00512 00514 virtual ~TePresenceStrategy() {} 00515 00518 /* 00519 \param first the first element of the Iterator 00520 \param last the last element of the Iterator 00521 \param columnName the attribute name to be generated in the TeProperty's 00522 */ 00523 virtual vector<TeProperty> compute (Iterator first, Iterator last, const string& columnName) 00524 { 00525 TeProperty prop; 00526 if (first != last) 00527 prop.value_ = "1"; 00528 else 00529 prop = this->defaultValue_; 00530 00531 TePropertyVector result; 00532 prop.attr_.rep_.name_ = columnName; 00533 prop.attr_.rep_.type_ = TeINT; 00534 prop.attr_.rep_.numChar_ = 48; 00535 result.push_back (prop); 00536 return result; 00537 } 00538 }; 00539 00541 template<class Iterator> 00542 class TeMajorityStrategy: public TeComputeAttrStrategy<Iterator> 00543 { 00544 public: 00546 /* 00547 \param defaultType the type of the default value 00548 */ 00549 TeMajorityStrategy (TeAttrDataType defaultType = TeINT, string defaultValue = "", string dummyV = "") 00550 { 00551 this->defaultValue_.attr_.rep_.type_ = defaultType; 00552 this->defaultValue_.value_ = defaultValue; 00553 dummy = dummyV; 00554 } 00555 00557 virtual ~TeMajorityStrategy() {} 00558 00560 /* 00561 \param first the first element of the Iterator 00562 \param last the last element of the Iterator 00563 \param columnName the attribute name to be generated in the TeProperty's 00564 */ 00565 virtual vector<TeProperty> compute (Iterator first, Iterator last, const string& columnName) 00566 { 00567 TeProperty category; 00568 category.attr_.rep_.type_ = this->defaultValue_.attr_.rep_.type_; 00569 00570 map<string, int> count; 00571 Iterator it = first; 00572 while (it != last) 00573 { 00574 if (it.getProperty (category) && category.value_ != dummy) 00575 count[category.value_]++; 00576 00577 ++it; 00578 } 00579 00580 TeProperty prop; 00581 prop.attr_.rep_.type_ = category.attr_.rep_.type_; 00582 prop.value_ = this->defaultValue_.value_; 00583 prop.attr_.rep_.name_ = columnName; 00584 prop.attr_.rep_.numChar_ = 48; 00585 00586 int max = 0; 00587 map <string, int>:: iterator count_it = count.begin(); 00588 while(count_it != count.end()) 00589 { 00590 if ((*count_it).second > max) 00591 { 00592 prop.value_ = (*count_it).first; 00593 max = (*count_it).second; 00594 } 00595 ++count_it; 00596 } 00597 TePropertyVector result; 00598 result.push_back (prop); 00599 return result; 00600 } 00601 private: 00602 string dummy; 00603 }; 00604 00605 00607 template<class Iterator> 00608 class TeMajorityCategoryStrategy: public TeComputeAttrStrategy<Iterator> 00609 { 00610 public: 00612 /* 00613 \param classesMap the returning values for each categoty 00614 \param defaultValue the type of the attribute to be created 00615 */ 00616 TeMajorityCategoryStrategy (const map<string, string>& classesMap, TeAttrDataType defaultType = TeINT) 00617 { 00618 this->defaultValue_.attr_.rep_.type_ = defaultType; 00619 this->defaultValue_.value_ = "0"; 00620 classesMap_ = classesMap; 00621 } 00622 00624 virtual ~TeMajorityCategoryStrategy() {} 00625 00627 /* 00628 \param first the first element of the Iterator 00629 \param last the last element of the Iterator 00630 \param columnName the attribute name to be generated in the TeProperty's 00631 */ 00632 virtual vector<TeProperty> compute (Iterator first, Iterator last, const string& columnName) 00633 { 00634 TeProperty category; 00635 category.attr_.rep_.type_ = this->defaultValue_.attr_.rep_.type_; 00636 00637 // initialize count 00638 map<string, int> count; 00639 map<string, string>::iterator itMap = classesMap_.begin(); 00640 while (itMap != classesMap_.end()) 00641 { 00642 count[(*itMap).second] = 0; 00643 ++itMap; 00644 } 00645 00646 Iterator it = first; 00647 while (it != last) 00648 { 00649 if (it.getProperty (category)) 00650 { 00651 count[classesMap_[category.value_]]++; 00652 } 00653 ++it; 00654 } 00655 00656 TePropertyVector result; 00657 TeProperty prop; 00658 prop.attr_.rep_.type_ = TeSTRING; 00659 // prop.value_ = defaultValue_.value_; 00660 prop.attr_.rep_.name_ = columnName; 00661 prop.attr_.rep_.numChar_ = 48; 00662 00663 int max = 0; 00664 map <string, int>:: iterator count_it = count.begin(); 00665 while(count_it != count.end()) 00666 { 00667 if ((*count_it).second > max) 00668 { 00669 prop.value_ = (*count_it).first; 00670 max = (*count_it).second; 00671 } 00672 ++count_it; 00673 } 00674 00675 result.push_back (prop); 00676 return result; 00677 } 00678 00679 protected: 00680 map<string, string> classesMap_; 00681 }; 00692 00693 class TL_DLL TeComputeSpatialStrategy 00694 { 00695 public: 00697 virtual ~TeComputeSpatialStrategy() {} 00698 00700 /* 00701 \param box compute the attribute of a cell having this box 00702 */ 00703 virtual string compute(TeBox box) = 0; 00704 00706 virtual TeAttrDataType Type() { return TeREAL; } 00707 00709 /* 00710 \param box the box to be used 00711 \patam att the attribute returned together with the objects. If none, this function returns only the geometries 00712 */ 00713 TeQuerier* getWithinGeometry(TeBox box, string att = ""); 00714 00715 protected: 00717 /* 00718 \param theme_ the theme to be used as basis for computing the attribute 00719 \param rep_ the representation to be used 00720 */ 00721 TeComputeSpatialStrategy (TeTheme* theme_, TeGeomRep rep_) { theme = theme_; rep = rep_; } 00722 00724 TeTheme* theme; 00725 00727 TeGeomRep rep; 00728 }; 00729 00730 00733 class TL_DLL TeAverageWeighByAreaStrategy: public TeComputeSpatialStrategy 00734 { 00735 public: 00737 /* 00738 \param theme_ the theme to be used as basis for computing the attribute 00739 \param att_ the attribute used to compute the sum. It must be numerical 00740 \param rep_ the representation to be used 00741 */ 00742 TeAverageWeighByAreaStrategy (TeTheme* theme_, string att_, TeGeomRep rep_) : TeComputeSpatialStrategy(theme_, rep_) { attribute = att_; } 00743 00745 virtual ~TeAverageWeighByAreaStrategy() {} 00746 00748 /* 00749 \param box compute the attribute of a cell having this box 00750 */ 00751 virtual string compute (TeBox box); 00752 00753 private: 00755 string attribute; 00756 }; 00757 00758 00761 class TL_DLL TeSumWeighByAreaStrategy: public TeComputeSpatialStrategy 00762 { 00763 public: 00765 /* 00766 \param theme_ the theme to be used as basis for computing the attribute 00767 \param att_ the attribute used to compute the sum. It must be numerical 00768 \param rep_ the representation to be used 00769 */ 00770 TeSumWeighByAreaStrategy (TeTheme* theme_, string att_, TeGeomRep rep_) : TeComputeSpatialStrategy(theme_, rep_) { attribute = att_; } 00771 00773 virtual ~TeSumWeighByAreaStrategy() {} 00774 00776 /* 00777 \param box compute the attribute of a cell having this box 00778 */ 00779 virtual string compute (TeBox box); 00780 00781 private: 00783 string attribute; 00784 }; 00785 00786 00788 class TL_DLL TeCategoryMajorityStrategy: public TeComputeSpatialStrategy 00789 { 00790 public: 00792 /* 00793 \param theme_ the theme to be used as basis for computing the attribute 00794 \param att_ the attribute used to compute the majority 00795 \param classesMap a map to reclassify the values 00796 */ 00797 TeCategoryMajorityStrategy (TeTheme* theme_, string att_, map<string, string>& classesMap) : TeComputeSpatialStrategy(theme_, TePOLYGONS) 00798 {classesMap = classesMap; attribute = att_;} 00799 00801 virtual ~TeCategoryMajorityStrategy() {} 00802 00804 /* 00805 \param box compute the attribute of a cell having this box 00806 */ 00807 virtual string compute (TeBox box); 00808 00809 protected: 00811 map<string, string> classesMap; 00812 00814 string attribute; 00815 }; 00816 00817 00821 class TL_DLL TeCountObjectsStrategy: public TeComputeSpatialStrategy 00822 { 00823 public: 00825 /* 00826 \param theme_ the theme to be used as basis for computing the attribute 00827 \param geom_ the representation to be used 00828 */ 00829 TeCountObjectsStrategy (TeTheme* theme_, TeGeomRep geom_) : TeComputeSpatialStrategy(theme_, geom_) { } 00830 00832 virtual ~TeCountObjectsStrategy() { } 00833 00835 /* 00836 \param box compute the attribute of a cell having this box 00837 */ 00838 virtual string compute (TeBox box); 00839 00841 virtual TeAttrDataType Type() { return TeINT; } 00842 }; 00843 00844 00846 class TL_DLL TeCountPolygonalObjectsStrategy: public TeCountObjectsStrategy 00847 { 00848 public: 00850 /* 00851 \param theme_ the theme to be used as basis for computing the attribute 00852 */ 00853 TeCountPolygonalObjectsStrategy (TeTheme* theme_) : TeCountObjectsStrategy(theme_, TePOLYGONS) {} 00854 00856 /* 00857 \param box compute the attribute of a cell having this box 00858 */ 00859 virtual string compute (TeBox box); 00860 }; 00861 00862 00864 class TL_DLL TeCountLineObjectsStrategy: public TeCountObjectsStrategy 00865 { 00866 public: 00868 /* 00869 \param theme_ the theme to be used as basis for computing the attribute 00870 */ 00871 TeCountLineObjectsStrategy (TeTheme* theme_) : TeCountObjectsStrategy(theme_, TeLINES) {} 00872 00874 /* 00875 \param box compute the attribute of a cell having this box 00876 */ 00877 virtual string compute (TeBox box); 00878 }; 00879 00880 00882 class TL_DLL TeCountPointObjectsStrategy: public TeCountObjectsStrategy 00883 { 00884 public: 00886 /* 00887 \param theme_ the theme to be used as basis for computing the attribute 00888 */ 00889 TeCountPointObjectsStrategy (TeTheme* theme_) : TeCountObjectsStrategy(theme_, TePOINTS) {} 00890 }; 00891 00892 00894 class TL_DLL TeLineLengthStrategy: public TeComputeSpatialStrategy 00895 { 00896 public: 00898 /* 00899 \param theme_ the theme to be used as basis for computing the attribute 00900 */ 00901 TeLineLengthStrategy (TeTheme* theme_) : TeComputeSpatialStrategy(theme_, TeLINES){} 00902 00904 virtual ~TeLineLengthStrategy() {} 00905 00907 /* 00908 \param box compute the attribute of a cell having this box 00909 */ 00910 virtual string compute (TeBox box); 00911 }; 00912 00913 00915 class TL_DLL TeTotalAreaPercentageStrategy: public TeComputeSpatialStrategy 00916 { 00917 public: 00919 /* 00920 \param theme_ the theme to be used as basis for computing the attribute 00921 */ 00922 TeTotalAreaPercentageStrategy (TeTheme* theme_) : TeComputeSpatialStrategy(theme_, TePOLYGONS){} 00923 00925 virtual ~TeTotalAreaPercentageStrategy() {} 00926 00928 /* 00929 \param box compute the attribute of a cell having this box 00930 */ 00931 virtual string compute (TeBox box); 00932 }; 00933 00934 /* 00935 // pedro@20061214 00937 class TeMinimumDistanceNetStrategy: public TeComputeSpatialStrategy 00938 { 00939 public: 00941 TeMinimumDistanceNetStrategy(TeTheme* theme_, TeGeomRep rep_, TeGraphNetwork* net, double dist_ = 50) : TeComputeSpatialStrategy(theme_, rep_) { maxDist = dist_; tree = NULL; } 00942 00944 virtual ~TeMinimumDistanceNetStrategy() { if(tree) delete tree; } 00945 00946 void CreatePoints(TeCoord2D p1, TeCoord2D p2); // create all intermediate points between them, using the maximum distance 00947 00948 virtual string compute (TeBox box); 00949 00950 virtual TeAttrDataType Type() { return TeREAL; } 00951 00952 private: 00953 00954 double maxDist; 00955 00956 vector<pair<TeCoord2D, TePoint> > dataSet; 00957 00958 KDTREE* tree; 00959 }; 00960 */ 00961 00962 00964 class TL_DLL TeMinimumDistanceStrategy: public TeComputeSpatialStrategy 00965 { 00966 public: 00968 /* 00969 \param theme_ the theme to be used as basis for computing the attribute 00970 \param gep_ the geometry to be used 00971 \param distError_ the maximum error tolerated by this operator 00972 */ 00973 TeMinimumDistanceStrategy(TeTheme* theme_, TeGeomRep rep_, double distError_ = 50); 00974 00976 virtual ~TeMinimumDistanceStrategy() { if(tree) delete tree; } 00977 00979 /* 00980 \param box compute the attribute of a cell having this box 00981 */ 00982 virtual string compute (TeBox box); 00983 00984 protected: 00986 void CreatePoints(TeCoord2D p1, TeCoord2D p2); 00987 00989 double maxDist; 00990 00992 vector<pair<TeCoord2D, TePoint> > dataSet; 00993 00995 KDTREE* tree; 00996 }; 00997 00998 01001 class TL_DLL TeMinimumDistancePolygonsStrategy: public TeMinimumDistanceStrategy 01002 { 01003 public: 01005 /* 01006 \param theme_ the theme to be used as basis for computing the attribute 01007 \param distError_ the maximum error tolerated by this operator 01008 */ 01009 TeMinimumDistancePolygonsStrategy(TeTheme* theme_, double distError_ = 150); 01010 01012 virtual ~TeMinimumDistancePolygonsStrategy() {} 01013 01015 /* 01016 \param box compute the attribute of a cell having this box 01017 */ 01018 virtual string compute (TeBox box); 01019 }; 01020 01021 01023 class TL_DLL TeMinimumDistanceLinesStrategy : public TeMinimumDistanceStrategy 01024 { 01025 public: 01027 /* 01028 \param theme_ the theme to be used as basis for computing the attribute 01029 \param distError_ the maximum error tolerated by this operator 01030 */ 01031 TeMinimumDistanceLinesStrategy(TeTheme* theme_, double distError_ = 150); 01032 01034 virtual ~TeMinimumDistanceLinesStrategy() {} 01035 }; 01036 01037 01040 class TL_DLL TeMinimumDistancePointsStrategy: public TeMinimumDistanceStrategy 01041 { 01042 public: 01044 /* 01045 \param theme_ the theme to be used as basis for computing the attribute 01046 */ 01047 TeMinimumDistancePointsStrategy(TeTheme* theme_); 01048 01050 virtual ~TeMinimumDistancePointsStrategy() {} 01051 }; 01052 01054 #endif 01055