1. fixed shape datasource bug - attributes were ignored for point/pointz/pointm types
2. use boost::thread for mutex/lock 3 use boost::noncopyable 4 build agg as a shared lib for now 5. corrected panning code in map.cpp 6. improved coord_transform
This commit is contained in:
parent
81ace03173
commit
955ff4c4f5
21 changed files with 204 additions and 337 deletions
|
@ -81,13 +81,10 @@ if not conf.CheckLibWithHeader('tiff','tiff.h','C'):
|
|||
env = conf.Finish()
|
||||
|
||||
Export('env')
|
||||
|
||||
#build boost libs (filesystem, regex, python)
|
||||
env.SConscript('boost/SConscript')
|
||||
|
||||
#build agg lib
|
||||
env.SConscript('agg/SConscript')
|
||||
|
||||
#build boost libs (filesystem, regex, python etc)
|
||||
env.SConscript('boost/SConscript')
|
||||
#main lib
|
||||
SConscript('src/SConscript')
|
||||
|
||||
|
|
|
@ -25,4 +25,5 @@ agg_root = env['AGG_ROOT']
|
|||
agg_headers = agg_root + '/include'
|
||||
agg_src_dir = agg_root + '/src/'
|
||||
agg_src = glob.glob(agg_src_dir + '*.cpp')
|
||||
agg_lib = env.StaticLibrary('libagg',agg_src,LIBS=[],CPPPATH=agg_headers)
|
||||
agg_lib = env.SharedLibrary('libagg',agg_src,LIBS=[],CPPPATH=agg_headers)
|
||||
env.Install(prefix+'/lib',agg_lib)
|
||||
|
|
|
@ -44,3 +44,8 @@ boost_serialization_src = glob.glob(serialization_src_dir+ '*.cpp')
|
|||
lib_boost_serialization = env.SharedLibrary('libboost-serialization',boost_serialization_src,LIBS=[],CPPPATH=boost_root)
|
||||
env.Install(prefix+'/lib',lib_boost_serialization)
|
||||
|
||||
#boost thread
|
||||
thread_src_dir = boost_root + '/libs/thread/src/'
|
||||
boost_thread_src = glob.glob(thread_src_dir+ '*.cpp')
|
||||
lib_boost_thread = env.SharedLibrary('libboost-thread',boost_thread_src,LIBS=[],CPPPATH=boost_root)
|
||||
env.Install(prefix+'/lib',lib_boost_thread)
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include "utils.hpp"
|
||||
#include "connection.hpp"
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <boost/thread/mutex.hpp>
|
||||
|
||||
using namespace mapnik;
|
||||
using std::string;
|
||||
|
@ -68,7 +69,7 @@ public:
|
|||
|
||||
bool registerPool(const ConnectionCreator<Connection>& creator,int initialSize,int maxSize)
|
||||
{
|
||||
Lock lock(&mutex_);
|
||||
mutex::scoped_lock lock(mutex_);
|
||||
if (pools_.find(creator.id())==pools_.end())
|
||||
{
|
||||
return pools_.insert(std::make_pair(creator.id(),
|
||||
|
@ -80,7 +81,7 @@ public:
|
|||
}
|
||||
const boost::shared_ptr<PoolType>& getPool(const std::string& key)
|
||||
{
|
||||
Lock lock(&mutex_);
|
||||
mutex::scoped_lock lock(mutex_);
|
||||
ContType::const_iterator itr=pools_.find(key);
|
||||
if (itr!=pools_.end())
|
||||
{
|
||||
|
@ -92,7 +93,7 @@ public:
|
|||
|
||||
const HolderType& get(const std::string& key)
|
||||
{
|
||||
Lock lock(&mutex_);
|
||||
mutex::scoped_lock lock(mutex_);
|
||||
ContType::const_iterator itr=pools_.find(key);
|
||||
if (itr!=pools_.end())
|
||||
{
|
||||
|
|
|
@ -151,10 +151,9 @@ feature_ptr shape_featureset<filterT>::next()
|
|||
++count_;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
return feature_ptr();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
if (attr_ids_.size())
|
||||
{
|
||||
shape_.dbf().move_to(shape_.id_);
|
||||
|
@ -167,12 +166,11 @@ feature_ptr shape_featureset<filterT>::next()
|
|||
}
|
||||
catch (...)
|
||||
{
|
||||
//TODO
|
||||
std::cerr << "error processing attributes " << std::endl;
|
||||
}
|
||||
++pos;
|
||||
}
|
||||
}
|
||||
}
|
||||
return feature;
|
||||
}
|
||||
else
|
||||
|
|
|
@ -154,6 +154,7 @@ feature_ptr shape_index_featureset<filterT>::next()
|
|||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (attr_ids_.size())
|
||||
{
|
||||
feature->reserve_props(attr_ids_.size());
|
||||
|
@ -172,7 +173,6 @@ feature_ptr shape_index_featureset<filterT>::next()
|
|||
++pos;
|
||||
}
|
||||
}
|
||||
}
|
||||
return feature;
|
||||
}
|
||||
else
|
||||
|
|
|
@ -35,14 +35,13 @@ namespace mapnik
|
|||
int height;
|
||||
double scale_;
|
||||
Envelope<double> extent;
|
||||
coord2d center_;
|
||||
public:
|
||||
CoordTransform(int width,int height,const Envelope<double>& extent)
|
||||
:width(width),height(height),extent(extent),center_(extent.center())
|
||||
:width(width),height(height),extent(extent)
|
||||
{
|
||||
double sx=((double)width)/extent.width();
|
||||
double sy=((double)height)/extent.height();
|
||||
scale_=std::min(sx,sy);
|
||||
scale_=sx;//std::min(sx,sy);
|
||||
}
|
||||
|
||||
inline double scale() const
|
||||
|
@ -50,50 +49,63 @@ namespace mapnik
|
|||
return scale_;
|
||||
}
|
||||
|
||||
double forward_x(double x) const
|
||||
inline void forward_x(double* x) const
|
||||
{
|
||||
return (x-center_.x)*scale_+0.5*width;
|
||||
*x = (*x - extent.minx() ) * scale_;
|
||||
}
|
||||
|
||||
double forward_y(double y) const
|
||||
inline void forward_y(double* y) const
|
||||
{
|
||||
return -(y-center_.y)*scale_+0.5*height;
|
||||
*y = (extent.maxy() - *y) * scale_;
|
||||
}
|
||||
|
||||
inline void backward_x(double* x) const
|
||||
{
|
||||
*x = extent.minx() + *x/scale_;
|
||||
}
|
||||
|
||||
inline void backward_y(double* y) const
|
||||
{
|
||||
*y = extent.maxy() - *y/scale_;
|
||||
}
|
||||
|
||||
inline coord2d& forward(coord2d& c) const
|
||||
{
|
||||
c.x=(c.x-center_.x)*scale_+0.5*width;
|
||||
c.y=-(c.y-center_.y)*scale_+0.5*height;
|
||||
forward_x(&c.x);
|
||||
forward_y(&c.y);
|
||||
return c;
|
||||
}
|
||||
|
||||
inline coord2d& backward(coord2d& c) const
|
||||
{
|
||||
c.x=(c.x-0.5*width)/scale_+center_.x;
|
||||
c.y=-(c.y-0.5*height)/scale_+center_.y;
|
||||
backward_x(&c.x);
|
||||
backward_y(&c.y);
|
||||
return c;
|
||||
}
|
||||
|
||||
inline Envelope<double> forward(const Envelope<double>& e) const
|
||||
{
|
||||
|
||||
double x0=(e.minx()-center_.x)*scale_+0.5*width;
|
||||
double x1=(e.maxx()-center_.x)*scale_+0.5*width;
|
||||
|
||||
double y0=-(e.miny()-center_.y)*scale_+0.5*height;
|
||||
double y1=-(e.maxy()-center_.y)*scale_+0.5*height;
|
||||
|
||||
double x0 = e.minx();
|
||||
double y0 = e.miny();
|
||||
double x1 = e.maxx();
|
||||
double y1 = e.maxy();
|
||||
forward_x(&x0);
|
||||
forward_y(&y0);
|
||||
forward_x(&x1);
|
||||
forward_y(&y1);
|
||||
return Envelope<double>(x0,y0,x1,y1);
|
||||
}
|
||||
|
||||
inline Envelope<double> backward(const Envelope<double>& e) const
|
||||
{
|
||||
|
||||
double x0=(e.minx()-0.5*width)/scale_+center_.x;
|
||||
double x1=(e.maxx()-0.5*width)/scale_+center_.x;
|
||||
|
||||
double y0=-(e.miny()-0.5*height)/scale_+center_.y;
|
||||
double y1=-(e.maxy()-0.5*height)/scale_+center_.y;
|
||||
double x0 = e.minx();
|
||||
double y0 = e.miny();
|
||||
double x1 = e.maxx();
|
||||
double y1 = e.maxy();
|
||||
backward_x(&x0);
|
||||
backward_y(&y0);
|
||||
backward_x(&x1);
|
||||
backward_y(&y1);
|
||||
|
||||
return Envelope<double>(x0,y0,x1,y1);
|
||||
}
|
||||
|
@ -102,8 +114,7 @@ namespace mapnik
|
|||
{
|
||||
for (unsigned i=0;i<coords.size();++i)
|
||||
{
|
||||
coords[i].x=(coords[i].x-center_.x)*scale_+0.5*width;
|
||||
coords[i].y=-(coords[i].y-center_.y)*scale_+0.5*height;
|
||||
forward(coords[i]);
|
||||
}
|
||||
return coords;
|
||||
}
|
||||
|
@ -112,8 +123,7 @@ namespace mapnik
|
|||
{
|
||||
for (unsigned i=0;i<coords.size();++i)
|
||||
{
|
||||
coords[i].x=(coords[i].x-0.5*width)/scale_+center_.x;
|
||||
coords[i].y=-(coords[i].y-0.5*height)/scale_+center_.y;
|
||||
backward(coords[i]);
|
||||
}
|
||||
return coords;
|
||||
}
|
||||
|
|
|
@ -29,7 +29,6 @@
|
|||
#include "query.hpp"
|
||||
#include "feature_layer_desc.hpp"
|
||||
|
||||
//#include "ptr.hpp"
|
||||
#include <boost/shared_ptr.hpp>
|
||||
|
||||
namespace mapnik
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include "feature.hpp"
|
||||
#include <vector>
|
||||
|
||||
|
||||
namespace mapnik
|
||||
{
|
||||
typedef rule<Feature,filter> rule_type;
|
||||
|
@ -50,6 +51,7 @@ namespace mapnik
|
|||
{
|
||||
rules_.push_back(rule);
|
||||
}
|
||||
|
||||
rules const& get_rules() const
|
||||
{
|
||||
return rules_;
|
||||
|
|
|
@ -23,10 +23,12 @@
|
|||
|
||||
#include "symbolizer.hpp"
|
||||
#include "image_data.hpp"
|
||||
#include <boost/utility.hpp>
|
||||
|
||||
namespace mapnik
|
||||
{
|
||||
struct image_symbolizer : public symbolizer
|
||||
struct image_symbolizer : public symbolizer,
|
||||
private boost::noncopyable
|
||||
{
|
||||
private:
|
||||
ImageData32 symbol_;
|
||||
|
@ -40,8 +42,6 @@ namespace mapnik
|
|||
try
|
||||
{
|
||||
std::auto_ptr<ImageReader> reader(get_image_reader(type,file));
|
||||
std::cout<<"image width="<<reader->width()<<std::endl;
|
||||
std::cout<<"image height="<<reader->height()<<std::endl;
|
||||
reader->read(0,0,symbol_);
|
||||
}
|
||||
catch (...)
|
||||
|
@ -56,22 +56,16 @@ namespace mapnik
|
|||
{
|
||||
int w=symbol_.width();
|
||||
int h=symbol_.height();
|
||||
|
||||
geometry_type::path_iterator<SHIFT0> itr=geom.begin<SHIFT0>();
|
||||
while (itr!=geom.end<SHIFT0>())
|
||||
double x,y;
|
||||
unsigned size = geom.num_points();
|
||||
for (unsigned pos = 0; pos < size ;++pos)
|
||||
{
|
||||
int x=itr->x;
|
||||
int y=itr->y;
|
||||
int px=int(x-0.5*w);
|
||||
int py=int(y-0.5*h);
|
||||
geom.vertex(&x,&y);
|
||||
int px=int(x - 0.5 * w);
|
||||
int py=int(y - 0.5 * h);
|
||||
image.set_rectangle(px,py,symbol_);
|
||||
++itr;
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
image_symbolizer(const image_symbolizer&);
|
||||
image_symbolizer& operator=(const image_symbolizer&);
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -45,12 +45,13 @@
|
|||
|
||||
#include "symbolizer.hpp"
|
||||
#include "stroke.hpp"
|
||||
//#include "line_aa.hpp"
|
||||
//#include "scanline_aa.hpp"
|
||||
|
||||
#include <boost/utility.hpp>
|
||||
|
||||
namespace mapnik
|
||||
{
|
||||
struct line_symbolizer : public symbolizer
|
||||
struct line_symbolizer : public symbolizer,
|
||||
private boost::noncopyable
|
||||
{
|
||||
private:
|
||||
stroke stroke_;
|
||||
|
@ -77,27 +78,6 @@ namespace mapnik
|
|||
double g=col.green()/255.0;
|
||||
double b=col.blue()/255.0;
|
||||
|
||||
if (0) //stroke_.width() == 1.0)
|
||||
{
|
||||
typedef agg::renderer_outline_aa<ren_base> renderer_oaa;
|
||||
typedef agg::rasterizer_outline_aa<renderer_oaa> rasterizer_outline_aa;
|
||||
agg::line_profile_aa prof;
|
||||
prof.width(stroke_.get_width());
|
||||
renderer_oaa ren_oaa(renb, prof);
|
||||
rasterizer_outline_aa ras_oaa(ren_oaa);
|
||||
|
||||
ren_oaa.color(agg::rgba(r, g, b, stroke_.get_opacity()));
|
||||
ras_oaa.add_path(geom);
|
||||
|
||||
|
||||
//LineRasterizerAA<Image32> rasterizer(image);
|
||||
//rasterizer.render<SHIFT0>(geom,stroke_.get_color());
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
//typedef agg::renderer_base<agg::pixfmt_rgba32> ren_base;
|
||||
|
||||
typedef agg::renderer_scanline_aa_solid<ren_base> renderer;
|
||||
renderer ren(renb);
|
||||
|
@ -108,7 +88,7 @@ namespace mapnik
|
|||
if (stroke_.has_dash())
|
||||
{
|
||||
|
||||
agg::conv_dash<geometry<vertex2d,vertex_vector> > dash(geom);
|
||||
agg::conv_dash<geometry<vertex2d> > dash(geom);
|
||||
dash_array const& d = stroke_.get_dash_array();
|
||||
dash_array::const_iterator itr = d.begin();
|
||||
dash_array::const_iterator end = d.end();
|
||||
|
@ -117,7 +97,7 @@ namespace mapnik
|
|||
dash.add_dash(itr->first, itr->second);
|
||||
++itr;
|
||||
}
|
||||
agg::conv_stroke<agg::conv_dash<geometry<vertex2d,vertex_vector> > > stroke(dash);
|
||||
agg::conv_stroke<agg::conv_dash<geometry<vertex2d> > > stroke(dash);
|
||||
|
||||
line_join_e join=stroke_.get_line_join();
|
||||
if ( join == MITER_JOIN)
|
||||
|
@ -147,7 +127,7 @@ namespace mapnik
|
|||
}
|
||||
else
|
||||
{
|
||||
agg::conv_stroke<geometry<vertex2d,vertex_vector> > stroke(geom);
|
||||
agg::conv_stroke<geometry<vertex2d> > stroke(geom);
|
||||
|
||||
line_join_e join=stroke_.get_line_join();
|
||||
if ( join == MITER_JOIN)
|
||||
|
@ -176,11 +156,6 @@ namespace mapnik
|
|||
agg::render_scanlines(ras, sl, ren);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
private:
|
||||
line_symbolizer(const line_symbolizer&);
|
||||
line_symbolizer& operator=(const line_symbolizer&);
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include "expression.hpp"
|
||||
|
||||
#include <boost/regex.hpp>
|
||||
#include <iostream>
|
||||
|
||||
namespace mapnik
|
||||
{
|
||||
|
|
|
@ -28,21 +28,6 @@
|
|||
|
||||
namespace mapnik {
|
||||
|
||||
class style_cache : public singleton <style_cache,CreateStatic>
|
||||
{
|
||||
friend class CreateStatic<style_cache>;
|
||||
private:
|
||||
static std::map<std::string,Style > styles_;
|
||||
style_cache();
|
||||
~style_cache();
|
||||
style_cache(const style_cache&);
|
||||
style_cache& operator=(const style_cache&);
|
||||
public:
|
||||
static bool insert(const std::string& name,const Style& style);
|
||||
static void remove(const std::string& name);
|
||||
static const Style& find(const std::string& name);
|
||||
};
|
||||
|
||||
class named_style_cache : public singleton <named_style_cache,CreateStatic>
|
||||
{
|
||||
friend class CreateStatic<named_style_cache>;
|
||||
|
|
|
@ -29,10 +29,11 @@
|
|||
#include <iostream>
|
||||
#include <cmath>
|
||||
|
||||
#include <boost/thread/mutex.hpp>
|
||||
|
||||
namespace mapnik
|
||||
{
|
||||
class Mutex;
|
||||
class Lock;
|
||||
using boost::mutex;
|
||||
|
||||
template <typename T>
|
||||
class CreateUsingNew
|
||||
|
@ -90,7 +91,7 @@ namespace mapnik
|
|||
throw std::runtime_error("dead reference!");
|
||||
}
|
||||
protected:
|
||||
static Mutex mutex_;
|
||||
static mutex mutex_;
|
||||
singleton() {}
|
||||
virtual ~singleton()
|
||||
{
|
||||
|
@ -102,7 +103,7 @@ namespace mapnik
|
|||
{
|
||||
if (!pInstance_)
|
||||
{
|
||||
Lock lock(&mutex_);
|
||||
mutex::scoped_lock lock(mutex_);
|
||||
if (!pInstance_)
|
||||
{
|
||||
if (destroyed_)
|
||||
|
@ -120,7 +121,7 @@ namespace mapnik
|
|||
};
|
||||
|
||||
template <typename T,
|
||||
template <typename T> class CreatePolicy> Mutex singleton<T,CreatePolicy>::mutex_;
|
||||
template <typename T> class CreatePolicy> mutex singleton<T,CreatePolicy>::mutex_;
|
||||
template <typename T,
|
||||
template <typename T> class CreatePolicy> T* singleton<T,CreatePolicy>::pInstance_=0;
|
||||
template <typename T,
|
||||
|
@ -163,59 +164,6 @@ namespace mapnik
|
|||
}
|
||||
};
|
||||
|
||||
class Mutex
|
||||
{
|
||||
private:
|
||||
pthread_mutex_t mutex_;
|
||||
public:
|
||||
Mutex()
|
||||
{
|
||||
pthread_mutex_init(&mutex_,0);
|
||||
}
|
||||
void lock()
|
||||
{
|
||||
pthread_mutex_lock(&mutex_);
|
||||
}
|
||||
void unlock()
|
||||
{
|
||||
pthread_mutex_unlock(&mutex_);
|
||||
}
|
||||
bool trylock()
|
||||
{
|
||||
return (pthread_mutex_trylock(&mutex_)==0);
|
||||
}
|
||||
~Mutex()
|
||||
{
|
||||
pthread_mutex_destroy(&mutex_);
|
||||
}
|
||||
};
|
||||
|
||||
class Lock
|
||||
{
|
||||
private:
|
||||
Mutex* mutex_;
|
||||
public:
|
||||
explicit Lock(Mutex* mutex)
|
||||
:mutex_(mutex)
|
||||
{
|
||||
if (mutex_) mutex_->lock();
|
||||
}
|
||||
|
||||
~Lock()
|
||||
{
|
||||
if (mutex_)
|
||||
mutex_->unlock();
|
||||
}
|
||||
private:
|
||||
Lock();
|
||||
Lock(const Lock&);
|
||||
Lock& operator=(const Lock&);
|
||||
void* operator new(std::size_t);
|
||||
void* operator new[](std::size_t);
|
||||
void operator delete(void*);
|
||||
void operator delete[](void*);
|
||||
Lock* operator&();
|
||||
};
|
||||
|
||||
struct timer
|
||||
{
|
||||
|
@ -269,8 +217,6 @@ namespace mapnik
|
|||
throw BadConversion("fromString("+s+")");
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline bool space (char c)
|
||||
{
|
||||
return isspace(c);
|
||||
|
|
|
@ -127,9 +127,9 @@ namespace mapnik
|
|||
if (pos >= pos_) return;
|
||||
unsigned block = pos >> block_shift;
|
||||
value_type* vertex = vertexs_[block] + (( pos & block_mask) << 1);
|
||||
*vertex=t.forward_x(*vertex);
|
||||
t.forward_x(vertex);
|
||||
++vertex;
|
||||
*vertex=t.forward_y(*vertex);
|
||||
t.forward_y(vertex);
|
||||
}
|
||||
|
||||
private:
|
||||
|
|
|
@ -30,7 +30,7 @@ freetype2_root = env['FREETYPE2_ROOT']
|
|||
|
||||
headers =[ '#include',boost_root,freetype2_root,agg_headers]
|
||||
|
||||
libraries=['rt','z','png','ltdl','jpeg','tiff','agg','boost-filesystem','boost-regex','boost-serialization']
|
||||
libraries=['rt','z','png','ltdl','jpeg','tiff','agg','boost-filesystem','boost-regex','boost-serialization','boost-thread']
|
||||
libpaths = [prefix+'/lib','#agg']
|
||||
linkflags = '-Wl,-rpath-link,. -Wl,-soname,libmapnik.so'
|
||||
|
||||
|
@ -43,15 +43,12 @@ source = Split(
|
|||
image_reader.cpp
|
||||
image_util.cpp
|
||||
layer.cpp
|
||||
line_aa.cpp
|
||||
map.cpp
|
||||
memory.cpp
|
||||
params.cpp
|
||||
plugin.cpp
|
||||
png_reader.cpp
|
||||
render.cpp
|
||||
scanline_aa.cpp
|
||||
scanline.cpp
|
||||
style_cache.cpp
|
||||
style.cpp
|
||||
text.cpp
|
||||
|
|
|
@ -22,6 +22,8 @@
|
|||
|
||||
#include <algorithm>
|
||||
#include <stdexcept>
|
||||
|
||||
#include <boost/thread/mutex.hpp>
|
||||
#include <boost/filesystem/operations.hpp>
|
||||
|
||||
namespace mapnik
|
||||
|
@ -88,7 +90,8 @@ namespace mapnik
|
|||
|
||||
void datasource_cache::register_datasources(const std::string& str)
|
||||
{
|
||||
Lock lock(&mutex_);
|
||||
mutex::scoped_lock lock(mapnik::singleton<mapnik::datasource_cache,
|
||||
mapnik::CreateStatic>::mutex_);
|
||||
filesystem::path path(str);
|
||||
filesystem::directory_iterator end_itr;
|
||||
if (exists(path))
|
||||
|
|
13
src/map.cpp
13
src/map.cpp
|
@ -140,6 +140,7 @@ namespace mapnik
|
|||
double h = factor * currentExtent_.height();
|
||||
currentExtent_ = Envelope<double>(center.x - 0.5 * w, center.y - 0.5 * h,
|
||||
center.x + 0.5 * w, center.y + 0.5 * h);
|
||||
fixAspectRatio();
|
||||
}
|
||||
|
||||
void Map::zoomToBox(const Envelope<double> &box)
|
||||
|
@ -170,10 +171,14 @@ namespace mapnik
|
|||
|
||||
void Map::pan(int x,int y)
|
||||
{
|
||||
CoordTransform t(width_,height_,currentExtent_);
|
||||
coord2d pt(x,y);
|
||||
t.backward(pt);
|
||||
currentExtent_.re_center(pt.x,pt.y);
|
||||
int dx = x - int(0.5 * width_);
|
||||
int dy = int(0.5 * height_) - y;
|
||||
double s = width_/currentExtent_.width();
|
||||
double minx = currentExtent_.minx() + dx/s;
|
||||
double maxx = currentExtent_.maxx() + dx/s;
|
||||
double miny = currentExtent_.miny() + dy/s;
|
||||
double maxy = currentExtent_.maxy() + dy/s;
|
||||
currentExtent_.init(minx,miny,maxx,maxy);
|
||||
}
|
||||
|
||||
void Map::pan_and_zoom(int x,int y,double factor)
|
||||
|
|
|
@ -50,7 +50,6 @@ namespace mapnik
|
|||
std::set<std::string> names;
|
||||
attribute_collector<Feature> collector(names);
|
||||
property_index<Feature> indexer(names);
|
||||
|
||||
query q(bbox,width,height);
|
||||
double scale = 1.0/t.scale();
|
||||
std::vector<rule_type*> if_rules;
|
||||
|
@ -138,28 +137,6 @@ namespace mapnik
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
//if (l.isSelectable() && l.selection().size()) //TODO !!!
|
||||
//{
|
||||
//volatile style_cache* styles=style_cache::instance();
|
||||
// const Style& style=style_cache::instance()->find(l.selection_style());
|
||||
|
||||
// std::vector<ref_ptr<Feature> >& selection=l.selection();
|
||||
|
||||
// Style::Iterator pos = style.begin();
|
||||
// if (pos!=style.end()) {
|
||||
// std::vector<ref_ptr<Feature> >::iterator itr=selection.begin();
|
||||
//
|
||||
// while (itr!=selection.end())
|
||||
// {
|
||||
// geometry_ptr& geom=(*itr)->get_geometry();
|
||||
// geom->transform(t);
|
||||
// (*pos)->render(*geom,image);
|
||||
// ++itr;
|
||||
// }
|
||||
// }
|
||||
// l.clear_selection();
|
||||
//}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -187,11 +164,11 @@ namespace mapnik
|
|||
}
|
||||
|
||||
template <typename Image>
|
||||
void Renderer<Image>::render(const Map& map,Image& image)
|
||||
void Renderer<Image>::render(Map const& map,Image& image)
|
||||
{
|
||||
timer clock;
|
||||
//////////////////////////////////////////////////////
|
||||
const Envelope<double>& extent=map.getCurrentExtent();
|
||||
Envelope<double> const& extent=map.getCurrentExtent();
|
||||
std::cout<<"BBOX:"<<extent<<std::endl;
|
||||
double scale=map.scale();
|
||||
std::cout<<" scale="<<scale<<std::endl;
|
||||
|
@ -204,10 +181,10 @@ namespace mapnik
|
|||
|
||||
for (size_t n=0;n<map.layerCount();++n)
|
||||
{
|
||||
const Layer& l=map.getLayer(n);
|
||||
Layer const& l=map.getLayer(n);
|
||||
if (l.isVisible(scale)) // TODO: extent check
|
||||
{
|
||||
const datasource_p& ds=l.datasource();
|
||||
datasource_p const& ds=l.datasource();
|
||||
if (!ds) continue;
|
||||
if (ds->type() == datasource::Vector)
|
||||
{
|
||||
|
|
|
@ -20,39 +20,10 @@
|
|||
|
||||
#include "style_cache.hpp"
|
||||
#include "line_symbolizer.hpp"
|
||||
#include <boost/thread/mutex.hpp>
|
||||
|
||||
namespace mapnik
|
||||
{
|
||||
|
||||
style_cache::style_cache() {}
|
||||
style_cache::~style_cache() {}
|
||||
|
||||
std::map<std::string,Style> style_cache::styles_;
|
||||
|
||||
bool style_cache::insert(const std::string& name,const Style& style)
|
||||
{
|
||||
Lock lock(&mutex_);
|
||||
return styles_.insert(make_pair(name,style)).second;
|
||||
}
|
||||
|
||||
void style_cache::remove(const std::string& name)
|
||||
{
|
||||
Lock lock(&mutex_);
|
||||
styles_.erase(name);
|
||||
}
|
||||
|
||||
const Style& style_cache::find(const std::string& name)
|
||||
{
|
||||
Lock lock(&mutex_);
|
||||
std::map<std::string,Style>::iterator itr=styles_.find(name);
|
||||
if (itr!=styles_.end())
|
||||
{
|
||||
return itr->second;
|
||||
}
|
||||
static const Style default_style(boost::shared_ptr<symbolizer>(new line_symbolizer(Color(255,0,0))));
|
||||
return default_style;
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
named_style_cache::named_style_cache() {}
|
||||
named_style_cache::~named_style_cache() {}
|
||||
|
||||
|
@ -60,19 +31,19 @@ namespace mapnik
|
|||
|
||||
bool named_style_cache::insert(const std::string& name,const feature_type_style& style)
|
||||
{
|
||||
Lock lock(&mutex_);
|
||||
mutex::scoped_lock lock(mutex_);
|
||||
return styles_.insert(make_pair(name,style)).second;
|
||||
}
|
||||
|
||||
void named_style_cache::remove(const std::string& name)
|
||||
{
|
||||
Lock lock(&mutex_);
|
||||
mutex::scoped_lock lock(mutex_);
|
||||
styles_.erase(name);
|
||||
}
|
||||
|
||||
feature_type_style named_style_cache::find(const std::string& name)
|
||||
{
|
||||
Lock lock(&mutex_);
|
||||
mutex::scoped_lock lock(mutex_);
|
||||
std::map<std::string,feature_type_style>::iterator itr=styles_.find(name);
|
||||
if (itr!=styles_.end())
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue