WKT (or GeoJSON) doesn't allow nesting of polygons. You can just have polygons and holes. Islands within the holes need to be described as separate polygons. To that end, we gather the islands from all holes and return them to be processed as separate polygons.
| 29 | // separate polygons. To that end, we gather the islands from all holes |
| 30 | // and return them to be processed as separate polygons. |
| 31 | std::vector<Path *> Path::writePolygon(std::ostream& out) const |
| 32 | { |
| 33 | std::vector<Path *> islands; |
| 34 | |
| 35 | out << "("; |
| 36 | writeRing(out); |
| 37 | const std::vector<Path *>& paths = subPaths(); |
| 38 | for (auto& p : paths) |
| 39 | { |
| 40 | out << ", "; |
| 41 | p->writeRing(out); |
| 42 | const std::vector<Path *>& subs(p->subPaths()); |
| 43 | islands.insert(islands.end(), subs.begin(), subs.end()); |
| 44 | } |
| 45 | out << ")"; |
| 46 | |
| 47 | return islands; |
| 48 | } |
| 49 | |
| 50 | void Path::toWKT(std::ostream& output) const |
| 51 | { |