• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • tdeabc
 

tdeabc

  • tdeabc
geo.cpp
1/*
2 This file is part of libtdeabc.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
19*/
20
21#include <tqdatastream.h>
22
23#include "geo.h"
24
25using namespace TDEABC;
26
27Geo::Geo()
28 : mLatitude( 91 ), mLongitude( 181 ), mValidLat( false ), mValidLong( false )
29{
30}
31
32Geo::Geo( float latitude, float longitude )
33{
34 setLatitude( latitude );
35 setLongitude( longitude );
36}
37
38void Geo::setLatitude( float latitude )
39{
40 if ( latitude >= -90 && latitude <= 90 ) {
41 mLatitude = latitude;
42 mValidLat = true;
43 } else {
44 mLatitude = 91;
45 mValidLat = false;
46 }
47}
48
49float Geo::latitude() const
50{
51 return mLatitude;
52}
53
54void Geo::setLongitude( float longitude)
55{
56 if ( longitude >= -180 && longitude <= 180 ) {
57 mLongitude = longitude;
58 mValidLong = true;
59 } else {
60 mLongitude = 181;
61 mValidLong = false;
62 }
63}
64
65float Geo::longitude() const
66{
67 return mLongitude;
68}
69
70bool Geo::isValid() const
71{
72 return mValidLat && mValidLong;
73}
74
75bool Geo::operator==( const Geo &g ) const
76{
77 if ( !g.isValid() && !isValid() ) return true;
78 if ( !g.isValid() || !isValid() ) return false;
79 if ( g.mLatitude == mLatitude && g.mLongitude == mLongitude ) return true;
80 return false;
81}
82
83bool Geo::operator!=( const Geo &g ) const
84{
85 if ( !g.isValid() && !isValid() ) return false;
86 if ( !g.isValid() || !isValid() ) return true;
87 if ( g.mLatitude == mLatitude && g.mLongitude == mLongitude ) return false;
88 return true;
89}
90
91TQString Geo::asString() const
92{
93 return "(" + TQString::number(mLatitude) + "," + TQString::number(mLongitude) + ")";
94}
95
96TQDataStream &TDEABC::operator<<( TQDataStream &s, const Geo &geo )
97{
98 return s << (float)geo.mLatitude << (float)geo.mLongitude;
99}
100
101TQDataStream &TDEABC::operator>>( TQDataStream &s, Geo &geo )
102{
103 s >> geo.mLatitude >> geo.mLongitude;
104
105 geo.mValidLat = true;
106 geo.mValidLong = true;
107
108 return s;
109}
TDEABC::Geo
Geographic position.
Definition: geo.h:36
TDEABC::Geo::asString
TQString asString() const
Returns string representation of geographical position.
Definition: geo.cpp:91
TDEABC::Geo::setLongitude
void setLongitude(float)
Sets the longitude.
Definition: geo.cpp:54
TDEABC::Geo::Geo
Geo()
Construct invalid geographics position object.
Definition: geo.cpp:27
TDEABC::Geo::isValid
bool isValid() const
Returns, if this object contains a valid geographical position.
Definition: geo.cpp:70
TDEABC::Geo::setLatitude
void setLatitude(float)
Sets the latitude.
Definition: geo.cpp:38
TDEABC::Geo::longitude
float longitude() const
Returns the longitude.
Definition: geo.cpp:65
TDEABC::Geo::latitude
float latitude() const
Returns the latitude.
Definition: geo.cpp:49
TDEABC
static data, shared by ALL addressee objects
Definition: address.h:48

tdeabc

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

tdeabc

Skip menu "tdeabc"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdeabc by doxygen 1.9.4
This website is maintained by Timothy Pearson.