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

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

No 'using xy' declarations in headers
Reorder includes with local files on top, and methods by decreasing publicity

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
24#include "Object.h"
25
26#include <cmath>
27#include <fstream>
28#include <iostream>
29#include <map>
30#include <string>
31#include <vector>
32
33
34namespace OSM
35{
36
37class Node : public Object
38{
39private:
40        double lat, lon;
41
42public:
43        Node()
44        {
45                lat=lon=0;
46                id = 0;
47        }
48
49        Node(double lt, double ln)
50        {
51                lat=lt;
52                lon=ln;
53                id=0;
54        }
55        Node(int i,double lt, double ln)
56        {
57                lat=lt;
58                lon=ln;
59                id=i;
60        }
61
62        bool operator==(const Node& tp)
63        {
64                return (fabs(lat-tp.lat)<0.000001) && (fabs(lon-tp.lon)<0.000001);
65        }
66
67        double getLat() { return lat; }
68        double getLon() { return lon; }
69
70        void setCoords(double lat,double lon)
71                { this->lat=lat; this->lon=lon; }
72
73        void toXML(std::ostream &strm)
74        {
75                std::streamsize old = strm.precision(15);
76                if (hasTags()) {
77                        strm << "  <node id='" << id << "' lat='" << lat << "' lon='" << lon
78                                        <<"'>" << std::endl;
79                        tagsToXML(strm);
80                        strm << "  </node>" << std::endl;
81                } else {
82                        strm << "  <node id='" << id << "' lat='" << lat << "' lon='" << lon
83                                        <<"'/>" << std::endl;
84                }
85                strm.precision(old);
86        }
87};
88
89}
90#endif
Note: See TracBrowser for help on using the repository browser.