source: subversion/applications/editors/osm-editor/qt3/Node.cpp @ 16590

Last change on this file since 16590 was 1158, checked in by nick, 13 years ago

moved current version to qt3 directory in preparation for qt4

File size: 2.8 KB
Line 
1#include "Node.h"
2#include "NodeMetaDataHandler.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 */
22namespace OpenStreetMap
23{
24
25// 180306 updated for 0.3
26// 080706 updated to allow for the fact that all tags now stored
27int Node::toOSM(QTextStream& outfile, bool allUid)
28{
29    int sent_id = (osm_id>0 || (allUid&&osm_id)) ? osm_id: 0;
30        outfile.precision(10); // 250306 in response to request
31    outfile << "<node lat='" <<  lat <<
32                "' lon='" <<  lon << "'";
33   
34    outfile << " id='" << sent_id << "' >" << endl;
35   
36        /*
37    if(name != "")
38        outfile << "<tag k='name' v='" << name << "'/>" << endl;
39
40        // 180506 handle new style keys (ie. not class)
41    if(type != "")
42        {
43                NodeMetaDataHandler mdh;
44                NodeMetaData md = mdh.getMetaData(type);
45                if(md.key!="" || md.value!="")
46                outfile << "<tag k='"<<md.key<<"' v='" << md.value << "'/>" << endl;
47        }
48        */
49
50        // 080706 all tags written out, not just those of interest to osmeditor2
51        for(std::map<QString,QString>::iterator i=tags.begin(); i!=tags.end(); i++)
52        {
53                if(i->second!="")
54                {
55                        outfile << "<tag k='"<<i->first<<"' v='" << i->second << "'/>"
56                                <<endl;
57                }
58        }
59
60    outfile << "</node>" << endl;
61}
62
63// 180306 updated for 0.3
64QByteArray Node::toOSM()
65{
66    QByteArray xml;
67    QTextStream str(xml, IO_WriteOnly);
68    str<<"<osm version='0.3'>"<<endl;
69    toOSM(str);
70    str<<"</osm>"<<endl;
71    str<<'\0';
72    return xml;
73}
74// 180306 not changed as this is the old curl way of doing it
75// 130506 took out the old curl way of doing it
76
77// Used when creating segments from trackpoints
78void Node::trackpointToNode()
79{
80    if(type=="trackpoint")
81        type="node";
82}
83
84QString Node::getType()
85{
86                // Use tags
87                //return type;
88                NodeMetaDataHandler mdh;
89                QString curType;
90                for(std::map<QString,QString>::iterator i=tags.begin(); i!=tags.end();
91                        i++)
92                {
93                        curType = mdh.getNodeType(i->first,i->second);
94                        if(curType!="" && curType!="node")
95                                return curType;
96                }
97                return "node";
98}
99
100}
Note: See TracBrowser for help on using the repository browser.