root/tools/osm2pgrouting/tags/release-0.1/src/Export2DB.h

Revision 189, 2.8 KB (checked in by murray, 2 years ago)

osm2pgrouting: add a new tool to this project, which converts and imports osm data to a pgrouting
table

Line 
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 "Node.h"
26#include "Way.h"
27
28using namespace osm;
29
30/**
31 * This class connects to a postgresql database. For using this class,
32 * you also need to install postgis and pgrouting
33 */
34
35class Export2DB
36{
37
38public:
39        /**
40         * Construktor
41         * @param host Host address of the database
42         * @param user a user, who has write access to the database
43         * @param dbname name of the database
44         *
45         */
46        Export2DB(std::string host, std::string user, std::string dbname, std::string port, std::string password);
47        /**
48         * Destructor
49         * closes the connection to the database
50         */ 
51        ~Export2DB();
52       
53        //! connects to database
54        int connect();
55        //! creates needed tables
56        void createTables();
57        //! exports nodes to the database
58        void exportNode(long long id, double lon, double lat, ushort numOfUse );
59        //! exports ways to the database
60        void exportWay(Way* way);
61        /**
62         * creates the topology
63         * Be careful, it takes some time.
64         *
65         * for example:
66         * complete germany: OSM file with a size of 1,1 GiB.
67         * Export and create topology:
68         * time took circa 30 hours on an Intel Xeon 2,4 GHz with 2 GiB Ram.
69         * But only for the streettypes "motorway", "primary" and "secondary"
70         */
71        void createTopology();
72        //! Be careful! It deletes the created tables!
73        void dropTables();
74       
75private:
76PGconn *mycon;
77std::string conninf;
78};
79
80
81#endif
Note: See TracBrowser for help on using the browser.