Skip to content

Commit d10845b

Browse files
authored
Merge pull request #194 from pgRouting/develop
Fixes #191
2 parents 6ffac06 + d3f4e2f commit d10845b

File tree

7 files changed

+28
-10
lines changed

7 files changed

+28
-10
lines changed

NEWS

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
osm2pgRouting 2.3.0
1+
osm2pgRouting 2.3.2
2+
3+
* Fix: Only on linux: use the wc command to count lines
4+
* Fix: the `osm_<tables>` are created only when addnodes flag is on
5+
* Fix: removed unused flag of the command line
6+
7+
osm2pgRouting 2.3.1
28

39
* Fix: When keys have spaces
410
* Fix: Generating relations

src/database/Export2DB.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ void Export2DB::createTables() const {
135135
exit(1);
136136
}
137137

138+
if (m_vm.count("addnodes")) {
138139
try {
139140
pqxx::connection db_conn(conninf);
140141
pqxx::work Xaction(db_conn);
@@ -156,6 +157,7 @@ void Export2DB::createTables() const {
156157
std::cerr << "WARNING: could not create osm-* tables" << std::endl;
157158
std::cerr << " Insertions on osm_* tables are going to be ignored" << std::endl;
158159
}
160+
}
159161
}
160162

161163

src/database/osm_nodes_config.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@ Tables::osm_nodes_config() const {
4444
/* standard column creation string */
4545
std::string(
4646
" osm_id bigint PRIMARY KEY"
47-
+ (m_vm.count("attributes") ?
47+
+ (m_vm.count("attributes") && m_vm.count("addnodes") ?
4848
(std::string(", attributes hstore"))
4949
: "")
50-
+ (m_vm.count("tags") ?
50+
+ (m_vm.count("tags") && m_vm.count("addnodes") ?
5151
(std::string(", tags hstore"))
5252
#if 0
5353
(std::string(", tags ") + (m_vm.count("hstore") ? "hstore" : "json"))

src/database/osm_relations_config.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@ Tables::osm_relations_config() const {
4545
std::string(
4646
" osm_id bigint PRIMARY KEY"
4747
" , members hstore"
48-
+ (m_vm.count("attributes") ?
48+
+ (m_vm.count("attributes") && m_vm.count("addnodes") ?
4949
(std::string(", attributes hstore"))
5050
: "")
51-
+ (m_vm.count("tags") ?
51+
+ (m_vm.count("tags") && m_vm.count("addnodes")?
5252
(std::string(", tags hstore"))
5353
: "")
5454
),

src/database/osm_ways_config.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,11 @@ Tables::osm_ways_config() const {
4444
/* standard column creation string */
4545
std::string(
4646
" osm_id bigint PRIMARY KEY"
47-
" , members hstore"
48-
+ (m_vm.count("attributes") ?
49-
(std::string(", attributes hstore"))
47+
//" , members hstore"
48+
+ (m_vm.count("attributes") && m_vm.count("addnodes") ?
49+
(std::string(", attributes hstore"))
5050
: "")
51-
+ (m_vm.count("tags") ?
51+
+ (m_vm.count("tags") && m_vm.count("addnodes") ?
5252
(std::string(", tags hstore"))
5353
#if 0
5454
(std::string(", tags ") + (m_vm.count("hstore") ? "hstore" : "json"))

src/osm_elements/osm2pgrouting.cpp

+7-1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
#include "utilities/handle_pgpass.h"
4242
#include "utilities/prog_options.h"
4343

44+
#if defined(__linux__)
4445
static
4546
size_t lines_in_file(const std::string file_name) {
4647
FILE *in;
@@ -67,6 +68,7 @@ size_t lines_in_file(const std::string file_name) {
6768
exit(1);
6869
}
6970
}
71+
#endif
7072

7173

7274
int main(int argc, char* argv[]) {
@@ -161,7 +163,7 @@ int main(int argc, char* argv[]) {
161163
std::cout << " HINT: CREATE EXTENSION postGIS\n";
162164
return 1;
163165
}
164-
if ((vm.count("attributes") || vm.count("tags"))
166+
if ((vm.count("attributes") || vm.count("tags") || vm.count("addnodes"))
165167
&& !dbConnection.has_extension("hstore")) {
166168
std::cout << "ERROR: hstore not found\n";
167169
std::cout << " HINT: CREATE EXTENSION hstore\n";
@@ -201,6 +203,7 @@ int main(int argc, char* argv[]) {
201203
std::cout << " - Done \n";
202204

203205

206+
#if defined(__linux__)
204207
std::cout << "Counting lines ...\n";
205208
auto total_lines = lines_in_file(dataFile);
206209
std::cout << " - Done \n";
@@ -210,6 +213,9 @@ int main(int argc, char* argv[]) {
210213
<< "\ttotal lines: "
211214
<< total_lines
212215
<< endl;
216+
#else
217+
size_t total_lines = 0;
218+
#endif
213219
osm2pgr::OSMDocument document(config, vm, dbConnection, total_lines);
214220
osm2pgr::OSMDocumentParserCallback callback(document);
215221

src/utilities/prog_options.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,9 @@ void get_option_description(po::options_description &od_desc) {
5151
("schema", po::value<std::string>()->default_value(""), "Database schema to put tables.\n blank:\t defaults to default schema dictated by PostgreSQL search_path.")
5252
("prefix", po::value<std::string>()->default_value(""), "Prefix added at the beginning of the table names.")
5353
("suffix", po::value<std::string>()->default_value(""), "Suffix added at the end of the table names.")
54+
#if 0
5455
("postgis", "Install postgis if not found.") // TODO(vicky) remove before realesing
56+
#endif
5557
("addnodes", "Import the osm_nodes, osm_ways & osm_relations tables.")
5658
("attributes", "Include attributes information.")
5759
("tags", "Include tag information.")
@@ -100,7 +102,9 @@ process_command_line(po::variables_map &vm) {
100102
std::cout << "schema= " << vm["schema"].as<std::string>() << "\n";
101103
std::cout << "prefix = " << vm["prefix"].as<std::string>() << "\n";
102104
std::cout << "suffix = " << vm["suffix"].as<std::string>() << "\n";
105+
#if 0
103106
std::cout << (vm.count("postgis")? "I" : "Don't I") << "nstall postgis if not found\n";
107+
#endif
104108
std::cout << (vm.count("clean")? "D" : "Don't d") << "rop tables\n";
105109
std::cout << (vm.count("no-index")? "D" : "Don't c") << "reate indexes\n";
106110
std::cout << (vm.count("addnodes")? "A" : "Don't a") << "dd OSM nodes\n";

0 commit comments

Comments
 (0)