[Igarden-commit] Garden/source/SourceMaterialDB AttributeDictionary.cpp, 1.41.2.9, 1.41.2.10 Attri
Status: Beta
Brought to you by:
jlbedell
|
From: Jeffrey B. <jlb...@us...> - 2008-05-13 03:00:14
|
Update of /cvsroot/igarden/Garden/source/SourceMaterialDB In directory sc8-pr-cvs2.sourceforge.net:/tmp/cvs-serv8858/source/SourceMaterialDB Modified Files: Tag: Release_branch_v1 AttributeDictionary.cpp AttributeDictionary.h Log Message: Improve material search query Index: AttributeDictionary.cpp =================================================================== RCS file: /cvsroot/igarden/Garden/source/SourceMaterialDB/AttributeDictionary.cpp,v retrieving revision 1.41.2.9 retrieving revision 1.41.2.10 diff -C2 -d -r1.41.2.9 -r1.41.2.10 *** AttributeDictionary.cpp 21 Mar 2008 22:07:33 -0000 1.41.2.9 --- AttributeDictionary.cpp 13 May 2008 03:00:09 -0000 1.41.2.10 *************** *** 1844,1847 **** --- 1844,1848 ---- view = key->GetView(); count = key->GetViewClass()->NumProperties(); + for(iter = 0, totalItems = 0, matchingItems = 0; iter < count; iter++) { *************** *** 1850,1856 **** { totalItems++; ! if(!record->isEmpty(propertyID)) { ! if(propertyID == kFieldCanonicalName) { String nameOne, nameTwo; --- 1851,1882 ---- { totalItems++; ! ! if(record->isEmpty(propertyID)) { ! if(MatchIfEmpty(propertyID)) ! matchingItems++; ! } ! else ! { ! if(propertyID == kPlantZone) ! { ! long mtype; ! ! if(record->GetInt32(kFieldMaterialType, &mtype) && ! ((mtype == kMaterialTypeAnnual) || (mtype == kMaterialTypeAnnualVegetable))) ! { ! matchingItems++; ! } ! else ! { ! Int32 intA, intB; ! ! record->GetInt32(propertyID, &intA); ! key->GetInt32(propertyID, &intB); ! if((intA & intB) != 0) ! matchingItems++; ! } ! } ! else if(propertyID == kFieldCanonicalName) { String nameOne, nameTwo; *************** *** 1889,1892 **** --- 1915,1920 ---- otherType = key->GetMaterialType(); + printf(" myType = %ld otherType = %ld\n", myType, otherType); + if(otherType == myType) matchingItems++; *************** *** 1896,1902 **** myItem = myType & 0x0000FFFFL; testGroup = otherType & 0xFFFF0000L; ! if(myGroup == 0) ! matchingItems++; ! else if(myGroup == testGroup && myItem == 0 ? true : false) matchingItems++; } --- 1924,1928 ---- myItem = myType & 0x0000FFFFL; testGroup = otherType & 0xFFFF0000L; ! if(myGroup == testGroup && myItem == 0 ? true : false) matchingItems++; } *************** *** 1913,1922 **** case kAttrMenu: case kAttrSize: ! if(record->GetInt32(propertyID, &intA) && key->GetInt32(propertyID, &intB)) ! { ! if(intA == intB) ! matchingItems++; ! } ! else matchingItems++; break; --- 1939,1945 ---- case kAttrMenu: case kAttrSize: ! record->GetInt32(propertyID, &intA); ! key->GetInt32(propertyID, &intB); ! if(intA == intB) matchingItems++; break; *************** *** 1924,1933 **** case kAttrBitfield: case kAttrBitfieldRange: ! if(record->GetInt32(propertyID, &intA) && key->GetInt32(propertyID, &intB)) ! { ! if((intA & intB) != 0) ! matchingItems++; ! } ! else matchingItems++; break; --- 1947,1953 ---- case kAttrBitfield: case kAttrBitfieldRange: ! record->GetInt32(propertyID, &intA); ! key->GetInt32(propertyID, &intB); ! if((intA & intB) != 0) matchingItems++; break; *************** *** 1935,1944 **** case kAttrSizeRange: case kAttrIntegerRange: ! if(record->GetValueInt32Range(propertyID, lowerA, upperA) && key->GetValueInt32Range(propertyID, lowerB, upperB)) ! { ! if(lowerA >= lowerB && upperA <= upperB) ! matchingItems++; ! } ! else matchingItems++; break; --- 1955,1961 ---- case kAttrSizeRange: case kAttrIntegerRange: ! record->GetValueInt32Range(propertyID, lowerA, upperA); ! key->GetValueInt32Range(propertyID, lowerB, upperB); ! if(lowerA >= lowerB && upperA <= upperB) matchingItems++; break; *************** *** 1975,1979 **** } } ! if(totalItems != 0) return (matchingItems * 100) / totalItems; --- 1992,1996 ---- } } ! if(totalItems != 0) return (matchingItems * 100) / totalItems; *************** *** 1983,1986 **** --- 2000,2043 ---- } + bool AttributeDictionary::MatchIfEmpty(propertyID_t id) + { + switch(id) + { + case kFieldCanonicalName: + case kFieldVariantName: + case kFieldCommonName: + case kFieldMaterialType: + case kDescription: + case kAlternateCommonNames: + return false; + + default: + return true; + } + + // kPlantZone, kPlantSpread, kPlantForm, + // kGrowthRate, kLifeExpectancy, kSoilPh, + // kSoilTexture, kSoilMoisture, kRootPattern, + // kTransplantEase, kTransplantCondition, kAvailability, + // kShadeTolerance, kBranchPattern, kLeafingPeriod, + // kFoliageFinish, kFoliageTexture, kFoliageDensity, + // kFoliageColor, kAutumnColor, kAutumnVisibility, + // kLeafFall, kSex, kFlowerType, + // kFlowerColor, kFlowerSeason, kFlowerDuration, + // kFlowerVisibility, kFlowerFragrance, kFruitType, + // kFruitColor, kFruitPeriod, kFruitDuration, + // kFruitVisibility, kEdibility, kSongbirdValue, + // kFlowerSize, kCutFlower, kFruitFrequency, + // kFruitStorable, kAirborneSaltTolerance, kOzoneTolerance, + // kAirPollutionTolerance, kFloodTolerance, kDroughtTolerance, + // kSulphurDioxideTolerance, kWinterWindTolerance, kBranchTexture, + // kBranchDensity, kTwigColor, kBarkTexture, + // kBarkColor, kPlantHeightYr20, kPlantSpreadYr20, + // kFlowerHeight, kSowLocation, kPlantSeedDepth, + // kNumSeedsSown, kUserComments, kInstanceSupplierIDs, + // kMaterialLength, kMaterialWidth, kPlantInstanceHeight, + // kPlantInstanceSpread, kMaterialInstanceLength, kMaterialInstanceWidth, + } + // --------------------------------------------------------------------------- Index: AttributeDictionary.h =================================================================== RCS file: /cvsroot/igarden/Garden/source/SourceMaterialDB/AttributeDictionary.h,v retrieving revision 1.9.2.3 retrieving revision 1.9.2.4 diff -C2 -d -r1.9.2.3 -r1.9.2.4 *** AttributeDictionary.h 21 Mar 2008 22:07:33 -0000 1.9.2.3 --- AttributeDictionary.h 13 May 2008 03:00:11 -0000 1.9.2.4 *************** *** 89,92 **** --- 89,93 ---- // methods static void AddInfoEntry(attributeID_t id, attributeType_t typeVal, attributeClass_t classVal, char *argXMLName, short resourceID = 0); + static bool MatchIfEmpty(propertyID_t id); // attributes |