Skip to content

Commit

Permalink
removing some unussed flags
Browse files Browse the repository at this point in the history
  • Loading branch information
cvvergara committed Oct 9, 2017
1 parent 87d9941 commit 116ce99
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 20 deletions.
6 changes: 2 additions & 4 deletions include/osm_elements/OSMDocument.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,17 +102,15 @@ class OSMDocument {
}


#ifndef _WIN32
void wait_child() const;
#endif

template <typename T>
void
osm_table_export(const T &osm_items, const std::string &table) const {
if (osm_items.empty()) return;

if (m_vm.count("addnodes")) {
#ifndef _WIN32
#if 0
auto pid = fork();
if (pid < 0) {
std::cerr << "Failed to fork" << endl;
Expand All @@ -128,7 +126,7 @@ class OSMDocument {
m_db_conn.export_osm(export_items, table);

if (m_vm.count("addnodes")) {
#ifndef _WIN32
#if 0
/*
* finish the child process
*/
Expand Down
12 changes: 11 additions & 1 deletion src/database/Export2DB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,9 @@ void Export2DB::createFKeys() const {
}

void Export2DB::process_pois() const {
if (!m_vm.count("addnodes")) return;

std::cout << "\nAdding functions for processing Points of Interest ..." << endl;
/* osm2pgr_pois_update_part_of_topology */
execute(pois().sql(0));

Expand All @@ -594,7 +597,15 @@ void Export2DB::process_pois() const {
/* osm2pgr_pois_update */
execute(pois().sql(4));

std::cout << "\nTo process pointsOfInterest table:"
"\nosm2pgr_pois_update(radius deault 200, within default 50)\n"
"\n - Using areas of (radius)mts on POIS"
"\n - Using edges that are at least (within) mts of each POI"
"\nPOIS that do not have a closest edge is considered as too far\n";


return;
#if 0
std::string array;
int64_t total = 0;
auto limit = get_val(
Expand Down Expand Up @@ -636,7 +647,6 @@ void Export2DB::process_pois() const {

execute("SELECT osm2pgr_pois_find_side()");
execute("SELECT osm2pgr_pois_new_geom()");
#if 0
execute(
"\n WITH "
"\n base AS ("
Expand Down
14 changes: 11 additions & 3 deletions src/database/table_management.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ Tables::Tables(const po::variables_map &vm) :
+ "\n$$"
+ "\nLANGUAGE plpgsql;"
+ "\nCOMMENT ON FUNCTION osm2pgr_pois_update_part_of_topology()"
+ "\n IS 'osm2pgRouting generated function';"
+ "\n IS 'osm2pgrouting generated function';"
);


Expand Down Expand Up @@ -249,7 +249,7 @@ Tables::Tables(const po::variables_map &vm) :
+"\n WHERE ST_Intersects(the_geom, bufferWays)"
+"\n ),"
+"\n first AS ("
+"\n SELECT ways.id AS wid,"
+"\n SELECT ways.gid AS wid,"
+"\n source_osm, target_osm,"
+"\n ST_distance(pois.the_geom::geography, ways.the_geom::geography) AS dist,"
+"\n pois.osm_id AS vid,"
Expand Down Expand Up @@ -281,6 +281,8 @@ Tables::Tables(const po::variables_map &vm) :
+"\n END;"
+"\n $$"
+"\n LANGUAGE plpgsql;"
+"\nCOMMENT ON FUNCTION osm2pgr_pois_update_not_part_of_topology(float,float,bigint[])"
+ "\n IS 'osm2pgrouting generated function';"
);

m_points_of_interest.add_sql(
Expand Down Expand Up @@ -333,6 +335,8 @@ Tables::Tables(const po::variables_map &vm) :
+ "\n WHERE last.pid = " + pois().addSchema() + ".pid;"
+"\n $$"
+"\n LANGUAGE sql;"
+"\nCOMMENT ON FUNCTION osm2pgr_pois_find_side()"
+ "\n IS 'osm2pgrouting generated function';"
);

m_points_of_interest.add_sql(
Expand All @@ -348,11 +352,13 @@ Tables::Tables(const po::variables_map &vm) :
+ "\n WHERE vertex_id IS NOT NULL;"
+ "\n $$"
+ "\n LANGUAGE sql;"
+"\nCOMMENT ON FUNCTION osm2pgr_pois_new_geom()"
+ "\n IS 'osm2pgrouting generated function';"
);


m_points_of_interest.add_sql(
"\nCREATE OR REPLACE FUNCTION osm2pgr_pois_update(radius FLOAT, within FLOAT)"
"\nCREATE OR REPLACE FUNCTION osm2pgr_pois_update(radius FLOAT DEFAULT 200, within FLOAT DEFAULT 50)"

"\n RETURNS BIGINT AS"
"\n $$"
Expand Down Expand Up @@ -408,6 +414,8 @@ Tables::Tables(const po::variables_map &vm) :
+"\n END;"
+"\n $$"
+"\n LANGUAGE plpgsql;"
+"\nCOMMENT ON FUNCTION osm2pgr_pois_update(float, float)"
+ "\n IS 'osm2pgrouting generated function. osm2pgr_pois_update(radius, within)\nworking on areas of (radius)mts\nOn edges that are at least (within) mts of each POI';"
);


Expand Down
16 changes: 8 additions & 8 deletions src/osm_elements/OSMDocument.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#include <iostream>
#include <algorithm>

#ifndef _WIN32
#if 0
#include <sys/wait.h>
#endif

Expand All @@ -55,9 +55,9 @@ OSMDocument::OSMDocument(
}


#ifndef _WIN32
void
OSMDocument::wait_child() const {
#if 0
while (true) {
int status;
pid_t done = wait(&status);
Expand All @@ -70,8 +70,8 @@ OSMDocument::wait_child() const {
}
}
}
}
#endif
}


void
Expand All @@ -97,7 +97,7 @@ void OSMDocument::AddWay(const Way &w) {
}


if (m_vm.count("addways")) {
if (m_vm.count("addnodes")) {
if ((m_ways.size() % m_chunk_size) == 0) {
wait_child();
if (m_ways.size() % 200000 == 0) {
Expand All @@ -112,13 +112,13 @@ void OSMDocument::AddWay(const Way &w) {

void
OSMDocument::AddRelation(const Relation &r) {
if (m_vm.count("addways") && m_relations.empty()) {
if (m_vm.count("addnodes") && m_relations.empty()) {
wait_child();
osm_table_export(m_ways, "osm_ways");
std::cout << "\nFinal osm_ways:\t" << m_ways.size();
}

if (m_vm.count("addrelations")) {
if (m_vm.count("addnodes")) {
wait_child();
if (m_relations.size() % 100000 == 0) {
std::cout << "\nCurrent osm_relations:\t" << m_relations.size();
Expand Down Expand Up @@ -226,7 +226,7 @@ OSMDocument::export_pois() const {
std::string table("pointsofinterest");
if (m_nodes.empty()) return;

#ifndef _WIN32
#if 0
if (m_vm.count("fork")) {
auto pid = fork();
if (pid < 0) {
Expand All @@ -253,7 +253,7 @@ OSMDocument::export_pois() const {
m_db_conn.export_osm(export_items, table);
}

#ifndef _WIN32
#if 0
if (m_vm.count("fork")) {
/*
* finish the child process
Expand Down
12 changes: 8 additions & 4 deletions src/utilities/prog_options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,18 @@ void get_option_description(po::options_description &od_desc) {
("prefix", po::value<std::string>()->default_value(""), "Prefix added at the beginning of the table names.")
("suffix", po::value<std::string>()->default_value(""), "Suffix added at the end of the table names.")
("postgis", "Install postgis if not found.") // TODO(vicky) remove before realesing
("addnodes", "Import the osm_nodes table.")
("addways", "Import the osm_ways table.")
("addrelations", "Import the osm_relations table.")
("addnodes", "Import the osm_nodes, osm_ways & osm_relations tables.")
("attributes", "Include attributes information.")
("tags", "Include tag information.")
("hstore", "Use hstore for attributes and/or tags. (not indicating will use json)")
("chunk", po::value<std::size_t>()->default_value(20000), "Exporting chunk size.")
("clean", "Drop previously created tables.")
("no-index", "Do not create indexes (when is not the first file)")
("no-index", "Do not create indexes (Use when indexes are already created)");
#if 0
("addways", "Import the osm_ways table.")
("addrelations", "Import the osm_relations table.")
("fork", "Use fork (works on small files).");
#endif

db_options_od_desc.add_options()
// database options
Expand Down Expand Up @@ -104,6 +106,8 @@ process_command_line(po::variables_map &vm) {
std::cout << (vm.count("addnodes")? "A" : "Don't a") << "dd OSM nodes\n";
std::cout << (vm.count("addways")? "A" : "Don't a") << "dd OSM ways\n";
std::cout << (vm.count("addrelations")? "A" : "Don't a") << "dd OSM relations\n";
#if 0
std::cout << (vm.count("fork")? "F" : "Don't f") << "ork\n";
#endif
std::cout << "***************************************************\n";
}

0 comments on commit 116ce99

Please sign in to comment.