10 #include <opentrep/Travel.pb.h>
23 treppb::QueryAnswer oQueryAnswer;
26 const bool kOKStatus =
true;
27 oQueryAnswer.set_ok_status (kOKStatus);
38 treppb::PlaceList* lPlaceListPtr = oQueryAnswer.mutable_place_list();
39 assert (lPlaceListPtr != NULL);
42 for (LocationList_T::const_iterator itLocation = iLocationList.begin();
43 itLocation != iLocationList.end(); ++itLocation) {
44 const Location& lLocation = *itLocation;
47 treppb::Place* lPlacePtr = lPlaceListPtr->add_place();
48 assert (lPlacePtr != NULL);
57 treppb::UnknownKeywordList* lUnknownKeywordListPtr =
58 oQueryAnswer.mutable_unmatched_keyword_list();
59 assert (lUnknownKeywordListPtr != NULL);
62 for (WordList_T::const_iterator itWord = iNonMatchedWordList.begin();
63 itWord != iNonMatchedWordList.end(); ++itWord) {
64 const Word_T& lWord = *itWord;
65 lUnknownKeywordListPtr->add_word (lWord);
69 oQueryAnswer.SerializeToOstream (&oStream);
80 treppb::IATACode* lIataAirportPtr = ioPlace.mutable_tvl_code();
81 assert (lIataAirportPtr != NULL);
82 lIataAirportPtr->set_code (lIataCode);
86 const treppb::PlaceType& lPlaceType = lLocationType.
getTypeAsPB();
87 const treppb::PlaceType_LocationType& lPlaceTypeEnum = lPlaceType.type();
88 treppb::PlaceType* lPlaceTypePtr = ioPlace.mutable_loc_type();
89 assert (lPlaceTypePtr != NULL);
90 lPlaceTypePtr->set_type (lPlaceTypeEnum);
94 treppb::GeonameID* lGeonameIDPtr = ioPlace.mutable_geoname_id();
95 assert (lGeonameIDPtr != NULL);
96 lGeonameIDPtr->set_id (lGeonamesID);
100 treppb::ICAOCode* lIcaoCodePtr = ioPlace.mutable_icao_code();
101 assert (lIcaoCodePtr != NULL);
102 lIcaoCodePtr->set_code (lIcaoCode);
106 treppb::FAACode* lFaaCodePtr = ioPlace.mutable_faa_code();
107 assert (lFaaCodePtr != NULL);
108 lFaaCodePtr->set_code (lFaaCode);
112 ioPlace.set_name_utf (lUtfName);
114 ioPlace.set_name_ascii (lAsciiName);
119 treppb::FeatureType* lFeatTypePtr = ioPlace.mutable_feat_type();
120 assert (lFeatTypePtr != NULL);
121 treppb::FeatureClass* lFeatClassPtr = lFeatTypePtr->mutable_fclass();
122 assert (lFeatClassPtr != NULL);
123 treppb::FeatureCode* lFeatCodePtr = lFeatTypePtr->mutable_fcode();
124 assert (lFeatCodePtr != NULL);
125 lFeatClassPtr->set_code (lFeatClass);
126 lFeatCodePtr->set_code (lFeatCode);
131 treppb::GeoPoint* lPointPtr = ioPlace.mutable_coord();
132 assert (lPointPtr != NULL);
133 lPointPtr->set_latitude (lLatitude);
134 lPointPtr->set_longitude (lLongitude);
138 treppb::IATACode* lCityCodePtr = ioPlace.mutable_city_code();
139 assert (lCityCodePtr != NULL);
140 lCityCodePtr->set_code (lCityCode);
144 ioPlace.set_city_name_utf (lCityUtfName);
146 ioPlace.set_city_name_ascii (lCityAsciiName);
150 treppb::StateCode* lStateCodePtr = ioPlace.mutable_state_code();
151 assert (lStateCodePtr != NULL);
152 lStateCodePtr->set_code (lStateCode);
156 treppb::CountryCode* lCountryCodePtr = ioPlace.mutable_country_code();
157 assert (lCountryCodePtr != NULL);
158 lCountryCodePtr->set_code (lCountryCode);
162 treppb::AltCountryCode* lAltCountryCodePtr =
163 ioPlace.mutable_alt_country_code();
164 assert (lAltCountryCodePtr != NULL);
165 lAltCountryCodePtr->set_code (lAltCountryCode);
169 ioPlace.set_country_name (lCountryName);
173 treppb::ContinentCode* lContinentCodePtr = ioPlace.mutable_continent_code();
174 assert (lContinentCodePtr != NULL);
175 lContinentCodePtr->set_code (lContinentCode);
179 ioPlace.set_continent_name (lContinentName);
183 treppb::Admin1Code* lAdm1CodePtr = ioPlace.mutable_adm1_code();
184 assert (lAdm1CodePtr != NULL);
185 lAdm1CodePtr->set_code (lAdm1Code);
189 ioPlace.set_adm1_name_utf (lAdm1UtfName);
191 ioPlace.set_adm1_name_ascii (lAdm1AsciiName);
195 treppb::Admin2Code* lAdm2CodePtr = ioPlace.mutable_adm2_code();
196 assert (lAdm2CodePtr != NULL);
197 lAdm2CodePtr->set_code (lAdm2Code);
201 ioPlace.set_adm2_name_utf (lAdm2UtfName);
203 ioPlace.set_adm2_name_ascii (lAdm2AsciiName);
207 treppb::Admin3Code* lAdm3CodePtr = ioPlace.mutable_adm3_code();
208 assert (lAdm3CodePtr != NULL);
209 lAdm3CodePtr->set_code (lAdm3Code);
213 treppb::Admin4Code* lAdm4CodePtr = ioPlace.mutable_adm4_code();
214 assert (lAdm4CodePtr != NULL);
215 lAdm4CodePtr->set_code (lAdm4Code);
219 treppb::Population* lPopulationPtr = ioPlace.mutable_population();
220 assert (lPopulationPtr != NULL);
221 lPopulationPtr->set_value (lPopulation);
225 treppb::Elevation* lElevationPtr = ioPlace.mutable_elevation();
226 assert (lElevationPtr != NULL);
227 lElevationPtr->set_value (lElevation);
231 treppb::GTopo30* lGTopo30Ptr = ioPlace.mutable_gtopo30();
232 assert (lGTopo30Ptr != NULL);
233 lGTopo30Ptr->set_value (lGTopo30);
237 treppb::PageRank* lPageRankPtr = ioPlace.mutable_page_rank();
238 assert (lPageRankPtr != NULL);
239 lPageRankPtr->set_rank (lPageRank);
243 treppb::TimeZone* lTimeZonePtr = ioPlace.mutable_tz();
244 assert (lTimeZonePtr != NULL);
245 lTimeZonePtr->set_tz (lTimeZone);
249 treppb::TZOffSet* lGMTOffsetPtr = ioPlace.mutable_gmt_offset();
250 assert (lGMTOffsetPtr != NULL);
251 lGMTOffsetPtr->set_offset (lGMTOffset);
255 treppb::TZOffSet* lDSTOffsetPtr = ioPlace.mutable_dst_offset();
256 assert (lDSTOffsetPtr != NULL);
257 lDSTOffsetPtr->set_offset (lDSTOffset);
261 treppb::TZOffSet* lRAWOffsetPtr = ioPlace.mutable_raw_offset();
262 assert (lRAWOffsetPtr != NULL);
263 lRAWOffsetPtr->set_offset (lRAWOffset);
267 treppb::Date* lGeonameModDatePtr = ioPlace.mutable_mod_date();
268 assert (lGeonameModDatePtr != NULL);
269 lGeonameModDatePtr->set_date (boost::gregorian::to_iso_extended_string(lGeonameModDate));
273 treppb::TravelRelatedList* lTvlPORListPtr = ioPlace.mutable_tvl_por_list();
274 assert (lTvlPORListPtr != NULL);
275 lTvlPORListPtr->add_tvl_code (lTvlPORList);
279 treppb::WikiLinkList* lWikiLinkListPtr = ioPlace.mutable_link_list();
280 assert (lWikiLinkListPtr != NULL);
281 treppb::WikiLink* lWikiLinkPtr = lWikiLinkListPtr->add_link();
282 assert (lWikiLinkPtr != NULL);
283 treppb::LanguageCode* lLangCodePtr = lWikiLinkPtr->mutable_lang();
284 assert (lLangCodePtr != NULL);
285 lLangCodePtr->set_code (
"en");
286 lWikiLinkPtr->set_link (lWikiLink);
290 treppb::Date* lDateFromPtr = ioPlace.mutable_date_from();
291 assert (lDateFromPtr != NULL);
292 lDateFromPtr->set_date (boost::gregorian::to_iso_extended_string(lDateFrom));
296 treppb::Date* lDateEndPtr = ioPlace.mutable_date_end();
297 assert (lDateEndPtr != NULL);
298 lDateEndPtr->set_date (boost::gregorian::to_iso_extended_string(lDateEnd));
302 treppb::Comment* lCommentPtr = ioPlace.mutable_comment();
303 assert (lCommentPtr != NULL);
304 lCommentPtr->set_text (lComment);
308 treppb::AltNameList* lAltNameListPtr = ioPlace.mutable_alt_name_list();
309 assert (lAltNameListPtr != NULL);
312 for (NameMatrix_T::const_iterator itNameList = lNameMatrix.begin();
313 itNameList != lNameMatrix.end(); ++itNameList) {
314 const Names& lNameListRef = itNameList->second;
317 for (NameList_T::const_iterator itName = lNameList.begin();
318 itName != lNameList.end(); ++itName) {
319 const std::string& lName = *itName;
321 treppb::AltName* lAltNamePtr = lAltNameListPtr->add_name();
322 assert (lAltNamePtr != NULL);
324 treppb::LanguageCode* lLangCodePtr = lAltNamePtr->mutable_lang();
325 assert (lLangCodePtr != NULL);
326 lLangCodePtr->set_code (lLangCode);
327 lAltNamePtr->set_name (lName);
333 treppb::MatchingPercentage* lPercentagePtr =
334 ioPlace.mutable_matching_percentage();
335 assert (lPercentagePtr != NULL);
336 lPercentagePtr->set_percentage (lPercentage);
344 treppb::KeywordList* lOriginalKeywordListPtr =
345 ioPlace.mutable_original_keyword_list();
346 assert (lOriginalKeywordListPtr != NULL);
347 lOriginalKeywordListPtr->add_word (lOriginalKeywords);
355 treppb::KeywordList* lCorrectedKeywordListPtr =
356 ioPlace.mutable_corrected_keyword_list();
357 assert (lCorrectedKeywordListPtr != NULL);
358 lCorrectedKeywordListPtr->add_word (lCorrectedKeywords);
362 treppb::EditDistance* lEditDistanceActualPtr =
363 ioPlace.mutable_edit_distance_actual();
364 assert (lEditDistanceActualPtr != NULL);
365 lEditDistanceActualPtr->set_dist (lEditDistanceActual);
370 treppb::EditDistance* lEditDistanceAllowablePtr =
371 ioPlace.mutable_edit_distance_actual();
372 assert (lEditDistanceAllowablePtr != NULL);
373 lEditDistanceAllowablePtr->set_dist (lEditDistanceAllowable);
377 treppb::PlaceList* lExtraPlaceListPtr = ioPlace.mutable_extra_place_list();
378 assert (lExtraPlaceListPtr != NULL);
379 for (LocationList_T::const_iterator itLoc = lExtraLocationList.begin();
380 itLoc != lExtraLocationList.end(); ++itLoc) {
381 const Location& lExtraLocation = *itLoc;
383 treppb::Place* lPlacePtr = lExtraPlaceListPtr->add_place();
384 assert (lPlacePtr != NULL);
391 treppb::PlaceList* lAltPlaceListPtr = ioPlace.mutable_alt_place_list();
392 assert (lAltPlaceListPtr != NULL);
393 for (LocationList_T::const_iterator itLoc = lAltLocationList.begin();
394 itLoc != lAltLocationList.end(); ++itLoc) {
395 const Location& lAlternateLocation = *itLoc;
397 treppb::Place* lPlacePtr = lAltPlaceListPtr->add_place();
398 assert (lPlacePtr != NULL);
static void exportLocation(treppb::Place &, const Location &)
Class modelling the primary key of a location/POR (point of reference).
const Admin3Code_T & getAdmin3Code() const
const Admin1Code_T & getAdmin1Code() const
const CountryCode_T & getCountryCode() const
const Latitude_T & getLatitude() const
const Population_T & getPopulation() const
const Date_T & getDateFrom() const
const IATAType & getIataType() const
treppb::PlaceType getTypeAsPB() const
Structure modelling a (geographical) location.
const Admin1ASCIIName_T & getAdmin1AsciiName() const
const FeatureCode_T & getFeatureCode() const
const CityASCIIName_T & getCityAsciiName() const
const FAACode_T & getFaaCode() const
const NbOfErrors_T & getAllowableEditDistance() const
const ContinentName_T & getContinentName() const
const NameMatrix_T & getNameMatrix() const
const Admin1UTFName_T & getAdmin1UtfName() const
boost::gregorian::date Date_T
std::list< Word_T > WordList_T
const LocationList_T & getAlternateLocationList() const
std::list< std::string > NameList_T
const std::string & getCorrectedKeywords() const
const TvlPORListString_T & getTvlPORListString() const
const Date_T & getModificationDate() const
unsigned int Population_T
const NameMatrix & getNameMatrix() const
const Admin2UTFName_T & getAdmin2UtfName() const
const Date_T & getDateEnd() const
const AltCountryCode_T & getAltCountryCode() const
const PageRank_T & getPageRank() const
const ICAOCode_T & getIcaoCode() const
const CommonName_T & getCommonName() const
unsigned short NbOfErrors_T
const MatchingPercentage_T & getPercentage() const
const NbOfErrors_T & getEditDistance() const
const FeatureClass_T & getFeatureClass() const
const CityUTFName_T & getCityUtfName() const
std::list< Location > LocationList_T
const RawOffset_T & getRawOffset() const
const GeonamesID_T & getGeonamesID() const
const Elevation_T & getElevation() const
const Admin2Code_T & getAdmin2Code() const
const NameList_T & getNameList() const
const Comment_T & getComment() const
const GTopo30_T & getGTopo30() const
const LocationList_T & getExtraLocationList() const
const LocationKey & getKey() const
const Admin2ASCIIName_T & getAdmin2AsciiName() const
const ContinentCode_T & getContinentCode() const
const CityCode_T & getCityCode() const
const std::string & getOriginalKeywords() const
std::map< LanguageCode_T, Names > NameMatrix_T
LanguageCode_T getLanguageCode() const
const Admin4Code_T & getAdmin4Code() const
const StateCode_T & getStateCode() const
Enumeration of output types.
const CountryName_T & getCountryName() const
const WikiLink_T & getWikiLink() const
const IATACode_T & getIataCode() const
const ASCIIName_T & getAsciiName() const
double MatchingPercentage_T
const DSTOffset_T & getDSTOffset() const
const GMTOffset_T & getGMTOffset() const
static void exportLocationList(std::ostream &, const LocationList_T &, const WordList_T &iNonMatchedWordList)
const TimeZone_T & getTimeZone() const
const Longitude_T & getLongitude() const