Marble/Runners/ReverseGeocoding: Difference between revisions
Earthwings (talk | contribs) |
CezarMocan (talk | contribs) No edit summary |
||
Line 8: | Line 8: | ||
pre=[[Projects/Marble/Runners/Search|Tutorial 7 - Searching]]| | pre=[[Projects/Marble/Runners/Search|Tutorial 7 - Searching]]| | ||
next=[[Projects/Marble/Runners/ | next=[[Projects/Marble/Runners/LoadingKML|Tutorial 9 - Loading .kml files into your Marble Widget]]| | ||
}} | }} | ||
Revision as of 07:38, 20 June 2012
Editing Projects/Marble/MarbleCPlusPlus
Languages: عربي | Asturianu | Català | Česky | Kaszëbsczi | Dansk | Deutsch | English | Esperanto | Español | Eesti | فارسی | Suomi | Français | Galego | Italiano | 日本語 | 한국어 | Norwegian | Polski | Português Brasileiro | Română | Русский | Svenska | Slovenčina | Slovenščina | српски | Türkçe | Tiếng Việt | Українська | 简体中文 | 繁體中文
Tutorial Series | Marble C++ Tutorial |
Previous | Tutorial 7 - Searching |
What's Next | Tutorial 9 - Loading .kml files into your Marble Widget |
Further Reading | n/a |
Reverse geocoding
Marble uses so-called runners to calculate routes, do reverse geocoding, parse files and search for placemarks (cities, addresses, points of interest, ...). This tutorial shows how to use the MarbleRunnerManager class to get a textual description of a given coordinate.
#include <QtGui/QApplication>
#include <QtCore/QDebug>
#include <marble/MarbleWidget.h>
#include <marble/MarbleModel.h>
#include <marble/MarbleRunnerManager.h>
#include <marble/GeoDataPlacemark.h>
using namespace Marble;
int main(int argc, char** argv)
{
QApplication app(argc,argv);
MarbleModel *model = new MarbleModel;
MarbleRunnerManager* manager = new MarbleRunnerManager( model->pluginManager() );
manager->setModel( model );
GeoDataCoordinates position( -0.15845, 51.52380, 0.0, GeoDataCoordinates::Degree );
qDebug() << position.toString() << "is" << manager->searchReverseGeocoding( position );
}
Copy and paste the code above into a text editor. Then save it as my_marble.cpp and compile it by entering the following command on the command line:
g++ -I /usr/include/qt4/ -o my_marble my_marble.cpp -lmarblewidget -lQtGui -lQtCore
If things go fine, execute ./my_marble and the output looks similar to this:
" 0° 09' 30.4"W, 51° 31' 25.7"N" is "Sherlock Holmes Museum, "221b", Baker Street, Marylebone, City of Westminster, Greater London, England, NW1 6AX, United Kingdom"
- You need Qt and Marble development packages (or comparable git installations), version 1.3 (Marble library 0.13), shipped post KDE 4.8
- If Qt headers are not installed in /usr/include/qt4 on your system, change the path in the g++ call above accordingly.
- Likewise, add -I /path/to/marble/headers if they're not to be found in /usr/include