Returns the second endpoint in a segment to be used as a hexagon's vertex
| 51 | |
| 52 | // Returns the second endpoint in a segment to be used as a hexagon's vertex |
| 53 | Point H3Grid::findPoint(Segment& s) |
| 54 | { |
| 55 | DirEdge dir_edge; |
| 56 | if (PDALH3cellsToDirectedEdge(ij2h3(s.hex), ij2h3(edgeHex(s.hex, s.edge)), &dir_edge) != E_SUCCESS) { |
| 57 | std::ostringstream oss; |
| 58 | oss << "Can't get directed edge between hexagons (" << s.hex.i << |
| 59 | ", " << s.hex.j <<") and (" << edgeHex(s.hex, s.edge).i <<", " << |
| 60 | edgeHex(s.hex, s.edge).j << ")."; |
| 61 | throw hexer_error(oss.str()); |
| 62 | } |
| 63 | |
| 64 | CellBoundary edge_bound; |
| 65 | |
| 66 | if (PDALH3directedEdgeToBoundary(dir_edge, &edge_bound) != E_SUCCESS) |
| 67 | throw hexer_error("unable to get cell boundary from directed edge!"); |
| 68 | double x = PDALH3radsToDegs(edge_bound.verts[1].lng); |
| 69 | double y = PDALH3radsToDegs(edge_bound.verts[1].lat); |
| 70 | |
| 71 | return Point{x, y}; |
| 72 | } |
| 73 | |
| 74 | HexId H3Grid::edgeHex(HexId hex, int edge) const |
| 75 | { |
no test coverage detected