Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

+ fix GeoJSON output in metawriter_json

  (FIXME: output proper geometry types - don't shortcut to Multi***)
  • Loading branch information...
commit 24dc1f60e2a4e93a8d47881c9fdeb1c0eb21d9b2 1 parent e22b422
@artemp artemp authored
Showing with 18 additions and 25 deletions.
  1. +18 −25 include/mapnik/metawriter_json.hpp
View
43 include/mapnik/metawriter_json.hpp
@@ -62,30 +62,29 @@ class metawriter_json_stream : public metawriter_base,
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 @@ class metawriter_json_stream : public metawriter_base,
}
}
- template <typename T>
- void write_line_polygon(T & path, CoordTransform const& t, bool polygon);
-
-
-
-
private:
std::ostream *f_;
};
Please sign in to comment.
Something went wrong with that request. Please try again.