Location信息对很多有地址进行搜索的应用来说非常重要。比如对dianping这样的应用来说,我们可以通过地址来获取当前位置的一些信息。在这篇文章中,我们来介绍如何获取Scope架构中的位置信息。这个位置信息可以对我们很多的搜索是非常重要的。
[ScopeConfig] DisplayName = Scopetest Scope Description = This is a Scopetest scope Art = screenshot.png Author = Firstname Lastname Icon = icon.png LocationDataNeeded=true [Appearance] PageHeader.Logo = logo.png
#include <unity/scopes/SearchMetadata.h> // added
....
void Query::run(sc::SearchReplyProxy const& reply) {
try {
cerr << "starting to get the location" << endl;
auto metadata = search_metadata();
if (metadata.has_location()) {
cerr << "it has location data" << endl;
auto location = metadata.location();
if (location.has_country_code()) {
cerr << "country code: " << location.country_code() << endl;
}
if ( location.has_area_code() ) {
cerr << "area code: " << location.area_code() << endl;
}
if ( location.has_city() ) {
cerr << "city: " << location.city() << endl;
}
if ( location.has_country_name() ) {
cerr << "" << location.country_name() << endl;
}
if ( location.has_altitude()) {
cerr << "altitude: " << location.altitude() << endl;
cerr << "longitude: " << location.longitude() << endl;
cerr << "latitude: " << location.latitude() << endl;
}
if ( location.has_horizontal_accuracy()) {
cerr << "horizotal accuracy: " << location.horizontal_accuracy() << endl;
}
if ( location.has_region_code() ) {
cerr << "region code: " << location.region_code() << endl;
}
if ( location.has_region_name() ) {
cerr << "region name: " << location.region_name() << endl;
}
if ( location.has_zip_postal_code() ) {
cerr << "zip postal code: " << location.zip_postal_code() << endl;
}
}
....
}怎么在Ubuntu Scope中获取location地址信息
原文地址:http://blog.csdn.net/ubuntutouch/article/details/39960643