mirror of
https://github.com/mapnik/mapnik.git
synced 2026-02-01 17:36:36 +00:00
Metawriter support for LineSymbolizer and LinePatternSymbolizer
This commit is contained in:
parent
fb4baa4fcf
commit
7fea0f7a6c
@ -93,6 +93,10 @@ class metawriter
|
||||
Feature const& feature,
|
||||
CoordTransform const& t,
|
||||
metawriter_properties const& properties)=0;
|
||||
virtual void add_line(path_type & path,
|
||||
Feature const& feature,
|
||||
CoordTransform const& t,
|
||||
metawriter_properties const& properties)=0;
|
||||
|
||||
/** Start processing.
|
||||
* Write file header, init database connection, ...
|
||||
|
||||
@ -52,6 +52,10 @@ public:
|
||||
Feature const& feature,
|
||||
CoordTransform const& t,
|
||||
metawriter_properties const& properties);
|
||||
virtual void add_line(path_type & path,
|
||||
Feature const& feature,
|
||||
CoordTransform const& t,
|
||||
metawriter_properties const& properties);
|
||||
|
||||
virtual void start(metawriter_property_map const& properties);
|
||||
virtual void stop();
|
||||
@ -100,6 +104,7 @@ protected:
|
||||
*f_ << ",";
|
||||
}
|
||||
}
|
||||
void write_line_polygon(path_type & path, CoordTransform const& t, bool polygon);
|
||||
|
||||
private:
|
||||
std::ostream *f_;
|
||||
|
||||
@ -69,7 +69,7 @@ void agg_renderer<T>::process(line_pattern_symbolizer const& sym,
|
||||
renderer_type ren(ren_base, pattern);
|
||||
ren.clip_box(0,0,width_,height_);
|
||||
rasterizer_type ras(ren);
|
||||
|
||||
metawriter_with_properties writer = sym.get_metawriter();
|
||||
for (unsigned i=0;i<feature.num_geometries();++i)
|
||||
{
|
||||
geometry2d const& geom = feature.get_geometry(i);
|
||||
@ -77,6 +77,7 @@ void agg_renderer<T>::process(line_pattern_symbolizer const& sym,
|
||||
{
|
||||
path_type path(t_,geom,prj_trans);
|
||||
ras.add_path(path);
|
||||
if (writer.first) writer.first->add_line(path, feature, t_, writer.second);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -70,7 +70,7 @@ void agg_renderer<T>::process(line_symbolizer const& sym,
|
||||
ras_ptr->gamma(agg::gamma_linear());
|
||||
|
||||
agg::scanline_p8 sl;
|
||||
|
||||
metawriter_with_properties writer = sym.get_metawriter();
|
||||
for (unsigned i=0;i<feature.num_geometries();++i)
|
||||
{
|
||||
geometry2d const& geom = feature.get_geometry(i);
|
||||
@ -140,6 +140,7 @@ void agg_renderer<T>::process(line_symbolizer const& sym,
|
||||
stroke.generator().miter_limit(4.0);
|
||||
stroke.generator().width(stroke_.get_width() * scale_factor_);
|
||||
ras_ptr->add_path(stroke);
|
||||
if (writer.first) writer.first->add_line(path, feature, t_, writer.second);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -262,10 +262,22 @@ void metawriter_json_stream::add_polygon(path_type & path,
|
||||
CoordTransform const& t,
|
||||
metawriter_properties const& properties)
|
||||
{
|
||||
std::cout << count_ << "Polygon\n";
|
||||
write_feature_header("Polygon");
|
||||
std::cout << count_ << "Polygon started\n";
|
||||
write_line_polygon(path, t, true);
|
||||
write_properties(feature, properties);
|
||||
}
|
||||
|
||||
void metawriter_json_stream::add_line(path_type & path,
|
||||
Feature const& feature,
|
||||
CoordTransform const& t,
|
||||
metawriter_properties const& properties)
|
||||
{
|
||||
write_feature_header("MultiLineString");
|
||||
write_line_polygon(path, t, false);
|
||||
write_properties(feature, properties);
|
||||
}
|
||||
|
||||
void metawriter_json_stream::write_line_polygon(path_type & path, CoordTransform const& t, bool polygon){
|
||||
*f_ << " [";
|
||||
double x, y, last_x=0.0, last_y=0.0;
|
||||
unsigned cmd, last_cmd = SEG_END;
|
||||
@ -275,7 +287,7 @@ void metawriter_json_stream::add_polygon(path_type & path,
|
||||
while ((cmd = path.vertex(&x, &y)) != SEG_END) {
|
||||
if (cmd == SEG_LINETO) {
|
||||
if (last_cmd == SEG_MOVETO) {
|
||||
//Start new polygon
|
||||
//Start new polygon/line
|
||||
if (polygon_count++) *f_ << "], ";
|
||||
*f_ << "[";
|
||||
write_point(t, last_x, last_y, true);
|
||||
@ -288,8 +300,6 @@ void metawriter_json_stream::add_polygon(path_type & path,
|
||||
last_cmd = cmd;
|
||||
}
|
||||
*f_ << "]]";
|
||||
write_properties(feature, properties);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user