added feature factory
This commit is contained in:
parent
fc015c3a10
commit
01f9df9b43
13 changed files with 182 additions and 76 deletions
|
@ -28,7 +28,7 @@ opts.Add(PathOption('AGG_ROOT','agg source root directory','/opt/agg23'))
|
||||||
opts.Add(PathOption('FREETYPE2_ROOT','freetype2 root directory','/opt/freetype2'))
|
opts.Add(PathOption('FREETYPE2_ROOT','freetype2 root directory','/opt/freetype2'))
|
||||||
opts.Add(PathOption('PYTHON_ROOT','python root directory','/opt/python'))
|
opts.Add(PathOption('PYTHON_ROOT','python root directory','/opt/python'))
|
||||||
opts.Add('PYTHON_VERSION','python version','2.4')
|
opts.Add('PYTHON_VERSION','python version','2.4')
|
||||||
opts.Add(ListOption('DATASOURCES','list of available datasources','postgis',['postgis','shape']))
|
opts.Add(ListOption('DATASOURCES','list of available datasources','shape',['postgis','shape','raster']))
|
||||||
opts.Add('POSTGRESQL_ROOT','path to postgresql prefix','/usr/local')
|
opts.Add('POSTGRESQL_ROOT','path to postgresql prefix','/usr/local')
|
||||||
|
|
||||||
platform = ARGUMENTS.get("OS",Platform())
|
platform = ARGUMENTS.get("OS",Platform())
|
||||||
|
@ -36,9 +36,9 @@ platform = ARGUMENTS.get("OS",Platform())
|
||||||
build_dir = 'build'
|
build_dir = 'build'
|
||||||
build_prefix = build_dir+'/'+str(platform)
|
build_prefix = build_dir+'/'+str(platform)
|
||||||
|
|
||||||
cxx = 'g++'
|
#cxx = 'g++'
|
||||||
|
|
||||||
env = Environment(CXX=cxx,ENV=os.environ, options=opts)
|
env = Environment(ENV=os.environ, options=opts)
|
||||||
|
|
||||||
cxx_debug='-Wall -ftemplate-depth-100 -O0 -fno-inline -g -pthread -DDEBUG'
|
cxx_debug='-Wall -ftemplate-depth-100 -O0 -fno-inline -g -pthread -DDEBUG'
|
||||||
cxx_release='-Wall -ftemplate-depth-100 -O3 -finline-functions -Wno-inline -pthread -DNDEBUG'
|
cxx_release='-Wall -ftemplate-depth-100 -O3 -finline-functions -Wno-inline -pthread -DNDEBUG'
|
||||||
|
|
|
@ -86,6 +86,11 @@ namespace mapnik
|
||||||
{
|
{
|
||||||
return raster_;
|
return raster_;
|
||||||
}
|
}
|
||||||
|
void set_raster(raster_type const& raster)
|
||||||
|
{
|
||||||
|
raster_=raster;
|
||||||
|
}
|
||||||
|
|
||||||
void reserve_props(unsigned n)
|
void reserve_props(unsigned n)
|
||||||
{
|
{
|
||||||
props_.reserve(n);
|
props_.reserve(n);
|
||||||
|
|
37
include/feature_factory.hpp
Normal file
37
include/feature_factory.hpp
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
/* This file is part of Mapnik (c++ mapping toolkit)
|
||||||
|
* Copyright (C) 2005 Artem Pavlenko
|
||||||
|
*
|
||||||
|
* Mapnik is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//$Id$
|
||||||
|
|
||||||
|
#ifndef FEATURE_FACTORY_HPP
|
||||||
|
#define FEATURE_FACTORY_HPP
|
||||||
|
|
||||||
|
#include "feature.hpp"
|
||||||
|
namespace mapnik
|
||||||
|
{
|
||||||
|
struct feature_factory
|
||||||
|
{
|
||||||
|
static Feature* create (int fid)
|
||||||
|
{
|
||||||
|
return new Feature(fid);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif //FEATURE_FACTORY_HPP
|
|
@ -65,8 +65,8 @@ namespace mapnik
|
||||||
void add_to_selection(ref_ptr<Feature>& feature) const;
|
void add_to_selection(ref_ptr<Feature>& feature) const;
|
||||||
std::vector<ref_ptr<Feature> >& selection() const;
|
std::vector<ref_ptr<Feature> >& selection() const;
|
||||||
void clear_selection() const;
|
void clear_selection() const;
|
||||||
const datasource_p& datasource() const;
|
datasource_p const& datasource() const;
|
||||||
const Envelope<double>& envelope() const;
|
Envelope<double> const& envelope() const;
|
||||||
virtual ~Layer();
|
virtual ~Layer();
|
||||||
private:
|
private:
|
||||||
void swap(const Layer& other);
|
void swap(const Layer& other);
|
||||||
|
|
|
@ -28,10 +28,10 @@ namespace mapnik
|
||||||
class Map
|
class Map
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
static const int MIN_MAPSIZE=16;
|
static const unsigned MIN_MAPSIZE=16;
|
||||||
static const int MAX_MAPSIZE=1024;
|
static const unsigned MAX_MAPSIZE=1024;
|
||||||
int width_;
|
unsigned width_;
|
||||||
int height_;
|
unsigned height_;
|
||||||
int srid_;
|
int srid_;
|
||||||
Color background_;
|
Color background_;
|
||||||
std::vector<Layer> layers_;
|
std::vector<Layer> layers_;
|
||||||
|
@ -46,8 +46,11 @@ namespace mapnik
|
||||||
void removeLayer(size_t index);
|
void removeLayer(size_t index);
|
||||||
void removeLayer(const char* lName);
|
void removeLayer(const char* lName);
|
||||||
std::vector<Layer> const& layers() const;
|
std::vector<Layer> const& layers() const;
|
||||||
int getWidth() const;
|
unsigned getWidth() const;
|
||||||
int getHeight() const;
|
unsigned getHeight() const;
|
||||||
|
void setWidth(unsigned width);
|
||||||
|
void setHeight(unsigned height);
|
||||||
|
void resize(unsigned width,unsigned height);
|
||||||
int srid() const;
|
int srid() const;
|
||||||
void setBackground(const Color& c);
|
void setBackground(const Color& c);
|
||||||
const Color& getBackground() const;
|
const Color& getBackground() const;
|
||||||
|
|
|
@ -57,6 +57,7 @@
|
||||||
#include "wkb.hpp"
|
#include "wkb.hpp"
|
||||||
#include "map.hpp"
|
#include "map.hpp"
|
||||||
#include "feature_type_style.hpp"
|
#include "feature_type_style.hpp"
|
||||||
|
#include "feature_factory.hpp"
|
||||||
#include "math_expr.hpp"
|
#include "math_expr.hpp"
|
||||||
#include "value.hpp"
|
#include "value.hpp"
|
||||||
#include "expression.hpp"
|
#include "expression.hpp"
|
||||||
|
@ -73,4 +74,4 @@ namespace mapnik
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif //MAPNIK_HPP
|
#endif //MAPNIK_HPP
|
||||||
|
|
|
@ -23,8 +23,6 @@
|
||||||
|
|
||||||
#include "symbolizer.hpp"
|
#include "symbolizer.hpp"
|
||||||
#include "image_reader.hpp"
|
#include "image_reader.hpp"
|
||||||
//#include "scanline_aa.hpp"
|
|
||||||
//#include "line_aa.hpp"
|
|
||||||
#include "agg_basics.h"
|
#include "agg_basics.h"
|
||||||
#include "agg_rendering_buffer.h"
|
#include "agg_rendering_buffer.h"
|
||||||
#include "agg_rasterizer_scanline_aa.h"
|
#include "agg_rasterizer_scanline_aa.h"
|
||||||
|
@ -33,6 +31,7 @@
|
||||||
#include "agg_renderer_scanline.h"
|
#include "agg_renderer_scanline.h"
|
||||||
#include "agg_pixfmt_rgba.h"
|
#include "agg_pixfmt_rgba.h"
|
||||||
#include "agg_path_storage.h"
|
#include "agg_path_storage.h"
|
||||||
|
#include "agg_span_allocator.h"
|
||||||
#include "agg_span_pattern_rgba.h"
|
#include "agg_span_pattern_rgba.h"
|
||||||
|
|
||||||
namespace mapnik
|
namespace mapnik
|
||||||
|
@ -50,8 +49,6 @@ namespace mapnik
|
||||||
|
|
||||||
void render(geometry_type& geom,Image32& image) const
|
void render(geometry_type& geom,Image32& image) const
|
||||||
{
|
{
|
||||||
//ScanlineRasterizerAA<Image32> rasterizer(image);
|
|
||||||
//rasterizer.render<SHIFT8>(geom,fill_);
|
|
||||||
typedef agg::renderer_base<agg::pixfmt_rgba32> ren_base;
|
typedef agg::renderer_base<agg::pixfmt_rgba32> ren_base;
|
||||||
typedef agg::renderer_scanline_aa_solid<ren_base> renderer;
|
typedef agg::renderer_scanline_aa_solid<ren_base> renderer;
|
||||||
agg::row_ptr_cache<agg::int8u> buf(image.raw_data(),image.width(),image.height(),
|
agg::row_ptr_cache<agg::int8u> buf(image.raw_data(),image.width(),image.height(),
|
||||||
|
@ -62,14 +59,14 @@ namespace mapnik
|
||||||
double r=fill_.red()/255.0;
|
double r=fill_.red()/255.0;
|
||||||
double g=fill_.green()/255.0;
|
double g=fill_.green()/255.0;
|
||||||
double b=fill_.blue()/255.0;
|
double b=fill_.blue()/255.0;
|
||||||
|
double a=fill_.alpha()/255.0;
|
||||||
renderer ren(renb);
|
renderer ren(renb);
|
||||||
|
|
||||||
agg::rasterizer_scanline_aa<> ras;
|
agg::rasterizer_scanline_aa<> ras;
|
||||||
agg::scanline_u8 sl;
|
agg::scanline_u8 sl;
|
||||||
ras.clip_box(0,0,image.width(),image.height());
|
ras.clip_box(0,0,image.width(),image.height());
|
||||||
ras.add_path(geom);
|
ras.add_path(geom);
|
||||||
ren.color(agg::rgba(r, g, b, 1.0));
|
ren.color(agg::rgba(r, g, b, a));
|
||||||
agg::render_scanlines(ras, sl, ren);
|
agg::render_scanlines(ras, sl, ren);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,8 +89,6 @@ namespace mapnik
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
std::auto_ptr<ImageReader> reader(get_image_reader(type,file));
|
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,pattern_);
|
reader->read(0,0,pattern_);
|
||||||
}
|
}
|
||||||
catch (...)
|
catch (...)
|
||||||
|
@ -107,7 +102,6 @@ namespace mapnik
|
||||||
void render(geometry_type& geom,Image32& image) const
|
void render(geometry_type& geom,Image32& image) const
|
||||||
{
|
{
|
||||||
typedef agg::renderer_base<agg::pixfmt_rgba32> ren_base;
|
typedef agg::renderer_base<agg::pixfmt_rgba32> ren_base;
|
||||||
typedef agg::renderer_scanline_aa_solid<ren_base> renderer_solid;
|
|
||||||
|
|
||||||
agg::row_ptr_cache<agg::int8u> buf(image.raw_data(),image.width(),image.height(),
|
agg::row_ptr_cache<agg::int8u> buf(image.raw_data(),image.width(),image.height(),
|
||||||
image.width()*4);
|
image.width()*4);
|
||||||
|
@ -124,19 +118,23 @@ namespace mapnik
|
||||||
agg::order_rgba,
|
agg::order_rgba,
|
||||||
wrap_x_type,
|
wrap_x_type,
|
||||||
wrap_y_type> span_gen_type;
|
wrap_y_type> span_gen_type;
|
||||||
typedef agg::renderer_scanline_aa<ren_base, span_gen_type> renderer_type;
|
|
||||||
|
|
||||||
|
typedef agg::renderer_scanline_aa<ren_base,
|
||||||
|
agg::span_allocator<agg::rgba8>,
|
||||||
|
span_gen_type> renderer_type;
|
||||||
|
|
||||||
unsigned offset_x = 0;
|
unsigned offset_x = 0;
|
||||||
unsigned offset_y = 0;
|
unsigned offset_y = 0;
|
||||||
|
|
||||||
agg::span_allocator<agg::rgba8> sa;
|
agg::span_allocator<agg::rgba8> sa;
|
||||||
span_gen_type sg(sa, pattern_rbuf, offset_x, offset_y);
|
span_gen_type sg(pattern_rbuf,offset_x, offset_y);
|
||||||
renderer_type rp(renb, sg);
|
renderer_type rp(renb,sa, sg);
|
||||||
|
|
||||||
agg::rasterizer_scanline_aa<> ras;
|
agg::rasterizer_scanline_aa<> ras;
|
||||||
agg::scanline_u8 sl;
|
agg::scanline_u8 sl;
|
||||||
ras.clip_box(0,0,image.width(),image.height());
|
ras.clip_box(0,0,image.width(),image.height());
|
||||||
ras.add_path(geom);
|
ras.add_path(geom);
|
||||||
//ren.color(agg::rgba(r, g, b, 1.0));
|
|
||||||
agg::render_scanlines(ras, sl, rp);
|
agg::render_scanlines(ras, sl, rp);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,29 +33,39 @@ namespace mapnik
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
Envelope<double> bbox_;
|
Envelope<double> bbox_;
|
||||||
|
unsigned width_;
|
||||||
|
unsigned height_;
|
||||||
filter<Feature>* filter_;
|
filter<Feature>* filter_;
|
||||||
std::set<std::string> names_;
|
std::set<std::string> names_;
|
||||||
public:
|
public:
|
||||||
query()
|
query(unsigned width,unsigned height)
|
||||||
: bbox_(std::numeric_limits<double>::min(),
|
: bbox_(std::numeric_limits<double>::min(),
|
||||||
std::numeric_limits<double>::min(),
|
std::numeric_limits<double>::min(),
|
||||||
std::numeric_limits<double>::max(),
|
std::numeric_limits<double>::max(),
|
||||||
std::numeric_limits<double>::max()),
|
std::numeric_limits<double>::max()),
|
||||||
|
width_(width),
|
||||||
|
height_(height),
|
||||||
filter_(new all_filter<Feature>)
|
filter_(new all_filter<Feature>)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
query(const Envelope<double>& bbox)
|
query(const Envelope<double>& bbox,unsigned width,unsigned height)
|
||||||
: bbox_(bbox),
|
: bbox_(bbox),
|
||||||
|
width_(width),
|
||||||
|
height_(height),
|
||||||
filter_(new all_filter<Feature>)
|
filter_(new all_filter<Feature>)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
query(const Envelope<double>& bbox,const filter<Feature>& f)
|
query(const Envelope<double>& bbox,unsigned width,unsigned height,const filter<Feature>& f)
|
||||||
: bbox_(bbox),
|
: bbox_(bbox),
|
||||||
|
width_(width),
|
||||||
|
height_(height),
|
||||||
filter_(f.clone())
|
filter_(f.clone())
|
||||||
{}
|
{}
|
||||||
|
|
||||||
query(const query& other)
|
query(const query& other)
|
||||||
: bbox_(other.bbox_),
|
: bbox_(other.bbox_),
|
||||||
|
width_(other.width_),
|
||||||
|
height_(other.height_),
|
||||||
filter_(other.filter_->clone())
|
filter_(other.filter_->clone())
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
@ -65,6 +75,8 @@ namespace mapnik
|
||||||
delete filter_;
|
delete filter_;
|
||||||
filter_=tmp;
|
filter_=tmp;
|
||||||
bbox_=other.bbox_;
|
bbox_=other.bbox_;
|
||||||
|
width_=other.width_;
|
||||||
|
height_=other.height_;
|
||||||
names_=other.names_;
|
names_=other.names_;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
@ -79,6 +91,16 @@ namespace mapnik
|
||||||
return bbox_;
|
return bbox_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned get_width() const
|
||||||
|
{
|
||||||
|
return width_;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned get_height() const
|
||||||
|
{
|
||||||
|
return height_;
|
||||||
|
}
|
||||||
|
|
||||||
void set_filter(const filter<Feature>& f)
|
void set_filter(const filter<Feature>& f)
|
||||||
{
|
{
|
||||||
filter<Feature>* tmp=f.clone();
|
filter<Feature>* tmp=f.clone();
|
||||||
|
|
|
@ -39,8 +39,11 @@ namespace mapnik
|
||||||
static void render(const Map& map,Image& image);
|
static void render(const Map& map,Image& image);
|
||||||
private:
|
private:
|
||||||
Renderer();
|
Renderer();
|
||||||
static void renderLayer(const Layer& l,const CoordTransform& t,const Envelope<double>& bbox,Image& image);
|
static void render_vector_layer(const Layer& l,unsigned width,unsigned height,
|
||||||
|
const Envelope<double>& bbox,Image& image);
|
||||||
|
static void render_raster_layer(const Layer& l,unsigned width,unsigned height,
|
||||||
|
const Envelope<double>& bbox,Image& image);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif //RENDER_HPP
|
#endif //RENDER_HPP
|
||||||
|
|
|
@ -18,13 +18,12 @@
|
||||||
# $Id$
|
# $Id$
|
||||||
|
|
||||||
#edit this file
|
#edit this file
|
||||||
|
|
||||||
PREFIX = '/opt/mapnik'
|
PREFIX = '/opt/mapnik'
|
||||||
BOOST_ROOT = '/opt/boost'
|
BOOST_ROOT = '/home/artem/projects/boost_1_33_0'
|
||||||
FREETYPE2_ROOT = '/opt/freetype2'
|
FREETYPE2_ROOT = '/usr/include/freetype2'
|
||||||
PYTHON_VERSION = '2.4'
|
PYTHON_VERSION = '2.4'
|
||||||
PYTHON_ROOT = '/opt/python'
|
PYTHON_ROOT = '/opt/python'
|
||||||
AGG_ROOT = '/opt/agg23'
|
AGG_ROOT = '/opt/agg24'
|
||||||
|
|
||||||
# postgis datasource
|
# postgis datasource
|
||||||
POSTGRESQL_ROOT = '/opt/postgresql8'
|
POSTGRESQL_ROOT = '/opt/postgresql8'
|
||||||
|
|
63
src/map.cpp
63
src/map.cpp
|
@ -77,16 +77,44 @@ namespace mapnik
|
||||||
return layers_;
|
return layers_;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Map::getWidth() const
|
unsigned Map::getWidth() const
|
||||||
{
|
{
|
||||||
return width_;
|
return width_;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Map::getHeight() const
|
unsigned Map::getHeight() const
|
||||||
{
|
{
|
||||||
return height_;
|
return height_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Map::setWidth(unsigned width)
|
||||||
|
{
|
||||||
|
if (width >= MIN_MAPSIZE && width <= MAX_MAPSIZE)
|
||||||
|
{
|
||||||
|
width_=width;
|
||||||
|
fixAspectRatio();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Map::setHeight(unsigned height)
|
||||||
|
{
|
||||||
|
if (height >= MIN_MAPSIZE && height <= MAX_MAPSIZE)
|
||||||
|
{
|
||||||
|
height_=height;
|
||||||
|
fixAspectRatio();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void Map::resize(unsigned width,unsigned height)
|
||||||
|
{
|
||||||
|
if (width >= MIN_MAPSIZE && width <= MAX_MAPSIZE &&
|
||||||
|
height >= MIN_MAPSIZE && height <= MAX_MAPSIZE)
|
||||||
|
{
|
||||||
|
width_=width;
|
||||||
|
height_=height;
|
||||||
|
fixAspectRatio();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int Map::srid() const
|
int Map::srid() const
|
||||||
{
|
{
|
||||||
return srid_;
|
return srid_;
|
||||||
|
@ -121,28 +149,15 @@ namespace mapnik
|
||||||
{
|
{
|
||||||
double ratio1 = (double) width_ / (double) height_;
|
double ratio1 = (double) width_ / (double) height_;
|
||||||
double ratio2 = currentExtent_.width() / currentExtent_.height();
|
double ratio2 = currentExtent_.width() / currentExtent_.height();
|
||||||
if (ratio1 >= 1.0)
|
|
||||||
{
|
if (ratio2 > ratio1)
|
||||||
if (ratio2 > ratio1)
|
{
|
||||||
{
|
currentExtent_.height(currentExtent_.width() / ratio1);
|
||||||
currentExtent_.height(currentExtent_.width() / ratio1);
|
}
|
||||||
}
|
else if (ratio2 < ratio1)
|
||||||
else
|
{
|
||||||
{
|
currentExtent_.width(currentExtent_.height() * ratio1);
|
||||||
currentExtent_.width(currentExtent_.height() * ratio1);
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (ratio2 > ratio1)
|
|
||||||
{
|
|
||||||
currentExtent_.width(currentExtent_.height() * ratio1);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
currentExtent_.height(currentExtent_.width() / ratio1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const Envelope<double>& Map::getCurrentExtent() const
|
const Envelope<double>& Map::getCurrentExtent() const
|
||||||
|
|
|
@ -43,15 +43,12 @@ namespace mapnik
|
||||||
{
|
{
|
||||||
|
|
||||||
template <typename Image>
|
template <typename Image>
|
||||||
void Renderer<Image>::renderLayer(const Layer& l,const CoordTransform& t,
|
void Renderer<Image>::render_vector_layer(const Layer& l,unsigned width,unsigned height,
|
||||||
const Envelope<double>& bbox,Image& image)
|
const Envelope<double>& bbox,Image& image)
|
||||||
{
|
{
|
||||||
const datasource_p& ds=l.datasource();
|
const datasource_p& ds=l.datasource();
|
||||||
if (!ds) return;
|
if (!ds) return;
|
||||||
|
CoordTransform t(width,height,bbox);
|
||||||
//volatile named_style_cache* styles=named_style_cache::instance();
|
|
||||||
|
|
||||||
//get copy
|
|
||||||
std::vector<std::string> const& namedStyles=l.styles();
|
std::vector<std::string> const& namedStyles=l.styles();
|
||||||
std::vector<std::string>::const_iterator stylesIter=namedStyles.begin();
|
std::vector<std::string>::const_iterator stylesIter=namedStyles.begin();
|
||||||
while (stylesIter!=namedStyles.end())
|
while (stylesIter!=namedStyles.end())
|
||||||
|
@ -62,7 +59,7 @@ namespace mapnik
|
||||||
attribute_collector<Feature> collector(names);
|
attribute_collector<Feature> collector(names);
|
||||||
property_index<Feature> indexer(names);
|
property_index<Feature> indexer(names);
|
||||||
|
|
||||||
query q(bbox);
|
query q(bbox,width,height);
|
||||||
double scale = 1.0/t.scale();
|
double scale = 1.0/t.scale();
|
||||||
std::vector<rule_type*> if_rules;
|
std::vector<rule_type*> if_rules;
|
||||||
std::vector<rule_type*> else_rules;
|
std::vector<rule_type*> else_rules;
|
||||||
|
@ -148,7 +145,6 @@ namespace mapnik
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//delete feature;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -177,32 +173,59 @@ namespace mapnik
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename Image>
|
||||||
|
void Renderer<Image>::render_raster_layer(const Layer& l,unsigned width,unsigned height,
|
||||||
|
const Envelope<double>& bbox,Image& image)
|
||||||
|
{
|
||||||
|
const datasource_p& ds=l.datasource();
|
||||||
|
if (!ds) return;
|
||||||
|
query q(bbox,width,height);
|
||||||
|
featureset_ptr fs=ds->features(q);
|
||||||
|
if (fs)
|
||||||
|
{
|
||||||
|
feature_ptr feature;
|
||||||
|
while ((feature = fs->next()))
|
||||||
|
{
|
||||||
|
raster_ptr const& raster=feature->get_raster();
|
||||||
|
if (raster)
|
||||||
|
{
|
||||||
|
image.set_rectangle(raster->x_,raster->y_,raster->data_);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
template <typename Image>
|
template <typename Image>
|
||||||
void Renderer<Image>::render(const Map& map,Image& image)
|
void Renderer<Image>::render(const Map& map,Image& image)
|
||||||
{
|
{
|
||||||
timer clock;
|
timer clock;
|
||||||
//////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////
|
||||||
const Envelope<double>& extent=map.getCurrentExtent();
|
const Envelope<double>& extent=map.getCurrentExtent();
|
||||||
std::cout<<"BBOX:"<<extent<<"\n";
|
std::cout<<"BBOX:"<<extent<<std::endl;
|
||||||
double scale=map.scale();
|
double scale=map.scale();
|
||||||
std::cout<<" scale="<<scale<<"\n";
|
std::cout<<" scale="<<scale<<std::endl;
|
||||||
|
|
||||||
unsigned width=map.getWidth();
|
unsigned width=map.getWidth();
|
||||||
unsigned height=map.getHeight();
|
unsigned height=map.getHeight();
|
||||||
CoordTransform t(width,height,extent);
|
|
||||||
const Color& background=map.getBackground();
|
Color const& background=map.getBackground();
|
||||||
image.setBackground(background);
|
image.setBackground(background);
|
||||||
|
|
||||||
for (size_t n=0;n<map.layerCount();++n)
|
for (size_t n=0;n<map.layerCount();++n)
|
||||||
{
|
{
|
||||||
const Layer& l=map.getLayer(n);
|
const Layer& l=map.getLayer(n);
|
||||||
if (l.isVisible(scale))
|
if (l.isVisible(scale)) // TODO: extent check
|
||||||
{
|
{
|
||||||
//TODO make datasource to return its extent!!!
|
if (l.datasource()->type() == datasource::Vector)
|
||||||
renderLayer(l,t,extent,image);
|
{
|
||||||
|
render_vector_layer(l,width,height,extent,image);
|
||||||
|
}
|
||||||
|
else if (l.datasource()->type() == datasource::Raster)
|
||||||
|
{
|
||||||
|
render_raster_layer(l,width,height,extent,image);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
clock.stop();
|
clock.stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue