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

Last change on this file since 34562 was 11684, checked in by nienhueser, 11 years ago

Less inline definitions. Start to document things (doxygen style)

File size: 2.3 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
35/**
36 * A node represents a point with a unique ID and a known (latitude/longitude)
37 */
38class Node: public Object
39{
40public:
41        /**
42         * Constructor. Creates a node at the given position with index 0.
43         * @param lat Latitude of the point (node)
44         * @param lon Longitude of the point (node)
45         */
46        Node(double lat = 0, double lon = 0);
47
48        /**
49         * Constructor. Creates a node at the given position with the given index.
50         * @param index Unique node index
51         * @param lat Latitude of the point (node)
52         * @param lon Longitude of the point (node)
53         */
54        Node(int index, double lat, double lon);
55
56        /**
57         * Nodes are considered equal if both their
58         * longitude and latitude position differs less than
59         * 0.000001 each.
60         * @param other Node to compare to
61         * @return True if the nodes are equal (lon/lat difference is smaller than 0.000001 for each)
62         */
63        bool operator==(const Node& other);
64
65        /**
66         * Accessor for the node latitude
67         * @return Latitude of this node
68         */
69        double getLat();
70
71        /**
72         * Accessor for the node longitude
73         * @return Longitude of this node
74         */
75        double getLon();
76
77        /**
78         * Set longitude and latitude
79         * @param lat New latitude of this node
80         * @param lon New longitude of this node
81         * @see #getLat, #getLon
82         */
83        void setCoords(double lat, double lon);
84
85        /**
86         * Write an xml representation of this node to the given stream
87         * @param strm Stream to write to
88         */
89        void toXML(std::ostream &strm);
90
91private:
92        double lat, lon;
93};
94
95}
96#endif
Note: See TracBrowser for help on using the repository browser.