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::GeoJsonGraphFileLoader Class Reference

A GraphFileLoader plugin to load a geojson graph representation. More...

#include <nav2_route/include/nav2_route/plugins/graph_file_loaders/geojson_graph_file_loader.hpp>

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

Public Types

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

Public Member Functions

 GeoJsonGraphFileLoader ()=default
 Constructor.
 
 ~GeoJsonGraphFileLoader ()=default
 Destructor.
 
void configure (const nav2::LifecycleNode::SharedPtr node) override
 Configure, but do not store the node. More...
 
bool loadGraphFromFile (Graph &graph, GraphToIDMap &graph_to_id_map, std::string filepath) override
 Loads the geojson file into the graph. More...
 
- Public Member Functions inherited from nav2_route::GraphFileLoader
 GraphFileLoader ()=default
 Constructor.
 
virtual ~GraphFileLoader ()=default
 Virtual destructor.
 

Protected Member Functions

bool doesFileExist (const std::string &filepath)
 Checks if a file even exists on the filesystem. More...
 
void getGraphElements (const Json &features, std::vector< Json > &nodes, std::vector< Json > &edges)
 Get the nodes and edges from features. More...
 
void addNodesToGraph (Graph &graph, GraphToIDMap &graph_to_id_map, std::vector< Json > &nodes)
 Add nodes into the graph. More...
 
void addEdgesToGraph (Graph &graph, GraphToIDMap &graph_to_id_map, std::vector< Json > &edges)
 Add edges into the graph. More...
 
Coordinates convertCoordinatesFromJson (const Json &node)
 Converts the coordinates from the json object into the Coordinates type. More...
 
Metadata convertMetaDataFromJson (const Json &properties, const std::string &key="metadata")
 Converts the metadata from the json object into the metadata type. More...
 
Operation convertOperationFromJson (const Json &json_operation)
 Converts the operation from the json object into the operation type. More...
 
Operations convertOperationsFromJson (const Json &properties)
 Converts the operations data from the json object into the operations type if present. More...
 
EdgeCost convertEdgeCostFromJson (const Json &properties)
 Converts the edge cost data from the json object into the edge cost type. More...
 

Protected Attributes

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

Detailed Description

A GraphFileLoader plugin to load a geojson graph representation.

Definition at line 34 of file geojson_graph_file_loader.hpp.

Member Function Documentation

◆ addEdgesToGraph()

void nav2_route::GeoJsonGraphFileLoader::addEdgesToGraph ( Graph &  graph,
GraphToIDMap &  graph_to_id_map,
std::vector< Json > &  edges 
)
protected

Add edges into the graph.

Parameters
[out]graphThe graph that will contain the new edges
[in]graph_to_id_mapA map of node id to the graph id
[in]edgesThe edges to be added into the graph

Definition at line 102 of file geojson_graph_file_loader.cpp.

References convertEdgeCostFromJson(), convertMetaDataFromJson(), and convertOperationsFromJson().

Referenced by loadGraphFromFile().

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

◆ addNodesToGraph()

void nav2_route::GeoJsonGraphFileLoader::addNodesToGraph ( Graph &  graph,
GraphToIDMap &  graph_to_id_map,
std::vector< Json > &  nodes 
)
protected

Add nodes into the graph.

Parameters
[out]graphThe graph that will contain the new nodes
[out]graph_to_id_mapA map of node id to the graph index
[in]nodesThe nodes to be added into the graph

Definition at line 87 of file geojson_graph_file_loader.cpp.

References convertCoordinatesFromJson(), convertMetaDataFromJson(), and convertOperationsFromJson().

Referenced by loadGraphFromFile().

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

◆ configure()

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

Configure, but do not store the node.

Parameters
parentpointer to user's node

Implements nav2_route::GraphFileLoader.

Definition at line 25 of file geojson_graph_file_loader.cpp.

◆ convertCoordinatesFromJson()

