• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdeedu API Reference
  • KDE Home
  • Contact Us
 

marble

  • sources
  • kde-4.14
  • kdeedu
  • marble
  • src
  • plugins
  • runner
  • local-osm-search
LocalOsmSearchRunner.cpp
Go to the documentation of this file.
1 //
2 // This file is part of the Marble Virtual Globe.
3 //
4 // This program is free software licensed under the GNU LGPL. You can
5 // find a copy of this license in LICENSE.txt in the top directory of
6 // the source code.
7 //
8 // Copyright 2011 Dennis Nienhüser <earthwings@gentoo.org>
9 // Copyright 2013 Bernhard Beschow <bbeschow@cs.tu-berlin.de>
10 //
11 
12 #include "LocalOsmSearchRunner.h"
13 #include "DatabaseQuery.h"
14 
15 #include "MarbleDebug.h"
16 #include "GeoDataDocument.h"
17 #include "GeoDataPlacemark.h"
18 
19 #include <QString>
20 #include <QVector>
21 #include <QUrl>
22 
23 namespace Marble
24 {
25 
26 QMap<OsmPlacemark::OsmCategory, GeoDataFeature::GeoDataVisualCategory> LocalOsmSearchRunner::m_categoryMap;
27 
28 LocalOsmSearchRunner::LocalOsmSearchRunner( const QStringList &databaseFiles, QObject *parent ) :
29  SearchRunner( parent ),
30  m_database( databaseFiles )
31 {
32  if ( m_categoryMap.isEmpty() ) {
33  m_categoryMap[OsmPlacemark::UnknownCategory] = GeoDataFeature::OsmSite;
34  m_categoryMap[OsmPlacemark::Address] = GeoDataFeature::OsmSite;
35  m_categoryMap[OsmPlacemark::AccomodationCamping] = GeoDataFeature::AccomodationCamping;
36  m_categoryMap[OsmPlacemark::AccomodationHostel] = GeoDataFeature::AccomodationHostel;
37  m_categoryMap[OsmPlacemark::AccomodationHotel] = GeoDataFeature::AccomodationHotel;
38  m_categoryMap[OsmPlacemark::AccomodationMotel] = GeoDataFeature::AccomodationMotel;
39  m_categoryMap[OsmPlacemark::AccomodationYouthHostel] = GeoDataFeature::AccomodationYouthHostel;
40  m_categoryMap[OsmPlacemark::AmenityLibrary] = GeoDataFeature::AmenityLibrary;
41  m_categoryMap[OsmPlacemark::EducationCollege] = GeoDataFeature::EducationCollege;
42  m_categoryMap[OsmPlacemark::EducationSchool] = GeoDataFeature::EducationSchool;
43  m_categoryMap[OsmPlacemark::EducationUniversity] = GeoDataFeature::EducationUniversity;
44  m_categoryMap[OsmPlacemark::FoodBar] = GeoDataFeature::FoodBar;
45  m_categoryMap[OsmPlacemark::FoodBiergarten] = GeoDataFeature::FoodBiergarten;
46  m_categoryMap[OsmPlacemark::FoodCafe] = GeoDataFeature::FoodCafe;
47  m_categoryMap[OsmPlacemark::FoodFastFood] = GeoDataFeature::FoodFastFood;
48  m_categoryMap[OsmPlacemark::FoodPub] = GeoDataFeature::FoodPub;
49  m_categoryMap[OsmPlacemark::FoodRestaurant] = GeoDataFeature::FoodRestaurant;
50  m_categoryMap[OsmPlacemark::HealthDoctors] = GeoDataFeature::HealthDoctors;
51  m_categoryMap[OsmPlacemark::HealthHospital] = GeoDataFeature::HealthHospital;
52  m_categoryMap[OsmPlacemark::HealthPharmacy] = GeoDataFeature::HealthPharmacy;
53  m_categoryMap[OsmPlacemark::MoneyAtm] = GeoDataFeature::MoneyAtm;
54  m_categoryMap[OsmPlacemark::MoneyBank] = GeoDataFeature::MoneyBank;
55  m_categoryMap[OsmPlacemark::ShoppingBeverages] = GeoDataFeature::ShoppingBeverages;
56  m_categoryMap[OsmPlacemark::ShoppingHifi] = GeoDataFeature::ShoppingHifi;
57  m_categoryMap[OsmPlacemark::ShoppingSupermarket] = GeoDataFeature::ShoppingSupermarket;
58  m_categoryMap[OsmPlacemark::TouristAttraction] = GeoDataFeature::TouristAttraction;
59  m_categoryMap[OsmPlacemark::TouristCastle] = GeoDataFeature::TouristCastle;
60  m_categoryMap[OsmPlacemark::TouristCinema] = GeoDataFeature::TouristCinema;
61  m_categoryMap[OsmPlacemark::TouristMonument] = GeoDataFeature::TouristMonument;
62  m_categoryMap[OsmPlacemark::TouristMuseum] = GeoDataFeature::TouristMuseum;
63  m_categoryMap[OsmPlacemark::TouristRuin] = GeoDataFeature::TouristRuin;
64  m_categoryMap[OsmPlacemark::TouristTheatre] = GeoDataFeature::TouristTheatre;
65  m_categoryMap[OsmPlacemark::TouristThemePark] = GeoDataFeature::TouristThemePark;
66  m_categoryMap[OsmPlacemark::TouristViewPoint] = GeoDataFeature::TouristViewPoint;
67  m_categoryMap[OsmPlacemark::TouristZoo] = GeoDataFeature::TouristZoo;
68  m_categoryMap[OsmPlacemark::TransportAirport] = GeoDataFeature::TransportAerodrome;
69  m_categoryMap[OsmPlacemark::TransportAirportTerminal] = GeoDataFeature::TransportAirportTerminal;
70  m_categoryMap[OsmPlacemark::TransportBusStation] = GeoDataFeature::TransportBusStation;
71  m_categoryMap[OsmPlacemark::TransportBusStop] = GeoDataFeature::TransportBusStop;
72  m_categoryMap[OsmPlacemark::TransportCarShare] = GeoDataFeature::TransportCarShare;
73  m_categoryMap[OsmPlacemark::TransportFuel] = GeoDataFeature::TransportFuel;
74  m_categoryMap[OsmPlacemark::TransportParking] = GeoDataFeature::TransportParking;
75  m_categoryMap[OsmPlacemark::TransportTrainStation] = GeoDataFeature::TransportTrainStation;
76  m_categoryMap[OsmPlacemark::TransportTramStop] = GeoDataFeature::TransportTramStop;
77  m_categoryMap[OsmPlacemark::TransportRentalBicycle] = GeoDataFeature::TransportRentalBicycle;
78  m_categoryMap[OsmPlacemark::TransportRentalCar] = GeoDataFeature::TransportRentalCar;
79  m_categoryMap[OsmPlacemark::TransportSpeedCamera] = GeoDataFeature::OsmSite;
80  m_categoryMap[OsmPlacemark::TransportTaxiRank] = GeoDataFeature::TransportTaxiRank;
81  m_categoryMap[OsmPlacemark::PlacesRegion] = GeoDataFeature::OsmSite;
82  m_categoryMap[OsmPlacemark::PlacesCounty] = GeoDataFeature::OsmSite;
83  m_categoryMap[OsmPlacemark::PlacesCity] = GeoDataFeature::LargeCity;
84  m_categoryMap[OsmPlacemark::PlacesTown] = GeoDataFeature::MediumCity;
85  m_categoryMap[OsmPlacemark::PlacesVillage] = GeoDataFeature::SmallCity;
86  m_categoryMap[OsmPlacemark::PlacesHamlet] = GeoDataFeature::OsmSite;
87  m_categoryMap[OsmPlacemark::PlacesIsolatedDwelling] = GeoDataFeature::OsmSite;
88  m_categoryMap[OsmPlacemark::PlacesSuburb] = GeoDataFeature::OsmSite;
89  m_categoryMap[OsmPlacemark::PlacesLocality] = GeoDataFeature::OsmSite;
90  m_categoryMap[OsmPlacemark::PlacesIsland] = GeoDataFeature::OsmSite;
91  }
92 }
93 
94 LocalOsmSearchRunner::~LocalOsmSearchRunner()
95 {
96 }
97 
98 
99 void LocalOsmSearchRunner::search( const QString &searchTerm, const GeoDataLatLonBox &preferred )
100 {
101  const DatabaseQuery userQuery( model(), searchTerm, preferred );
102 
103  QVector<OsmPlacemark> placemarks = m_database.find( userQuery );
104 
105  QVector<GeoDataPlacemark*> result;
106  foreach( const OsmPlacemark &placemark, placemarks ) {
107  GeoDataPlacemark* hit = new GeoDataPlacemark;
108  hit->setName( placemark.name() );
109  if ( placemark.category() == OsmPlacemark::Address && !placemark.houseNumber().isEmpty() ) {
110  hit->setName( hit->name() + ' ' + placemark.houseNumber() );
111  }
112  if ( !placemark.additionalInformation().isEmpty() ) {
113  hit->setName( hit->name() + '(' + placemark.additionalInformation() + ')' );
114  }
115  if ( placemark.category() != OsmPlacemark::UnknownCategory ) {
116  hit->setVisualCategory( m_categoryMap[placemark.category()] );
117  }
118  hit->setGeometry( new GeoDataPoint( placemark.longitude(), placemark.latitude(), 0.0, GeoDataCoordinates::Degree ) );
119  result << hit;
120  }
121 
122  emit searchFinished( result );
123 }
124 
125 } // namespace Marble
126 
127 #include "LocalOsmSearchRunner.moc"
GeoDataDocument.h
Marble::GeoDataPoint
A Geometry object representing a 3d point.
Definition: GeoDataPoint.h:47
LocalOsmSearchRunner.h
Marble::GeoDataFeature::TouristAttraction
Definition: GeoDataFeature.h:199
Marble::GeoDataFeature::TransportTrainStation
Definition: GeoDataFeature.h:221
Marble::GeoDataFeature::FoodPub
Definition: GeoDataFeature.h:181
Marble::GeoDataFeature::TransportCarShare
Definition: GeoDataFeature.h:215
Marble::OsmPlacemark::EducationUniversity
Definition: OsmPlacemark.h:38
Marble::OsmPlacemark::PlacesIsland
Definition: OsmPlacemark.h:85
Marble::OsmDatabase::find
QVector< OsmPlacemark > find(const DatabaseQuery &userQuery)
Search the database for matching regions and placemarks.
Definition: OsmDatabase.cpp:79
Marble::GeoDataFeature::AccomodationCamping
Definition: GeoDataFeature.h:162
Marble::GeoDataFeature::TransportTramStop
Definition: GeoDataFeature.h:222
Marble::OsmPlacemark::Address
Definition: OsmPlacemark.h:34
Marble::OsmPlacemark::TransportAirport
Definition: OsmPlacemark.h:63
Marble::GeoDataFeature::TransportTaxiRank
Definition: GeoDataFeature.h:220
Marble::OsmPlacemark::PlacesHamlet
Definition: OsmPlacemark.h:81
Marble::OsmPlacemark::TouristRuin
Definition: OsmPlacemark.h:58
Marble::LocalOsmSearchRunner::search
virtual void search(const QString &searchTerm, const GeoDataLatLonBox &preferred)
Start a placemark search.
Definition: LocalOsmSearchRunner.cpp:99
Marble::GeoDataFeature::TouristViewPoint
Definition: GeoDataFeature.h:207
Marble::GeoDataFeature::setVisualCategory
void setVisualCategory(GeoDataVisualCategory category)
Sets the symbol index of the placemark.
Definition: GeoDataFeature.cpp:770
Marble::OsmPlacemark::TouristTheatre
Definition: OsmPlacemark.h:59
Marble::GeoDataFeature::OsmSite
Definition: GeoDataFeature.h:124
Marble::OsmPlacemark::PlacesCity
Definition: OsmPlacemark.h:78
Marble::OsmPlacemark::AccomodationHostel
Definition: OsmPlacemark.h:30
Marble::OsmPlacemark
A lightweight data structure to represent points of interest like addresses with support for serializ...
Definition: OsmPlacemark.h:24
QMap
Marble::OsmPlacemark::PlacesTown
Definition: OsmPlacemark.h:79
Marble::LocalOsmSearchRunner::LocalOsmSearchRunner
LocalOsmSearchRunner(const QStringList &databaseFiles, QObject *parent=0)
Definition: LocalOsmSearchRunner.cpp:28
Marble::SearchRunner::searchFinished
void searchFinished(QVector< GeoDataPlacemark * > result)
This is emitted to indicate that the runner has finished the placemark search.
Marble::GeoDataFeature::HealthHospital
Definition: GeoDataFeature.h:186
Marble::GeoDataFeature::MoneyAtm
Definition: GeoDataFeature.h:190
Marble::OsmPlacemark::TransportTramStop
Definition: OsmPlacemark.h:75
Marble::OsmPlacemark::MoneyAtm
Definition: OsmPlacemark.h:48
Marble::GeoDataFeature::ShoppingBeverages
Definition: GeoDataFeature.h:194
Marble::GeoDataFeature::AmenityLibrary
Definition: GeoDataFeature.h:169
Marble::OsmPlacemark::TransportSpeedCamera
Definition: OsmPlacemark.h:72
MarbleDebug.h
Marble::OsmPlacemark::FoodBar
Definition: OsmPlacemark.h:39
Marble::GeoDataFeature::AccomodationMotel
Definition: GeoDataFeature.h:165
Marble::GeoDataCoordinates::Degree
Definition: GeoDataCoordinates.h:66
Marble::GeoDataFeature::AccomodationYouthHostel
Definition: GeoDataFeature.h:166
Marble::OsmPlacemark::TransportAirportTerminal
Definition: OsmPlacemark.h:64
Marble::OsmPlacemark::TouristCinema
Definition: OsmPlacemark.h:55
Marble::GeoDataFeature::MoneyBank
Definition: GeoDataFeature.h:191
Marble::GeoDataFeature::FoodCafe
Definition: GeoDataFeature.h:179
Marble::OsmPlacemark::TransportRentalCar
Definition: OsmPlacemark.h:71
Marble::OsmPlacemark::TransportTrainStation
Definition: OsmPlacemark.h:74
Marble::GeoDataFeature::AccomodationHostel
Definition: GeoDataFeature.h:163
Marble::OsmPlacemark::TouristCastle
Definition: OsmPlacemark.h:54
Marble::OsmPlacemark::AccomodationMotel
Definition: OsmPlacemark.h:32
Marble::OsmPlacemark::AmenityLibrary
Definition: OsmPlacemark.h:35
Marble::GeoDataFeature::setName
void setName(const QString &value)
Set a new name for this feature.
Definition: GeoDataFeature.cpp:549
Marble::OsmPlacemark::FoodFastFood
Definition: OsmPlacemark.h:42
Marble::OsmPlacemark::AccomodationHotel
Definition: OsmPlacemark.h:31
Marble::OsmPlacemark::ShoppingBeverages
Definition: OsmPlacemark.h:50
QObject
Marble::GeoDataFeature::TransportAerodrome
Definition: GeoDataFeature.h:211
Marble::GeoDataFeature::AccomodationHotel
Definition: GeoDataFeature.h:164
QString::isEmpty
bool isEmpty() const
Marble::OsmPlacemark::PlacesIsolatedDwelling
Definition: OsmPlacemark.h:82
Marble::GeoDataFeature::TransportBusStation
Definition: GeoDataFeature.h:213
Marble::OsmPlacemark::UnknownCategory
Definition: OsmPlacemark.h:28
Marble::OsmPlacemark::HealthPharmacy
Definition: OsmPlacemark.h:47
Marble::GeoDataFeature::TransportRentalBicycle
Definition: GeoDataFeature.h:218
Marble::OsmPlacemark::houseNumber
QString houseNumber() const
Placemark's house number, if any.
Definition: OsmPlacemark.cpp:43
Marble::OsmPlacemark::FoodRestaurant
Definition: OsmPlacemark.h:44
Marble::GeoDataFeature::TouristCinema
Definition: GeoDataFeature.h:201
Marble::OsmPlacemark::MoneyBank
Definition: OsmPlacemark.h:49
Marble::OsmPlacemark::TouristViewPoint
Definition: OsmPlacemark.h:61
Marble::GeoDataFeature::HealthDoctors
Definition: GeoDataFeature.h:185
Marble::GeoDataFeature::ShoppingSupermarket
Definition: GeoDataFeature.h:196
Marble::OsmPlacemark::additionalInformation
QString additionalInformation() const
Regions' name.
Definition: OsmPlacemark.cpp:63
Marble::OsmPlacemark::TouristMonument
Definition: OsmPlacemark.h:56
Marble::GeoDataFeature::FoodFastFood
Definition: GeoDataFeature.h:180
QString
Marble::OsmPlacemark::HealthHospital
Definition: OsmPlacemark.h:46
Marble::GeoDataFeature::TouristRuin
Definition: GeoDataFeature.h:204
GeoDataPlacemark.h
Marble::OsmPlacemark::latitude
qreal latitude() const
Latitude of the placemark's center point, in degree.
Definition: OsmPlacemark.cpp:83
Marble::OsmPlacemark::name
QString name() const
Placemark name.
Definition: OsmPlacemark.cpp:33
Marble::SearchRunner::model
const MarbleModel * model() const
Access to the currently used model, or null if no was set with.
Definition: SearchRunner.cpp:25
QStringList
Marble::OsmPlacemark::category
OsmCategory category() const
Definition: OsmPlacemark.cpp:23
Marble::OsmPlacemark::HealthDoctors
Definition: OsmPlacemark.h:45
Marble::GeoDataFeature::TransportFuel
Definition: GeoDataFeature.h:216
Marble::LocalOsmSearchRunner::~LocalOsmSearchRunner
~LocalOsmSearchRunner()
Definition: LocalOsmSearchRunner.cpp:94
Marble::GeoDataFeature::TouristZoo
Definition: GeoDataFeature.h:208
Marble::OsmPlacemark::EducationCollege
Definition: OsmPlacemark.h:36
Marble::GeoDataFeature::LargeCity
Definition: GeoDataFeature.h:96
Marble::OsmPlacemark::TransportBusStop
Definition: OsmPlacemark.h:66
Marble::OsmPlacemark::TransportTaxiRank
Definition: OsmPlacemark.h:73
Marble::OsmPlacemark::PlacesLocality
Definition: OsmPlacemark.h:84
Marble::GeoDataFeature::TouristTheatre
Definition: GeoDataFeature.h:205
Marble::OsmPlacemark::FoodCafe
Definition: OsmPlacemark.h:41
Marble::OsmPlacemark::FoodPub
Definition: OsmPlacemark.h:43
Marble::OsmPlacemark::TouristMuseum
Definition: OsmPlacemark.h:57
Marble::OsmPlacemark::TouristZoo
Definition: OsmPlacemark.h:62
Marble::GeoDataFeature::EducationUniversity
Definition: GeoDataFeature.h:174
Marble::OsmPlacemark::longitude
qreal longitude() const
Longitude of the placemark's center point, in degree.
Definition: OsmPlacemark.cpp:73
Marble::OsmPlacemark::TransportRentalBicycle
Definition: OsmPlacemark.h:70
Marble::GeoDataFeature::EducationCollege
Definition: GeoDataFeature.h:172
QVector
Marble::GeoDataFeature::FoodBar
Definition: GeoDataFeature.h:177
Marble::OsmPlacemark::TransportFuel
Definition: OsmPlacemark.h:68
Marble::OsmPlacemark::TransportCarShare
Definition: OsmPlacemark.h:67
Marble::OsmPlacemark::PlacesSuburb
Definition: OsmPlacemark.h:83
Marble::OsmPlacemark::ShoppingHifi
Definition: OsmPlacemark.h:51
Marble::GeoDataFeature::name
QString name() const
The name of the feature.
Definition: GeoDataFeature.cpp:544
Marble::OsmPlacemark::AccomodationCamping
Definition: OsmPlacemark.h:29
Marble::OsmPlacemark::PlacesCounty
Definition: OsmPlacemark.h:77
Marble::GeoDataFeature::MediumCity
Definition: GeoDataFeature.h:88
Marble::OsmPlacemark::ShoppingSupermarket
Definition: OsmPlacemark.h:52
Marble::OsmPlacemark::PlacesVillage
Definition: OsmPlacemark.h:80
Marble::OsmPlacemark::AccomodationYouthHostel
Definition: OsmPlacemark.h:33
Marble::GeoDataFeature::TouristCastle
Definition: GeoDataFeature.h:200
Marble::GeoDataFeature::TransportRentalCar
Definition: GeoDataFeature.h:219
Marble::GeoDataFeature::TransportBusStop
Definition: GeoDataFeature.h:214
Marble::OsmPlacemark::TransportBusStation
Definition: OsmPlacemark.h:65
Marble::DatabaseQuery
Parse result of a user's search term.
Definition: DatabaseQuery.h:29
Marble::GeoDataFeature::ShoppingHifi
Definition: GeoDataFeature.h:195
Marble::OsmPlacemark::TransportParking
Definition: OsmPlacemark.h:69
Marble::OsmPlacemark::TouristThemePark
Definition: OsmPlacemark.h:60
DatabaseQuery.h
Marble::GeoDataPlacemark
a class representing a point of interest on the map
Definition: GeoDataPlacemark.h:54
Marble::OsmPlacemark::TouristAttraction
Definition: OsmPlacemark.h:53
Marble::GeoDataFeature::TouristMuseum
Definition: GeoDataFeature.h:203
Marble::SearchRunner
Definition: SearchRunner.h:30
Marble::OsmPlacemark::FoodBiergarten
Definition: OsmPlacemark.h:40
Marble::OsmPlacemark::PlacesRegion
Definition: OsmPlacemark.h:76
Marble::GeoDataFeature::TouristMonument
Definition: GeoDataFeature.h:202
Marble::GeoDataFeature::HealthPharmacy
Definition: GeoDataFeature.h:187
Marble::GeoDataFeature::TransportAirportTerminal
Definition: GeoDataFeature.h:212
Marble::GeoDataFeature::EducationSchool
Definition: GeoDataFeature.h:173
Marble::GeoDataLatLonBox
A class that defines a 2D bounding box for geographic data.
Definition: GeoDataLatLonBox.h:51
Marble::GeoDataFeature::FoodBiergarten
Definition: GeoDataFeature.h:178
Marble::GeoDataFeature::FoodRestaurant
Definition: GeoDataFeature.h:182
Marble::GeoDataFeature::TransportParking
Definition: GeoDataFeature.h:217
Marble::GeoDataFeature::TouristThemePark
Definition: GeoDataFeature.h:206
Marble::OsmPlacemark::EducationSchool
Definition: OsmPlacemark.h:37
Marble::GeoDataFeature::SmallCity
Definition: GeoDataFeature.h:84
Marble::GeoDataPlacemark::setGeometry
void setGeometry(GeoDataGeometry *entry)
Sets the current Geometry of this Placemark.
Definition: GeoDataPlacemark.cpp:230
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:13:40 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

marble

Skip menu "marble"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdeedu API Reference

Skip menu "kdeedu API Reference"
  • Analitza
  •     lib
  • kalgebra
  • kalzium
  •   libscience
  • kanagram
  • kig
  •   lib
  • klettres
  • marble
  • parley
  • rocs
  •   App
  •   RocsCore
  •   VisualEditor
  •   stepcore

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal