source: subversion/applications/utils/export/guidise/Parser.h @ 27053

Last change on this file since 27053 was 24604, checked in by nick, 9 years ago

added guidise: tool to give features geographically-based unique (hopefully) IDs

File size: 1.4 KB
Line 
1#ifndef PARSER_H
2#define PARSER_H
3
4// based on the libosm parser
5// http://svn.openstreetmap.org/applications/lib/libosm/
6
7#include <expat.h>
8
9#include <cstdio>
10#include <cstdlib>
11#include <iostream>
12#include <string>
13#include <map>
14#include <vector>
15
16using std::cout;
17using std::cerr;
18using std::endl;
19
20
21struct Node
22{
23        double lat, lon;
24        int count;
25
26        Node(double lat,double lon)
27        {
28                this->lat=lat;
29                this->lon=lon;
30                count=0;
31        }
32};
33
34/**
35 * Xml parser for OSM
36 */
37class Parser
38{
39public:
40        static bool parse(XML_Parser p,std::istream &stream);
41
42        /**
43         * @return An empty string if no error occurred in the last parse call,
44         * or a description of the error otherwise
45         */
46        static std::string getError();
47
48        static void startElement(void *d, const XML_Char* name,
49                        const XML_Char** attrs);
50        static void endElement(void *d, const XML_Char* name);
51        static void characters(void*, const XML_Char* txt, int txtlen);
52
53private:
54
55        static void writeCurrentTags(std::map<std::string,std::string>& tags);
56        static void freeNodes();
57
58        static int curID;
59        static bool inNode, inWay;
60        static std::map <int,Node*> nodes;
61        static std::map<std::string,std::string> nodetags;
62        static std::vector<Node*> waynodes;
63        static std::string error;
64        static double lon,lat;
65};
66
67long long getNodeGUID(double lon, double lat,std::map<std::string,std::string>
68                                                &nodetags);
69long long getWayGUID(std::vector<Node*> waynodes);
70
71#endif
Note: See TracBrowser for help on using the repository browser.