Skip to content
Browse files

Merge branch 'master' into move_bind_logic_to_layer

Conflicts:
	bindings/python/mapnik_layer.cpp
	include/mapnik/symbolizer_helpers.hpp
	src/agg/process_line_symbolizer.cpp
	src/cairo_renderer.cpp
	src/feature_style_processor.cpp
  • Loading branch information...
2 parents a4c4c4b + 207ecfd commit d206657dd437fc90425c678de4356f42fa09cca7 @artemp artemp committed Mar 12, 2012
View
2 SConstruct
@@ -1411,7 +1411,9 @@ if not preconfigured:
pthread = '-pthread'
# Common debugging flags.
+ # http://lists.fedoraproject.org/pipermail/devel/2010-November/144952.html
debug_flags = '-g -fno-omit-frame-pointer -DDEBUG -DMAPNIK_DEBUG'
+
ndebug_flags = '-DNDEBUG'
View
27 bindings/python/mapnik_layer.cpp
@@ -54,7 +54,8 @@ struct layer_pickle_suite : boost::python::pickle_suite
{
s.append(style_names[i]);
}
- return boost::python::make_tuple(l.clear_label_cache(),l.getMinZoom(),l.getMaxZoom(),l.isQueryable(),l.datasource_parameters(),l.cache_features(),s);
+ return boost::python::make_tuple(l.clear_label_cache(),
+l.min_zoom(),l.max_zoom(),l.queryable(),l.datasource()->params(),l.cache_features(),s);
}
static void
@@ -72,11 +73,11 @@ struct layer_pickle_suite : boost::python::pickle_suite
l.set_clear_label_cache(extract<bool>(state[0]));
- l.setMinZoom(extract<double>(state[1]));
+ l.set_min_zoom(extract<double>(state[1]));
- l.setMaxZoom(extract<double>(state[2]));
+ l.set_max_zoom(extract<double>(state[2]));
- l.setQueryable(extract<bool>(state[3]));
+ l.set_queryable(extract<bool>(state[3]));
mapnik::parameters params = extract<parameters>(state[4]);
l.set_datasource_parameters(params);
@@ -163,7 +164,7 @@ void export_layer()
"box2d(-1.0,-1.0,0.0,0.0) # default until a datasource is loaded\n"
)
- .def("visible", &layer::isVisible,
+ .def("visible", &layer::visible,
"Return True if this layer's data is active and visible at a given scale.\n"
"\n"
"Otherwise returns False.\n"
@@ -184,8 +185,8 @@ void export_layer()
)
.add_property("active",
- &layer::isActive,
- &layer::setActive,
+ &layer::active,
+ &layer::set_active,
"Get/Set whether this layer is active and will be rendered.\n"
"\n"
"Usage:\n"
@@ -238,8 +239,8 @@ void export_layer()
)
.add_property("maxzoom",
- &layer::getMaxZoom,
- &layer::setMaxZoom,
+ &layer::max_zoom,
+ &layer::set_max_zoom,
"Get/Set the maximum zoom lever of the layer.\n"
"\n"
"Usage:\n"
@@ -253,8 +254,8 @@ void export_layer()
)
.add_property("minzoom",
- &layer::getMinZoom,
- &layer::setMinZoom,
+ &layer::min_zoom,
+ &layer::set_min_zoom,
"Get/Set the minimum zoom lever of the layer.\n"
"\n"
"Usage:\n"
@@ -283,8 +284,8 @@ void export_layer()
)
.add_property("queryable",
- &layer::isQueryable,
- &layer::setQueryable,
+ &layer::queryable,
+ &layer::set_queryable,
"Get/Set whether this layer is queryable.\n"
"\n"
"Usage:\n"
View
6 demo/viewer/layerlistmodel.cpp
@@ -49,7 +49,7 @@ QVariant LayerListModel::data(QModelIndex const& index,int role) const
else if (role == Qt::DecorationRole)
{
double scale = map_->scale();
- if (map_->layers().at(index.row()).isVisible(scale))
+ if (map_->layers().at(index.row()).visible(scale))
{
return QIcon(":/images/globe.png");
}
@@ -60,7 +60,7 @@ QVariant LayerListModel::data(QModelIndex const& index,int role) const
}
else if (role == Qt::CheckStateRole)
{
- if (map_->layers().at(index.row()).isActive())
+ if (map_->layers().at(index.row()).active())
return QVariant(Qt::Checked);
else
return QVariant(Qt::Unchecked);
@@ -92,7 +92,7 @@ bool LayerListModel::setData(const QModelIndex &index,
{
int status = value.toInt();
std::vector<mapnik::layer> & layers = const_cast<std::vector<mapnik::layer>& >(map_->layers());
- layers.at(index.row()).setActive(status);
+ layers.at(index.row()).set_active(status);
emit dataChanged(index, index);
return true;
}
View
2 demo/viewer/mapwidget.cpp
@@ -157,7 +157,7 @@ void MapWidget::mousePressEvent(QMouseEvent* e)
if (int(index) != selectedLayer_) continue;
layer & layer = map_->layers()[index];
- if (!layer.isVisible(scale_denom)) continue;
+ if (!layer.visible(scale_denom)) continue;
std::string name = layer.name();
double x = e->x();
double y = e->y();
View
12 include/mapnik/font_engine_freetype.hpp
@@ -263,7 +263,7 @@ template <typename T>
class MAPNIK_DECL face_manager : private boost::noncopyable
{
typedef T font_engine_type;
- typedef std::map<std::string,face_ptr> faces;
+ typedef std::map<std::string,face_ptr> face_ptr_cache_type;
public:
face_manager(T & engine)
@@ -272,9 +272,9 @@ class MAPNIK_DECL face_manager : private boost::noncopyable
face_ptr get_face(std::string const& name)
{
- typename faces::iterator itr;
- itr = faces_.find(name);
- if (itr != faces_.end())
+ face_ptr_cache_type::iterator itr;
+ itr = face_ptr_cache_.find(name);
+ if (itr != face_ptr_cache_.end())
{
return itr->second;
}
@@ -283,7 +283,7 @@ class MAPNIK_DECL face_manager : private boost::noncopyable
face_ptr face = engine_.create_face(name);
if (face)
{
- faces_.insert(make_pair(name,face));
+ face_ptr_cache_.insert(make_pair(name,face));
}
return face;
}
@@ -335,7 +335,7 @@ class MAPNIK_DECL face_manager : private boost::noncopyable
}
private:
- faces faces_;
+ face_ptr_cache_type face_ptr_cache_;
font_engine_type & engine_;
stroker_ptr stroker_;
};
View
26 include/mapnik/layer.hpp
@@ -88,44 +88,44 @@ class MAPNIK_DECL layer
std::vector<std::string>& styles();
/*!
- * @param maxZoom The minimum zoom level to set
+ * @param max_zoom The minimum zoom level to set
*/
- void setMinZoom(double minZoom);
+ void set_min_zoom(double min_zoom);
/*!
- * @param maxZoom The maximum zoom level to set
+ * @param max_zoom The maximum zoom level to set
*/
- void setMaxZoom(double maxZoom);
+ void set_max_zoom(double max_zoom);
/*!
* @return the minimum zoom level of the layer.
*/
- double getMinZoom() const;
+ double min_zoom() const;
/*!
* @return the maximum zoom level of the layer.
*/
- double getMaxZoom() const;
+ double max_zoom() const;
/*!
* @brief Set whether this layer is active and will be rendered.
*/
- void setActive(bool active);
+ void set_active(bool active);
/*!
* @return whether this layer is active and will be rendered.
*/
- bool isActive() const;
+ bool active() const;
/*!
* @brief Set whether this layer is queryable.
*/
- void setQueryable(bool queryable);
+ void set_queryable(bool queryable);
/*!
* @return whether this layer is queryable or not.
*/
- bool isQueryable() const;
+ bool queryable() const;
/*!
* @brief Get the visability for a specific scale.
@@ -139,7 +139,7 @@ class MAPNIK_DECL layer
* or
* scale < maxzoom + 1e-6
*/
- bool isVisible(double scale) const;
+ bool visible(double scale) const;
/*!
* @param clear_cache Set whether this layer's labels are cached.
@@ -197,8 +197,8 @@ class MAPNIK_DECL layer
std::string name_;
std::string srs_;
- double minZoom_;
- double maxZoom_;
+ double min_zoom_;
+ double max_zoom_;
bool active_;
bool queryable_;
bool clear_label_cache_;
View
1 include/mapnik/mapped_memory_cache.hpp
@@ -49,6 +49,7 @@ struct MAPNIK_DECL mapped_memory_cache :
static boost::unordered_map<std::string,mapped_region_ptr> cache_;
static bool insert(std::string const& key, mapped_region_ptr);
static boost::optional<mapped_region_ptr> find(std::string const& key, bool update_cache = false);
+ static void clear();
};
}
View
1 include/mapnik/marker_cache.hpp
@@ -50,6 +50,7 @@ struct MAPNIK_DECL marker_cache :
static boost::unordered_map<std::string,marker_ptr> cache_;
static bool insert(std::string const& key, marker_ptr);
static boost::optional<marker_ptr> find(std::string const& key, bool update_cache = false);
+ static void clear();
};
}
View
17 include/mapnik/symbolizer_helpers.hpp
@@ -69,8 +69,8 @@ class text_symbolizer_helper
angle_(0.0),
placement_valid_(false),
points_on_line_(false),
- finder_(),
- query_extent_(query_extent)
+ query_extent_(query_extent),
+ finder_()
{
initialize_geometries();
if (!geometries_to_process_.size()) return;
@@ -139,11 +139,24 @@ class shield_symbolizer_helper: public text_symbolizer_helper<FaceManagerT, Dete
unsigned width,
unsigned height,
double scale_factor,
+<<<<<<< HEAD
CoordTransform const& t,
FaceManagerT & font_manager,
DetectorT & detector,
box2d<double> const& query_extent) :
text_symbolizer_helper<FaceManagerT, DetectorT>(sym, feature, prj_trans, width, height, scale_factor, t, font_manager, detector, query_extent),
+||||||| merged common ancestors
+ CoordTransform const& t,
+ FaceManagerT & font_manager,
+ DetectorT & detector) :
+ text_symbolizer_helper<FaceManagerT, DetectorT>(sym, feature, prj_trans, width, height, scale_factor, t, font_manager, detector),
+=======
+ CoordTransform const &t,
+ FaceManagerT &font_manager,
+ DetectorT &detector,
+ box2d<double> const& query_extent) :
+ text_symbolizer_helper<FaceManagerT, DetectorT>(sym, feature, prj_trans, width, height, scale_factor, t, font_manager, detector, query_extent),
+>>>>>>> master
sym_(sym)
{
this->points_on_line_ = true;
View
2 src/agg/process_line_symbolizer.cpp
@@ -132,7 +132,7 @@ void agg_renderer<T>::process(line_symbolizer const& sym,
clipped_geometry_type clipped(geom);
clipped.clip_box(ext.minx(),ext.miny(),ext.maxx(),ext.maxy());
path_type path(t_,clipped,prj_trans);
-
+
if (stroke_.has_dash())
{
agg::conv_dash<path_type> dash(path);
View
11 src/cairo_renderer.cpp
@@ -254,11 +254,10 @@ cairo_face_ptr cairo_face_manager::get_face(face_ptr face)
}
else
{
- entry = cairo_face_ptr(new cairo_face(font_engine_, face));
-
+ entry = boost::make_shared<cairo_face>(font_engine_, face);
cache_.insert(std::make_pair(face, entry));
}
-
+
return entry;
}
@@ -633,7 +632,7 @@ cairo_renderer_base::cairo_renderer_base(Map const& m, Cairo::RefPtr<Cairo::Cont
: m_(m),
context_(context),
t_(m.width(),m.height(),m.get_current_extent(),offset_x,offset_y),
- font_engine_(new freetype_engine()),
+ font_engine_(boost::make_shared<freetype_engine>()),
font_manager_(*font_engine_),
face_manager_(font_engine_,font_manager_),
detector_(box2d<double>(-m.buffer_size() ,-m.buffer_size() , m.width() + m.buffer_size() ,m.height() + m.buffer_size()))
@@ -1066,9 +1065,9 @@ void cairo_renderer_base::start_map_processing(Map const& map)
detector_.extent().width(), detector_.extent().height(),
1.0 /*scale_factor*/,
t_, font_manager_, detector_, query_extent_);
-
+
cairo_context context(context_);
-
+
while (helper.next()) {
placements_type &placements = helper.placements();
for (unsigned int ii = 0; ii < placements.size(); ++ii)
View
10 src/feature_style_processor.cpp
@@ -112,7 +112,7 @@ void feature_style_processor<Processor>::apply()
BOOST_FOREACH ( layer const& lyr, m_.layers() )
{
- if (lyr.isVisible(scale_denom))
+ if (lyr.visible(scale_denom))
{
std::set<std::string> names;
apply_to_layer(lyr, p, proj, scale_denom, names);
@@ -146,7 +146,7 @@ void feature_style_processor<Processor>::apply(mapnik::layer const& lyr, std::se
double scale_denom = mapnik::scale_denominator(m_,proj.is_geographic());
scale_denom *= scale_factor_;
- if (lyr.isVisible(scale_denom))
+ if (lyr.visible(scale_denom))
{
apply_to_layer(lyr, p, proj, scale_denom, names);
}
@@ -264,8 +264,10 @@ void feature_style_processor<Processor>::apply_to_layer(layer const& lay, Proces
box2d<double> query_ext = m_.get_current_extent();
box2d<double> unbuffered_extent = m_.get_current_extent();
prj_trans.forward(query_ext, PROJ_ENVELOPE_POINTS);
- query::resolution_type res(m_.width()/query_ext.width(),
- m_.height()/query_ext.height());
+ double qw = query_ext.width()>0 ? query_ext.width() : 1;
+ double qh = query_ext.height()>0 ? query_ext.height() : 1;
+ query::resolution_type res(m_.width()/qw,
+ m_.height()/qh);
query q(layer_ext,res,scale_denom,unbuffered_extent);
p.start_layer_processing(lay, query_ext);
View
5 src/font_engine_freetype.cpp
@@ -30,6 +30,7 @@
// boost
#include <boost/algorithm/string.hpp>
#include <boost/filesystem.hpp>
+#include <boost/make_shared.hpp>
#include <sstream>
// icu
@@ -178,7 +179,7 @@ face_ptr freetype_engine::create_face(std::string const& family_name)
&face);
if (!error)
{
- return face_ptr (new font_face(face));
+ return boost::make_shared<font_face>(face);
}
}
return face_ptr();
@@ -190,7 +191,7 @@ stroker_ptr freetype_engine::create_stroker()
FT_Error error = FT_Stroker_New(library_, &s);
if (!error)
{
- return stroker_ptr(new stroker(s));
+ return boost::make_shared<stroker>(s);
}
return stroker_ptr();
}
View
3 src/formatting/text.cpp
@@ -29,6 +29,7 @@
// boost
#include <boost/algorithm/string.hpp>
+#include <boost/make_shared.hpp>
namespace mapnik
{
@@ -50,7 +51,7 @@ node_ptr text_node::from_xml(boost::property_tree::ptree const& xml)
std::string data = xml.data();
boost::trim(data);
if (data.empty()) return node_ptr(); //No text
- return node_ptr(new text_node(parse_expression(data, "utf8")));
+ return boost::make_shared<text_node>(parse_expression(data, "utf8"));
}
void text_node::apply(char_properties const& p, Feature const& feature, processed_text &output) const
View
40 src/layer.cpp
@@ -38,8 +38,8 @@ namespace mapnik
layer::layer(std::string const& name, std::string const& srs)
: name_(name),
srs_(srs),
- minZoom_(0),
- maxZoom_(std::numeric_limits<double>::max()),
+ min_zoom_(0),
+ max_zoom_(std::numeric_limits<double>::max()),
active_(true),
queryable_(false),
clear_label_cache_(false),
@@ -50,8 +50,8 @@ layer::layer(std::string const& name, std::string const& srs)
layer::layer(const layer& rhs)
: name_(rhs.name_),
srs_(rhs.srs_),
- minZoom_(rhs.minZoom_),
- maxZoom_(rhs.maxZoom_),
+ min_zoom_(rhs.min_zoom_),
+ max_zoom_(rhs.max_zoom_),
active_(rhs.active_),
queryable_(rhs.queryable_),
clear_label_cache_(rhs.clear_label_cache_),
@@ -76,8 +76,8 @@ void layer::swap(const layer& rhs)
{
name_=rhs.name_;
srs_ = rhs.srs_;
- minZoom_=rhs.minZoom_;
- maxZoom_=rhs.maxZoom_;
+ min_zoom_=rhs.min_zoom_;
+ max_zoom_=rhs.max_zoom_;
active_=rhs.active_;
queryable_=rhs.queryable_;
clear_label_cache_ = rhs.clear_label_cache_;
@@ -124,47 +124,47 @@ std::vector<std::string> & layer::styles()
return styles_;
}
-void layer::setMinZoom(double minZoom)
+void layer::set_min_zoom(double min_zoom)
{
- minZoom_=minZoom;
+ min_zoom_=min_zoom;
}
-void layer::setMaxZoom(double maxZoom)
+void layer::set_max_zoom(double max_zoom)
{
- maxZoom_=maxZoom;
+ max_zoom_=max_zoom;
}
-double layer::getMinZoom() const
+double layer::min_zoom() const
{
- return minZoom_;
+ return min_zoom_;
}
-double layer::getMaxZoom() const
+double layer::max_zoom() const
{
- return maxZoom_;
+ return max_zoom_;
}
-void layer::setActive(bool active)
+void layer::set_active(bool active)
{
active_=active;
}
-bool layer::isActive() const
+bool layer::active() const
{
return active_;
}
-bool layer::isVisible(double scale) const
+bool layer::visible(double scale) const
{
- return isActive() && scale >= minZoom_ - 1e-6 && scale < maxZoom_ + 1e-6;
+ return active() && scale >= min_zoom_ - 1e-6 && scale < max_zoom_ + 1e-6;
}
-void layer::setQueryable(bool queryable)
+void layer::set_queryable(bool queryable)
{
queryable_=queryable;
}
-bool layer::isQueryable() const
+bool layer::queryable() const
{
return queryable_;
}
View
18 src/load_map.cpp
@@ -678,25 +678,25 @@ void map_parser::parse_layer( Map & map, ptree const & lay )
optional<boolean> status = get_opt_attr<boolean>(lay, "status");
if (status)
{
- lyr.setActive( * status );
+ lyr.set_active( * status );
}
- optional<double> minZoom = get_opt_attr<double>(lay, "minzoom");
- if (minZoom)
+ optional<double> min_zoom = get_opt_attr<double>(lay, "minzoom");
+ if (min_zoom)
{
- lyr.setMinZoom( * minZoom );
+ lyr.set_min_zoom( * min_zoom );
}
- optional<double> maxZoom = get_opt_attr<double>(lay, "maxzoom");
- if (maxZoom)
+ optional<double> max_zoom = get_opt_attr<double>(lay, "maxzoom");
+ if (max_zoom)
{
- lyr.setMaxZoom( * maxZoom );
+ lyr.set_max_zoom( * max_zoom );
}
optional<boolean> queryable = get_opt_attr<boolean>(lay, "queryable");
if (queryable)
{
- lyr.setQueryable( * queryable );
+ lyr.set_queryable( * queryable );
}
optional<boolean> clear_cache =
@@ -1661,7 +1661,7 @@ void map_parser::parse_raster_symbolizer( rule & rule, ptree const & sym )
if (css_tag.first == "RasterColorizer")
{
- raster_colorizer_ptr colorizer(new raster_colorizer());
+ raster_colorizer_ptr colorizer = boost::make_shared<raster_colorizer>();
raster_sym.set_colorizer(colorizer);
parse_raster_colorizer(colorizer, css_tag.second);
}
View
102 src/map.cpp
@@ -29,6 +29,9 @@
#include <mapnik/hit_test_filter.hpp>
#include <mapnik/scale_denominator.hpp>
+// boost
+#include <boost/make_shared.hpp>
+
// icu
#include <unicode/uversion.h>
@@ -396,7 +399,7 @@ void Map::zoom_all()
std::vector<layer>::const_iterator end = layers_.end();
while (itr != end)
{
- if (itr->isActive())
+ if (itr->active())
{
std::string const& layer_srs = itr->srs();
projection proj1(layer_srs);
@@ -451,54 +454,57 @@ void Map::zoom_to_box(const box2d<double> &box)
void Map::fixAspectRatio()
{
- double ratio1 = (double) width_ / (double) height_;
- double ratio2 = current_extent_.width() / current_extent_.height();
- if (ratio1 == ratio2) return;
-
- switch(aspectFixMode_)
+ if (current_extent_.width() > 0 && current_extent_.height() > 0)
{
- case ADJUST_BBOX_HEIGHT:
- current_extent_.height(current_extent_.width() / ratio1);
- break;
- case ADJUST_BBOX_WIDTH:
- current_extent_.width(current_extent_.height() * ratio1);
- break;
- case ADJUST_CANVAS_HEIGHT:
- height_ = int (width_ / ratio2 + 0.5);
- break;
- case ADJUST_CANVAS_WIDTH:
- width_ = int (height_ * ratio2 + 0.5);
- break;
- case GROW_BBOX:
- if (ratio2 > ratio1)
- current_extent_.height(current_extent_.width() / ratio1);
- else
- current_extent_.width(current_extent_.height() * ratio1);
- break;
- case SHRINK_BBOX:
- if (ratio2 < ratio1)
+ double ratio1 = static_cast<double>(width_) / static_cast<double>(height_);
+ double ratio2 = current_extent_.width() / current_extent_.height();
+ if (ratio1 == ratio2) return;
+
+ switch(aspectFixMode_)
+ {
+ case ADJUST_BBOX_HEIGHT:
current_extent_.height(current_extent_.width() / ratio1);
- else
+ break;
+ case ADJUST_BBOX_WIDTH:
current_extent_.width(current_extent_.height() * ratio1);
- break;
- case GROW_CANVAS:
- if (ratio2 > ratio1)
- width_ = (int) (height_ * ratio2 + 0.5);
- else
- height_ = int (width_ / ratio2 + 0.5);
- break;
- case SHRINK_CANVAS:
- if (ratio2 > ratio1)
+ break;
+ case ADJUST_CANVAS_HEIGHT:
height_ = int (width_ / ratio2 + 0.5);
- else
- width_ = (int) (height_ * ratio2 + 0.5);
- break;
- default:
- if (ratio2 > ratio1)
- current_extent_.height(current_extent_.width() / ratio1);
- else
- current_extent_.width(current_extent_.height() * ratio1);
- break;
+ break;
+ case ADJUST_CANVAS_WIDTH:
+ width_ = int (height_ * ratio2 + 0.5);
+ break;
+ case GROW_BBOX:
+ if (ratio2 > ratio1)
+ current_extent_.height(current_extent_.width() / ratio1);
+ else
+ current_extent_.width(current_extent_.height() * ratio1);
+ break;
+ case SHRINK_BBOX:
+ if (ratio2 < ratio1)
+ current_extent_.height(current_extent_.width() / ratio1);
+ else
+ current_extent_.width(current_extent_.height() * ratio1);
+ break;
+ case GROW_CANVAS:
+ if (ratio2 > ratio1)
+ width_ = static_cast<int>(height_ * ratio2 + 0.5);
+ else
+ height_ = int (width_ / ratio2 + 0.5);
+ break;
+ case SHRINK_CANVAS:
+ if (ratio2 > ratio1)
+ height_ = int (width_ / ratio2 + 0.5);
+ else
+ width_ = static_cast<int>(height_ * ratio2 + 0.5);
+ break;
+ default:
+ if (ratio2 > ratio1)
+ current_extent_.height(current_extent_.width() / ratio1);
+ else
+ current_extent_.width(current_extent_.height() * ratio1);
+ break;
+ }
}
}
@@ -581,7 +587,8 @@ featureset_ptr Map::query_point(unsigned index, double x, double y) const
#endif
featureset_ptr fs = ds->features_at_point(mapnik::coord2d(x,y));
if (fs)
- return featureset_ptr(new filter_featureset<hit_test_filter>(fs,hit_test_filter(x,y,tol)));
+ return boost::make_shared<filter_featureset<hit_test_filter> >(fs,
+ hit_test_filter(x,y,tol));
}
}
catch (...)
@@ -626,7 +633,8 @@ featureset_ptr Map::query_map_point(unsigned index, double x, double y) const
#endif
featureset_ptr fs = ds->features_at_point(mapnik::coord2d(x,y));
if (fs)
- return featureset_ptr(new filter_featureset<hit_test_filter>(fs,hit_test_filter(x,y,tol)));
+ return boost::make_shared<filter_featureset<hit_test_filter> >(fs,
+ hit_test_filter(x,y,tol));
}
}
catch (...)
View
13 src/mapped_memory_cache.cpp
@@ -29,13 +29,22 @@
#include <boost/assert.hpp>
#include <boost/interprocess/file_mapping.hpp>
#include <boost/filesystem/operations.hpp>
+#include <boost/make_shared.hpp>
namespace mapnik
{
boost::unordered_map<std::string, mapped_region_ptr> mapped_memory_cache::cache_;
-bool mapped_memory_cache::insert (std::string const& uri, mapped_region_ptr mem)
+void mapped_memory_cache::clear()
+{
+#ifdef MAPNIK_THREADSAFE
+ mutex::scoped_lock lock(mutex_);
+#endif
+ return cache_.clear();
+}
+
+bool mapped_memory_cache::insert(std::string const& uri, mapped_region_ptr mem)
{
#ifdef MAPNIK_THREADSAFE
mutex::scoped_lock lock(mutex_);
@@ -63,7 +72,7 @@ boost::optional<mapped_region_ptr> mapped_memory_cache::find(std::string const&
try
{
file_mapping mapping(uri.c_str(),read_only);
- mapped_region_ptr region(new mapped_region(mapping,read_only));
+ mapped_region_ptr region(boost::make_shared<mapped_region>(mapping,read_only));
result.reset(region);
View
10 src/marker_cache.cpp
@@ -44,7 +44,15 @@ namespace mapnik
boost::unordered_map<std::string, marker_ptr> marker_cache::cache_;
-bool marker_cache::insert (std::string const& uri, marker_ptr path)
+void marker_cache::clear()
+{
+#ifdef MAPNIK_THREADSAFE
+ mutex::scoped_lock lock(mutex_);
+#endif
+ return cache_.clear();
+}
+
+bool marker_cache::insert(std::string const& uri, marker_ptr path)
{
#ifdef MAPNIK_THREADSAFE
mutex::scoped_lock lock(mutex_);
View
8 src/memory_datasource.cpp
@@ -25,6 +25,10 @@
#include <mapnik/memory_datasource.hpp>
#include <mapnik/memory_featureset.hpp>
#include <mapnik/feature_factory.hpp>
+
+// boost
+#include <boost/make_shared.hpp>
+
// stl
#include <algorithm>
@@ -76,7 +80,7 @@ datasource::datasource_t memory_datasource::type() const
featureset_ptr memory_datasource::features(const query& q) const
{
- return featureset_ptr(new memory_featureset(q.get_bbox(),*this));
+ return boost::make_shared<memory_featureset>(q.get_bbox(),*this);
}
@@ -86,7 +90,7 @@ featureset_ptr memory_datasource::features_at_point(coord2d const& pt) const
#ifdef MAPNIK_DEBUG
std::clog << "box=" << box << ", pt x=" << pt.x << ", y=" << pt.y << "\n";
#endif
- return featureset_ptr(new memory_featureset(box,*this));
+ return boost::make_shared<memory_featureset>(box,*this);
}
box2d<double> memory_datasource::envelope() const
View
5 src/metawriter_factory.cpp
@@ -27,6 +27,7 @@
#include <mapnik/metawriter_json.hpp>
#include <mapnik/metawriter_inmem.hpp>
+#include <boost/make_shared.hpp>
#include <boost/optional.hpp>
using boost::property_tree::ptree;
@@ -44,7 +45,7 @@ metawriter_create(const boost::property_tree::ptree &pt) {
optional<string> properties = get_opt_attr<string>(pt, "default-output");
if (type == "json") {
string file = get_attr<string>(pt, "file");
- metawriter_json_ptr json = metawriter_json_ptr(new metawriter_json(properties, parse_path(file)));
+ metawriter_json_ptr json = boost::make_shared<metawriter_json>(properties, parse_path(file));
optional<boolean> output_empty = get_opt_attr<boolean>(pt, "output-empty");
if (output_empty) {
json->set_output_empty(*output_empty);
@@ -57,7 +58,7 @@ metawriter_create(const boost::property_tree::ptree &pt) {
writer = json;
} else if (type == "inmem") {
- metawriter_inmem_ptr inmem = metawriter_inmem_ptr(new metawriter_inmem(properties));
+ metawriter_inmem_ptr inmem = boost::make_shared<metawriter_inmem>(properties);
writer = inmem;
} else {
throw config_error(string("Unknown type '") + type + "'");
View
4 src/parse_path.cpp
@@ -23,11 +23,13 @@
#include <mapnik/parse_path.hpp>
#include <mapnik/path_expression_grammar.hpp>
+#include <boost/make_shared.hpp>
+
namespace mapnik {
path_expression_ptr parse_path(std::string const & str)
{
- path_expression_ptr path(new path_expression) ;
+ path_expression_ptr path = boost::make_shared<path_expression>() ;
path_expression_grammar<std::string::const_iterator> g;
std::string::const_iterator itr = str.begin();
View
7 src/placement_finder.cpp
@@ -437,12 +437,11 @@ void placement_finder<DetectorT>::find_point_placement(double label_x,
current_placement->center.y - dy - ci.ymax);
// if there is an overlap with existing envelopes, then exit - no placement
+
if (!detector_.extent().intersects(e) ||
(!p.allow_overlap &&
- !detector_.has_point_placement(e, pi.get_actual_minimum_distance())
- )
- )
- {
+ !detector_.has_point_placement(e, pi.get_actual_minimum_distance())))
+ {
return;
}
View
16 src/save_map.cpp
@@ -631,29 +631,29 @@ void serialize_layer( ptree & map_node, const layer & layer, bool explicit_defau
set_attr( layer_node, "srs", layer.srs() );
}
- if ( !layer.isActive() || explicit_defaults )
+ if ( !layer.active() || explicit_defaults )
{
- set_attr/*<bool>*/( layer_node, "status", layer.isActive() );
+ set_attr/*<bool>*/( layer_node, "status", layer.active() );
}
if ( layer.clear_label_cache() || explicit_defaults )
{
set_attr/*<bool>*/( layer_node, "clear-label-cache", layer.clear_label_cache() );
}
- if ( layer.getMinZoom() )
+ if ( layer.min_zoom() )
{
- set_attr( layer_node, "minzoom", layer.getMinZoom() );
+ set_attr( layer_node, "minzoom", layer.min_zoom() );
}
- if ( layer.getMaxZoom() != std::numeric_limits<double>::max() )
+ if ( layer.max_zoom() != std::numeric_limits<double>::max() )
{
- set_attr( layer_node, "maxzoom", layer.getMaxZoom() );
+ set_attr( layer_node, "maxzoom", layer.max_zoom() );
}
- if ( layer.isQueryable() || explicit_defaults )
+ if ( layer.queryable() || explicit_defaults )
{
- set_attr( layer_node, "queryable", layer.isQueryable() );
+ set_attr( layer_node, "queryable", layer.queryable() );
}
if ( layer.cache_features() || explicit_defaults )
View
2 src/text_placements/registry.cpp
@@ -23,6 +23,7 @@
#include <mapnik/text_placements/registry.hpp>
#include <mapnik/text_placements/simple.hpp>
#include <mapnik/text_placements/list.hpp>
+#include <mapnik/text_placements/dummy.hpp>
namespace mapnik
{
@@ -33,6 +34,7 @@ registry::registry()
{
register_name("simple", &text_placements_simple::from_xml);
register_name("list", &text_placements_list::from_xml);
+ register_name("dummy", &text_placements_list::from_xml);
}
void registry::register_name(std::string name, from_xml_function_ptr ptr, bool overwrite)
View
5 src/text_properties.cpp
@@ -26,6 +26,9 @@
#include <mapnik/expression_string.hpp>
#include <mapnik/formatting/text.hpp>
+// boost
+#include <boost/make_shared.hpp>
+
namespace mapnik
{
using boost::optional;
@@ -218,7 +221,7 @@ void text_symbolizer_properties::add_expressions(expression_set &output) const
void text_symbolizer_properties::set_old_style_expression(expression_ptr expr)
{
- tree_ = formatting::node_ptr(new formatting::text_node(expr));
+ tree_ = boost::make_shared<formatting::text_node>(expr);
}
char_properties::char_properties() :
View
7 tests/visual_tests/test.py
@@ -2,12 +2,11 @@
# -*- coding: utf-8 -*-
import mapnik
-import cairo
import sys
import os.path
from compare import compare, summary
-dirname = os.path.dirname(sys.argv[0])
+dirname = os.path.dirname(__file__)
files = [
("list", 800, 600, 400, 300, 250, 200, 150, 100),
("simple", 800, 600, 400, 300, 250, 200, 150, 100),
@@ -40,7 +39,7 @@ def render(filename, width, height=100):
mapnik.load_map(m, os.path.join(dirname, "%s.xml" % filename), False)
bbox = mapnik.Box2d(-0.05, -0.01, 0.95, 0.01)
m.zoom_to_box(bbox)
- basefn = '%s-%d' % (filename, width)
+ basefn = os.path.join(dirname,'%s-%d' % (filename, width))
mapnik.render_to_file(m, basefn+'-agg.png')
diff = compare(basefn + '-agg.png', basefn + '-reference.png')
if diff > 0:
@@ -61,6 +60,6 @@ def render(filename, width, height=100):
m = render(f[0], width[0], width[1])
else:
m = render(f[0], width)
- mapnik.save_map(m, "%s-out.xml" % f[0])
+ mapnik.save_map(m, os.path.join(dirname,"%s-out.xml" % f[0]))
summary()
View
9 utils/performance/mapnik-speed-check
@@ -39,6 +39,11 @@ def f_(set):
if __name__=='__main__':
# if passed, set up bbox
+
+ #test_ = "load()"
+ test_ = "render()"
+ init(stylesheet)
+
if len(sys.argv) == 4:
bbox = sys.argv[3]
if ',' in bbox:
@@ -47,10 +52,6 @@ if __name__=='__main__':
parts = bbox.split(' ')
env = mapnik.Box2d(*map(float,parts))
m.zoom_to_box(env)
-
- #test_ = "load()"
- test_ = "render()"
- init(stylesheet)
# load once - making sure mmap'd shapefiles are loaded
eval(test_)

0 comments on commit d206657

Please sign in to comment.
Something went wrong with that request. Please try again.