polygon_type create_polygon(const osmium::WayNodeList& wnl, use_nodes un = use_nodes::unique, direction dir = direction::forward) { polygon_start(); size_t num_points = 0; if (un == use_nodes::unique) { osmium::Location last_location; switch (dir) { case direction::forward: num_points = fill_polygon_unique(wnl.cbegin(), wnl.cend()); break; case direction::backward: num_points = fill_polygon_unique(wnl.crbegin(), wnl.crend()); break; } } else { switch (dir) { case direction::forward: num_points = fill_polygon(wnl.cbegin(), wnl.cend()); break; case direction::backward: num_points = fill_polygon(wnl.crbegin(), wnl.crend()); break; } } if (num_points < 4) { throw osmium::geometry_error{"need at least four points for polygon"}; } return polygon_finish(num_points); }
linestring_type create_linestring(const osmium::WayNodeList& wnl, use_nodes un = use_nodes::unique, direction dir = direction::forward) { linestring_start(); size_t num_points = 0; if (un == use_nodes::unique) { osmium::Location last_location; switch (dir) { case direction::forward: num_points = fill_linestring_unique(wnl.cbegin(), wnl.cend()); break; case direction::backward: num_points = fill_linestring_unique(wnl.crbegin(), wnl.crend()); break; } } else { switch (dir) { case direction::forward: num_points = fill_linestring(wnl.cbegin(), wnl.cend()); break; case direction::backward: num_points = fill_linestring(wnl.crbegin(), wnl.crend()); break; } } if (num_points < 2) { throw osmium::geometry_error("not enough points for linestring"); } return linestring_finish(num_points); }