9 #include <opentrep/Travel.pb.h> 21 std::string oStr (
"");
24 treppb::QueryAnswer lQueryAnswer;
27 const bool kOKStatus =
true;
28 lQueryAnswer.set_ok_status (kOKStatus);
39 treppb::PlaceList* lPlaceListPtr = lQueryAnswer.mutable_place_list();
40 assert (lPlaceListPtr != NULL);
43 for (LocationList_T::const_iterator itLocation = iLocationList.begin();
44 itLocation != iLocationList.end(); ++itLocation) {
45 const Location& lLocation = *itLocation;
48 treppb::Place* lPlacePtr = lPlaceListPtr->add_place();
49 assert (lPlacePtr != NULL);
58 treppb::UnknownKeywordList* lUnknownKeywordListPtr =
59 lQueryAnswer.mutable_unmatched_keyword_list();
60 assert (lUnknownKeywordListPtr != NULL);
63 for (WordList_T::const_iterator itWord = iNonMatchedWordList.begin();
64 itWord != iNonMatchedWordList.end(); ++itWord) {
65 const Word_T& lWord = *itWord;
66 lUnknownKeywordListPtr->add_word (lWord);
70 const bool pbSerialStatus = lQueryAnswer.SerializeToString (&oStr);
71 if (pbSerialStatus ==
false) {
72 std::ostringstream errStr;
73 errStr <<
"Error - The OPTD Travel protocol buffer object cannot be " 74 <<
"serialized into a C++ string";
89 treppb::IATACode* lIataAirportPtr = ioPlace.mutable_tvl_code();
90 assert (lIataAirportPtr != NULL);
91 lIataAirportPtr->set_code (lIataCode);
95 const treppb::PlaceType& lPlaceType = lLocationType.
getTypeAsPB();
96 const treppb::PlaceType_LocationType& lPlaceTypeEnum = lPlaceType.type();
97 treppb::PlaceType* lPlaceTypePtr = ioPlace.mutable_loc_type();
98 assert (lPlaceTypePtr != NULL);
99 lPlaceTypePtr->set_type (lPlaceTypeEnum);
103 treppb::GeonamesID* lGeonamesIDPtr = ioPlace.mutable_geonames_id();
104 assert (lGeonamesIDPtr != NULL);
105 lGeonamesIDPtr->set_id (lGeonamesID);
109 treppb::ICAOCode* lIcaoCodePtr = ioPlace.mutable_icao_code();
110 assert (lIcaoCodePtr != NULL);
111 lIcaoCodePtr->set_code (lIcaoCode);
115 treppb::FAACode* lFaaCodePtr = ioPlace.mutable_faa_code();
116 assert (lFaaCodePtr != NULL);
117 lFaaCodePtr->set_code (lFaaCode);
121 treppb::UNLOCodeList* lUNLOCodeListPtr = ioPlace.mutable_unlocode_list();
122 assert (lUNLOCodeListPtr != NULL);
124 for (UNLOCodeList_T::const_iterator itUNLOCode = lUNLOCodeList.begin();
125 itUNLOCode != lUNLOCodeList.end(); ++itUNLOCode) {
127 treppb::UNLOCode* lUNLOCodePtr = lUNLOCodeListPtr->add_unlocode();
128 assert (lUNLOCodePtr != NULL);
129 lUNLOCodePtr->set_code (lUNLOCode);
134 ioPlace.set_name_utf (lUtfName);
136 ioPlace.set_name_ascii (lAsciiName);
141 treppb::FeatureType* lFeatTypePtr = ioPlace.mutable_feat_type();
142 assert (lFeatTypePtr != NULL);
143 treppb::FeatureClass* lFeatClassPtr = lFeatTypePtr->mutable_fclass();
144 assert (lFeatClassPtr != NULL);
145 treppb::FeatureCode* lFeatCodePtr = lFeatTypePtr->mutable_fcode();
146 assert (lFeatCodePtr != NULL);
147 lFeatClassPtr->set_code (lFeatClass);
148 lFeatCodePtr->set_code (lFeatCode);
153 treppb::GeoPoint* lPointPtr = ioPlace.mutable_coord();
154 assert (lPointPtr != NULL);
155 lPointPtr->set_latitude (lLatitude);
156 lPointPtr->set_longitude (lLongitude);
160 treppb::CityList* lCityListPtr = ioPlace.mutable_city_list();
161 assert (lCityListPtr != NULL);
163 for (CityDetailsList_T::const_iterator itCity = lCityList.begin();
164 itCity != lCityList.end(); ++itCity) {
166 treppb::City* lCityPtr = lCityListPtr->add_city();
167 assert (lCityPtr != NULL);
171 treppb::IATACode* lIataCodePtr = lCityPtr->mutable_code();
172 assert (lIataCodePtr != NULL);
173 lIataCodePtr->set_code (lIataCode);
177 treppb::GeonamesID* lGeonamesIDPtr = lCityPtr->mutable_geonames_id();
178 assert (lGeonamesIDPtr != NULL);
179 lGeonamesIDPtr->set_id (lGeonamesID);
183 lCityPtr->set_name_utf (lCityUtfName);
187 lCityPtr->set_name_ascii (lCityAsciiName);
192 treppb::StateCode* lStateCodePtr = ioPlace.mutable_state_code();
193 assert (lStateCodePtr != NULL);
194 lStateCodePtr->set_code (lStateCode);
198 treppb::CountryCode* lCountryCodePtr = ioPlace.mutable_country_code();
199 assert (lCountryCodePtr != NULL);
200 lCountryCodePtr->set_code (lCountryCode);
204 treppb::AltCountryCode* lAltCountryCodePtr =
205 ioPlace.mutable_alt_country_code();
206 assert (lAltCountryCodePtr != NULL);
207 lAltCountryCodePtr->set_code (lAltCountryCode);
211 ioPlace.set_country_name (lCountryName);
215 treppb::WorldAreaCode* lWorldAreaCodePtr = ioPlace.mutable_wac_code();
216 assert (lWorldAreaCodePtr != NULL);
217 lWorldAreaCodePtr->set_code (lWAC);
221 ioPlace.set_wac_name (lWACName);
225 treppb::CurrencyCode* lCurrencyCodePtr = ioPlace.mutable_currency_code();
226 assert (lCurrencyCodePtr != NULL);
227 lCurrencyCodePtr->set_code (lCurrencyCode);
231 treppb::ContinentCode* lContinentCodePtr = ioPlace.mutable_continent_code();
232 assert (lContinentCodePtr != NULL);
233 lContinentCodePtr->set_code (lContinentCode);
237 ioPlace.set_continent_name (lContinentName);
241 treppb::Admin1Code* lAdm1CodePtr = ioPlace.mutable_adm1_code();
242 assert (lAdm1CodePtr != NULL);
243 lAdm1CodePtr->set_code (lAdm1Code);
247 ioPlace.set_adm1_name_utf (lAdm1UtfName);
249 ioPlace.set_adm1_name_ascii (lAdm1AsciiName);
253 treppb::Admin2Code* lAdm2CodePtr = ioPlace.mutable_adm2_code();
254 assert (lAdm2CodePtr != NULL);
255 lAdm2CodePtr->set_code (lAdm2Code);
259 ioPlace.set_adm2_name_utf (lAdm2UtfName);
261 ioPlace.set_adm2_name_ascii (lAdm2AsciiName);
265 treppb::Admin3Code* lAdm3CodePtr = ioPlace.mutable_adm3_code();
266 assert (lAdm3CodePtr != NULL);
267 lAdm3CodePtr->set_code (lAdm3Code);
271 treppb::Admin4Code* lAdm4CodePtr = ioPlace.mutable_adm4_code();
272 assert (lAdm4CodePtr != NULL);
273 lAdm4CodePtr->set_code (lAdm4Code);
277 treppb::Population* lPopulationPtr = ioPlace.mutable_population();
278 assert (lPopulationPtr != NULL);
279 lPopulationPtr->set_value (lPopulation);
283 treppb::Elevation* lElevationPtr = ioPlace.mutable_elevation();
284 assert (lElevationPtr != NULL);
285 lElevationPtr->set_value (lElevation);
289 treppb::GTopo30* lGTopo30Ptr = ioPlace.mutable_gtopo30();
290 assert (lGTopo30Ptr != NULL);
291 lGTopo30Ptr->set_value (lGTopo30);
295 treppb::PageRank* lPageRankPtr = ioPlace.mutable_page_rank();
296 assert (lPageRankPtr != NULL);
297 lPageRankPtr->set_rank (lPageRank);
301 treppb::TimeZone* lTimeZonePtr = ioPlace.mutable_tz();
302 assert (lTimeZonePtr != NULL);
303 lTimeZonePtr->set_tz (lTimeZone);
307 treppb::TZOffSet* lGMTOffsetPtr = ioPlace.mutable_gmt_offset();
308 assert (lGMTOffsetPtr != NULL);
309 lGMTOffsetPtr->set_offset (lGMTOffset);
313 treppb::TZOffSet* lDSTOffsetPtr = ioPlace.mutable_dst_offset();
314 assert (lDSTOffsetPtr != NULL);
315 lDSTOffsetPtr->set_offset (lDSTOffset);
319 treppb::TZOffSet* lRAWOffsetPtr = ioPlace.mutable_raw_offset();
320 assert (lRAWOffsetPtr != NULL);
321 lRAWOffsetPtr->set_offset (lRAWOffset);
325 treppb::Date* lGeonameModDatePtr = ioPlace.mutable_mod_date();
326 assert (lGeonameModDatePtr != NULL);
327 lGeonameModDatePtr->set_date (boost::gregorian::to_iso_extended_string(lGeonameModDate));
331 treppb::TravelRelatedList* lTvlPORListPtr = ioPlace.mutable_tvl_por_list();
332 assert (lTvlPORListPtr != NULL);
333 lTvlPORListPtr->add_tvl_code (lTvlPORList);
337 treppb::WikiLinkList* lWikiLinkListPtr = ioPlace.mutable_link_list();
338 assert (lWikiLinkListPtr != NULL);
339 treppb::WikiLink* lWikiLinkPtr = lWikiLinkListPtr->add_link();
340 assert (lWikiLinkPtr != NULL);
341 treppb::LanguageCode* lLangCodePtr = lWikiLinkPtr->mutable_lang();
342 assert (lLangCodePtr != NULL);
343 lLangCodePtr->set_code (
"en");
344 lWikiLinkPtr->set_link (lWikiLink);
348 treppb::Date* lDateFromPtr = ioPlace.mutable_date_from();
349 assert (lDateFromPtr != NULL);
350 lDateFromPtr->set_date (boost::gregorian::to_iso_extended_string(lDateFrom));
354 treppb::Date* lDateEndPtr = ioPlace.mutable_date_end();
355 assert (lDateEndPtr != NULL);
356 lDateEndPtr->set_date (boost::gregorian::to_iso_extended_string(lDateEnd));
360 treppb::Comment* lCommentPtr = ioPlace.mutable_comment();
361 assert (lCommentPtr != NULL);
362 lCommentPtr->set_text (lComment);
366 treppb::AltNameList* lAltNameListPtr = ioPlace.mutable_alt_name_list();
367 assert (lAltNameListPtr != NULL);
370 for (NameMatrix_T::const_iterator itNameList = lNameMatrix.begin();
371 itNameList != lNameMatrix.end(); ++itNameList) {
372 const Names& lNameListRef = itNameList->second;
375 for (NameList_T::const_iterator itName = lNameList.begin();
376 itName != lNameList.end(); ++itName) {
377 const std::string& lName = *itName;
379 treppb::AltName* lAltNamePtr = lAltNameListPtr->add_name();
380 assert (lAltNamePtr != NULL);
382 treppb::LanguageCode* lLangCodePtr = lAltNamePtr->mutable_lang();
383 assert (lLangCodePtr != NULL);
384 lLangCodePtr->set_code (lLangCode);
385 lAltNamePtr->set_name (lName);
391 treppb::MatchingPercentage* lPercentagePtr =
392 ioPlace.mutable_matching_percentage();
393 assert (lPercentagePtr != NULL);
394 lPercentagePtr->set_percentage (lPercentage);
402 treppb::KeywordList* lOriginalKeywordListPtr =
403 ioPlace.mutable_original_keyword_list();
404 assert (lOriginalKeywordListPtr != NULL);
405 lOriginalKeywordListPtr->add_word (lOriginalKeywords);
413 treppb::KeywordList* lCorrectedKeywordListPtr =
414 ioPlace.mutable_corrected_keyword_list();
415 assert (lCorrectedKeywordListPtr != NULL);
416 lCorrectedKeywordListPtr->add_word (lCorrectedKeywords);
420 treppb::EditDistance* lEditDistanceActualPtr =
421 ioPlace.mutable_edit_distance_actual();
422 assert (lEditDistanceActualPtr != NULL);
423 lEditDistanceActualPtr->set_dist (lEditDistanceActual);
428 treppb::EditDistance* lEditDistanceAllowablePtr =
429 ioPlace.mutable_edit_distance_actual();
430 assert (lEditDistanceAllowablePtr != NULL);
431 lEditDistanceAllowablePtr->set_dist (lEditDistanceAllowable);
435 treppb::PlaceList* lExtraPlaceListPtr = ioPlace.mutable_extra_place_list();
436 assert (lExtraPlaceListPtr != NULL);
437 for (LocationList_T::const_iterator itLoc = lExtraLocationList.begin();
438 itLoc != lExtraLocationList.end(); ++itLoc) {
439 const Location& lExtraLocation = *itLoc;
441 treppb::Place* lPlacePtr = lExtraPlaceListPtr->add_place();
442 assert (lPlacePtr != NULL);
449 treppb::PlaceList* lAltPlaceListPtr = ioPlace.mutable_alt_place_list();
450 assert (lAltPlaceListPtr != NULL);
451 for (LocationList_T::const_iterator itLoc = lAltLocationList.begin();
452 itLoc != lAltLocationList.end(); ++itLoc) {
453 const Location& lAlternateLocation = *itLoc;
455 treppb::Place* lPlacePtr = lAltPlaceListPtr->add_place();
456 assert (lPlacePtr != NULL);
static void exportLocation(treppb::Place &, const Location &)
Class modelling the primary key of a location/POR (point of reference).
const Date_T & getDateEnd() const
Class modelling the elementary details of a city.
std::list< UNLOCode_T > UNLOCodeList_T
unsigned int GeonamesID_T
const ContinentName_T & getContinentName() const
const Date_T & getModificationDate() const
Structure modelling a (geographical) location.
const AltCountryCode_T & getAltCountryCode() const
static std::string exportLocationList(const LocationList_T &, const WordList_T &iNonMatchedWordList)
const CurrencyCode_T & getCurrencyCode() const
const Admin1Code_T & getAdmin1Code() const
const NbOfErrors_T & getAllowableEditDistance() const
const NbOfErrors_T & getEditDistance() const
const NameMatrix_T & getNameMatrix() const
const DSTOffset_T & getDSTOffset() const
const WikiLink_T & getWikiLink() const
boost::gregorian::date Date_T
std::list< Word_T > WordList_T
const FAACode_T & getFaaCode() const
std::list< std::string > NameList_T
unsigned int Population_T
const PageRank_T & getPageRank() const
const CityUTFName_T & getUtfName() const
const Admin2ASCIIName_T & getAdmin2AsciiName() const
const Comment_T & getComment() const
const CountryCode_T & getCountryCode() const
const IATACode_T & getIataCode() const
const NameList_T & getNameList() const
const Population_T & getPopulation() const
const Latitude_T & getLatitude() const
const FeatureClass_T & getFeatureClass() const
const GTopo30_T & getGTopo30() const
const IATAType & getIataType() const
const IATACode_T & getIataCode() const
const GeonamesID_T & getGeonamesID() const
const Admin1UTFName_T & getAdmin1UtfName() const
unsigned short NbOfErrors_T
const TvlPORListString_T & getTvlPORListString() const
const Admin2Code_T & getAdmin2Code() const
std::list< Location > LocationList_T
const UNLOCodeList_T & getUNLOCodeList() const
const GMTOffset_T & getGMTOffset() const
const NameMatrix & getNameMatrix() const
const TimeZone_T & getTimeZone() const
const ICAOCode_T & getIcaoCode() const
const ContinentCode_T & getContinentCode() const
const StateCode_T & getStateCode() const
const ASCIIName_T & getAsciiName() const
const Admin3Code_T & getAdmin3Code() const
const CountryName_T & getCountryName() const
const Elevation_T & getElevation() const
const Admin2UTFName_T & getAdmin2UtfName() const
const GeonamesID_T & getGeonamesID() const
const Longitude_T & getLongitude() const
std::map< LanguageCode_T, Names > NameMatrix_T
const RawOffset_T & getRawOffset() const
const CommonName_T & getCommonName() const
const LocationKey & getKey() const
const Admin4Code_T & getAdmin4Code() const
Enumeration of place/location types with respect to their use for transportation purposes.
const std::string & getCorrectedKeywords() const
LanguageCode_T getLanguageCode() const
const WACName_T & getWACName() const
std::list< CityDetails > CityDetailsList_T
A list of cities, for instance the list of cities served by a travel-/transport-related POR (point of...
double MatchingPercentage_T
treppb::PlaceType getTypeAsPB() const
const WAC_T & getWAC() const
const Date_T & getDateFrom() const
const std::string & getOriginalKeywords() const
const CityASCIIName_T & getAsciiName() const
const LocationList_T & getAlternateLocationList() const
const FeatureCode_T & getFeatureCode() const
const MatchingPercentage_T & getPercentage() const
const LocationList_T & getExtraLocationList() const
const CityDetailsList_T & getCityList() const
const Admin1ASCIIName_T & getAdmin1AsciiName() const