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

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

moved current version to qt3 directory in preparation for qt4

File size: 2.7 KB
Line 
1#include "NodeMetaDataHandler.h"
2#include <qstringlist.h>
3
4#include <iostream>
5using std::cout;
6using std::cerr;
7using std::endl;
8
9namespace OpenStreetMap
10{
11
12// Tests an incoming set of matadata against the required criteria
13bool NodeMetaData::testmatch(const NodeMetaData& indata)
14{ 
15        // 090706 if the key is class and the value is the specified value
16        // that also counts as a match
17        return (key==indata.key && value==indata.value) ||
18                        (key=="class" && value==indata.value);
19}
20
21NodeMetaDataHandler::NodeMetaDataHandler()
22{
23        nData["pub"] = NodeMetaData("amenity","pub");
24        nData["church"] = NodeMetaData("amenity","church");
25        nData["viewpoint"] = NodeMetaData ("tourism","viewpoint");
26        nData["hill"] = NodeMetaData("natural","peak");
27        nData["farm"] = NodeMetaData("residence","farm");
28        nData["hamlet"] = NodeMetaData("place","hamlet");
29        nData["village"] = NodeMetaData("place","village");
30        nData["small town"] = NodeMetaData("place","small town");
31        nData["large town"] = NodeMetaData("place","town");
32        nData["city"] = NodeMetaData("place","city");
33        nData["railway station"] = NodeMetaData("railway","station");
34        nData["car park"] = NodeMetaData("amenity","parking");
35        nData["mast"] = NodeMetaData("man_made","mast");
36        nData["point of interest"] = NodeMetaData("leisure","point_of_interest");
37        nData["suburb"] = NodeMetaData("place","suburb");
38        nData["waypoint"] = NodeMetaData("waypoint","waypoint");
39        nData["campsite"] = NodeMetaData("tourism","camp_site");
40        nData["restaurant"] = NodeMetaData("amenity","restaurant");
41        nData["tea shop"] = NodeMetaData("amenity","tea shop");
42        nData["bridge"] = NodeMetaData("highway","bridge");
43        nData["barn"] = NodeMetaData("man_made","barn");
44        nData["country park"] = NodeMetaData("leisure","country_park");
45
46        // Put area stuff in here too. Plan is to rename from NodeMetaData to
47        // something else.
48        nData["wood"] = NodeMetaData("landuse","wood");
49        nData["heath"] = NodeMetaData("natural","heath");
50        nData["lake"] = NodeMetaData("natural","water");
51}
52
53// Returns the metadata matching a node type
54NodeMetaData NodeMetaDataHandler::getMetaData(const QString& type) 
55{
56        std::map<QString,NodeMetaData>::iterator i = nData.find(type);
57        if (i==nData.end())
58                return NodeMetaData();
59        return i->second;
60}
61
62// Returns the node type matching node meta data
63QString NodeMetaDataHandler::getNodeType(const QString& k,const QString &v) 
64{
65        NodeMetaData nd(k,v);
66
67        for(std::map<QString,NodeMetaData>::iterator i=nData.begin();
68                                        i!=nData.end(); i++)
69        {
70                if (i->second.testmatch(nd))
71                        return i->first;
72        }
73        return "node";
74}
75
76bool NodeMetaDataHandler::keyExists(const QString& k)
77{
78        for(std::map<QString,NodeMetaData>::iterator i=nData.begin();
79                i!=nData.end(); i++)
80        {
81                if (i->second.key == k)
82                        return true; 
83        }
84        return false;
85}
86
87}
Note: See TracBrowser for help on using the repository browser.