18 _world (NULL), _placeHolder (NULL), _mainPlace (NULL),
19 _location (IATACode_T (
""), IATAType::
LAST_VALUE, 0,
20 ICAOCode_T (
""), FAACode_T (
""),
21 CommonName_T (
""), ASCIIName_T (
""), 0,
22 Date_T (1970, 01, 01),
Date_T (2999, 12, 31), Comment_T (
""),
23 CityCode_T (
""), CityUTFName_T (
""), CityASCIIName_T (
""), 0,
25 CountryCode_T (
""), AltCountryCode_T (
""), CountryName_T (
""),
28 FeatureClass_T (
""), FeatureCode_T (
""),
29 Admin1Code_T (
""), Admin1UTFName_T (
""), Admin1ASCIIName_T (
""),
30 Admin2Code_T (
""), Admin2UTFName_T (
""), Admin2ASCIIName_T (
""),
31 Admin3Code_T (
""), Admin4Code_T (
""),
32 0, 0, 0, TimeZone_T (
""), 0, 0, 0,
33 Date_T (2000, 01, 01), TvlPORListString_T (
""),
35 RawDataString_T (
"")),
40 Place::Place (
const LocationKey& iKey) :
41 _world (NULL), _placeHolder (NULL), _mainPlace (NULL),
42 _location (iKey.getIataCode(), iKey.getIataType(), iKey.getGeonamesID(),
43 ICAOCode_T (
""), FAACode_T (
""),
44 CommonName_T (
""), ASCIIName_T (
""), 0,
45 Date_T (1970, 01, 01),
Date_T (2999, 12, 31), Comment_T (
""),
46 CityCode_T (
""), CityUTFName_T (
""), CityASCIIName_T (
""), 0,
48 CountryCode_T (
""), AltCountryCode_T (
""), CountryName_T (
""),
51 FeatureClass_T (
""), FeatureCode_T (
""),
52 Admin1Code_T (
""), Admin1UTFName_T (
""), Admin1ASCIIName_T (
""),
53 Admin2Code_T (
""), Admin2UTFName_T (
""), Admin2ASCIIName_T (
""),
54 Admin3Code_T (
""), Admin4Code_T (
""),
55 0, 0, 0, TimeZone_T (
""), 0, 0, 0,
56 Date_T (2000, 01, 01), TvlPORListString_T (
""),
58 RawDataString_T (
"")),
63 Place::Place (
const Location& iLocation) :
64 _world (NULL), _placeHolder (NULL), _mainPlace (NULL),
65 _location (iLocation), _docID (0) {
69 Place::Place (
const Place& iPlace) :
70 _world (iPlace._world), _placeHolder (iPlace._placeHolder),
71 _mainPlace (iPlace._mainPlace),
72 _location (iPlace._location),
73 _docID (iPlace._docID),
74 _termSetMap (iPlace._termSetMap), _spellingSet (iPlace._spellingSet),
75 _stemmingSet (iPlace._stemmingSet), _synonymSet (iPlace._synonymSet) {
84 std::ostringstream oStr;
86 oStr <<
", " << _docID
89 if (_extraPlaceList.empty() ==
false) {
90 oStr <<
"; Extra matches: {";
91 unsigned short idx = 0;
92 for (PlaceOrderedList_T::const_iterator itLoc = _extraPlaceList.begin();
93 itLoc != _extraPlaceList.end(); ++itLoc, ++idx) {
97 const Place* lExtraPlace_ptr = *itLoc;
98 assert (lExtraPlace_ptr != NULL);
104 if (_alternatePlaceList.empty() ==
false) {
105 oStr <<
"; Alternate matches: {";
106 unsigned short idx = 0;
107 for (PlaceOrderedList_T::const_iterator itLoc =
108 _alternatePlaceList.begin();
109 itLoc != _alternatePlaceList.end(); ++itLoc, ++idx) {
113 const Place* lAlternatePlace_ptr = *itLoc;
114 assert (lAlternatePlace_ptr != NULL);
130 std::ostringstream oStr;
132 oStr <<
", " << _docID;
134 if (_extraPlaceList.empty() ==
false) {
135 oStr <<
" " << _extraPlaceList.size() <<
" extra match(es)";
138 if (_alternatePlaceList.empty() ==
false) {
139 oStr <<
" " << _alternatePlaceList.size() <<
" alternate match(es)";
156 std::ostringstream oStr;
161 for (TermSetMap_T::const_iterator itStringSet = _termSetMap.begin();
162 itStringSet != _termSetMap.end(); ++itStringSet, ++idx_map) {
167 const Weight_T& lWeight = itStringSet->first;
168 oStr <<
"[" << lWeight <<
"] ";
171 const StringSet_T& lStringSet = itStringSet->second;
173 for (StringSet_T::const_iterator itString = lStringSet.begin();
174 itString != lStringSet.end(); ++itString, ++idx_set) {
178 const std::string& lString = *itString;
184 oStr <<
"; [spelling] ";
186 for (StringSet_T::const_iterator itTerm = _spellingSet.begin();
187 itTerm != _spellingSet.end(); ++itTerm, ++idx) {
191 const std::string& lTerm = *itTerm;
204 std::ostringstream oStr;
206 oStr <<
", " << _docID;
212 std::ostringstream oStr;
220 _spellingSet.clear();
221 _stemmingSet.clear();
231 TermSetMap_T::const_iterator itTermSet = _termSetMap.find (iWeight);
232 if (itTermSet != _termSetMap.end()) {
233 oTermSet = itTermSet->second;
241 bool hasInsertBeenSuccessful =
true;
244 TermSetMap_T::iterator itTermSet = _termSetMap.find (iWeight);
246 if (itTermSet == _termSetMap.end()) {
248 hasInsertBeenSuccessful =
249 _termSetMap.insert (TermSetMap_T::value_type (iWeight, iTermSet)).second;
252 assert (hasInsertBeenSuccessful ==
true);
258 for (StringSet_T::const_iterator itString = iTermSet.begin();
259 itString != iTermSet.end(); ++itString) {
260 const std::string& lString = *itString;
261 lStringSet.insert (lString);
265 return hasInsertBeenSuccessful;
270 const std::string& iBaseName,
284 for (FeatureNameList_T::const_iterator itFeatName = lFeatureNameList.begin();
285 itFeatName != lFeatureNameList.end(); ++itFeatName) {
288 lTermSet.insert (iBaseName +
" " + lFeatureName);
321 lTermSet.insert (lTokenisedName);
327 if (iCityUtfName.empty() ==
false) {
328 lTermSet.insert (lTokenisedName +
" " + iCityUtfName);
332 if (iCityAsciiName.empty() ==
false) {
333 lTermSet.insert (lTokenisedName +
" " + iCityAsciiName);
337 if (iAdm1UtfName.empty() ==
false) {
338 lTermSet.insert (lTokenisedName +
" " + iAdm1UtfName);
342 if (iAdm1AsciiName.empty() ==
false) {
343 lTermSet.insert (lTokenisedName +
" " + iAdm1AsciiName);
347 if (iAdm2UtfName.empty() ==
false) {
348 lTermSet.insert (lTokenisedName +
" " + iAdm2UtfName);
352 if (iAdm2AsciiName.empty() ==
false) {
353 lTermSet.insert (lTokenisedName +
" " + iAdm2AsciiName);
357 lTermSet.insert (lTokenisedName +
" " + iStateCode);
360 lTermSet.insert (lTokenisedName +
" " + iCountryCode);
363 lTermSet.insert (lTokenisedName +
" " + iCountryName);
366 lTermSet.insert (lTokenisedName +
" " + iContinentName);
369 _spellingSet.insert (lTokenisedName);
375 const std::string& lNormalisedCommonName =
376 iTransliterator.
normalise (lTokenisedName);
379 lTermSet.insert (lNormalisedCommonName);
387 if (iCityUtfName.empty() ==
false) {
388 lTermSet.insert (lNormalisedCommonName +
" " + iCityUtfName);
393 if (iCityAsciiName.empty() ==
false) {
394 lTermSet.insert (lNormalisedCommonName +
" " + iCityAsciiName);
399 if (iAdm1UtfName.empty() ==
false) {
400 lTermSet.insert (lNormalisedCommonName +
" " + iAdm1UtfName);
405 if (iAdm1AsciiName.empty() ==
false) {
406 lTermSet.insert (lNormalisedCommonName +
" " + iAdm1AsciiName);
411 if (iAdm2UtfName.empty() ==
false) {
412 lTermSet.insert (lNormalisedCommonName +
" " + iAdm2UtfName);
417 if (iAdm2AsciiName.empty() ==
false) {
418 lTermSet.insert (lNormalisedCommonName +
" " + iAdm2AsciiName);
423 lTermSet.insert (lNormalisedCommonName +
" " + iStateCode);
427 lTermSet.insert (lNormalisedCommonName +
" " + iCountryCode);
431 lTermSet.insert (lNormalisedCommonName +
" " + iCountryName);
435 lTermSet.insert (lNormalisedCommonName +
" " + iContinentName);
438 _spellingSet.insert (lNormalisedCommonName);
464 +
static_cast<const Weight_T> (lPageRankDouble / 5.0);
478 const std::string& lIataCode = _location.
getIataCode();
479 if (lIataCode.empty() ==
false) {
480 lWeightedTermSet.insert (lIataCode);
481 _spellingSet.insert (lIataCode);
489 const std::string& lIcaoCode = _location.
getIcaoCode();
490 if (lIcaoCode.empty() ==
false) {
491 lWeightedTermSet.insert (lIcaoCode);
492 _spellingSet.insert (lIcaoCode);
500 const std::string& lFaaCode = _location.
getFaaCode();
501 if (lFaaCode.empty() ==
false) {
502 lWeightedTermSet.insert (lFaaCode);
503 _spellingSet.insert (lFaaCode);
512 if (lGeonamesID != 0) {
513 std::stringstream oStr;
515 const std::string lGeonamesIDStr = oStr.str();
516 lStdTermSet.insert (lGeonamesIDStr);
517 _spellingSet.insert (lGeonamesIDStr);
521 if (lFeatureCode.empty() ==
false) {
522 lWeightedTermSet.insert (lFeatureCode);
523 _spellingSet.insert (lFeatureCode);
527 const std::string& lCityCode = _location.
getCityCode();
528 if (lCityCode.empty() ==
false && lCityCode != lIataCode) {
529 lWeightedTermSet.insert (lCityCode);
530 _spellingSet.insert (lCityCode);
535 if (lCityUtfName.empty() ==
false) {
536 lWeightedTermSet.insert (lCityUtfName);
537 _spellingSet.insert (lCityUtfName);
542 if (lCityAsciiName.empty() ==
false) {
543 lWeightedTermSet.insert (lCityAsciiName);
544 _spellingSet.insert (lCityAsciiName);
548 const std::string& lStateCode = _location.
getStateCode();
549 if (lStateCode.empty() ==
false) {
550 lWeightedTermSet.insert (lStateCode);
551 _spellingSet.insert (lStateCode);
556 lWeightedTermSet.insert (lCountryCode);
560 if (lCountryName.empty() ==
false) {
561 lWeightedTermSet.insert (lCountryName);
562 _spellingSet.insert (lCountryName);
567 if (lAdm1Code.empty() ==
false) {
568 lWeightedTermSet.insert (lAdm1Code);
573 if (lAdm1UtfName.empty() ==
false) {
574 lWeightedTermSet.insert (lAdm1UtfName);
575 _spellingSet.insert (lAdm1UtfName);
580 if (lAdm1AsciiName.empty() ==
false) {
581 lWeightedTermSet.insert (lAdm1AsciiName);
582 _spellingSet.insert (lAdm1AsciiName);
587 if (lAdm2Code.empty() ==
false) {
588 lWeightedTermSet.insert (lAdm2Code);
593 if (lAdm2UtfName.empty() ==
false) {
594 lWeightedTermSet.insert (lAdm2UtfName);
595 _spellingSet.insert (lAdm2UtfName);
600 if (lAdm2AsciiName.empty() ==
false) {
601 lWeightedTermSet.insert (lAdm2AsciiName);
602 _spellingSet.insert (lAdm2AsciiName);
607 lWeightedTermSet.insert (lContinentName);
612 if (lCommonName.empty() ==
false) {
629 const std::string& lASCIIName = _location.
getAsciiName();
630 if (lASCIIName.empty() ==
false) {
649 for (NameMatrix_T::const_iterator itNameList = lNameMatrix.begin();
650 itNameList != lNameMatrix.end(); ++itNameList) {
653 const Names& lNames = itNameList->second;
658 for (NameList_T::const_iterator itName = lNameList.begin();
659 itName != lNameList.end(); ++itName) {
660 const std::string& lName = *itName;
664 if (lName.empty() ==
false) {
671 lWordCombinationHolder.
_list;
672 for (WordCombinationHolder::StringList_T::const_iterator itString =
674 itString != lStringList.end(); ++itString) {
675 const std::string& lWordCombination = *itString;
676 const std::string& lNormalisedWordCombination =
677 iTransliterator.
normalise (lWordCombination);
680 lStdTermSet.insert (lWordCombination);
681 _spellingSet.insert (lWordCombination);
684 lStdTermSet.insert (lNormalisedWordCombination);
685 _spellingSet.insert (lNormalisedWordCombination);
703 const bool hasFoundNameList =
getNameList (K_DEFAULT_LANGUAGE_CODE,
706 if (hasFoundNameList ==
false) {
708 std::ostringstream errorStr;
709 errorStr <<
"No list of names in (American) English ("
710 << K_DEFAULT_LANGUAGE_CODE
711 <<
" locale) can be found for the following place: "
719 if (_extraPlaceList.empty() ==
false) {
720 for (PlaceOrderedList_T::const_iterator itLoc = _extraPlaceList.begin();
721 itLoc != _extraPlaceList.end(); ++itLoc) {
722 const Place* lExtraPlace_ptr = *itLoc;
723 assert (lExtraPlace_ptr != NULL);
732 if (_alternatePlaceList.empty() ==
false) {
733 for (PlaceOrderedList_T::const_iterator itLoc =
734 _alternatePlaceList.begin();
735 itLoc != _alternatePlaceList.end(); ++itLoc) {
736 const Place* lAlternatePlace_ptr = *itLoc;
737 assert (lAlternatePlace_ptr != NULL);
const Percentage_T K_DEFAULT_PAGE_RANK
const Admin1Code_T & getAdmin1Code() const
const CountryCode_T & getCountryCode() const
#define OPENTREP_LOG_ERROR(iToBeLogged)
const Location & getLocation() const
std::set< std::string > StringSet_T
void addExtraLocation(const Location &iExtraLocation)
void addNameToXapianSets(const Weight_T &, const LocationName_T &, const FeatureCode_T &, const CityUTFName_T &, const CityASCIIName_T &, const Admin1UTFName_T &, const Admin1ASCIIName_T &, const Admin2UTFName_T &, const Admin2ASCIIName_T &, const StateCode_T &, const CountryCode_T &, const CountryName_T &, const ContinentName_T &, const OTransliterator &)
std::string createStringFromWordList(const WordList_T &iWordList, const unsigned short iSplitIdx, const bool iFromBeginningFlag)
Structure modelling a (geographical) location.
const Admin1ASCIIName_T & getAdmin1AsciiName() const
const FeatureCode_T & getFeatureCode() const
bool addTermSet(const Weight_T &, const StringSet_T &)
const CityASCIIName_T & getCityAsciiName() const
const FAACode_T & getFaaCode() const
const ContinentName_T & getContinentName() const
const NameMatrix_T & getNameMatrix() const
std::string shortDisplay() const
std::string toShortString() const
const Admin1UTFName_T & getAdmin1UtfName() const
static FeatureNameList_T getFeatureList(const FeatureCode_T &)
std::list< FeatureName_T > FeatureNameList_T
boost::gregorian::date Date_T
std::list< Word_T > WordList_T
std::list< std::string > NameList_T
void toStream(std::ostream &) const
const NameMatrix & getNameMatrix() const
const Admin2UTFName_T & getAdmin2UtfName() const
const Location & completeLocation()
bool getNameList(const LanguageCode_T &iLanguageCode, NameList_T &ioNameList) const
const PageRank_T & getPageRank() const
const GeonamesID_T & getGeonamesID() const
const ICAOCode_T & getIcaoCode() const
const CommonName_T & getCommonName() const
const CityUTFName_T & getCityUtfName() const
Class modelling a place/POR (point of reference).
void buildIndexSets(const OTransliterator &)
std::list< std::string > StringList_T
std::string toString() const
std::string toBasicString() const
const IATACode_T & getIataCode() const
std::string display() const
const NameList_T & getNameList() const
void fromStream(std::istream &)
const Weight_T K_DEFAULT_INDEXING_STD_WEIGHT
StringSet_T getTermSet(const Weight_T &) const
const Admin2ASCIIName_T & getAdmin2AsciiName() const
void tokeniseStringIntoWordList(const std::string &iPhrase, WordList_T &ioWordList)
const CityCode_T & getCityCode() const
std::map< LanguageCode_T, Names > NameMatrix_T
void addAlternateLocation(const Location &iAlternateLocation)
std::string toString() const
std::string toShortString() const
const StateCode_T & getStateCode() const
std::string normalise(const std::string &iString) const
const CountryName_T & getCountryName() const
const ASCIIName_T & getAsciiName() const
std::string describeSets() const
const Weight_T K_DEFAULT_INDEXING_EXTRA_WEIGHT