Nav2 Navigation Stack - rolling  main
ROS 2 Navigation Stack
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
nav2_route::GeoJsonGraphFileSaver Class Reference

A GraphFileSaver plugin to save a geojson graph representation. More...

#include <nav2_route/include/nav2_route/plugins/graph_file_savers/geojson_graph_file_saver.hpp>

Inheritance diagram for nav2_route::GeoJsonGraphFileSaver:
Inheritance graph
[legend]
Collaboration diagram for nav2_route::GeoJsonGraphFileSaver:
Collaboration graph
[legend]

Public Types

using Json = nlohmann::json
 
- Public Types inherited from nav2_route::GraphFileSaver
using Ptr = std::shared_ptr< GraphFileSaver >
 

Public Member Functions

 GeoJsonGraphFileSaver ()=default
 Constructor.
 
 ~GeoJsonGraphFileSaver ()=default
 Destructor.
 
void configure (const nav2::LifecycleNode::SharedPtr node) override
 Configure, but do not store the node. More...
 
bool saveGraphToFile (Graph &graph, std::string filepath) override
 Saves the graph to a geojson file. More...
 
- Public Member Functions inherited from nav2_route::GraphFileSaver
 GraphFileSaver ()=default
 Constructor.
 
virtual ~GraphFileSaver ()=default
 Virtual destructor.
 

Protected Member Functions

void loadNodesFromGraph (Graph &graph, std::vector< Json > &json_features)
 Add nodes into the graph. More...
 
void loadEdgesFromGraph (Graph &graph, std::vector< Json > &json_edges)
 Add edges into the graph. More...
 
void convertMetaDataToJson (const Metadata &metadata, Json &json_metadata)
 Convert graph metadata to Json. More...
 
void convertOperationsToJson (const Operations &operations, Json &json_operations)
 Convert graph operation to Json. More...
 

Protected Attributes

rclcpp::Logger logger_ {rclcpp::get_logger("GeoJsonGraphFileSaver")}
 

Detailed Description

A GraphFileSaver plugin to save a geojson graph representation.

Definition at line 35 of file geojson_graph_file_saver.hpp.

Member Function Documentation

◆ configure()

void nav2_route::GeoJsonGraphFileSaver::configure ( const nav2::LifecycleNode::SharedPtr  node)
overridevirtual

Configure, but do not store the node.

Parameters
parentpointer to user's node

Implements nav2_route::GraphFileSaver.

Definition at line 25 of file geojson_graph_file_saver.cpp.

◆ convertMetaDataToJson()

void nav2_route::GeoJsonGraphFileSaver::convertMetaDataToJson ( const Metadata metadata,
Json &  json_metadata 
)
protected

Convert graph metadata to Json.

Parameters
metadataMetadata from a node or edge in the graph
json_metadataJson entry to store metadata in

Definition at line 116 of file geojson_graph_file_saver.cpp.

Referenced by convertOperationsToJson(), loadEdgesFromGraph(), and loadNodesFromGraph().

Here is the caller graph for this function:

◆ convertOperationsToJson()

void nav2_route::GeoJsonGraphFileSaver::convertOperationsToJson ( const Operations &  operations,
Json &  json_operations 
)
protected

Convert graph operation to Json.

Parameters
OperationsOperations information from the graph
json_operationsJson entry to store operation data in

Definition at line 160 of file geojson_graph_file_saver.cpp.

References convertMetaDataToJson().

Referenced by loadEdgesFromGraph(), and loadNodesFromGraph().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ loadEdgesFromGraph()

void nav2_route::GeoJsonGraphFileSaver::loadEdgesFromGraph ( Graph &  graph,
std::vector< Json > &  json_edges 
)
protected

Add edges into the graph.

Parameters
[out]graphThe graph that will contain the new edges
[in]json_edgesJson array to add the edges to

Definition at line 88 of file geojson_graph_file_saver.cpp.

References convertMetaDataToJson(), and convertOperationsToJson().

Referenced by saveGraphToFile().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ loadNodesFromGraph()

void nav2_route::GeoJsonGraphFileSaver::loadNodesFromGraph ( Graph &  graph,
std::vector< Json > &  json_features 
)
protected

Add nodes into the graph.

Parameters
[out]graphThe graph that will contain the new nodes
[in]json_featuresJson array to add the nodes to

Definition at line 61 of file geojson_graph_file_saver.cpp.

References convertMetaDataToJson(), and convertOperationsToJson().

Referenced by saveGraphToFile().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ saveGraphToFile()

bool nav2_route::GeoJsonGraphFileSaver::saveGraphToFile ( Graph &  graph,
std::string  filepath 
)
overridevirtual

Saves the graph to a geojson file.

Parameters
graphThe graph to save to the geojson file
filepathThe path to save the graph to
Returns
True if successful

Implements nav2_route::GraphFileSaver.

Definition at line 32 of file geojson_graph_file_saver.cpp.

References loadEdgesFromGraph(), and loadNodesFromGraph().

Here is the call graph for this function:

The documentation for this class was generated from the following files: