source: subversion/applications/lib/libosm/Way.cpp @ 11682

Revision 11682, 1.7 KB checked in by nienhueser, 5 years ago (diff)

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

Line 
1#include "Way.h"
2#include "Components.h"
3#include <cfloat>
4#include <iostream>
5
6/*
7Copyright (C) 2006 Nick Whitelegg, Hogweed Software, nick@hogweed.org
8
9This program is free software; you can redistribute it and/or modify
10it under the terms of the GNU General Public License as published by
11the Free Software Foundation; either version 2 of the License, or
12(at your option) any later version.
13
14This program is distributed in the hope that it will be useful,
15but WITHOUT ANY WARRANTY; without even the implied warranty of
16MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17GNU General Public License for more details.
18
19You should have received a copy of the GNU General Public License
20along with this program; if not, write to the Free Software
21Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111 USA
22
23 */
24
25using std::endl;
26using std::vector;
27
28namespace OSM
29{
30
31// remove a node - returns its position
32int Way::removeNode(int n)
33{
34        for(vector<int>::iterator i=nodes.begin(); i!=nodes.end(); i++)
35        {
36                if(*i==n)
37                {
38                        int index = i-nodes.begin();
39                        nodes.erase(i);
40                        return index;
41                }
42        }
43        return -1;
44}
45
46// Insert a node at position 'index'
47bool Way::addNodeAt(int index, int n)
48{
49        vector<int>::iterator i = nodes.begin() + index;
50        if(n>0)
51        {
52                nodes.insert(i,n);
53                return true;
54        }
55        return false;
56}
57
58int Way::getNode(int i)
59{
60        return (i>=0 && i<static_cast<int>(nodes.size())) ?  (nodes[i]) : -1;
61}
62
63void Way::toXML(std::ostream &strm)
64{
65        if (hasTags() || nodes.size()) {
66                strm << "  <way id='" << id << "'>" << endl;
67                for(unsigned int count=0; count<nodes.size(); count++)
68                        strm  << "    <node id='" << nodes[count] << "'/>" << endl;
69                tagsToXML(strm);
70                strm << "  </way>" << endl;
71        } else {
72                strm << "  <way id='" << id << "'/>" << endl;
73        }
74
75}
76
77}
Note: See TracBrowser for help on using the repository browser.