Loading src/db/SubmarineCable.cpp +3 −2 Original line number Diff line number Diff line Loading @@ -40,7 +40,7 @@ SubmarineCable::SubmarineCable(std::string dbPath) { BOOST_LOG_TRIVIAL(error) << "Database connection failed in SubmarineCable!"; } std::string queryString = "SELECT lat1, lon1, lat2, lon2 FROM submarinecable_edges"; std::string queryString = "SELECT lat1, lon1, lat2, lon2, link_id FROM submarinecable_edges"; sqlite3_prepare_v2(_sqliteDB, queryString.c_str(), queryString.length(), &_stmt, NULL); retval = sqlite3_step(_stmt); Loading @@ -55,6 +55,7 @@ SubmarineCableEdge SubmarineCable::getNext() { double lon1 = sqlite3_column_double(_stmt, 1); double lat2 = sqlite3_column_double(_stmt, 2); double lon2 = sqlite3_column_double(_stmt, 3); int linkID = sqlite3_column_int(_stmt, 4); int retval = sqlite3_step(_stmt); if (retval == SQLITE_ROW) Loading @@ -62,7 +63,7 @@ SubmarineCableEdge SubmarineCable::getNext() { else _rowAvailable = false; SubmarineCableEdge edge(std::make_pair(lat1, lon1), std::make_pair(lat2, lon2)); SubmarineCableEdge edge(std::make_pair(lat1, lon1), std::make_pair(lat2, lon2), linkID); return edge; } src/db/SubmarineCable.hpp +3 −1 Original line number Diff line number Diff line Loading @@ -39,7 +39,9 @@ struct SubmarineCableEdge { GeographicPositionTuple coord1; GeographicPositionTuple coord2; SubmarineCableEdge(GeographicPositionTuple c1, GeographicPositionTuple c2) : coord1(c1), coord2(c2) {} int linkID; SubmarineCableEdge(GeographicPositionTuple c1, GeographicPositionTuple c2, int lID) : coord1(c1), coord2(c2), linkID(lID) {} }; class SubmarineCable : public SQLiteReader, public ResultIterator<SubmarineCableEdge> { Loading src/topo/Graph.hpp +1 −0 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ #define GRAPH_HPP #include <lemon/list_graph.h> #include <memory> #include <list> Loading src/topo/base_topo/NodeImporter.cpp +41 −0 Original line number Diff line number Diff line Loading @@ -214,13 +214,51 @@ void NodeImporter::importSubmarineCableEdges(BaseTopology_Ptr base_topo) { std::unique_ptr<SubmarineCable> sc(new SubmarineCable(_dbFilename)); unsigned int skipped = 0; int lastLinkID = -1; GeographicPositionTuple posFirst; GeographicPositionTuple posLast; std::vector<GeographicNode_Ptr> edgePositions; while (sc->hasNext()) { SubmarineCableEdge edge = sc->getNext(); if (edge.coord1 == edge.coord2) { ++skipped; continue; } if(edge.linkID != lastLinkID) { for(GeographicNode_Ptr n1 : edgePositions) { bool n1OK = fabs(fabs(n1->lon()) - 180.0) < 1.0; for(GeographicNode_Ptr n2 : edgePositions) { if(n1 == n2 || n2->id() < n1->id()) continue; bool n2OK = fabs(fabs(n2->lon()) - 180.0) < 1.0; if(n1OK && n2OK && GeometricHelpers::sphericalDistToKM(GeometricHelpers::sphericalDist(n1, n2)) < 4) { Graph::Node u; Graph::Node v; u = base_topo->getGraph()->nodeFromId(n1->id()); v = base_topo->getGraph()->nodeFromId(n2->id()); if(lemon::findEdge(*base_topo->getGraph(), u, v) != lemon::INVALID) continue; GeographicEdge_Ptr edge_ptr(new SeaCableEdge); assert(u != v); base_topo->addEdge(u, v, edge_ptr); BOOST_LOG_TRIVIAL(info) << "Add extra edge on link:" << edge.linkID << " (" << n1->id() << "," << n2->id() << ")"; } } } edgePositions.clear(); lastLinkID = edge.linkID; } GeographicPositionTuple c1 = std::make_pair(edge.coord1.first, edge.coord1.second); GeographicPositionTuple c2 = std::make_pair(edge.coord2.first, edge.coord2.second); Loading @@ -239,6 +277,9 @@ void NodeImporter::importSubmarineCableEdges(BaseTopology_Ptr base_topo) { GeographicNode_Ptr n1 = findNearest(c1N); GeographicNode_Ptr n2 = findNearest(c2N); edgePositions.push_back(n1); edgePositions.push_back(n2); Graph::Node u; Graph::Node v; Loading Loading
src/db/SubmarineCable.cpp +3 −2 Original line number Diff line number Diff line Loading @@ -40,7 +40,7 @@ SubmarineCable::SubmarineCable(std::string dbPath) { BOOST_LOG_TRIVIAL(error) << "Database connection failed in SubmarineCable!"; } std::string queryString = "SELECT lat1, lon1, lat2, lon2 FROM submarinecable_edges"; std::string queryString = "SELECT lat1, lon1, lat2, lon2, link_id FROM submarinecable_edges"; sqlite3_prepare_v2(_sqliteDB, queryString.c_str(), queryString.length(), &_stmt, NULL); retval = sqlite3_step(_stmt); Loading @@ -55,6 +55,7 @@ SubmarineCableEdge SubmarineCable::getNext() { double lon1 = sqlite3_column_double(_stmt, 1); double lat2 = sqlite3_column_double(_stmt, 2); double lon2 = sqlite3_column_double(_stmt, 3); int linkID = sqlite3_column_int(_stmt, 4); int retval = sqlite3_step(_stmt); if (retval == SQLITE_ROW) Loading @@ -62,7 +63,7 @@ SubmarineCableEdge SubmarineCable::getNext() { else _rowAvailable = false; SubmarineCableEdge edge(std::make_pair(lat1, lon1), std::make_pair(lat2, lon2)); SubmarineCableEdge edge(std::make_pair(lat1, lon1), std::make_pair(lat2, lon2), linkID); return edge; }
src/db/SubmarineCable.hpp +3 −1 Original line number Diff line number Diff line Loading @@ -39,7 +39,9 @@ struct SubmarineCableEdge { GeographicPositionTuple coord1; GeographicPositionTuple coord2; SubmarineCableEdge(GeographicPositionTuple c1, GeographicPositionTuple c2) : coord1(c1), coord2(c2) {} int linkID; SubmarineCableEdge(GeographicPositionTuple c1, GeographicPositionTuple c2, int lID) : coord1(c1), coord2(c2), linkID(lID) {} }; class SubmarineCable : public SQLiteReader, public ResultIterator<SubmarineCableEdge> { Loading
src/topo/Graph.hpp +1 −0 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ #define GRAPH_HPP #include <lemon/list_graph.h> #include <memory> #include <list> Loading
src/topo/base_topo/NodeImporter.cpp +41 −0 Original line number Diff line number Diff line Loading @@ -214,13 +214,51 @@ void NodeImporter::importSubmarineCableEdges(BaseTopology_Ptr base_topo) { std::unique_ptr<SubmarineCable> sc(new SubmarineCable(_dbFilename)); unsigned int skipped = 0; int lastLinkID = -1; GeographicPositionTuple posFirst; GeographicPositionTuple posLast; std::vector<GeographicNode_Ptr> edgePositions; while (sc->hasNext()) { SubmarineCableEdge edge = sc->getNext(); if (edge.coord1 == edge.coord2) { ++skipped; continue; } if(edge.linkID != lastLinkID) { for(GeographicNode_Ptr n1 : edgePositions) { bool n1OK = fabs(fabs(n1->lon()) - 180.0) < 1.0; for(GeographicNode_Ptr n2 : edgePositions) { if(n1 == n2 || n2->id() < n1->id()) continue; bool n2OK = fabs(fabs(n2->lon()) - 180.0) < 1.0; if(n1OK && n2OK && GeometricHelpers::sphericalDistToKM(GeometricHelpers::sphericalDist(n1, n2)) < 4) { Graph::Node u; Graph::Node v; u = base_topo->getGraph()->nodeFromId(n1->id()); v = base_topo->getGraph()->nodeFromId(n2->id()); if(lemon::findEdge(*base_topo->getGraph(), u, v) != lemon::INVALID) continue; GeographicEdge_Ptr edge_ptr(new SeaCableEdge); assert(u != v); base_topo->addEdge(u, v, edge_ptr); BOOST_LOG_TRIVIAL(info) << "Add extra edge on link:" << edge.linkID << " (" << n1->id() << "," << n2->id() << ")"; } } } edgePositions.clear(); lastLinkID = edge.linkID; } GeographicPositionTuple c1 = std::make_pair(edge.coord1.first, edge.coord1.second); GeographicPositionTuple c2 = std::make_pair(edge.coord2.first, edge.coord2.second); Loading @@ -239,6 +277,9 @@ void NodeImporter::importSubmarineCableEdges(BaseTopology_Ptr base_topo) { GeographicNode_Ptr n1 = findNearest(c1N); GeographicNode_Ptr n2 = findNearest(c2N); edgePositions.push_back(n1); edgePositions.push_back(n2); Graph::Node u; Graph::Node v; Loading