Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Offset enabled for LinePatternSymbolizer #1528

Closed
wants to merge 1 commit into from

2 participants

@PetrDlouhy

Partial fix for #1241, which enables offsetting of LinePatternSymbolizer.

@springmeyer
Owner

thanks for the patch. Looks good. I will try to review in the coming weeks and apply.

@PetrDlouhy

Hi, could this patch be applied?

@springmeyer
Owner

Apologies for the delay. Could you update the python bindings and add tests? For tests you should add validation that the property round trips in python in the file tests/python_tests/object_test.py and add a visual test in tests/visual_tests by adding a style that uses the new property - the idea here being that this will help catch any regressions in the behavior.

@springmeyer
Owner

Ping. Are you able to handle the above tasks @PetrDlouhy ? If not just let me know so I can plan time. Would be great to get this merged.

@PetrDlouhy

Oh, sorry. I forgot about this a bit. I will try to find time to finish that.

@PetrDlouhy PetrDlouhy closed this
@PetrDlouhy

Pull request was updated in #1991

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Sep 12, 2012
  1. @PetrDlouhy
This page is out of date. Refresh to see the latest.
View
3  include/mapnik/line_pattern_symbolizer.hpp
@@ -34,6 +34,9 @@ struct MAPNIK_DECL line_pattern_symbolizer :
{
line_pattern_symbolizer(path_expression_ptr file);
line_pattern_symbolizer(line_pattern_symbolizer const& rhs);
+ double offset_;
+ double offset() const;
+ void set_offset(double offset);
};
}
View
5 src/agg/process_line_pattern_symbolizer.cpp
@@ -102,6 +102,8 @@ void agg_renderer<T>::process(line_pattern_symbolizer const& sym,
float half_stroke = (*mark)->width()/2.0;
if (half_stroke > 1)
padding *= half_stroke;
+ if (fabs(sym.offset()) > 0)
+ padding *= fabs(sym.offset()) * 1.2;
double x0 = query_extent_.minx();
double y0 = query_extent_.miny();
double x1 = query_extent_.maxx();
@@ -109,13 +111,14 @@ void agg_renderer<T>::process(line_pattern_symbolizer const& sym,
clipping_extent.init(x0 - padding, y0 - padding, x1 + padding , y1 + padding);
}
- typedef boost::mpl::vector<clip_line_tag,transform_tag,smooth_tag> conv_types;
+ typedef boost::mpl::vector<clip_line_tag,transform_tag,offset_transform_tag,smooth_tag> conv_types;
vertex_converter<box2d<double>, rasterizer_type, line_pattern_symbolizer,
CoordTransform, proj_transform, agg::trans_affine, conv_types>
converter(clipping_extent,ras,sym,t_,prj_trans,tr,scale_factor_);
if (sym.clip()) converter.set<clip_line_tag>(); //optional clip (default: true)
converter.set<transform_tag>(); //always transform
+ if (fabs(sym.offset()) > 0.0) converter.set<offset_transform_tag>(); // parallel offset
if (sym.smooth() > 0.0) converter.set<smooth_tag>(); // optional smooth converter
BOOST_FOREACH(geometry_type & geom, feature.paths())
View
14 src/line_pattern_symbolizer.cpp
@@ -27,9 +27,19 @@ namespace mapnik
{
line_pattern_symbolizer::line_pattern_symbolizer(path_expression_ptr file)
- : symbolizer_with_image(file), symbolizer_base() {}
+ : symbolizer_with_image(file), symbolizer_base(), offset_(0.0) {}
line_pattern_symbolizer::line_pattern_symbolizer(line_pattern_symbolizer const& rhs)
- : symbolizer_with_image(rhs), symbolizer_base(rhs) {}
+ : symbolizer_with_image(rhs), symbolizer_base(rhs), offset_(rhs.offset_) {}
+
+double line_pattern_symbolizer::offset() const
+{
+ return offset_;
+}
+
+void line_pattern_symbolizer::set_offset(double offset)
+{
+ offset_=offset;
+}
}
View
5 src/load_map.cpp
@@ -1050,10 +1050,15 @@ void map_parser::parse_line_pattern_symbolizer(rule & rule, xml_node const & sym
}
}
+
file = ensure_relative_to_xml(file);
ensure_exists(file);
line_pattern_symbolizer symbol( parse_path(file, sym.get_tree().path_expr_grammar) );
+ // offset value
+ optional<double> offset = sym.get_opt_attr<double>("offset");
+ if (offset) symbol.set_offset(*offset);
+
parse_symbolizer_base(symbol, sym);
rule.append(symbol);
}
View
5 src/save_map.cpp
@@ -107,6 +107,11 @@ class serialize_symbolizer : public boost::static_visitor<>
ptree::value_type("LinePatternSymbolizer",
ptree()))->second;
+ if (sym.offset() != 0.0 || explicit_defaults_ )
+ {
+ set_attr( sym_node, "offset", sym.offset() );
+ }
+
add_image_attributes( sym_node, sym );
serialize_symbolizer_base(sym_node, sym);
}
Something went wrong with that request. Please try again.