Merge pull request #4132 from zdila/master
add support for spacing-offset
This commit is contained in:
commit
3e178a2153
9 changed files with 25 additions and 10 deletions
|
@ -42,6 +42,7 @@ struct markers_placement_params
|
||||||
box2d<double> size;
|
box2d<double> size;
|
||||||
agg::trans_affine tr;
|
agg::trans_affine tr;
|
||||||
double spacing;
|
double spacing;
|
||||||
|
double spacing_offset;
|
||||||
double max_error;
|
double max_error;
|
||||||
bool allow_overlap;
|
bool allow_overlap;
|
||||||
bool avoid_edges;
|
bool avoid_edges;
|
||||||
|
|
|
@ -43,10 +43,12 @@ public:
|
||||||
: point_placement(locator, detector, params),
|
: point_placement(locator, detector, params),
|
||||||
first_point_(true),
|
first_point_(true),
|
||||||
spacing_(0.0),
|
spacing_(0.0),
|
||||||
|
spacing_offset_(NAN),
|
||||||
marker_width_((params.size * params.tr).width()),
|
marker_width_((params.size * params.tr).width()),
|
||||||
path_(locator)
|
path_(locator)
|
||||||
{
|
{
|
||||||
spacing_ = params.spacing < 1 ? 100 : params.spacing;
|
spacing_ = params.spacing < 1 ? 100 : params.spacing;
|
||||||
|
spacing_offset_ = params.spacing_offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
void rewind()
|
void rewind()
|
||||||
|
@ -77,7 +79,7 @@ public:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
first_point_ = false;
|
first_point_ = false;
|
||||||
move = spacing_ / 2.0;
|
move = std::isnan(spacing_offset_) ? spacing_ / 2.0 : spacing_offset_;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (path_.forward(move))
|
while (path_.forward(move))
|
||||||
|
@ -113,6 +115,7 @@ public:
|
||||||
private:
|
private:
|
||||||
bool first_point_;
|
bool first_point_;
|
||||||
double spacing_;
|
double spacing_;
|
||||||
|
double spacing_offset_;
|
||||||
double marker_width_;
|
double marker_width_;
|
||||||
vertex_cache path_;
|
vertex_cache path_;
|
||||||
};
|
};
|
||||||
|
|
|
@ -185,6 +185,13 @@ struct symbolizer_default<value_double, keys::spacing>
|
||||||
static value_double value() { return 100.0; }
|
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
|
// max-error
|
||||||
template <>
|
template <>
|
||||||
struct symbolizer_default<value_double, keys::max_error>
|
struct symbolizer_default<value_double, keys::max_error>
|
||||||
|
|
|
@ -52,6 +52,7 @@ enum class keys : std::uint8_t
|
||||||
line_rasterizer,
|
line_rasterizer,
|
||||||
image_transform,
|
image_transform,
|
||||||
spacing,
|
spacing,
|
||||||
|
spacing_offset,
|
||||||
max_error,
|
max_error,
|
||||||
allow_overlap,
|
allow_overlap,
|
||||||
ignore_placement,
|
ignore_placement,
|
||||||
|
|
|
@ -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::opacity, node);
|
||||||
set_symbolizer_property<symbolizer_base,double>(sym, keys::fill_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, 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::max_error, node);
|
||||||
set_symbolizer_property<symbolizer_base,double>(sym, keys::offset, node);
|
set_symbolizer_property<symbolizer_base,double>(sym, keys::offset, node);
|
||||||
set_symbolizer_property<symbolizer_base,double>(sym, keys::width, node);
|
set_symbolizer_property<symbolizer_base,double>(sym, keys::width, node);
|
||||||
|
|
|
@ -225,6 +225,7 @@ markers_dispatch_params::markers_dispatch_params(box2d<double> const& size,
|
||||||
size,
|
size,
|
||||||
tr,
|
tr,
|
||||||
get<value_double, keys::spacing>(sym, feature, vars),
|
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_double, keys::max_error>(sym, feature, vars),
|
||||||
get<value_bool, keys::allow_overlap>(sym, feature, vars),
|
get<value_bool, keys::allow_overlap>(sym, feature, vars),
|
||||||
get<value_bool, keys::avoid_edges>(sym, feature, vars),
|
get<value_bool, keys::avoid_edges>(sym, feature, vars),
|
||||||
|
|
|
@ -80,6 +80,7 @@ static const property_meta_type key_meta[const_max_key] =
|
||||||
property_types::target_double },
|
property_types::target_double },
|
||||||
property_meta_type{ "transform", nullptr, property_types::target_transform },
|
property_meta_type{ "transform", nullptr, property_types::target_transform },
|
||||||
property_meta_type{ "spacing", nullptr, property_types::target_double },
|
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{ "max-error", nullptr, property_types::target_double },
|
||||||
property_meta_type{ "allow-overlap", nullptr, property_types::target_bool },
|
property_meta_type{ "allow-overlap", nullptr, property_types::target_bool },
|
||||||
property_meta_type{ "ignore-placement", nullptr, property_types::target_bool },
|
property_meta_type{ "ignore-placement", nullptr, property_types::target_bool },
|
||||||
|
|
|
@ -23,7 +23,7 @@ SECTION("empty geometry") {
|
||||||
mapnik::markers_placement_params params {
|
mapnik::markers_placement_params params {
|
||||||
mapnik::box2d<double>(0, 0, 10, 10),
|
mapnik::box2d<double>(0, 0, 10, 10),
|
||||||
agg::trans_affine(),
|
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);
|
placement_type placement(va, detector, params);
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ SECTION("point") {
|
||||||
mapnik::markers_placement_params params {
|
mapnik::markers_placement_params params {
|
||||||
mapnik::box2d<double>(0, 0, 10, 10),
|
mapnik::box2d<double>(0, 0, 10, 10),
|
||||||
agg::trans_affine(),
|
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);
|
placement_type placement(va, detector, params);
|
||||||
|
|
||||||
|
@ -75,7 +75,7 @@ SECTION("line string") {
|
||||||
mapnik::markers_placement_params params {
|
mapnik::markers_placement_params params {
|
||||||
mapnik::box2d<double>(0, 0, 10, 10),
|
mapnik::box2d<double>(0, 0, 10, 10),
|
||||||
agg::trans_affine(),
|
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);
|
placement_type placement(va, detector, params);
|
||||||
|
|
||||||
|
@ -109,7 +109,7 @@ SECTION("polygon") {
|
||||||
mapnik::markers_placement_params params {
|
mapnik::markers_placement_params params {
|
||||||
mapnik::box2d<double>(0, 0, 10, 10),
|
mapnik::box2d<double>(0, 0, 10, 10),
|
||||||
agg::trans_affine(),
|
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);
|
placement_type placement(va, detector, params);
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ SECTION("empty geometry") {
|
||||||
mapnik::markers_placement_params params {
|
mapnik::markers_placement_params params {
|
||||||
mapnik::box2d<double>(0, 0, 10, 10),
|
mapnik::box2d<double>(0, 0, 10, 10),
|
||||||
agg::trans_affine(),
|
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);
|
placement_type placement(va, detector, params);
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ SECTION("point") {
|
||||||
mapnik::markers_placement_params params {
|
mapnik::markers_placement_params params {
|
||||||
mapnik::box2d<double>(0, 0, 10, 10),
|
mapnik::box2d<double>(0, 0, 10, 10),
|
||||||
agg::trans_affine(),
|
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);
|
placement_type placement(va, detector, params);
|
||||||
|
|
||||||
|
@ -75,7 +75,7 @@ SECTION("line string") {
|
||||||
mapnik::markers_placement_params params {
|
mapnik::markers_placement_params params {
|
||||||
mapnik::box2d<double>(0, 0, 10, 10),
|
mapnik::box2d<double>(0, 0, 10, 10),
|
||||||
agg::trans_affine(),
|
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);
|
placement_type placement(va, detector, params);
|
||||||
|
|
||||||
|
@ -105,7 +105,7 @@ SECTION("line string zero length") {
|
||||||
mapnik::markers_placement_params params {
|
mapnik::markers_placement_params params {
|
||||||
mapnik::box2d<double>(0, 0, 10, 10),
|
mapnik::box2d<double>(0, 0, 10, 10),
|
||||||
agg::trans_affine(),
|
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);
|
placement_type placement(va, detector, params);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue