From 24dc1f60e2a4e93a8d47881c9fdeb1c0eb21d9b2 Mon Sep 17 00:00:00 2001 From: Artem Pavlenko Date: Tue, 12 Jun 2012 13:56:39 +0100 Subject: [PATCH] + fix GeoJSON output in metawriter_json (FIXME: output proper geometry types - don't shortcut to Multi***) --- include/mapnik/metawriter_json.hpp | 43 +++++++++++++----------------- 1 file changed, 18 insertions(+), 25 deletions(-) diff --git a/include/mapnik/metawriter_json.hpp b/include/mapnik/metawriter_json.hpp index 35a80cd6d..5695a451d 100644 --- a/include/mapnik/metawriter_json.hpp +++ b/include/mapnik/metawriter_json.hpp @@ -62,30 +62,29 @@ public: metawriter_properties const& properties) { write_feature_header("MultiLineString"); - *f_ << " ["; - double x, y, last_x=0.0, last_y=0.0; - unsigned cmd, last_cmd = SEG_END; - path.rewind(0); - - int polygon_count = 0; - while ((cmd = path.vertex(&x, &y)) != SEG_END) { - if (cmd == SEG_LINETO) { - if (last_cmd == SEG_MOVETO) { - //Start new polygon/line - if (polygon_count++) *f_ << "], "; - *f_ << "["; - write_point(t, last_x, last_y, true); - } + + path.rewind(0); + double x, y; + unsigned cmd; + int ring_count = 0; + while ((cmd = path.vertex(&x, &y)) != SEG_END) + { + if (cmd == SEG_MOVETO) + { + if (ring_count++ != 0) *f_ << "], "; + *f_ << "["; + write_point(t, x, y, true); + } + else if (cmd == SEG_LINETO) + { *f_ << ","; write_point(t, x, y, true); } - last_x = x; - last_y = y; - last_cmd = cmd; } - *f_ << "]]"; - + if (ring_count != 0) *f_ << "]"; + *f_ << "]"; + write_properties(feature, properties); } @@ -142,12 +141,6 @@ protected: } } - template - void write_line_polygon(T & path, CoordTransform const& t, bool polygon); - - - - private: std::ostream *f_; };