+ fix GeoJSON output in metawriter_json

(FIXME: output proper geometry types - don't shortcut to Multi***)
This commit is contained in:
Artem Pavlenko 2012-06-12 13:56:39 +01:00
parent e22b422455
commit 24dc1f60e2

View file

@ -62,29 +62,28 @@ public:
metawriter_properties const& properties) metawriter_properties const& properties)
{ {
write_feature_header("MultiLineString"); write_feature_header("MultiLineString");
*f_ << " ["; *f_ << " [";
double x, y, last_x=0.0, last_y=0.0;
unsigned cmd, last_cmd = SEG_END;
path.rewind(0); path.rewind(0);
double x, y;
int polygon_count = 0; unsigned cmd;
while ((cmd = path.vertex(&x, &y)) != SEG_END) { int ring_count = 0;
if (cmd == SEG_LINETO) { while ((cmd = path.vertex(&x, &y)) != SEG_END)
if (last_cmd == SEG_MOVETO) { {
//Start new polygon/line if (cmd == SEG_MOVETO)
if (polygon_count++) *f_ << "], "; {
if (ring_count++ != 0) *f_ << "], ";
*f_ << "["; *f_ << "[";
write_point(t, last_x, last_y, true); write_point(t, x, y, true);
} }
else if (cmd == SEG_LINETO)
{
*f_ << ","; *f_ << ",";
write_point(t, x, y, true); 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); write_properties(feature, properties);
} }
@ -142,12 +141,6 @@ protected:
} }
} }
template <typename T>
void write_line_polygon(T & path, CoordTransform const& t, bool polygon);
private: private:
std::ostream *f_; std::ostream *f_;
}; };