Reenable support for metawriters.

Implementations in individual metawriters are still missing.
This commit is contained in:
Hermann Kraus 2012-08-15 02:11:11 +02:00
parent 79ad6b395e
commit f9edcb71e0
7 changed files with 26 additions and 55 deletions

View file

@ -28,11 +28,11 @@
#include <mapnik/ctrans.hpp>
#include <mapnik/projection.hpp>
#include <mapnik/metawriter/properties.hpp>
#include <mapnik/text/placements_list.hpp>
// boost
#include <boost/utility.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/concept_check.hpp>
// stl
#include <set>
@ -63,15 +63,11 @@ public:
virtual void add_box(box2d<double> const& box, Feature const& feature,
CoordTransform const& t,
metawriter_properties const& properties)=0;
#if 0
virtual void add_text(boost::ptr_vector<text_path> const& placements,
box2d<double> const& extents,
virtual void add_text(placements_list const& positions,
Feature const& feature,
CoordTransform const& t,
metawriter_properties const& properties)=0;
#else
#warning MetaWriter: add_text disabled!
#endif
virtual void add_polygon(path_type & path,
Feature const& feature,
CoordTransform const& t,
@ -87,10 +83,7 @@ public:
* \param properties metawriter_property_map object with userdefined values.
* Useful for setting filename etc.
*/
virtual void start(metawriter_property_map const& properties)
{
boost::ignore_unused_variable_warning(properties);
}
virtual void start(metawriter_property_map const& /*properties*/) { }
/** Stop processing.
* Write file footer, close database connection, ...
@ -101,10 +94,7 @@ public:
*/
void set_size(int width, int height) { width_ = width; height_ = height; }
/** Set Map object's srs. */
virtual void set_map_srs(projection const& proj)
{
boost::ignore_unused_variable_warning(proj);
}
virtual void set_map_srs(projection const& /*proj*/) {}
/** Return the list of default properties. */
metawriter_properties const& get_default_properties() const { return dflt_properties_;}

View file

@ -65,13 +65,10 @@ public:
virtual void add_box(box2d<double> const& box, Feature const& feature,
CoordTransform const& t,
metawriter_properties const& properties);
#if 0
virtual void add_text(boost::ptr_vector<text_path> const& placements,
box2d<double> const& extents,
virtual void add_text(placements_list const& positions,
Feature const& feature,
CoordTransform const& t,
metawriter_properties const& properties);
#endif
virtual void add_polygon(path_type & path,
Feature const& feature,
CoordTransform const& t,

View file

@ -45,13 +45,10 @@ public:
virtual void add_box(box2d<double> const& box, Feature const& feature,
CoordTransform const& t,
metawriter_properties const& properties);
#if 0
virtual void add_text(boost::ptr_vector<text_path> const& placements,
box2d<double> const& extents,
virtual void add_text(placements_list const& positions,
Feature const& feature,
CoordTransform const& t,
metawriter_properties const& properties);
#endif
virtual void add_polygon(path_type & path,
Feature const& feature,
CoordTransform const& t,

View file

@ -55,9 +55,7 @@ public:
DetectorT &detector,
box2d<double> const& query_extent);
/** Return next placement.
* If no more placements are found false is returned.
*/
/** Return all placements.*/
placements_list const& get();
protected:
@ -72,7 +70,6 @@ protected:
proj_transform const& prj_trans_;
CoordTransform const& t_;
DetectorT & detector_;
metawriter_with_properties writer_;
box2d<double> dims_;
box2d<double> const& query_extent_;
//Processing
@ -139,7 +136,6 @@ protected:
using text_symbolizer_helper<FaceManagerT, DetectorT>::geo_itr_;
using text_symbolizer_helper<FaceManagerT, DetectorT>::point_itr_;
using text_symbolizer_helper<FaceManagerT, DetectorT>::points_;
using text_symbolizer_helper<FaceManagerT, DetectorT>::writer_;
using text_symbolizer_helper<FaceManagerT, DetectorT>::feature_;
using text_symbolizer_helper<FaceManagerT, DetectorT>::t_;
using text_symbolizer_helper<FaceManagerT, DetectorT>::detector_;

View file

@ -175,12 +175,12 @@ void metawriter_json_stream::add_box(box2d<double> const &box, Feature const& fe
}
#if 0
void metawriter_json_stream::add_text(
boost::ptr_vector<text_path> const& placements, box2d<double> const& extents,
void metawriter_json_stream::add_text(placements_list const& placements,
Feature const& feature, CoordTransform const& t,
metawriter_properties const& properties)
{
#if 0
/* Note:
Map coordinate system (and starting_{x,y}) starts in upper left corner
and grows towards lower right corner.
@ -261,8 +261,10 @@ void metawriter_json_stream::add_text(
*f_ << "]";
write_properties(feature, properties);
}
}
#else
#warning Metawriter: add_text() disabled.
#endif
}
void metawriter_json_stream::add_polygon(path_type & path,
Feature const& feature,

View file

@ -69,15 +69,13 @@ metawriter_inmem::add_box(box2d<double> const& box, Feature const& feature,
instances_.push_back(inst);
}
#if 0
void
metawriter_inmem::add_text(
boost::ptr_vector<text_path> const& /*text*/,
box2d<double> const& extents,
metawriter_inmem::add_text(placements_list const& /*positions*/,
Feature const& feature,
CoordTransform const& /*t*/,
metawriter_properties const& properties)
{
#if 0
if (extents.valid())
{
meta_instance inst;
@ -85,8 +83,10 @@ metawriter_inmem::add_text(
inst.box = extents;
instances_.push_back(inst);
}
}
#else
#warning Add text in metawriter_inmem disabled.
#endif
}
void
metawriter_inmem::add_polygon(path_type & path,

View file

@ -25,6 +25,7 @@
#include <mapnik/label_collision_detector.hpp>
#include <mapnik/font_engine_freetype.hpp>
#include <mapnik/text/layout.hpp>
#include <mapnik/metawriter.hpp>
#include "agg_conv_clip_polyline.h"
namespace mapnik {
@ -36,7 +37,6 @@ text_symbolizer_helper<FaceManagerT, DetectorT>::text_symbolizer_helper(const te
prj_trans_(prj_trans),
t_(t),
detector_(detector),
writer_(sym.get_metawriter()),
dims_(0, 0, width, height),
query_extent_(query_extent),
points_on_line_(false),
@ -60,6 +60,12 @@ placements_list const& text_symbolizer_helper<FaceManagerT, DetectorT>::get()
{
while (next_line_placement());
}
metawriter_with_properties writer = sym_.get_metawriter();
if (writer.first)
{
//TODO: Boxes for ShieldSymbolizer
writer.first->add_text(finder_.placements(), feature_, t_, writer.second);
}
return finder_.placements();
}
@ -94,11 +100,6 @@ bool text_symbolizer_helper<FaceManagerT, DetectorT>::next_line_placement()
{
//Found a placement
geo_itr_ = geometries_to_process_.erase(geo_itr_);
#if 0
if (writer_.first) writer_.first->add_text(
finder_->get_results(), finder_->get_extents(),
feature_, t_, writer_.second);
#endif
return true;
}
//No placement for this geometry. Keep it in geometries_to_process_ for next try.
@ -124,11 +125,6 @@ bool text_symbolizer_helper<FaceManagerT, DetectorT>::next_point_placement()
{
//Found a placement
point_itr_ = points_.erase(point_itr_);
#if 0
if (writer_.first) writer_.first->add_text(
finder_->get_results(), finder_->get_extents(),
feature_, t_, writer_.second);
#endif
return true;
}
//No placement for this point. Keep it in points_ for next try.
@ -315,13 +311,6 @@ bool shield_symbolizer_helper<FaceManagerT, DetectorT>::next_point_placement()
if (placement_->properties.allow_overlap || detector_.has_placement(marker_ext_))
{
detector_.insert(marker_ext_);
#if 0
if (writer_.first) {
writer_.first->add_box(marker_ext_, feature_, t_, writer_.second);
writer_.first->add_text(finder_->get_results(), finder_->get_extents(),
feature_, t_, writer_.second);
}
#endif
point_itr_ = points_.erase(point_itr_);
return true;
}