Class GeoJsonGraphFileLoader

Inheritance Relationships

Base Type

Class Documentation

class GeoJsonGraphFileLoader : public nav2_route::GraphFileLoader

A GraphFileLoader plugin to load a geojson graph representation.

Public Types

using Json = nlohmann::json

Public Functions

GeoJsonGraphFileLoader() = default

Constructor.

~GeoJsonGraphFileLoader() = default

Destructor.

virtual void configure(const rclcpp_lifecycle::LifecycleNode::SharedPtr node) override

Configure, but do not store the node.

Parameters:

parent – pointer to user’s node

virtual bool loadGraphFromFile(Graph &graph, GraphToIDMap &graph_to_id_map, std::string filepath) override

Loads the geojson file into the graph.

Parameters:
  • graph – The graph to be populated by the geojson file

  • graph_to_id_map – A map of node id’s to the graph index

  • filepath – The path of the file to load

Returns:

True if the graph was successfully loaded

Protected Functions

bool doesFileExist(const std::string &filepath)

Checks if a file even exists on the filesystem.

Parameters:

filepath – The filepath to be checked

Returns:

True if the file path provided exists

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

Get the nodes and edges from features.

Parameters:
  • features[in] The features that contain the nodes and edges

  • nodes[out] The nodes found within the features

  • edges[out] The edges found within the features

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

Add nodes into the graph.

Parameters:
  • graph[out] The graph that will contain the new nodes

  • graph_to_id_map[out] A map of node id to the graph index

  • nodes[in] The nodes to be added into the graph

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

Add edges into the graph.

Parameters:
  • graph[out] The graph that will contain the new edges

  • graph_to_id_map[in] A map of node id to the graph id

  • edges[in] The edges to be added into the graph

Coordinates convertCoordinatesFromJson(const Json &node)

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

Parameters:

node – The json object that holds the coordinate data

Returns:

The coordinates found in the json object

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

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

Parameters:
  • properties – The json object that holds the metadata

  • key – The key for the metadata

Returns:

The converted metadata

Operation convertOperationFromJson(const Json &json_operation)

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

Parameters:

json_operation – The json object that holds the operation data

Returns:

The converted operation data

Operations convertOperationsFromJson(const Json &properties)

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

Parameters:

properties – The json object that holds the operations data

Returns:

Operations The converted operations data

EdgeCost convertEdgeCostFromJson(const Json &properties)

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

Parameters:

properties – The json object that holds the edge cost data

Returns:

EdgeCost The converted edge cost data

Protected Attributes

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