1 | /*************************************************************************** |
---|
2 | * Copyright (C) 2008 by Daniel Wendt * |
---|
3 | * gentoo.murray@gmail.com * |
---|
4 | * * |
---|
5 | * This program is free software; you can redistribute it and/or modify * |
---|
6 | * it under the terms of the GNU General Public License as published by * |
---|
7 | * the Free Software Foundation; either version 2 of the License, or * |
---|
8 | * (at your option) any later version. * |
---|
9 | * * |
---|
10 | * This program is distributed in the hope that it will be useful, * |
---|
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
---|
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
---|
13 | * GNU General Public License for more details. * |
---|
14 | * * |
---|
15 | * You should have received a copy of the GNU General Public License * |
---|
16 | * along with this program; if not, write to the * |
---|
17 | * Free Software Foundation, Inc., * |
---|
18 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
---|
19 | ***************************************************************************/ |
---|
20 | |
---|
21 | #ifndef EXPORT2DB_H |
---|
22 | #define EXPORT2DB_H |
---|
23 | |
---|
24 | //#include "postgresql/libpq-fe.h" |
---|
25 | #include "libpq-fe.h" |
---|
26 | #include "Node.h" |
---|
27 | #include "Way.h" |
---|
28 | #include "Type.h" |
---|
29 | #include "Class.h" |
---|
30 | |
---|
31 | using namespace osm; |
---|
32 | |
---|
33 | /** |
---|
34 | * This class connects to a postgresql database. For using this class, |
---|
35 | * you also need to install postgis and pgrouting |
---|
36 | */ |
---|
37 | |
---|
38 | class Export2DB |
---|
39 | { |
---|
40 | |
---|
41 | public: |
---|
42 | /** |
---|
43 | * Construktor |
---|
44 | * @param host Host address of the database |
---|
45 | * @param user a user, who has write access to the database |
---|
46 | * @param dbname name of the database |
---|
47 | * |
---|
48 | */ |
---|
49 | Export2DB(std::string host, std::string user, std::string dbname, std::string port, std::string password); |
---|
50 | /** |
---|
51 | * Destructor |
---|
52 | * closes the connection to the database |
---|
53 | */ |
---|
54 | ~Export2DB(); |
---|
55 | |
---|
56 | //! connects to database |
---|
57 | int connect(); |
---|
58 | //! creates needed tables |
---|
59 | void createTables(); |
---|
60 | //! exports nodes to the database |
---|
61 | void exportNode(long long id, double lon, double lat, ushort numOfUse ); |
---|
62 | //! exports ways to the database |
---|
63 | void exportWay(Way* way); |
---|
64 | |
---|
65 | void exportType(Type* type); |
---|
66 | void exportClass(Type* type, Class* clss); |
---|
67 | |
---|
68 | |
---|
69 | /** |
---|
70 | * creates the topology |
---|
71 | * Be careful, it takes some time. |
---|
72 | * |
---|
73 | * for example: |
---|
74 | * complete germany: OSM file with a size of 1,1 GiB. |
---|
75 | * Export and create topology: |
---|
76 | * time took circa 30 hours on an Intel Xeon 2,4 GHz with 2 GiB Ram. |
---|
77 | * But only for the streettypes "motorway", "primary" and "secondary" |
---|
78 | */ |
---|
79 | void createTopology(); |
---|
80 | //! Be careful! It deletes the created tables! |
---|
81 | void dropTables(); |
---|
82 | |
---|
83 | private: |
---|
84 | PGconn *mycon; |
---|
85 | std::string conninf; |
---|
86 | }; |
---|
87 | |
---|
88 | |
---|
89 | #endif |
---|