source: subversion/applications/lib/libosm/Node.h @ 11683

Last change on this file since 11683 was 11683, checked in by nienhueser, 12 years ago

Start making accessors const
Encapsulate the previously public id member in the Object class
Replace some duplicated constructors with default arguments
Use initialization lists in constructors

File size: 1.8 KB
Line 
1#ifndef NODE_H
2#define NODE_H
3
4/*
5 Copyright (C) 2005 Nick Whitelegg, Hogweed Software, nick@hogweed.org
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111 USA
20
21 */
22
23#include "Object.h"
24
25#include <cmath>
26#include <fstream>
27#include <iostream>
28#include <map>
29#include <string>
30#include <vector>
31
32namespace OSM
33{
34
35class Node: public Object
36{
37private:
38        double lat, lon;
39
40public:
41        Node(double lt = 0, double ln = 0) :
42                Object(0), lat(lt), lon(ln)
43        {
44        }
45
46        Node(int i, double lt, double ln) :
47                Object(i), lat(lt), lon(ln)
48        {
49        }
50
51        bool operator==(const Node& tp)
52        {
53                return (fabs(lat - tp.lat) < 0.000001) && (fabs(lon - tp.lon)
54                                < 0.000001);
55        }
56
57        double getLat()
58        {
59                return lat;
60        }
61        double getLon()
62        {
63                return lon;
64        }
65
66        void setCoords(double lat, double lon)
67        {
68                this->lat = lat;
69                this->lon = lon;
70        }
71
72        void toXML(std::ostream &strm)
73        {
74                std::streamsize old = strm.precision(15);
75                if (hasTags())
76                {
77                        strm << "  <node id='" << id() << "' lat='" << lat << "' lon='"
78                                        << lon << "'>" << std::endl;
79                        tagsToXML(strm);
80                        strm << "  </node>" << std::endl;
81                }
82                else
83                {
84                        strm << "  <node id='" << id() << "' lat='" << lat << "' lon='"
85                                        << lon << "'/>" << std::endl;
86                }
87                strm.precision(old);
88        }
89};
90
91}
92#endif
Note: See TracBrowser for help on using the repository browser.