Coordinates nav2_route::GeoJsonGraphFileLoader::convertCoordinatesFromJson ( const Json &  node)
protected

Converts the coordinates from the json object into the Coordinates type.

Parameters
nodeThe json object that holds the coordinate data
Returns
The coordinates found in the json object

Definition at line 132 of file geojson_graph_file_loader.cpp.

Referenced by addNodesToGraph().

Here is the caller graph for this function:

◆ convertEdgeCostFromJson()

EdgeCost nav2_route::GeoJsonGraphFileLoader::convertEdgeCostFromJson ( const Json &  properties)
protected

Converts the edge cost data from the json object into the edge cost type.

Parameters
propertiesThe json object that holds the edge cost data
Returns
EdgeCost The converted edge cost data

Definition at line 225 of file geojson_graph_file_loader.cpp.

Referenced by addEdgesToGraph().

Here is the caller graph for this function:

◆ convertMetaDataFromJson()

Metadata nav2_route::GeoJsonGraphFileLoader::convertMetaDataFromJson ( const Json &  properties,
const std::string &  key = "metadata" 
)
protected

Converts the metadata from the json object into the metadata type.

Parameters
propertiesThe json object that holds the metadata
keyThe key for the metadata
Returns
The converted metadata

Definition at line 147 of file geojson_graph_file_loader.cpp.

Referenced by addEdgesToGraph(), addNodesToGraph(), and convertOperationFromJson().

Here is the caller graph for this function:

◆ convertOperationFromJson()

Operation nav2_route::GeoJsonGraphFileLoader::convertOperationFromJson ( const Json &  json_operation)
protected

Converts the operation from the json object into the operation type.

Parameters
json_operationThe json object that holds the operation data
Returns
The converted operation data

Definition at line 202 of file geojson_graph_file_loader.cpp.

References convertMetaDataFromJson().

Referenced by convertOperationsFromJson().

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

◆ convertOperationsFromJson()

Operations nav2_route::GeoJsonGraphFileLoader::convertOperationsFromJson ( const Json &  properties)
protected

Converts the operations data from the json object into the operations type if present.

Parameters
propertiesThe json object that holds the operations data
Returns
Operations The converted operations data

Definition at line 214 of file geojson_graph_file_loader.cpp.

References convertOperationFromJson().

Referenced by addEdgesToGraph(), and addNodesToGraph().

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

◆ doesFileExist()

bool nav2_route::GeoJsonGraphFileLoader::doesFileExist ( const std::string &  filepath)
protected

Checks if a file even exists on the filesystem.

Parameters
filepathThe filepath to be checked
Returns
True if the file path provided exists

Definition at line 67 of file geojson_graph_file_loader.cpp.

Referenced by loadGraphFromFile().

Here is the caller graph for this function:

◆ getGraphElements()

void nav2_route::GeoJsonGraphFileLoader::getGraphElements ( const Json &  features,
std::vector< Json > &  nodes,
std::vector< Json > &  edges 
)
protected

Get the nodes and edges from features.

Parameters
[in]featuresThe features that contain the nodes and edges
[out]nodesThe nodes found within the features
[out]edgesThe edges found within the features

Definition at line 72 of file geojson_graph_file_loader.cpp.

Referenced by loadGraphFromFile().

Here is the caller graph for this function:

◆ loadGraphFromFile()

bool nav2_route::GeoJsonGraphFileLoader::loadGraphFromFile ( Graph &  graph,
GraphToIDMap &  graph_to_id_map,
std::string  filepath 
)
overridevirtual

Loads the geojson file into the graph.

Parameters
graphThe graph to be populated by the geojson file
graph_to_id_mapA map of node id's to the graph index
filepathThe path of the file to load
Returns
True if the graph was successfully loaded

Implements nav2_route::GraphFileLoader.

Definition at line 32 of file geojson_graph_file_loader.cpp.

References addEdgesToGraph(), addNodesToGraph(), doesFileExist(), and getGraphElements().

Here is the call graph for this function:

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