• 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
OsmPlacemark.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 //
10 
11 #include "OsmPlacemark.h"
12 #include "DatabaseQuery.h"
13 
14 namespace Marble {
15 
16 OsmPlacemark::OsmPlacemark() : m_regionId( 0 ),
17  m_category( UnknownCategory ),
18  m_longitude( 0.0 ), m_latitude( 0.0 )
19 {
20  // nothing to do
21 }
22 
23 OsmPlacemark::OsmCategory OsmPlacemark::category() const
24 {
25  return m_category;
26 }
27 
28 void OsmPlacemark::setCategory( OsmCategory category )
29 {
30  m_category = category;
31 }
32 
33 QString OsmPlacemark::name() const
34 {
35  return m_name;
36 }
37 
38 void OsmPlacemark::setName( const QString &name )
39 {
40  m_name = name;
41 }
42 
43 QString OsmPlacemark::houseNumber() const
44 {
45  return m_houseNumber;
46 }
47 
48 void OsmPlacemark::setHouseNumber( const QString &houseNumber )
49 {
50  m_houseNumber = houseNumber;
51 }
52 
53 int OsmPlacemark::regionId() const
54 {
55  return m_regionId;
56 }
57 
58 void OsmPlacemark::setRegionId( int id )
59 {
60  m_regionId = id;
61 }
62 
63 QString OsmPlacemark::additionalInformation() const
64 {
65  return m_additionalInformation;
66 }
67 
68 void OsmPlacemark::setAdditionalInformation( const QString &name )
69 {
70  m_additionalInformation = name;
71 }
72 
73 qreal OsmPlacemark::longitude() const
74 {
75  return m_longitude;
76 }
77 
78 void OsmPlacemark::setLongitude( qreal longitude )
79 {
80  m_longitude = longitude;
81 }
82 
83 qreal OsmPlacemark::latitude() const
84 {
85  return m_latitude;
86 }
87 
88 void OsmPlacemark::setLatitude( qreal latitude )
89 {
90  m_latitude = latitude;
91 }
92 
93 
94 bool OsmPlacemark::operator<( const OsmPlacemark &other) const
95 {
96  if ( name() != other.name() ) {
97  return name() < other.name();
98  }
99 
100  if ( additionalInformation() != other.additionalInformation() ) {
101  return additionalInformation() < other.additionalInformation();
102  }
103 
104  if ( houseNumber() != other.houseNumber() ) {
105  return houseNumber() < other.houseNumber();
106  }
107 
108  if ( regionId() != other.regionId() ) {
109  return regionId() < other.regionId();
110  }
111 
112  if ( longitude() != other.longitude() ) {
113  return longitude() < other.longitude();
114  }
115 
116  return latitude() < other.latitude();
117 }
118 
119 bool OsmPlacemark::operator==( const OsmPlacemark &other ) const
120 {
121  return m_regionId == other.m_regionId &&
122  m_category == other.m_category &&
123  m_longitude == other.m_longitude &&
124  m_latitude == other.m_latitude &&
125  m_name == other.m_name &&
126  m_houseNumber == other.m_houseNumber &&
127  m_additionalInformation == other.m_additionalInformation;
128 }
129 
130 qreal OsmPlacemark::matchScore( const DatabaseQuery* query ) const
131 {
132  qreal score = 0.0;
133 
134  if ( query && query->resultFormat() == DatabaseQuery::AddressFormat ) {
135  if ( !query->region().isEmpty() ) {
136  if ( m_additionalInformation.compare( query->region(), Qt::CaseInsensitive ) == 0 ) {
137  score += 2.0;
138  } else if ( m_additionalInformation.startsWith( query->region(), Qt::CaseInsensitive ) ) {
139  score += 0.5;
140  }
141  }
142 
143  if ( !query->houseNumber().isEmpty() ) {
144  if ( m_houseNumber.compare( query->houseNumber(), Qt::CaseInsensitive ) == 0 ) {
145  score += 1.0;
146  } else if ( m_houseNumber.startsWith( query->houseNumber(), Qt::CaseInsensitive ) ) {
147  score += 0.5;
148  }
149  }
150 
151  if ( !query->street().isEmpty() ) {
152  if ( m_name.compare( query->street(), Qt::CaseInsensitive ) == 0 ) {
153  score += 2.0;
154  } else if ( m_name.startsWith( query->street(), Qt::CaseInsensitive ) ) {
155  score += 0.5;
156  }
157  }
158  }
159 
160  return score;
161 }
162 
163 }
Marble::OsmPlacemark::matchScore
qreal matchScore(const DatabaseQuery *query) const
Definition: OsmPlacemark.cpp:130
Marble::DatabaseQuery::region
QString region() const
Definition: DatabaseQuery.cpp:197
OsmPlacemark.h
Marble::OsmPlacemark::setAdditionalInformation
void setAdditionalInformation(const QString &name)
Definition: OsmPlacemark.cpp:68
Marble::OsmPlacemark
A lightweight data structure to represent points of interest like addresses with support for serializ...
Definition: OsmPlacemark.h:24
Marble::OsmPlacemark::setCategory
void setCategory(OsmCategory category)
Definition: OsmPlacemark.cpp:28
Marble::DatabaseQuery::resultFormat
ResultFormat resultFormat() const
Definition: DatabaseQuery.cpp:182
Marble::DatabaseQuery::AddressFormat
Definition: DatabaseQuery.h:39
Marble::OsmPlacemark::setName
void setName(const QString &name)
Definition: OsmPlacemark.cpp:38
Marble::DatabaseQuery::houseNumber
QString houseNumber() const
Definition: DatabaseQuery.cpp:192
Marble::OsmPlacemark::regionId
int regionId() const
Identifier of the smallest region containing this placemark, 0 if none (~main area).
Definition: OsmPlacemark.cpp:53
Marble::OsmPlacemark::setLatitude
void setLatitude(qreal latitude)
Definition: OsmPlacemark.cpp:88
Marble::OsmPlacemark::setRegionId
void setRegionId(int id)
Definition: OsmPlacemark.cpp:58
QString::isEmpty
bool isEmpty() const
QString::startsWith
bool startsWith(const QString &s, Qt::CaseSensitivity cs) const
Marble::OsmPlacemark::houseNumber
QString houseNumber() const
Placemark's house number, if any.
Definition: OsmPlacemark.cpp:43
Marble::OsmPlacemark::additionalInformation
QString additionalInformation() const
Regions' name.
Definition: OsmPlacemark.cpp:63
QString
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::OsmPlacemark::category
OsmCategory category() const
Definition: OsmPlacemark.cpp:23
Marble::OsmPlacemark::setLongitude
void setLongitude(qreal longitude)
Definition: OsmPlacemark.cpp:78
Marble::OsmPlacemark::longitude
qreal longitude() const
Longitude of the placemark's center point, in degree.
Definition: OsmPlacemark.cpp:73
Marble::DatabaseQuery::street
QString street() const
Definition: DatabaseQuery.cpp:187
Marble::OsmPlacemark::operator==
bool operator==(const OsmPlacemark &other) const
Definition: OsmPlacemark.cpp:119
Marble::OsmPlacemark::OsmCategory
OsmCategory
Definition: OsmPlacemark.h:27
Marble::OsmPlacemark::operator<
bool operator<(const OsmPlacemark &other) const
Placemarks are sorted by name by default.
Definition: OsmPlacemark.cpp:94
Marble::OsmPlacemark::setHouseNumber
void setHouseNumber(const QString &houseNumber)
Definition: OsmPlacemark.cpp:48
Marble::OsmPlacemark::OsmPlacemark
OsmPlacemark()
Definition: OsmPlacemark.cpp:16
Marble::DatabaseQuery
Parse result of a user's search term.
Definition: DatabaseQuery.h:29
QString::compare
int compare(const QString &other) const
DatabaseQuery.h
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:13:41 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