add support for drawing all geometry verticies with debug symbolizer mode=vertex and expose in python - closes #1848
This commit is contained in:
parent
fa2d2a73e0
commit
8634a04938
8 changed files with 58 additions and 6 deletions
|
@ -62,6 +62,7 @@ void export_polygon_pattern_symbolizer();
|
|||
void export_raster_symbolizer();
|
||||
void export_text_placement();
|
||||
void export_shield_symbolizer();
|
||||
void export_debug_symbolizer();
|
||||
void export_font_engine();
|
||||
void export_projection();
|
||||
void export_proj_transform();
|
||||
|
@ -463,6 +464,7 @@ BOOST_PYTHON_MODULE(_mapnik)
|
|||
export_raster_symbolizer();
|
||||
export_text_placement();
|
||||
export_shield_symbolizer();
|
||||
export_debug_symbolizer();
|
||||
export_font_engine();
|
||||
export_projection();
|
||||
export_proj_transform();
|
||||
|
|
|
@ -30,10 +30,25 @@
|
|||
namespace mapnik
|
||||
{
|
||||
|
||||
enum debug_symbolizer_mode_enum {
|
||||
DEBUG_SYM_MODE_COLLISION,
|
||||
DEBUG_SYM_MODE_VERTEX,
|
||||
debug_symbolizer_mode_enum_MAX
|
||||
};
|
||||
|
||||
DEFINE_ENUM( debug_symbolizer_mode_e, debug_symbolizer_mode_enum );
|
||||
|
||||
struct MAPNIK_DECL debug_symbolizer :
|
||||
public symbolizer_base
|
||||
{
|
||||
debug_symbolizer() : symbolizer_base() {}
|
||||
debug_symbolizer();
|
||||
debug_symbolizer(debug_symbolizer const& rhs);
|
||||
debug_symbolizer_mode_e get_mode() const;
|
||||
void set_mode(debug_symbolizer_mode_e mode);
|
||||
|
||||
private:
|
||||
debug_symbolizer_mode_e mode_;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -52,10 +52,37 @@ void agg_renderer<T>::process(debug_symbolizer const& sym,
|
|||
mapnik::feature_impl & feature,
|
||||
proj_transform const& prj_trans)
|
||||
{
|
||||
label_collision_detector4::query_iterator itr = detector_->begin(), end = detector_->end();
|
||||
for (;itr!=end; itr++)
|
||||
debug_symbolizer_mode_e mode = sym.get_mode();
|
||||
if (mode == DEBUG_SYM_MODE_COLLISION)
|
||||
{
|
||||
draw_rect(pixmap_, itr->box);
|
||||
label_collision_detector4::query_iterator itr = detector_->begin(), end = detector_->end();
|
||||
for (;itr!=end; itr++)
|
||||
{
|
||||
draw_rect(pixmap_, itr->box);
|
||||
}
|
||||
}
|
||||
else if (mode == DEBUG_SYM_MODE_VERTEX)
|
||||
{
|
||||
for (unsigned i=0; i<feature.num_geometries(); ++i)
|
||||
{
|
||||
geometry_type const& geom = feature.get_geometry(i);
|
||||
double x;
|
||||
double y;
|
||||
double z = 0;
|
||||
geom.rewind(0);
|
||||
unsigned cmd = 1;
|
||||
while ((cmd = geom.vertex(&x, &y)) != mapnik::SEG_END)
|
||||
{
|
||||
if (cmd == SEG_CLOSE) continue;
|
||||
prj_trans.backward(x,y,z);
|
||||
t_.forward(&x,&y);
|
||||
pixmap_.setPixel(x,y,0xff0000ff);
|
||||
pixmap_.setPixel(x-1,y-1,0xff0000ff);
|
||||
pixmap_.setPixel(x+1,y+1,0xff0000ff);
|
||||
pixmap_.setPixel(x-1,y+1,0xff0000ff);
|
||||
pixmap_.setPixel(x+1,y-1,0xff0000ff);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -109,6 +109,7 @@ else: # unix, non-macos
|
|||
|
||||
source = Split(
|
||||
"""
|
||||
debug_symbolizer.cpp
|
||||
request.cpp
|
||||
well_known_srs.cpp
|
||||
params.cpp
|
||||
|
|
|
@ -1531,8 +1531,10 @@ void map_parser::parse_raster_symbolizer(rule & rule, xml_node const & sym)
|
|||
void map_parser::parse_debug_symbolizer(rule & rule, xml_node const & sym)
|
||||
{
|
||||
debug_symbolizer symbol;
|
||||
|
||||
parse_symbolizer_base(symbol, sym);
|
||||
debug_symbolizer_mode_e mode =
|
||||
sym.get_attr<debug_symbolizer_mode_e>("mode", DEBUG_SYM_MODE_COLLISION);
|
||||
symbol.set_mode(mode);
|
||||
rule.append(symbol);
|
||||
}
|
||||
|
||||
|
|
|
@ -405,6 +405,7 @@ compile_get_opt_attr(expression_ptr);
|
|||
compile_get_attr(std::string);
|
||||
compile_get_attr(filter_mode_e);
|
||||
compile_get_attr(point_placement_e);
|
||||
compile_get_attr(debug_symbolizer_mode_e);
|
||||
compile_get_attr(marker_placement_e);
|
||||
compile_get_attr(marker_multi_policy_e);
|
||||
compile_get_attr(pattern_alignment_e);
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
<LineSymbolizer stroke="white" stroke-gamma="0" stroke-width="10"/>
|
||||
|
||||
<!-- small, clean, anti-aliased lines -->
|
||||
<LineSymbolizer stroke="red" stroke-gamma="1" stroke-width=".5"/>
|
||||
<DebugSymbolizer mode="vertex"/>
|
||||
|
||||
</Rule>
|
||||
</Style>
|
||||
|
|
|
@ -14,6 +14,10 @@ def setup():
|
|||
# from another directory we need to chdir()
|
||||
os.chdir(execution_path('.'))
|
||||
|
||||
def test_debug_symbolizer():
|
||||
s = mapnik.DebugSymbolizer()
|
||||
eq_(s.mode,mapnik.debug_symbolizer_mode.collision)
|
||||
|
||||
def test_raster_symbolizer():
|
||||
s = mapnik.RasterSymbolizer()
|
||||
eq_(s.comp_op,mapnik.CompositeOp.src_over) # note: mode is deprecated
|
||||
|
|
Loading…
Reference in a new issue