| 6 | |
| 7 | namespace generative::io { |
| 8 | class TGFGraphReader : public GraphReader |
| 9 | { |
| 10 | public: |
| 11 | TGFGraphReader(std::istream& input, const geos::geom::GeometryFactory& factory) : |
| 12 | GraphReader(input, factory) |
| 13 | { |
| 14 | } |
| 15 | |
| 16 | generative::noding::GeometryGraph read() noexcept override; |
| 17 | void read(const std::string& line) noexcept override; |
| 18 | |
| 19 | private: |
| 20 | std::list<generative::noding::GeometryGraph::Node> m_nodes_list; |
| 21 | std::vector<generative::noding::GeometryGraph::Node> m_nodes_vec; |
| 22 | //! @brief Indicates whether the reader is reading the nodes or the edges. |
| 23 | //! In the TGF format, there's a group of lines for the nodes, and a group of lines for the |
| 24 | //! edges, separated by a line with a single '#'. |
| 25 | bool m_reading_nodes = true; |
| 26 | |
| 27 | //! @brief Interpret the given line as a node. |
| 28 | //! @details A node has the format |
| 29 | //! @code |
| 30 | //! <id>[<whitespace><label>] |
| 31 | //! @endcode |
| 32 | //! where the ID is a numeric index into the array of all nodes, and the label is a WKT POINT or |
| 33 | //! POINT Z. |
| 34 | //! @warning The label is optional for any given TGF graph, but for our purposes, if the label |
| 35 | //! is missing, or cannot be parsed as a WKT POINT or POINT Z, the node will not be added. |
| 36 | //! @todo If the node is skipped, we need to ignore that node when adding edges... |
| 37 | void read_node(const std::string& line) noexcept; |
| 38 | |
| 39 | //! @brief Interpret the given line as an edge. |
| 40 | //! @details An edge has the format |
| 41 | //! @code |
| 42 | //! <id><whitespace><id>[<whitespace><label>] |
| 43 | //! @endcode |
| 44 | //! For our purposes, the IDs are numeric indices into the array of nodes, and the label will be |
| 45 | //! ignored. |
| 46 | void read_edge(const std::string& line) noexcept; |
| 47 | }; |
| 48 | } // namespace generative::io |
nothing calls this directly
no outgoing calls
no test coverage detected