Merge pull request #4132 from zdila/master

add support for spacing-offset
This commit is contained in:
Artem Pavlenko 2020-04-02 10:00:37 +01:00 committed by GitHub
commit 3e178a2153
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 25 additions and 10 deletions

View file

@ -42,6 +42,7 @@ struct markers_placement_params
box2d<double> size;
agg::trans_affine tr;
double spacing;
double spacing_offset;
double max_error;
bool allow_overlap;
bool avoid_edges;

View file

@ -43,10 +43,12 @@ public:
: point_placement(locator, detector, params),
first_point_(true),
spacing_(0.0),
spacing_offset_(NAN),
marker_width_((params.size * params.tr).width()),
path_(locator)
{
spacing_ = params.spacing < 1 ? 100 : params.spacing;
spacing_offset_ = params.spacing_offset;
}
void rewind()
@ -77,7 +79,7 @@ public:
return false;
}
first_point_ = false;
move = spacing_ / 2.0;
move = std::isnan(spacing_offset_) ? spacing_ / 2.0 : spacing_offset_;
}
while (path_.forward(move))
@ -113,6 +115,7 @@ public:
private:
bool first_point_;
double spacing_;
double spacing_offset_;
double marker_width_;
vertex_cache path_;
};

View file

@ -185,6 +185,13 @@ struct symbolizer_default<value_double, keys::spacing>
static value_double value() { return 100.0; }
};
// spacing-offset
template <>
struct symbolizer_default<value_double, keys::spacing_offset>
{
static value_double value() { return NAN; }
};
// max-error
template <>
struct symbolizer_default<value_double, keys::max_error>

View file

@ -52,6 +52,7 @@ enum class keys : std::uint8_t
line_rasterizer,
image_transform,
spacing,
spacing_offset,
max_error,
allow_overlap,
ignore_placement,

View file

@ -1124,6 +1124,7 @@ void map_parser::parse_markers_symbolizer(rule & rule, xml_node const& node)
set_symbolizer_property<symbolizer_base,double>(sym, keys::opacity, node);
set_symbolizer_property<symbolizer_base,double>(sym, keys::fill_opacity, node);
set_symbolizer_property<symbolizer_base,double>(sym, keys::spacing, node);
set_symbolizer_property<symbolizer_base,double>(sym, keys::spacing_offset, node);
set_symbolizer_property<symbolizer_base,double>(sym, keys::max_error, node);
set_symbolizer_property<symbolizer_base,double>(sym, keys::offset, node);
set_symbolizer_property<symbolizer_base,double>(sym, keys::width, node);

View file

@ -225,6 +225,7 @@ markers_dispatch_params::markers_dispatch_params(box2d<double> const& size,
size,
tr,
get<value_double, keys::spacing>(sym, feature, vars),
get<value_double, keys::spacing_offset>(sym, feature, vars),
get<value_double, keys::max_error>(sym, feature, vars),
get<value_bool, keys::allow_overlap>(sym, feature, vars),
get<value_bool, keys::avoid_edges>(sym, feature, vars),

View file

@ -80,6 +80,7 @@ static const property_meta_type key_meta[const_max_key] =
property_types::target_double },
property_meta_type{ "transform", nullptr, property_types::target_transform },
property_meta_type{ "spacing", nullptr, property_types::target_double },
property_meta_type{ "spacing-offset", nullptr, property_types::target_double },
property_meta_type{ "max-error", nullptr, property_types::target_double },
property_meta_type{ "allow-overlap", nullptr, property_types::target_bool },
property_meta_type{ "ignore-placement", nullptr, property_types::target_bool },

View file

@ -23,7 +23,7 @@ SECTION("empty geometry") {
mapnik::markers_placement_params params {
mapnik::box2d<double>(0, 0, 10, 10),
agg::trans_affine(),
0, 0, false, false, DIRECTION_AUTO, 1.0 };
0, NAN, 0, false, false, DIRECTION_AUTO, 1.0 };
placement_type placement(va, detector, params);
@ -45,7 +45,7 @@ SECTION("point") {
mapnik::markers_placement_params params {
mapnik::box2d<double>(0, 0, 10, 10),
agg::trans_affine(),
0, 0, false, false, DIRECTION_AUTO, 1.0 };
0, NAN, 0, false, false, DIRECTION_AUTO, 1.0 };
placement_type placement(va, detector, params);
@ -75,7 +75,7 @@ SECTION("line string") {
mapnik::markers_placement_params params {
mapnik::box2d<double>(0, 0, 10, 10),
agg::trans_affine(),
0, 0, false, false, DIRECTION_AUTO, 1.0 };
0, NAN, 0, false, false, DIRECTION_AUTO, 1.0 };
placement_type placement(va, detector, params);
@ -109,7 +109,7 @@ SECTION("polygon") {
mapnik::markers_placement_params params {
mapnik::box2d<double>(0, 0, 10, 10),
agg::trans_affine(),
0, 0, false, false, DIRECTION_AUTO, 1.0 };
0, NAN, 0, false, false, DIRECTION_AUTO, 1.0 };
placement_type placement(va, detector, params);

View file

@ -23,7 +23,7 @@ SECTION("empty geometry") {
mapnik::markers_placement_params params {
mapnik::box2d<double>(0, 0, 10, 10),
agg::trans_affine(),
0, 0, false, false, DIRECTION_AUTO, 1.0 };
0, NAN, 0, false, false, DIRECTION_AUTO, 1.0 };
placement_type placement(va, detector, params);
@ -45,7 +45,7 @@ SECTION("point") {
mapnik::markers_placement_params params {
mapnik::box2d<double>(0, 0, 10, 10),
agg::trans_affine(),
0, 0, false, false, DIRECTION_AUTO, 1.0 };
0, NAN, 0, false, false, DIRECTION_AUTO, 1.0 };
placement_type placement(va, detector, params);
@ -75,7 +75,7 @@ SECTION("line string") {
mapnik::markers_placement_params params {
mapnik::box2d<double>(0, 0, 10, 10),
agg::trans_affine(),
0, 0, false, false, DIRECTION_AUTO, 1.0 };
0, NAN, 0, false, false, DIRECTION_AUTO, 1.0 };
placement_type placement(va, detector, params);
@ -105,7 +105,7 @@ SECTION("line string zero length") {
mapnik::markers_placement_params params {
mapnik::box2d<double>(0, 0, 10, 10),
agg::trans_affine(),
0, 0, false, false, DIRECTION_AUTO, 1.0 };
0, NAN, 0, false, false, DIRECTION_AUTO, 1.0 };
placement_type placement(va, detector, params);
@ -119,4 +119,4 @@ SECTION("line string zero length") {
CHECK( !placement.get_point(x, y, angle, true) );
}
}
}