diff --git a/NEWS.md b/NEWS.md index 3a4e2a133ee..7a5fdc77d56 100644 --- a/NEWS.md +++ b/NEWS.md @@ -43,9 +43,7 @@ milestone for 4.0.0 **code enhancements:** -* Simplify C/C++ code for all overloads of - - * pgr_dijkstra +* Removal of unused C/C++ code **Removal of SQL deprecated functions** diff --git a/doc/src/release_notes.rst b/doc/src/release_notes.rst index 3a4e5ae0c59..0cc128e925c 100644 --- a/doc/src/release_notes.rst +++ b/doc/src/release_notes.rst @@ -74,9 +74,7 @@ milestone for 4.0.0 .. rubric:: code enhancements: -* Simplify C/C++ code for all overloads of - - * pgr_dijkstra +* Removal of unused C/C++ code .. rubric:: Removal of SQL deprecated functions diff --git a/include/c_common/trsp_pgget.h b/include/c_common/trsp_pgget.h deleted file mode 100644 index 50a48ca771f..00000000000 --- a/include/c_common/trsp_pgget.h +++ /dev/null @@ -1,98 +0,0 @@ -/*PGR-GNU***************************************************************** -File: trsp_pgget.h - -Copyright (c) 2015 pgRouting developers -Mail: project@pgrouting.org - -Copyright (c) 2023 Celia Virginia Vergara Castillo -mail: vicky at erosion.dev -Copyright (c) 2020 Mahmoud SAKR and Esteban ZIMANYI -mail: m_attia_sakrcw at yahoo.com, estebanzimanyicw at gmail.com -Copyright (c) 2016 Rohith Reddy -Copyright (c) 2016 Andrea Nardelli -mail: nrd.nardelli at gmail.com -Copyright (c) 2015 Celia Virginia Vergara Castillo -mail: vicky at erosion.dev - ------- - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - ********************************************************************PGR-GNU*/ -/** @file - -This is a copy of pgdata_getters.h - -The old version of TRSP -- Is the only function that has its own edge reader within its code, - hence the name of the file. -- The old version of TRSP will exist during 3.x series - - -@note -- The only function that remains is `fetch_edge` -- The old version of TRSP will be removed on V4 - - @todo: TODO V4 Delete this file -*/ -#ifndef INCLUDE_C_COMMON_TRSP_PGGET_H_ -#define INCLUDE_C_COMMON_TRSP_PGGET_H_ -#pragma once - -#ifdef __cplusplus -extern "C" { -#endif -#include -#include -#include -#include -#include -#include -#include -#include -#ifdef __cplusplus -} -#endif - -#ifdef __cplusplus -#include -#include -#else -#include -#include -#include -#endif - -#include "cpp_common/undefPostgresDefine.hpp" - -#ifdef __cplusplus -using Edge_t = struct Edge_rt; -#else -typedef struct Edge_rt Edge_t; -#endif - - -#ifdef __cplusplus -extern "C" { -#endif - -/** @brief Read edges called from C file*/ -void pgr_get_edges(char*, Edge_t**, size_t*, bool, bool, char**); - -#ifdef __cplusplus -} -#endif - -#endif // INCLUDE_C_COMMON_TRSP_PGGET_H_ diff --git a/include/cpp_common/trsp_pgfetch.hpp b/include/cpp_common/trsp_pgfetch.hpp deleted file mode 100644 index 32885aaeb28..00000000000 --- a/include/cpp_common/trsp_pgfetch.hpp +++ /dev/null @@ -1,78 +0,0 @@ -/*PGR-GNU***************************************************************** -File: trsp_pgfetch.hpp - -Copyright (c) 2015 pgRouting developers -Mail: project@pgrouting.org - -Copyright (c) 2023 Celia Virginia Vergara Castillo -mail: vicky at erosion.dev -Copyright (c) 2020 Mahmoud SAKR and Esteban ZIMANYI -mail: m_attia_sakrcw at yahoo.com, estebanzimanyicw at gmail.com -Copyright (c) 2016 Rohith Reddy -Copyright (c) 2016 Andrea Nardelli -mail: nrd.nardelli at gmail.com -Copyright (c) 2015 Celia Virginia Vergara Castillo -mail: vicky at erosion.dev - ------- - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - ********************************************************************PGR-GNU*/ -/** @file -This is a copy of pgdata_fetchers.hpp - -The old version of TRSP -- Is the only function that has its own edge reader within its code, - hence the name of the file. -- The old version of TRSP will exist during 3.x series - - -@note -- The only function that remains is `fetch_edge` -- The old version of TRSP will be removed on V4 - - @todo: V4 TODO Delete this file -*/ - -#ifndef INCLUDE_CPP_COMMON_TRSP_PGFETCH_HPP_ -#define INCLUDE_CPP_COMMON_TRSP_PGFETCH_HPP_ - -/* for HeapTuple, TupleDesc */ -extern "C" { -#include -#include -} - -#include -#include - -#include "cpp_common/undefPostgresDefine.hpp" - -using Edge_t = struct Edge_rt; - -namespace pgrouting { -using Column_info_t = struct Column_info_t; - - -void fetch_edge( - const HeapTuple, const TupleDesc &, - const std::vector &, - int64_t*, Edge_t*, size_t*, bool); - - -} // namespace pgrouting - -#endif // INCLUDE_CPP_COMMON_TRSP_PGFETCH_HPP_ diff --git a/src/cpp_common/CMakeLists.txt b/src/cpp_common/CMakeLists.txt index f45cce63ba9..85dd8d47e21 100644 --- a/src/cpp_common/CMakeLists.txt +++ b/src/cpp_common/CMakeLists.txt @@ -9,9 +9,4 @@ ADD_LIBRARY(cpp_common OBJECT get_check_data.cpp pgdata_fetchers.cpp pgdata_getters.cpp - - # for old trsp code - trsp_pgfetch.cpp - # linked as C, but compiled as C++ - trsp_pgget.cpp ) diff --git a/src/cpp_common/trsp_pgfetch.cpp b/src/cpp_common/trsp_pgfetch.cpp deleted file mode 100644 index aa4a5028605..00000000000 --- a/src/cpp_common/trsp_pgfetch.cpp +++ /dev/null @@ -1,108 +0,0 @@ -/*PGR-GNU***************************************************************** -File: trsp_pgfetch.cpp - -Copyright (c) 2015 pgRouting developers -Mail: project@pgrouting.org - -Copyright (c) 2023 Celia Virginia Vergara Castillo -mail: vicky at erosion.dev -Copyright (c) 2020 Mahmoud SAKR and Esteban ZIMANYI -mail: m_attia_sakrcw at yahoo.com, estebanzimanyicw at gmail.com -Copyright (c) 2016 Rohith Reddy -Copyright (c) 2016 Andrea Nardelli -mail: nrd.nardelli at gmail.com -Copyright (c) 2015 Celia Virginia Vergara Castillo -mail: vicky at erosion.dev - - ------- - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - ********************************************************************PGR-GNU*/ -/** @file - -This is a copy of pgdata_fetchers.cpp - -The old version of TRSP -- Is the only function that has its own edge reader within its code, - hence the name of the file. -- The old version of TRSP will exist during 3.x series - - -Notes -- The only function that remains is `fetch_edge` -- The old version of TRSP will be removed on V4 - -@todo: V4 TODO Delete this file - */ - -#include "cpp_common/trsp_pgfetch.hpp" - -#include -#include -#include - -#include "cpp_common/get_check_data.hpp" - -#include "cpp_common/info_t.hpp" -#include "c_types/edge_rt.h" - - -namespace pgrouting { - -void fetch_edge( - const HeapTuple tuple, - const TupleDesc &tupdesc, - const std::vector &info, - int64_t *default_id, - Edge_t *edge, - size_t *valid_edges, - bool normal) { - if (pgrouting::column_found(info[0].colNumber)) { - edge->id = pgrouting::getBigInt(tuple, tupdesc, info[0]); - } else { - edge->id = *default_id; - ++(*default_id); - } - - if (normal) { - edge->source = pgrouting::getBigInt(tuple, tupdesc, info[1]); - edge->target = pgrouting::getBigInt(tuple, tupdesc, info[2]); - } else { - edge->target = pgrouting::getBigInt(tuple, tupdesc, info[1]); - edge->source = pgrouting::getBigInt(tuple, tupdesc, info[2]); - } - - edge->cost = pgrouting::getFloat8(tuple, tupdesc, info[3]); - - if (pgrouting::column_found(info[4].colNumber)) { - edge->reverse_cost = pgrouting::getFloat8(tuple, tupdesc, info[4]); - } else { - edge->reverse_cost = -1; - } - - edge->cost = std::isinf(edge->cost)? - DBL_MAX : edge->cost; - - edge->reverse_cost = std::isinf(edge->reverse_cost)? - DBL_MAX : edge->reverse_cost; - - *valid_edges = edge->cost < 0? *valid_edges: *valid_edges + 1; - *valid_edges = edge->reverse_cost < 0? *valid_edges: *valid_edges + 1; -} - - -} // namespace pgrouting diff --git a/src/cpp_common/trsp_pgget.cpp b/src/cpp_common/trsp_pgget.cpp deleted file mode 100644 index 1991786ba61..00000000000 --- a/src/cpp_common/trsp_pgget.cpp +++ /dev/null @@ -1,110 +0,0 @@ -/*PGR-GNU***************************************************************** -File: trsp_pgget.cpp - -Copyright (c) 2015 pgRouting developers -Mail: project@pgrouting.org - -Copyright (c) 2023 Celia Virginia Vergara Castillo -mail: vicky at erosion.dev -Copyright (c) 2020 Mahmoud SAKR and Esteban ZIMANYI -mail: m_attia_sakrcw at yahoo.com, estebanzimanyicw at gmail.com -Copyright (c) 2016 Rohith Reddy -Copyright (c) 2016 Andrea Nardelli -mail: nrd.nardelli at gmail.com -Copyright (c) 2015 Celia Virginia Vergara Castillo -mail: vicky at erosion.dev - - ------- - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - - ********************************************************************PGR-GNU*/ -/** file - -This is a copy of pgdata_getters.cpp - -The old version of TRSP -- Is the only function that has its own edge reader within its code, - hence the name of the file. -- The old version of TRSP will exist during 3.x series - - -@note -- The only function that remains is `fetch_edge` -- The old version of TRSP will be removed on V4 - - @todo: V4 TODO Delete this file -*/ - -#include "c_common/trsp_pgget.h" -#include -#include -#include -#include - -#include "cpp_common/get_data.hpp" -#include "cpp_common/get_check_data.hpp" -#include "cpp_common/alloc.hpp" -#include "cpp_common/trsp_pgfetch.hpp" - -#include "cpp_common/info_t.hpp" -#include "c_types/edge_rt.h" - - -/** - For queries of the type: - ~~~~{.c} - SELECT id, source, target, cost, [reverse_cost] FROM edge_table; - ~~~~ - - @param[in] sql The query - @param[out] rows the edges array - @param[out] total_rows size of edges - @param[in] normal when false then the graph is reversed - @param[in] ignore_id when true id value of edge is ignored - @param[out] err_msg when not null, there was an error and contains the message - */ -void -pgr_get_edges( - char *sql, - Edge_t **rows, - size_t *total_rows, - bool normal, - bool ignore_id, - char **err_msg) { - using pgrouting::to_pg_msg; - using pgrouting::pgr_free; - using pgrouting::Column_info_t; - try { - std::vector info{ - {-1, 0, !ignore_id, "id", pgrouting::ANY_INTEGER}, - {-1, 0, true, "source", pgrouting::ANY_INTEGER}, - {-1, 0, true, "target", pgrouting::ANY_INTEGER}, - {-1, 0, true, "cost", pgrouting::ANY_NUMERICAL}, - {-1, 0, false, "reverse_cost", pgrouting::ANY_NUMERICAL}}; - - pgrouting::get_data(sql, rows, total_rows, normal, info, &pgrouting::fetch_edge); - } catch (const std::string &ex) { - (*rows) = pgr_free(*rows); - (*total_rows) = 0; - *err_msg = to_pg_msg(ex); - } catch(...) { - (*rows) = pgr_free(*rows); - (*total_rows) = 0; - *err_msg = to_pg_msg("Caught unknown exception!"); - } -} -