+ simplify geometry implementation

+ removed multiple geometry typedefs
+ use geometry_type
+ revert to storing vertices in vector_vertex
  (previous implementation using std::vector was
   fragmenting heap causing performance issues with large geometries)
+ FIXME: hit_test is broken!
This commit is contained in:
Artem Pavlenko 2010-11-03 13:19:15 +00:00
parent 0361061053
commit ab101401cd
41 changed files with 333 additions and 623 deletions

View file

@ -33,7 +33,7 @@
#include <mapnik/datasource.hpp> #include <mapnik/datasource.hpp>
#include <mapnik/wkb.hpp> #include <mapnik/wkb.hpp>
mapnik::geometry2d & (mapnik::Feature::*get_geom1)(unsigned) = &mapnik::Feature::get_geometry; mapnik::geometry_type & (mapnik::Feature::*get_geom1)(unsigned) = &mapnik::Feature::get_geometry;
namespace { namespace {

View file

@ -29,12 +29,12 @@
void export_geometry() void export_geometry()
{ {
using namespace boost::python; using namespace boost::python;
using mapnik::geometry2d; using mapnik::geometry_type;
class_<geometry2d, boost::noncopyable>("Geometry2d",no_init) class_<geometry_type, boost::noncopyable>("GeometryType",no_init)
.def("envelope",&geometry2d::envelope) .def("envelope",&geometry_type::envelope)
// .def("__str__",&geometry2d::to_string) // .def("__str__",&geometry_type::to_string)
.def("type",&geometry2d::type) .def("type",&geometry_type::type)
// TODO add other geometry2d methods // TODO add other geometry_type methods
; ;
} }

View file

@ -177,11 +177,11 @@ void MapWidget::mousePressEvent(QMouseEvent* e)
itr->second.to_string().c_str())); itr->second.to_string().c_str()));
} }
} }
typedef mapnik::coord_transform2<mapnik::CoordTransform,mapnik::geometry2d> path_type; typedef mapnik::coord_transform2<mapnik::CoordTransform,mapnik::geometry_type> path_type;
for (unsigned i=0; i<feat->num_geometries();++i) for (unsigned i=0; i<feat->num_geometries();++i)
{ {
mapnik::geometry2d & geom = feat->get_geometry(i); mapnik::geometry_type & geom = feat->get_geometry(i);
path_type path(t,geom,prj_trans); path_type path(t,geom,prj_trans);
if (geom.num_points() > 0) if (geom.num_points() > 0)
{ {

View file

@ -102,7 +102,7 @@ public:
box2d<double> result; box2d<double> result;
for (unsigned i=0;i<num_geometries();++i) for (unsigned i=0;i<num_geometries();++i)
{ {
geometry2d const& geom = get_geometry(i); geometry_type const& geom = get_geometry(i);
if (i==0) if (i==0)
{ {
box2d<double> box = geom.envelope(); box2d<double> box = geom.envelope();
@ -160,7 +160,7 @@ public:
} }
}; };
typedef feature<geometry2d,raster_ptr> Feature; typedef feature<geometry_type,raster_ptr> Feature;
inline std::ostream& operator<< (std::ostream & out,Feature const& f) inline std::ostream& operator<< (std::ostream & out,Feature const& f)
{ {

View file

@ -35,115 +35,16 @@
#include <boost/ptr_container/ptr_vector.hpp> #include <boost/ptr_container/ptr_vector.hpp>
namespace mapnik { namespace mapnik {
enum GeomType {
enum eGeomType {
Point = 1, Point = 1,
LineString = 2, LineString = 2,
Polygon = 3 Polygon = 3
}; };
template <typename T>
class geometry : private boost::noncopyable
{
public:
typedef T vertex_type;
typedef typename vertex_type::type value_type;
public:
geometry () {}
box2d<double> envelope() const
{
box2d<double> result;
double x(0);
double y(0);
rewind(0);
for (unsigned i=0;i<num_points();++i)
{
vertex(&x,&y);
if (i==0)
{
result.init(x,y,x,y);
}
else
{
result.expand_to_include(x,y);
}
}
return result;
}
virtual int type() const=0;
virtual double area() const=0;
virtual bool hit_test(value_type x,value_type y, double tol) const=0;
virtual void label_position(double *x, double *y) const=0;
virtual void move_to(value_type x,value_type y)=0;
virtual void line_to(value_type x,value_type y)=0;
virtual unsigned num_points() const = 0;
virtual unsigned vertex(double* x, double* y) const=0;
virtual void rewind(unsigned) const=0;
virtual void set_capacity(size_t size)=0;
virtual ~geometry() {}
};
template <typename T>
class point : public geometry<T>
{
typedef geometry<T> geometry_base;
typedef typename geometry<T>::vertex_type vertex_type;
typedef typename geometry<T>::value_type value_type;
private:
vertex_type pt_;
public:
point() : geometry<T>() {}
int type() const
{
return Point;
}
double area() const template <typename T, template <typename> class Container=vertex_vector>
{ class geometry
return 0;
}
void label_position(double *x, double *y) const
{
*x = pt_.x;
*y = pt_.y;
}
void move_to(value_type x,value_type y)
{
pt_.x = x;
pt_.y = y;
}
void line_to(value_type ,value_type ) {}
unsigned num_points() const
{
return 1;
}
unsigned vertex(double* x, double* y) const
{
*x = pt_.x;
*y = pt_.y;
return SEG_LINETO;
}
void rewind(unsigned ) const {}
bool hit_test(value_type x,value_type y, double tol) const
{
return point_in_circle(pt_.x,pt_.y, x,y,tol);
}
void set_capacity(size_t) {}
virtual ~point() {}
};
template <typename T, template <typename> class Container=vertex_vector2>
class polygon //: public geometry<T>
{ {
public: public:
typedef T vertex_type; typedef T vertex_type;
@ -151,31 +52,20 @@ public:
typedef Container<vertex_type> container_type; typedef Container<vertex_type> container_type;
private: private:
container_type cont_; container_type cont_;
eGeomType type_;
mutable unsigned itr_; mutable unsigned itr_;
public: public:
typedef typename container_type::const_iterator iterator; geometry(eGeomType type)
: type_(type),
iterator begin() const itr_(0)
{
return cont_.begin();
}
iterator end() const
{
return cont_.end();
}
polygon()
: //geometry_base(),
itr_(0)
{} {}
int type() const eGeomType type() const
{ {
return Polygon; return type_;
} }
double area() const double area() const
{ {
double sum = 0.0; double sum = 0.0;
@ -340,18 +230,20 @@ public:
itr_=0; itr_=0;
} }
bool hit_test(value_type x,value_type y, double tol) const bool hit_test(value_type x, value_type y, double tol) const
{ {
// FIXME !!!!!!!!!
// FIXME: this is a workaround around the regression metioned in // FIXME: this is a workaround around the regression metioned in
// http://trac.mapnik.org/ticket/560, not a definitive solution // http://trac.mapnik.org/ticket/560, not a definitive solution
if (cont_.size() > 1) { //if (cont_.size() > 1) {
return point_inside_path(x,y,cont_.begin(),cont_.end()); // return point_inside_path(x,y,cont_.begin(),cont_.end());
} else if (cont_.size() == 1) { //} else if (cont_.size() == 1) {
// Handle points // Handle points
double x0=boost::get<0>(*cont_.begin()); // double x0=boost::get<0>(*cont_.begin());
double y0=boost::get<1>(*cont_.begin()); // double y0=boost::get<1>(*cont_.begin());
return distance(x, y, x0, y0) <= abs(tol); // return distance(x, y, x0, y0) <= abs(tol);
} //}
return false; return false;
} }
@ -359,132 +251,12 @@ public:
{ {
cont_.set_capacity(size); cont_.set_capacity(size);
} }
//virtual ~polygon() {}
}; };
template <typename T, template <typename> class Container=vertex_vector2> typedef geometry<vertex2d,vertex_vector> geometry_type;
class line_string : public geometry<T> typedef boost::shared_ptr<geometry_type> geometry_ptr;
{ typedef boost::ptr_vector<geometry_type> geometry_containter;
typedef geometry<T> geometry_base;
typedef typename geometry_base::value_type value_type;
typedef typename geometry<T>::vertex_type vertex_type;
typedef Container<vertex_type> container_type;
private:
container_type cont_;
mutable unsigned itr_;
public:
line_string()
: geometry_base(),
itr_(0)
{}
int type() const
{
return LineString;
}
double area() const
{
return 0;
}
void label_position(double *x, double *y) const
{
// calculate mid point on line string
double x0=0;
double y0=0;
double x1=0;
double y1=0;
unsigned size = cont_.size();
if (size == 1)
{
cont_.get_vertex(0,x,y);
}
else if (size == 2)
{
cont_.get_vertex(0,&x0,&y0);
cont_.get_vertex(1,&x1,&y1);
*x = 0.5 * (x1 + x0);
*y = 0.5 * (y1 + y0);
}
else
{
double len=0.0;
for (unsigned pos = 1; pos < size; ++pos)
{
cont_.get_vertex(pos-1,&x0,&y0);
cont_.get_vertex(pos,&x1,&y1);
double dx = x1 - x0;
double dy = y1 - y0;
len += std::sqrt(dx * dx + dy * dy);
}
double midlen = 0.5 * len;
double dist = 0.0;
for (unsigned pos = 1; pos < size;++pos)
{
cont_.get_vertex(pos-1,&x0,&y0);
cont_.get_vertex(pos,&x1,&y1);
double dx = x1 - x0;
double dy = y1 - y0;
double seg_len = std::sqrt(dx * dx + dy * dy);
if (( dist + seg_len) >= midlen)
{
double r = (midlen - dist)/seg_len;
*x = x0 + (x1 - x0) * r;
*y = y0 + (y1 - y0) * r;
break;
}
dist += seg_len;
}
}
}
void line_to(value_type x,value_type y)
{
cont_.push_back(x,y,SEG_LINETO);
}
void move_to(value_type x,value_type y)
{
cont_.push_back(x,y,SEG_MOVETO);
}
unsigned num_points() const
{
return cont_.size();
}
unsigned vertex(double* x, double* y) const
{
return cont_.get_vertex(itr_++,x,y);
}
void rewind(unsigned ) const
{
itr_=0;
}
bool hit_test(value_type x,value_type y, double tol) const
{
return point_on_path(x,y,cont_.begin(),cont_.end(),tol);
}
void set_capacity(size_t size)
{
cont_.set_capacity(size);
}
virtual ~line_string() {}
};
//typedef point<vertex2d> point_impl;
//typedef line_string<vertex2d,vertex_vector2> line_string_impl;
typedef polygon<vertex2d,vertex_vector2> point_impl;
typedef polygon<vertex2d,vertex_vector2> line_string_impl;
typedef polygon<vertex2d,vertex_vector2> polygon_impl;
typedef polygon_impl geometry2d;
typedef boost::shared_ptr<geometry2d> geometry_ptr;
typedef boost::ptr_vector<geometry2d> geometry_containter;
} }
#endif //GEOMETRY_HPP #endif //GEOMETRY_HPP

View file

@ -40,7 +40,7 @@ public:
{ {
for (unsigned i=0;i<feature.num_geometries();++i) for (unsigned i=0;i<feature.num_geometries();++i)
{ {
geometry2d const& geom = feature.get_geometry(i); geometry_type const& geom = feature.get_geometry(i);
if (geom.hit_test(x_,y_,tol_)) if (geom.hit_test(x_,y_,tol_))
return true; return true;
} }

View file

@ -45,27 +45,18 @@ public:
layer_descriptor get_descriptor() const; layer_descriptor get_descriptor() const;
size_t size() const; size_t size() const;
private: private:
std::vector<mapnik::feature_ptr> features_; std::vector<feature_ptr> features_;
}; };
// This class implements a simple way of displaying point-based data // This class implements a simple way of displaying point-based data
// TODO -- possible redesign, move into separate file // TODO -- possible redesign, move into separate file
// //
class MAPNIK_DECL point_datasource : public mapnik::memory_datasource { class MAPNIK_DECL point_datasource : public memory_datasource {
public: public:
point_datasource() : feat_id(0) {} point_datasource() : feat_id(0) {}
void add_point(double x, double y, const char* key, const char* value) { void add_point(double x, double y, const char* key, const char* value);
mapnik::feature_ptr feature(mapnik::feature_factory::create(feat_id++)); inline int type() const { return datasource::Vector; }
mapnik::geometry2d * pt = new mapnik::point_impl;
pt->move_to(x,y);
feature->add_geometry(pt);
mapnik::transcoder tr("utf-8");
(*feature)[key] = tr.transcode(value);
this->push(feature);
}
int type() const { return mapnik::datasource::Vector; }
private: private:
int feat_id; int feat_id;

View file

@ -44,7 +44,7 @@ public:
while (pos_ != end_) while (pos_ != end_)
{ {
for (unsigned i=0; i<(*pos_)->num_geometries();++i) { for (unsigned i=0; i<(*pos_)->num_geometries();++i) {
geometry2d & geom = (*pos_)->get_geometry(i); geometry_type & geom = (*pos_)->get_geometry(i);
#ifdef MAPNIK_DEBUG #ifdef MAPNIK_DEBUG
std::clog << "bbox_=" << bbox_ << ", geom.envelope=" << geom.envelope() << "\n"; std::clog << "bbox_=" << bbox_ << ", geom.envelope=" << geom.envelope() << "\n";
#endif #endif

View file

@ -71,7 +71,7 @@ public:
class metawriter class metawriter
{ {
public: public:
typedef coord_transform2<CoordTransform,geometry2d> path_type; typedef coord_transform2<CoordTransform,geometry_type> path_type;
metawriter(metawriter_properties dflt_properties) : dflt_properties_(dflt_properties) {} metawriter(metawriter_properties dflt_properties) : dflt_properties_(dflt_properties) {}
virtual ~metawriter() {}; virtual ~metawriter() {};
/** Output a rectangular area. /** Output a rectangular area.

View file

@ -44,7 +44,7 @@ namespace mapnik { namespace svg {
template <typename OutputIterator> template <typename OutputIterator>
class svg_generator : private boost::noncopyable class svg_generator : private boost::noncopyable
{ {
typedef coord_transform2<CoordTransform, geometry2d> path_type; typedef coord_transform2<CoordTransform, geometry_type> path_type;
typedef svg::svg_root_attributes_grammar<OutputIterator> root_attributes_grammar; typedef svg::svg_root_attributes_grammar<OutputIterator> root_attributes_grammar;
typedef svg::svg_rect_attributes_grammar<OutputIterator> rect_attributes_grammar; typedef svg::svg_rect_attributes_grammar<OutputIterator> rect_attributes_grammar;

View file

@ -104,38 +104,38 @@ BOOST_FUSION_ADAPT_CLASS(
) )
/*! /*!
* mapnik::geometry2d is adapted to conform to the concepts * mapnik::geometry_type is adapted to conform to the concepts
* required by Karma to be recognized as a container of * required by Karma to be recognized as a container of
* attributes for output generation. * attributes for output generation.
*/ */
namespace boost { namespace spirit { namespace traits { namespace boost { namespace spirit { namespace traits {
template <> template <>
struct is_container<mapnik::geometry2d const> struct is_container<mapnik::geometry_type const>
: mpl::true_ : mpl::true_
{}; {};
template <> template <>
struct container_iterator<mapnik::geometry2d const> struct container_iterator<mapnik::geometry_type const>
{ {
typedef mapnik::geometry2d::iterator type; typedef mapnik::geometry_type::iterator type;
}; };
template <> template <>
struct begin_container<mapnik::geometry2d const> struct begin_container<mapnik::geometry_type const>
{ {
static mapnik::geometry2d::iterator static mapnik::geometry_type::iterator
call(mapnik::geometry2d const& g) call(mapnik::geometry_type const& g)
{ {
return g.begin(); return g.begin();
} }
}; };
template <> template <>
struct end_container<mapnik::geometry2d const> struct end_container<mapnik::geometry_type const>
{ {
static mapnik::geometry2d::iterator static mapnik::geometry_type::iterator
call(mapnik::geometry2d const& g) call(mapnik::geometry_type const& g)
{ {
return g.end(); return g.end();
} }
@ -191,7 +191,7 @@ namespace mapnik { namespace svg {
}; };
template <typename OutputIterator, typename PathType> template <typename OutputIterator, typename PathType>
struct svg_path_data_grammar : karma::grammar<OutputIterator, mapnik::geometry2d()> struct svg_path_data_grammar : karma::grammar<OutputIterator, mapnik::geometry_type()>
{ {
typedef path_coordinate_transformer<PathType> coordinate_transformer; typedef path_coordinate_transformer<PathType> coordinate_transformer;
typedef mapnik::vertex_vector2<mapnik::vertex2d>::vertex_type vertex_type; typedef mapnik::vertex_vector2<mapnik::vertex2d>::vertex_type vertex_type;
@ -234,7 +234,7 @@ namespace mapnik { namespace svg {
path_vertex_transformed_y = double_[_1 = _a][bind(&coordinate_transformer::current_y, &ct_, _a)]; path_vertex_transformed_y = double_[_1 = _a][bind(&coordinate_transformer::current_y, &ct_, _a)];
} }
karma::rule<OutputIterator, mapnik::geometry2d()> svg_path; karma::rule<OutputIterator, mapnik::geometry_type()> svg_path;
karma::rule<OutputIterator, vertex_type()> path_vertex; karma::rule<OutputIterator, vertex_type()> path_vertex;
karma::rule<OutputIterator, int()> path_vertex_command; karma::rule<OutputIterator, int()> path_vertex_command;
karma::rule<OutputIterator, vertex_component_type(), karma::locals<double> > path_vertex_component_x, path_vertex_component_y; karma::rule<OutputIterator, vertex_component_type(), karma::locals<double> > path_vertex_component_x, path_vertex_component_y;

View file

@ -75,10 +75,10 @@ public:
value_type** vertexs=vertexs_ + num_blocks_ - 1; value_type** vertexs=vertexs_ + num_blocks_ - 1;
while ( num_blocks_-- ) while ( num_blocks_-- )
{ {
delete [] *vertexs; ::operator delete(*vertexs);
--vertexs; --vertexs;
} }
delete [] vertexs_; ::operator delete(vertexs_);
} }
} }
unsigned size() const unsigned size() const
@ -121,66 +121,26 @@ private:
{ {
if (block >= max_blocks_) if (block >= max_blocks_)
{ {
value_type** new_vertexs = new value_type* [(max_blocks_ + grow_by) * 2]; value_type** new_vertexs =
static_cast<value_type**>(::operator new (sizeof(value_type*)*((max_blocks_ + grow_by) * 2)));
unsigned char** new_commands = (unsigned char**)(new_vertexs + max_blocks_ + grow_by); unsigned char** new_commands = (unsigned char**)(new_vertexs + max_blocks_ + grow_by);
if (vertexs_) if (vertexs_)
{ {
std::memcpy(new_vertexs,vertexs_,max_blocks_ * sizeof(value_type*)); std::memcpy(new_vertexs,vertexs_,max_blocks_ * sizeof(value_type*));
std::memcpy(new_commands,commands_,max_blocks_ * sizeof(unsigned char*)); std::memcpy(new_commands,commands_,max_blocks_ * sizeof(unsigned char*));
delete [] vertexs_; ::operator delete(vertexs_);
} }
vertexs_ = new_vertexs; vertexs_ = new_vertexs;
commands_ = new_commands; commands_ = new_commands;
max_blocks_ += grow_by; max_blocks_ += grow_by;
} }
vertexs_[block] = new value_type [block_size * 2 + block_size / (sizeof(value_type))]; vertexs_[block] = static_cast<value_type*>(::operator new(sizeof(value_type)*(block_size * 2 + block_size / (sizeof(value_type)))));
commands_[block] = (unsigned char*)(vertexs_[block] + block_size*2); commands_[block] = (unsigned char*)(vertexs_[block] + block_size*2);
++num_blocks_; ++num_blocks_;
} }
}; };
template <typename T>
struct vertex_vector2 //: boost::noncopyable
{
typedef typename T::type value_type;
typedef boost::tuple<value_type,value_type,char> vertex_type;
typedef typename std::vector<vertex_type>::const_iterator const_iterator;
vertex_vector2() {}
unsigned size() const
{
return cont_.size();
}
void push_back (value_type x,value_type y,unsigned command)
{
cont_.push_back(vertex_type(x,y,command));
}
unsigned get_vertex(unsigned pos,value_type* x,value_type* y) const
{
if (pos >= cont_.size()) return SEG_END;
vertex_type const& c = cont_[pos];
*x = boost::get<0>(c);
*y = boost::get<1>(c);
return boost::get<2>(c);
}
const_iterator begin() const
{
return cont_.begin();
}
const_iterator end() const
{
return cont_.end();
}
void set_capacity(size_t size)
{
cont_.reserve(size);
}
private:
std::vector<vertex_type> cont_;
};
} }
#endif //VERTEX_VECTOR_HPP #endif //VERTEX_VECTOR_HPP

View file

@ -33,8 +33,7 @@ using mapnik::box2d;
using mapnik::Feature; using mapnik::Feature;
using mapnik::feature_ptr; using mapnik::feature_ptr;
using mapnik::CoordTransform; using mapnik::CoordTransform;
using mapnik::point_impl; using mapnik::geometry_type;
using mapnik::geometry2d;
using mapnik::datasource_exception; using mapnik::datasource_exception;
@ -345,7 +344,7 @@ feature_ptr gdal_featureset::get_feature_at_point(mapnik::coord2d const& pt)
double det2 = gt[2]*Y + gt[5]*X; double det2 = gt[2]*Y + gt[5]*X;
unsigned x = det2/det, y = det1/det; unsigned x = det2/det, y = det1/det;
if(0<=x && x<raster_xsize && 0<=y && y<raster_ysize) { if(x<raster_xsize && y<raster_ysize) {
#ifdef MAPNIK_DEBUG #ifdef MAPNIK_DEBUG
std::clog << boost::format("GDAL Plugin: pt.x=%f pt.y=%f\n") % pt.x % pt.y; std::clog << boost::format("GDAL Plugin: pt.x=%f pt.y=%f\n") % pt.x % pt.y;
std::clog << boost::format("GDAL Plugin: x=%f y=%f\n") % x % y; std::clog << boost::format("GDAL Plugin: x=%f y=%f\n") % x % y;
@ -358,7 +357,7 @@ feature_ptr gdal_featureset::get_feature_at_point(mapnik::coord2d const& pt)
if(!hasNoData || value!=nodata) { if(!hasNoData || value!=nodata) {
// construct feature // construct feature
feature_ptr feature(new Feature(1)); feature_ptr feature(new Feature(1));
geometry2d * point = new point_impl; geometry_type * point = new geometry_type(mapnik::Point);
point->move_to(pt.x, pt.y); point->move_to(pt.x, pt.y);
feature->add_geometry(point); feature->add_geometry(point);
(*feature)["value"] = value; (*feature)["value"] = value;

View file

@ -72,8 +72,8 @@ feature_ptr kismet_featureset::next()
{ {
value = "wlan_crypted"; value = "wlan_crypted";
} }
mapnik::geometry2d * pt = new mapnik::point_impl; mapnik::geometry_type * pt = new mapnik::geometry_type(mapnik::Point);
pt->move_to(knd.bestlon_, knd.bestlat_); pt->move_to(knd.bestlon_, knd.bestlat_);
feature->add_geometry(pt); feature->add_geometry(pt);
(*feature)[key] = tr_->transcode(value.c_str ()); (*feature)[key] = tr_->transcode(value.c_str ());

View file

@ -44,7 +44,7 @@ using mapnik::feature_ptr;
using mapnik::point_impl; using mapnik::point_impl;
using mapnik::line_string_impl; using mapnik::line_string_impl;
using mapnik::polygon_impl; using mapnik::polygon_impl;
using mapnik::geometry2d; using mapnik::geometry_type;
using mapnik::geometry_utils; using mapnik::geometry_utils;
using mapnik::transcoder; using mapnik::transcoder;
using mapnik::datasource_exception; using mapnik::datasource_exception;
@ -243,7 +243,7 @@ void occi_featureset::convert_point (SDOGeometry* geom, feature_ptr feature, int
SDOPointType* sdopoint = geom->getSdo_point(); SDOPointType* sdopoint = geom->getSdo_point();
if (sdopoint && ! sdopoint->isNull()) if (sdopoint && ! sdopoint->isNull())
{ {
geometry2d* point = new point_impl; geometry_type* point = new geometry_type(mapnik::Point);
point->move_to (sdopoint->getX(), sdopoint->getY()); point->move_to (sdopoint->getX(), sdopoint->getY());
@ -259,10 +259,10 @@ void occi_featureset::convert_linestring (SDOGeometry* geom, feature_ptr feature
if (ord_size >= dimensions) if (ord_size >= dimensions)
{ {
geometry2d * line = new line_string_impl; geometry_type * line = new geometry_type(mapnik::LineString);
line->set_capacity (ord_size); line->set_capacity (ord_size);
fill_geometry2d (line, elem_info, ordinates, dimensions, false); fill_geometry_type (line, elem_info, ordinates, dimensions, false);
feature->add_geometry (line); feature->add_geometry (line);
} }
@ -276,10 +276,10 @@ void occi_featureset::convert_polygon (SDOGeometry* geom, feature_ptr feature, i
if (ord_size >= dimensions) if (ord_size >= dimensions)
{ {
geometry2d * poly = new polygon_impl; geometry_type * poly = new geometry_type(mapnik::Polygon);
poly->set_capacity (ord_size); poly->set_capacity (ord_size);
fill_geometry2d (poly, elem_info, ordinates, dimensions, false); fill_geometry_type (poly, elem_info, ordinates, dimensions, false);
feature->add_geometry (poly); feature->add_geometry (poly);
} }
@ -293,9 +293,9 @@ void occi_featureset::convert_multipoint (SDOGeometry* geom, feature_ptr feature
if (ord_size >= dimensions) if (ord_size >= dimensions)
{ {
geometry2d * point = new point_impl; geometry_type * point = new geometry_type(mapnik::Point);
fill_geometry2d (point, elem_info, ordinates, dimensions, true); fill_geometry_type (point, elem_info, ordinates, dimensions, true);
feature->add_geometry (point); feature->add_geometry (point);
} }
@ -320,10 +320,10 @@ void occi_featureset::convert_multilinestring (SDOGeometry* geom, feature_ptr fe
if (ord_size >= dimensions) if (ord_size >= dimensions)
{ {
geometry2d * line = new line_string_impl; geometry_type * line = new geometry_type(mapnik::LineString);
line->set_capacity (ord_size); line->set_capacity (ord_size);
fill_geometry2d (line, elem_info, ordinates, dimensions, false); fill_geometry_type (line, elem_info, ordinates, dimensions, false);
feature->add_geometry (line); feature->add_geometry (line);
} }
@ -348,10 +348,10 @@ void occi_featureset::convert_multipolygon (SDOGeometry* geom, feature_ptr featu
if (ord_size >= dimensions) if (ord_size >= dimensions)
{ {
geometry2d * poly = new polygon_impl; geometry_type * poly = new geometry_type(mapnik::Polygon);
poly->set_capacity (ord_size); poly->set_capacity (ord_size);
fill_geometry2d (poly, elem_info, ordinates, dimensions, false); fill_geometry_type (poly, elem_info, ordinates, dimensions, false);
feature->add_geometry (poly); feature->add_geometry (poly);
} }
@ -383,7 +383,7 @@ void occi_featureset::convert_collection (SDOGeometry* geom, feature_ptr feature
} }
*/ */
void occi_featureset::fill_geometry2d (geometry2d * geom, void occi_featureset::fill_geometry_type (geometry_type * geom,
const std::vector<Number>& elem_info, const std::vector<Number>& elem_info,
const std::vector<Number>& ordinates, const std::vector<Number>& ordinates,
const int dimensions, const int dimensions,
@ -447,7 +447,7 @@ void occi_featureset::fill_geometry2d (geometry2d * geom,
if (is_linear_element) if (is_linear_element)
{ {
fill_geometry2d (geom, fill_geometry_type (geom,
offset - 1, offset - 1,
next_offset - 1, next_offset - 1,
ordinates, ordinates,
@ -462,7 +462,7 @@ void occi_featureset::fill_geometry2d (geometry2d * geom,
} }
else else
{ {
fill_geometry2d (geom, fill_geometry_type (geom,
offset - 1, offset - 1,
ord_size, ord_size,
ordinates, ordinates,
@ -472,7 +472,7 @@ void occi_featureset::fill_geometry2d (geometry2d * geom,
} }
} }
void occi_featureset::fill_geometry2d (geometry2d * geom, void occi_featureset::fill_geometry_type (geometry_type * geom,
const int real_offset, const int real_offset,
const int next_offset, const int next_offset,
const std::vector<Number>& ordinates, const std::vector<Number>& ordinates,

View file

@ -58,12 +58,12 @@ class occi_featureset : public mapnik::Featureset
void convert_multipolygon (SDOGeometry* geom, mapnik::feature_ptr feature, int dims); void convert_multipolygon (SDOGeometry* geom, mapnik::feature_ptr feature, int dims);
//void convert_multipolygon_2 (SDOGeometry* geom, mapnik::feature_ptr feature, int dims); //void convert_multipolygon_2 (SDOGeometry* geom, mapnik::feature_ptr feature, int dims);
//void convert_collection (SDOGeometry* geom, mapnik::feature_ptr feature, int dims); //void convert_collection (SDOGeometry* geom, mapnik::feature_ptr feature, int dims);
void fill_geometry2d (mapnik::geometry2d * geom, void fill_geometry_type (mapnik::geometry_type * geom,
const std::vector<oracle::occi::Number>& elem_info, const std::vector<oracle::occi::Number>& elem_info,
const std::vector<oracle::occi::Number>& ordinates, const std::vector<oracle::occi::Number>& ordinates,
const int dimensions, const int dimensions,
const bool is_point_geom); const bool is_point_geom);
void fill_geometry2d (mapnik::geometry2d * geom, void fill_geometry_type (mapnik::geometry_type * geom,
const int real_offset, const int real_offset,
const int next_offset, const int next_offset,
const std::vector<oracle::occi::Number>& ordinates, const std::vector<oracle::occi::Number>& ordinates,

View file

@ -37,17 +37,7 @@ using std::endl;
using mapnik::feature_ptr; using mapnik::feature_ptr;
using mapnik::geometry_utils; using mapnik::geometry_utils;
using mapnik::geometry2d; using mapnik::geometry_type;
using mapnik::point_impl;
using mapnik::line_string_impl;
using mapnik::polygon_impl;
/*
using mapnik::query;
using mapnik::box2d;
using mapnik::CoordTransform;
using mapnik::Feature;
*/
void ogr_converter::convert_geometry (OGRGeometry* geom, feature_ptr feature, bool multiple_geometries) void ogr_converter::convert_geometry (OGRGeometry* geom, feature_ptr feature, bool multiple_geometries)
{ {
@ -102,7 +92,7 @@ void ogr_converter::convert_geometry (OGRGeometry* geom, feature_ptr feature, bo
void ogr_converter::convert_point (OGRPoint* geom, feature_ptr feature) void ogr_converter::convert_point (OGRPoint* geom, feature_ptr feature)
{ {
geometry2d* point = new point_impl; geometry_type * point = new geometry_type(mapnik::Point);
point->move_to (geom->getX(), geom->getY()); point->move_to (geom->getX(), geom->getY());
feature->add_geometry (point); feature->add_geometry (point);
} }
@ -110,7 +100,7 @@ void ogr_converter::convert_point (OGRPoint* geom, feature_ptr feature)
void ogr_converter::convert_linestring (OGRLineString* geom, feature_ptr feature) void ogr_converter::convert_linestring (OGRLineString* geom, feature_ptr feature)
{ {
int num_points = geom->getNumPoints (); int num_points = geom->getNumPoints ();
geometry2d * line = new line_string_impl; geometry_type * line = new geometry_type(mapnik::LineString);
line->set_capacity (num_points); line->set_capacity (num_points);
line->move_to (geom->getX (0), geom->getY (0)); line->move_to (geom->getX (0), geom->getY (0));
for (int i=1;i<num_points;++i) for (int i=1;i<num_points;++i)
@ -132,7 +122,7 @@ void ogr_converter::convert_polygon (OGRPolygon* geom, feature_ptr feature)
capacity += interior->getNumPoints (); capacity += interior->getNumPoints ();
} }
geometry2d * poly = new polygon_impl; geometry_type * poly = new geometry_type(mapnik::Polygon);
poly->set_capacity (num_points + capacity); poly->set_capacity (num_points + capacity);
poly->move_to (exterior->getX (0), exterior->getY (0)); poly->move_to (exterior->getX (0), exterior->getY (0));
for (int i=1;i<num_points;++i) for (int i=1;i<num_points;++i)
@ -155,8 +145,8 @@ void ogr_converter::convert_polygon (OGRPolygon* geom, feature_ptr feature)
void ogr_converter::convert_multipoint (OGRMultiPoint* geom, feature_ptr feature) void ogr_converter::convert_multipoint (OGRMultiPoint* geom, feature_ptr feature)
{ {
int num_geometries = geom->getNumGeometries (); int num_geometries = geom->getNumGeometries ();
geometry2d* point = new point_impl; geometry_type * point = new geometry_type(mapnik::Point);
for (int i=0;i<num_geometries;i++) for (int i=0;i<num_geometries;i++)
{ {
OGRPoint* ogrpoint = static_cast<OGRPoint*>(geom->getGeometryRef (i)); OGRPoint* ogrpoint = static_cast<OGRPoint*>(geom->getGeometryRef (i));
@ -188,9 +178,9 @@ void ogr_converter::convert_multilinestring (OGRMultiLineString* geom, feature_p
num_points += ls->getNumPoints (); num_points += ls->getNumPoints ();
} }
geometry2d * line = new line_string_impl; geometry_type * line = new geometry_type(mapnik::LineString);
line->set_capacity (num_points); line->set_capacity (num_points);
for (int i=0;i<num_geometries;i++) for (int i=0;i<num_geometries;i++)
{ {
OGRLineString* ls = static_cast<OGRLineString*>(geom->getGeometryRef (i)); OGRLineString* ls = static_cast<OGRLineString*>(geom->getGeometryRef (i));
@ -231,7 +221,7 @@ void ogr_converter::convert_multipolygon (OGRMultiPolygon* geom, feature_ptr fea
} }
} }
geometry2d * poly = new polygon_impl; geometry_type * poly = new geometry_type(mapnik::Polygon);
poly->set_capacity (capacity); poly->set_capacity (capacity);
for (int i=0;i<num_geometries;i++) for (int i=0;i<num_geometries;i++)

View file

@ -27,113 +27,109 @@
using mapnik::Feature; using mapnik::Feature;
using mapnik::feature_ptr; using mapnik::feature_ptr;
using mapnik::geometry2d; using mapnik::geometry_type;
using mapnik::point_impl;
using mapnik::line_string_impl;
using mapnik::polygon_impl;
using std::cerr; using std::cerr;
using std::endl; using std::endl;
template <typename filterT> template <typename filterT>
osm_featureset<filterT>::osm_featureset(const filterT& filter, osm_featureset<filterT>::osm_featureset(const filterT& filter,
osm_dataset * dataset, osm_dataset * dataset,
const std::set<std::string>& const std::set<std::string>&
attribute_names, attribute_names,
std::string const& encoding) std::string const& encoding)
: filter_(filter), : filter_(filter),
query_ext_(), query_ext_(),
tr_(new transcoder(encoding)), tr_(new transcoder(encoding)),
count_(0), count_(0),
dataset_ (dataset), dataset_ (dataset),
attribute_names_ (attribute_names) attribute_names_ (attribute_names)
{ {
dataset_->rewind(); dataset_->rewind();
} }
template <typename filterT> template <typename filterT>
feature_ptr osm_featureset<filterT>::next() feature_ptr osm_featureset<filterT>::next()
{ {
osm_item * cur_item = dataset_->next_item(); osm_item * cur_item = dataset_->next_item();
feature_ptr feature; feature_ptr feature;
bool success=false; bool success=false;
if(cur_item != NULL) if(cur_item != NULL)
{ {
if(dataset_->current_item_is_node()) if(dataset_->current_item_is_node())
{ {
feature= feature_ptr(new Feature(count_++)); feature= feature_ptr(new Feature(count_++));
double lat = static_cast<osm_node*>(cur_item)->lat; double lat = static_cast<osm_node*>(cur_item)->lat;
double lon = static_cast<osm_node*>(cur_item)->lon; double lon = static_cast<osm_node*>(cur_item)->lon;
geometry2d * point = new point_impl; geometry_type * point = new geometry_type(mapnik::Point);
point->move_to(lon,lat); point->move_to(lon,lat);
feature->add_geometry(point); feature->add_geometry(point);
success=true; success=true;
} }
else if (dataset_->current_item_is_way()) else if (dataset_->current_item_is_way())
{ {
bounds b = static_cast<osm_way*>(cur_item)->get_bounds(); bounds b = static_cast<osm_way*>(cur_item)->get_bounds();
// Loop until we find a feature which passes the filter // Loop until we find a feature which passes the filter
while(cur_item != NULL && while(cur_item != NULL &&
!filter_.pass(box2d<double>(b.w,b.s,b.e,b.n))) !filter_.pass(box2d<double>(b.w,b.s,b.e,b.n)))
{ {
cur_item = dataset_->next_item(); cur_item = dataset_->next_item();
if(cur_item!=NULL) if(cur_item!=NULL)
b = static_cast<osm_way*>(cur_item)->get_bounds(); b = static_cast<osm_way*>(cur_item)->get_bounds();
} }
if(cur_item != NULL) if(cur_item != NULL)
{ {
if(static_cast<osm_way*>(cur_item)->nodes.size()) if(static_cast<osm_way*>(cur_item)->nodes.size())
{ {
feature=feature_ptr(new Feature(count_++)); feature=feature_ptr(new Feature(count_++));
geometry2d *geom; geometry_type *geom;
if(static_cast<osm_way*>(cur_item)->is_polygon()) if(static_cast<osm_way*>(cur_item)->is_polygon())
geom=new polygon_impl; geom=new geometry_type(mapnik::Polygon);
else else
geom=new line_string_impl; geom=new geometry_type(mapnik::LineString);
geom->set_capacity(static_cast<osm_way*>(cur_item)->
nodes.size());
geom->move_to(static_cast<osm_way*>(cur_item)->
nodes[0]->lon,
static_cast<osm_way*>(cur_item)->
nodes[0]->lat);
for(unsigned int count=1; count<static_cast<osm_way*>(cur_item)
->nodes.size(); count++)
{
geom->line_to(static_cast<osm_way*>(cur_item)
->nodes[count]->lon,
static_cast<osm_way*>(cur_item)
->nodes[count]->lat);
}
feature->add_geometry(geom);
success=true;
}
}
}
// can feature_ptr be compared to NULL? - no
if(success)
{
std::map<std::string,std::string>::iterator i=
cur_item->keyvals.begin();
geom->set_capacity(static_cast<osm_way*>(cur_item)-> // add the keyvals to the feature. the feature seems to be a map
nodes.size()); // of some sort so this should work - see dbf_file::add_attribute()
geom->move_to(static_cast<osm_way*>(cur_item)-> while(i != cur_item->keyvals.end())
nodes[0]->lon, {
static_cast<osm_way*>(cur_item)-> //only add if in the specified set of attribute names
nodes[0]->lat); if(attribute_names_.find(i->first) != attribute_names_.end())
(*feature)[i->first] = tr_->transcode(i->second.c_str());
for(unsigned int count=1; count<static_cast<osm_way*>(cur_item) i++;
->nodes.size(); count++) }
{ return feature;
geom->line_to(static_cast<osm_way*>(cur_item) }
->nodes[count]->lon, }
static_cast<osm_way*>(cur_item) return feature_ptr();
->nodes[count]->lat);
}
feature->add_geometry(geom);
success=true;
}
}
}
// can feature_ptr be compared to NULL? - no
if(success)
{
std::map<std::string,std::string>::iterator i=
cur_item->keyvals.begin();
// add the keyvals to the feature. the feature seems to be a map
// of some sort so this should work - see dbf_file::add_attribute()
while(i != cur_item->keyvals.end())
{
//only add if in the specified set of attribute names
if(attribute_names_.find(i->first) != attribute_names_.end())
(*feature)[i->first] = tr_->transcode(i->second.c_str());
i++;
}
return feature;
}
}
return feature_ptr();
} }

View file

@ -36,7 +36,7 @@ using boost::bad_lexical_cast;
using boost::trim_copy; using boost::trim_copy;
using std::string; using std::string;
using mapnik::Feature; using mapnik::Feature;
using mapnik::geometry2d; using mapnik::geometry_type;
using mapnik::byte; using mapnik::byte;
using mapnik::geometry_utils; using mapnik::geometry_utils;

View file

@ -34,7 +34,7 @@ using mapnik::Feature;
using mapnik::feature_ptr; using mapnik::feature_ptr;
using mapnik::CoordTransform; using mapnik::CoordTransform;
using mapnik::point_impl; using mapnik::point_impl;
using mapnik::geometry2d; using mapnik::geometry_type;
using mapnik::query; using mapnik::query;

View file

@ -74,7 +74,7 @@ shape_featureset<filterT>::shape_featureset(const filterT& filter,
template <typename filterT> template <typename filterT>
feature_ptr shape_featureset<filterT>::next() feature_ptr shape_featureset<filterT>::next()
{ {
using mapnik::point_impl; using mapnik::geometry_type;
std::streampos pos=shape_.shp().pos(); std::streampos pos=shape_.shp().pos();
if (pos < std::streampos(file_length_ * 2)) if (pos < std::streampos(file_length_ * 2))
@ -86,7 +86,7 @@ feature_ptr shape_featureset<filterT>::next()
{ {
double x=shape_.shp().read_double(); double x=shape_.shp().read_double();
double y=shape_.shp().read_double(); double y=shape_.shp().read_double();
geometry2d * point = new point_impl; geometry_type * point = new geometry_type(mapnik::Point);
point->move_to(x,y); point->move_to(x,y);
feature->add_geometry(point); feature->add_geometry(point);
++count_; ++count_;
@ -96,7 +96,7 @@ feature_ptr shape_featureset<filterT>::next()
double x=shape_.shp().read_double(); double x=shape_.shp().read_double();
double y=shape_.shp().read_double(); double y=shape_.shp().read_double();
shape_.shp().skip(8); //m shape_.shp().skip(8); //m
geometry2d * point = new point_impl; geometry_type * point = new geometry_type(mapnik::Point);
point->move_to(x,y); point->move_to(x,y);
feature->add_geometry(point); feature->add_geometry(point);
++count_; ++count_;
@ -113,7 +113,7 @@ feature_ptr shape_featureset<filterT>::next()
{ {
shape_.shp().skip(8); shape_.shp().skip(8);
} }
geometry2d * point=new point_impl; geometry_type * point=new geometry_type(mapnik::Point);
point->move_to(x,y); point->move_to(x,y);
feature->add_geometry(point); feature->add_geometry(point);
++count_; ++count_;
@ -146,7 +146,7 @@ feature_ptr shape_featureset<filterT>::next()
{ {
double x=shape_.shp().read_double(); double x=shape_.shp().read_double();
double y=shape_.shp().read_double(); double y=shape_.shp().read_double();
geometry2d * point = new point_impl; geometry_type * point = new geometry_type(mapnik::Point);
point->move_to(x,y); point->move_to(x,y);
feature->add_geometry(point); feature->add_geometry(point);
} }
@ -160,7 +160,7 @@ feature_ptr shape_featureset<filterT>::next()
{ {
double x=shape_.shp().read_double(); double x=shape_.shp().read_double();
double y=shape_.shp().read_double(); double y=shape_.shp().read_double();
geometry2d * point = new point_impl; geometry_type * point = new geometry_type(mapnik::Point);
point->move_to(x,y); point->move_to(x,y);
feature->add_geometry(point); feature->add_geometry(point);
} }
@ -177,7 +177,7 @@ feature_ptr shape_featureset<filterT>::next()
{ {
double x=shape_.shp().read_double(); double x=shape_.shp().read_double();
double y=shape_.shp().read_double(); double y=shape_.shp().read_double();
geometry2d * point = new point_impl; geometry_type * point = new geometry_type(mapnik::Point);
point->move_to(x,y); point->move_to(x,y);
feature->add_geometry(point); feature->add_geometry(point);
} }
@ -197,42 +197,42 @@ feature_ptr shape_featureset<filterT>::next()
} }
case shape_io::shape_polyline: case shape_io::shape_polyline:
{ {
geometry2d * line = shape_.read_polyline(); geometry_type * line = shape_.read_polyline();
feature->add_geometry(line); feature->add_geometry(line);
++count_; ++count_;
break; break;
} }
case shape_io::shape_polylinem: case shape_io::shape_polylinem:
{ {
geometry2d * line = shape_.read_polylinem(); geometry_type * line = shape_.read_polylinem();
feature->add_geometry(line); feature->add_geometry(line);
++count_; ++count_;
break; break;
} }
case shape_io::shape_polylinez: case shape_io::shape_polylinez:
{ {
geometry2d * line = shape_.read_polylinez(); geometry_type * line = shape_.read_polylinez();
feature->add_geometry(line); feature->add_geometry(line);
++count_; ++count_;
break; break;
} }
case shape_io::shape_polygon: case shape_io::shape_polygon:
{ {
geometry2d * poly = shape_.read_polygon(); geometry_type * poly = shape_.read_polygon();
feature->add_geometry(poly); feature->add_geometry(poly);
++count_; ++count_;
break; break;
} }
case shape_io::shape_polygonm: case shape_io::shape_polygonm:
{ {
geometry2d * poly = shape_.read_polygonm(); geometry_type * poly = shape_.read_polygonm();
feature->add_geometry(poly); feature->add_geometry(poly);
++count_; ++count_;
break; break;
} }
case shape_io::shape_polygonz: case shape_io::shape_polygonz:
{ {
geometry2d * poly = shape_.read_polygonz(); geometry_type * poly = shape_.read_polygonz();
feature->add_geometry(poly); feature->add_geometry(poly);
++count_; ++count_;
break; break;

View file

@ -91,7 +91,7 @@ template <typename filterT>
feature_ptr shape_index_featureset<filterT>::next() feature_ptr shape_index_featureset<filterT>::next()
{ {
using mapnik::feature_factory; using mapnik::feature_factory;
using mapnik::point_impl; using mapnik::geometry_type;
if (itr_!=ids_.end()) if (itr_!=ids_.end())
{ {
int pos=*itr_++; int pos=*itr_++;
@ -103,7 +103,7 @@ feature_ptr shape_index_featureset<filterT>::next()
{ {
double x=shape_.shp().read_double(); double x=shape_.shp().read_double();
double y=shape_.shp().read_double(); double y=shape_.shp().read_double();
geometry2d * point = new point_impl; geometry_type * point = new geometry_type(mapnik::Point);
point->move_to(x,y); point->move_to(x,y);
feature->add_geometry(point); feature->add_geometry(point);
++count_; ++count_;
@ -114,7 +114,7 @@ feature_ptr shape_index_featureset<filterT>::next()
double x=shape_.shp().read_double(); double x=shape_.shp().read_double();
double y=shape_.shp().read_double(); double y=shape_.shp().read_double();
shape_.shp().skip(8);// skip m shape_.shp().skip(8);// skip m
geometry2d * point = new point_impl; geometry_type * point = new geometry_type(mapnik::Point);
point->move_to(x,y); point->move_to(x,y);
feature->add_geometry(point); feature->add_geometry(point);
++count_; ++count_;
@ -131,7 +131,7 @@ feature_ptr shape_index_featureset<filterT>::next()
{ {
shape_.shp().skip(8); shape_.shp().skip(8);
} }
geometry2d * point = new point_impl; geometry_type * point = new geometry_type(mapnik::Point);
point->move_to(x,y); point->move_to(x,y);
feature->add_geometry(point); feature->add_geometry(point);
++count_; ++count_;
@ -156,7 +156,7 @@ feature_ptr shape_index_featureset<filterT>::next()
{ {
double x=shape_.shp().read_double(); double x=shape_.shp().read_double();
double y=shape_.shp().read_double(); double y=shape_.shp().read_double();
geometry2d * point = new point_impl; geometry_type * point = new geometry_type(mapnik::Point);
point->move_to(x,y); point->move_to(x,y);
feature->add_geometry(point); feature->add_geometry(point);
} }
@ -166,42 +166,42 @@ feature_ptr shape_index_featureset<filterT>::next()
} }
case shape_io::shape_polyline: case shape_io::shape_polyline:
{ {
geometry2d * line = shape_.read_polyline(); geometry_type * line = shape_.read_polyline();
feature->add_geometry(line); feature->add_geometry(line);
++count_; ++count_;
break; break;
} }
case shape_io::shape_polylinem: case shape_io::shape_polylinem:
{ {
geometry2d * line = shape_.read_polylinem(); geometry_type * line = shape_.read_polylinem();
feature->add_geometry(line); feature->add_geometry(line);
++count_; ++count_;
break; break;
} }
case shape_io::shape_polylinez: case shape_io::shape_polylinez:
{ {
geometry2d * line = shape_.read_polylinez(); geometry_type * line = shape_.read_polylinez();
feature->add_geometry(line); feature->add_geometry(line);
++count_; ++count_;
break; break;
} }
case shape_io::shape_polygon: case shape_io::shape_polygon:
{ {
geometry2d * poly = shape_.read_polygon(); geometry_type * poly = shape_.read_polygon();
feature->add_geometry(poly); feature->add_geometry(poly);
++count_; ++count_;
break; break;
} }
case shape_io::shape_polygonm: case shape_io::shape_polygonm:
{ {
geometry2d * poly = shape_.read_polygonm(); geometry_type * poly = shape_.read_polygonm();
feature->add_geometry(poly); feature->add_geometry(poly);
++count_; ++count_;
break; break;
} }
case shape_io::shape_polygonz: case shape_io::shape_polygonz:
{ {
geometry2d * poly = shape_.read_polygonz(); geometry_type * poly = shape_.read_polygonz();
feature->add_geometry(poly); feature->add_geometry(poly);
++count_; ++count_;
break; break;

View file

@ -27,6 +27,7 @@
using mapnik::datasource_exception; using mapnik::datasource_exception;
using mapnik::geometry_type;
const std::string shape_io::SHP = ".shp"; const std::string shape_io::SHP = ".shp";
const std::string shape_io::DBF = ".dbf"; const std::string shape_io::DBF = ".dbf";
@ -106,14 +107,13 @@ dbf_file& shape_io::dbf()
return dbf_; return dbf_;
} }
geometry2d * shape_io::read_polyline() geometry_type * shape_io::read_polyline()
{ {
using mapnik::line_string_impl;
shape_file::record_type record(reclength_*2-36); shape_file::record_type record(reclength_*2-36);
shp_.read_record(record); shp_.read_record(record);
int num_parts=record.read_ndr_integer(); int num_parts=record.read_ndr_integer();
int num_points=record.read_ndr_integer(); int num_points=record.read_ndr_integer();
geometry2d * line = new line_string_impl; geometry_type * line = new geometry_type(mapnik::LineString);
line->set_capacity(num_points + num_parts); line->set_capacity(num_points + num_parts);
if (num_parts == 1) if (num_parts == 1)
{ {
@ -161,14 +161,13 @@ geometry2d * shape_io::read_polyline()
return line; return line;
} }
geometry2d * shape_io::read_polylinem() geometry_type * shape_io::read_polylinem()
{ {
using mapnik::line_string_impl;
shape_file::record_type record(reclength_*2-36); shape_file::record_type record(reclength_*2-36);
shp_.read_record(record); shp_.read_record(record);
int num_parts=record.read_ndr_integer(); int num_parts=record.read_ndr_integer();
int num_points=record.read_ndr_integer(); int num_points=record.read_ndr_integer();
geometry2d * line = new line_string_impl; geometry_type * line = new geometry_type(mapnik::LineString);
line->set_capacity(num_points + num_parts); line->set_capacity(num_points + num_parts);
if (num_parts == 1) if (num_parts == 1)
{ {
@ -224,14 +223,13 @@ geometry2d * shape_io::read_polylinem()
return line; return line;
} }
geometry2d * shape_io::read_polylinez() geometry_type * shape_io::read_polylinez()
{ {
using mapnik::line_string_impl;
shape_file::record_type record(reclength_*2-36); shape_file::record_type record(reclength_*2-36);
shp_.read_record(record); shp_.read_record(record);
int num_parts=record.read_ndr_integer(); int num_parts=record.read_ndr_integer();
int num_points=record.read_ndr_integer(); int num_points=record.read_ndr_integer();
geometry2d * line = new line_string_impl; geometry_type * line = new geometry_type(mapnik::LineString);
line->set_capacity(num_points + num_parts); line->set_capacity(num_points + num_parts);
if (num_parts == 1) if (num_parts == 1)
{ {
@ -294,15 +292,14 @@ geometry2d * shape_io::read_polylinez()
return line; return line;
} }
geometry2d * shape_io::read_polygon() geometry_type * shape_io::read_polygon()
{ {
using mapnik::polygon_impl;
shape_file::record_type record(reclength_*2-36); shape_file::record_type record(reclength_*2-36);
shp_.read_record(record); shp_.read_record(record);
int num_parts=record.read_ndr_integer(); int num_parts=record.read_ndr_integer();
int num_points=record.read_ndr_integer(); int num_points=record.read_ndr_integer();
std::vector<int> parts(num_parts); std::vector<int> parts(num_parts);
geometry2d * poly = new polygon_impl; geometry_type * poly = new geometry_type(mapnik::Polygon);
poly->set_capacity(num_points + num_parts); poly->set_capacity(num_points + num_parts);
for (int i=0;i<num_parts;++i) for (int i=0;i<num_parts;++i)
{ {
@ -335,15 +332,14 @@ geometry2d * shape_io::read_polygon()
return poly; return poly;
} }
geometry2d * shape_io::read_polygonm() geometry_type * shape_io::read_polygonm()
{ {
using mapnik::polygon_impl;
shape_file::record_type record(reclength_*2-36); shape_file::record_type record(reclength_*2-36);
shp_.read_record(record); shp_.read_record(record);
int num_parts=record.read_ndr_integer(); int num_parts=record.read_ndr_integer();
int num_points=record.read_ndr_integer(); int num_points=record.read_ndr_integer();
std::vector<int> parts(num_parts); std::vector<int> parts(num_parts);
geometry2d * poly = new polygon_impl; geometry_type * poly = new geometry_type(mapnik::Polygon);
poly->set_capacity(num_points + num_parts); poly->set_capacity(num_points + num_parts);
for (int i=0;i<num_parts;++i) for (int i=0;i<num_parts;++i)
{ {
@ -384,15 +380,14 @@ geometry2d * shape_io::read_polygonm()
return poly; return poly;
} }
geometry2d * shape_io::read_polygonz() geometry_type * shape_io::read_polygonz()
{ {
using mapnik::polygon_impl;
shape_file::record_type record(reclength_*2-36); shape_file::record_type record(reclength_*2-36);
shp_.read_record(record); shp_.read_record(record);
int num_parts=record.read_ndr_integer(); int num_parts=record.read_ndr_integer();
int num_points=record.read_ndr_integer(); int num_points=record.read_ndr_integer();
std::vector<int> parts(num_parts); std::vector<int> parts(num_parts);
geometry2d * poly=new polygon_impl; geometry_type * poly=new geometry_type(mapnik::Polygon);
poly->set_capacity(num_points + num_parts); poly->set_capacity(num_points + num_parts);
for (int i=0;i<num_parts;++i) for (int i=0;i<num_parts;++i)
{ {

View file

@ -35,8 +35,6 @@
#include <boost/iostreams/device/file.hpp> #include <boost/iostreams/device/file.hpp>
#include <boost/iostreams/device/mapped_file.hpp> #include <boost/iostreams/device/mapped_file.hpp>
using mapnik::geometry2d;
struct shape_io : boost::noncopyable struct shape_io : boost::noncopyable
{ {
static const std::string SHP; static const std::string SHP;
@ -89,12 +87,12 @@ public:
void move_to(int id); void move_to(int id);
int type() const; int type() const;
const box2d<double>& current_extent() const; const box2d<double>& current_extent() const;
geometry2d * read_polyline(); mapnik::geometry_type * read_polyline();
geometry2d * read_polylinem(); mapnik::geometry_type * read_polylinem();
geometry2d * read_polylinez(); mapnik::geometry_type * read_polylinez();
geometry2d * read_polygon(); mapnik::geometry_type * read_polygon();
geometry2d * read_polygonm(); mapnik::geometry_type * read_polygonm();
geometry2d * read_polygonz(); mapnik::geometry_type * read_polygonz();
}; };
#endif //SHAPE_IO_HPP #endif //SHAPE_IO_HPP

View file

@ -41,10 +41,6 @@ using mapnik::box2d;
using mapnik::CoordTransform; using mapnik::CoordTransform;
using mapnik::Feature; using mapnik::Feature;
using mapnik::feature_ptr; using mapnik::feature_ptr;
using mapnik::point_impl;
using mapnik::line_string_impl;
using mapnik::polygon_impl;
using mapnik::geometry2d;
using mapnik::geometry_utils; using mapnik::geometry_utils;
using mapnik::transcoder; using mapnik::transcoder;

View file

@ -24,7 +24,7 @@ mapnik::feature_ptr hello_featureset::next()
mapnik::coord2d center = box_.center(); mapnik::coord2d center = box_.center();
// create a new geometry // create a new geometry
mapnik::geometry2d * point = new mapnik::point_impl; mapnik::geometry_type * point = new mapnik::point_impl;
// we use path type geometries in Mapnik to fit nicely with AGG and Cairo // we use path type geometries in Mapnik to fit nicely with AGG and Cairo
// here we stick an x,y pair into the geometry // here we stick an x,y pair into the geometry

View file

@ -54,8 +54,8 @@ void agg_renderer<T>::process(building_symbolizer const& sym,
Feature const& feature, Feature const& feature,
proj_transform const& prj_trans) proj_transform const& prj_trans)
{ {
typedef coord_transform2<CoordTransform,geometry2d> path_type; typedef coord_transform2<CoordTransform,geometry_type> path_type;
typedef coord_transform3<CoordTransform,geometry2d> path_type_roof; typedef coord_transform3<CoordTransform,geometry_type> path_type_roof;
typedef agg::renderer_base<agg::pixfmt_rgba32_plain> ren_base; typedef agg::renderer_base<agg::pixfmt_rgba32_plain> ren_base;
typedef agg::renderer_scanline_aa_solid<ren_base> renderer; typedef agg::renderer_scanline_aa_solid<ren_base> renderer;
@ -78,11 +78,11 @@ void agg_renderer<T>::process(building_symbolizer const& sym,
for (unsigned i=0;i<feature.num_geometries();++i) for (unsigned i=0;i<feature.num_geometries();++i)
{ {
geometry2d const& geom = feature.get_geometry(i); geometry_type const& geom = feature.get_geometry(i);
if (geom.num_points() > 2) if (geom.num_points() > 2)
{ {
boost::scoped_ptr<geometry2d> frame(new line_string_impl); boost::scoped_ptr<geometry_type> frame(new geometry_type(LineString));
boost::scoped_ptr<geometry2d> roof(new polygon_impl); boost::scoped_ptr<geometry_type> roof(new geometry_type(Polygon));
std::deque<segment_t> face_segments; std::deque<segment_t> face_segments;
double x0(0); double x0(0);
double y0(0); double y0(0);
@ -109,7 +109,7 @@ void agg_renderer<T>::process(building_symbolizer const& sym,
std::deque<segment_t>::const_iterator itr=face_segments.begin(); std::deque<segment_t>::const_iterator itr=face_segments.begin();
for (;itr!=face_segments.end();++itr) for (;itr!=face_segments.end();++itr)
{ {
boost::scoped_ptr<geometry2d> faces(new polygon_impl); boost::scoped_ptr<geometry_type> faces(new geometry_type(Polygon));
faces->move_to(itr->get<0>(),itr->get<1>()); faces->move_to(itr->get<0>(),itr->get<1>());
faces->line_to(itr->get<2>(),itr->get<3>()); faces->line_to(itr->get<2>(),itr->get<3>());
faces->line_to(itr->get<2>(),itr->get<3>() + height); faces->line_to(itr->get<2>(),itr->get<3>() + height);

View file

@ -48,7 +48,7 @@ void agg_renderer<T>::process(line_pattern_symbolizer const& sym,
Feature const& feature, Feature const& feature,
proj_transform const& prj_trans) proj_transform const& prj_trans)
{ {
typedef coord_transform2<CoordTransform,geometry2d> path_type; typedef coord_transform2<CoordTransform,geometry_type> path_type;
typedef agg::line_image_pattern<agg::pattern_filter_bilinear_rgba8> pattern_type; typedef agg::line_image_pattern<agg::pattern_filter_bilinear_rgba8> pattern_type;
typedef agg::renderer_base<agg::pixfmt_rgba32_plain> renderer_base; typedef agg::renderer_base<agg::pixfmt_rgba32_plain> renderer_base;
typedef agg::renderer_outline_image<renderer_base, pattern_type> renderer_type; typedef agg::renderer_outline_image<renderer_base, pattern_type> renderer_type;
@ -72,7 +72,7 @@ void agg_renderer<T>::process(line_pattern_symbolizer const& sym,
metawriter_with_properties writer = sym.get_metawriter(); metawriter_with_properties writer = sym.get_metawriter();
for (unsigned i=0;i<feature.num_geometries();++i) for (unsigned i=0;i<feature.num_geometries();++i)
{ {
geometry2d const& geom = feature.get_geometry(i); geometry_type const& geom = feature.get_geometry(i);
if (geom.num_points() > 1) if (geom.num_points() > 1)
{ {
path_type path(t_,geom,prj_trans); path_type path(t_,geom,prj_trans);

View file

@ -50,7 +50,7 @@ void agg_renderer<T>::process(line_symbolizer const& sym,
proj_transform const& prj_trans) proj_transform const& prj_trans)
{ {
typedef agg::renderer_base<agg::pixfmt_rgba32_plain> ren_base; typedef agg::renderer_base<agg::pixfmt_rgba32_plain> ren_base;
typedef coord_transform2<CoordTransform,geometry2d> path_type; typedef coord_transform2<CoordTransform,geometry_type> path_type;
typedef agg::renderer_outline_aa<ren_base> renderer_oaa; typedef agg::renderer_outline_aa<ren_base> renderer_oaa;
typedef agg::rasterizer_outline_aa<renderer_oaa> rasterizer_outline_aa; typedef agg::rasterizer_outline_aa<renderer_oaa> rasterizer_outline_aa;
typedef agg::renderer_scanline_aa_solid<ren_base> renderer; typedef agg::renderer_scanline_aa_solid<ren_base> renderer;
@ -73,7 +73,7 @@ void agg_renderer<T>::process(line_symbolizer const& sym,
metawriter_with_properties writer = sym.get_metawriter(); metawriter_with_properties writer = sym.get_metawriter();
for (unsigned i=0;i<feature.num_geometries();++i) for (unsigned i=0;i<feature.num_geometries();++i)
{ {
geometry2d const& geom = feature.get_geometry(i); geometry_type const& geom = feature.get_geometry(i);
if (geom.num_points() > 1) if (geom.num_points() > 1)
{ {
path_type path(t_,geom,prj_trans); path_type path(t_,geom,prj_trans);

View file

@ -49,7 +49,7 @@ void agg_renderer<T>::process(markers_symbolizer const& sym,
Feature const& feature, Feature const& feature,
proj_transform const& prj_trans) proj_transform const& prj_trans)
{ {
typedef coord_transform2<CoordTransform,geometry2d> path_type; typedef coord_transform2<CoordTransform,geometry_type> path_type;
typedef agg::pixfmt_rgba32 pixfmt; typedef agg::pixfmt_rgba32 pixfmt;
typedef agg::renderer_base<pixfmt> renderer_base; typedef agg::renderer_base<pixfmt> renderer_base;
typedef agg::renderer_scanline_aa_solid<renderer_base> renderer_solid; typedef agg::renderer_scanline_aa_solid<renderer_base> renderer_solid;
@ -94,7 +94,7 @@ void agg_renderer<T>::process(markers_symbolizer const& sym,
for (unsigned i=0; i<feature.num_geometries(); ++i) for (unsigned i=0; i<feature.num_geometries(); ++i)
{ {
geometry2d const& geom = feature.get_geometry(i); geometry_type const& geom = feature.get_geometry(i);
if (geom.num_points() <= 1) if (geom.num_points() <= 1)
{ {
std::clog << "### Warning svg markers not supported yet for points within markers_symbolizer\n"; std::clog << "### Warning svg markers not supported yet for points within markers_symbolizer\n";
@ -175,7 +175,7 @@ void agg_renderer<T>::process(markers_symbolizer const& sym,
for (unsigned i=0; i<feature.num_geometries(); ++i) for (unsigned i=0; i<feature.num_geometries(); ++i)
{ {
geometry2d const& geom = feature.get_geometry(i); geometry_type const& geom = feature.get_geometry(i);
//if (geom.num_points() <= 1) continue; //if (geom.num_points() <= 1) continue;
if (placement_method == MARKER_POINT_PLACEMENT || geom.num_points() <= 1) if (placement_method == MARKER_POINT_PLACEMENT || geom.num_points() <= 1)
{ {

View file

@ -94,7 +94,7 @@ void agg_renderer<T>::process(point_symbolizer const& sym,
for (unsigned i=0; i<feature.num_geometries(); ++i) for (unsigned i=0; i<feature.num_geometries(); ++i)
{ {
geometry2d const& geom = feature.get_geometry(i); geometry_type const& geom = feature.get_geometry(i);
geom.label_position(&x,&y); geom.label_position(&x,&y);
prj_trans.backward(x,y,z); prj_trans.backward(x,y,z);
t_.forward(&x,&y); t_.forward(&x,&y);
@ -142,7 +142,7 @@ void agg_renderer<T>::process(point_symbolizer const& sym,
{ {
for (unsigned i=0; i<feature.num_geometries(); ++i) for (unsigned i=0; i<feature.num_geometries(); ++i)
{ {
geometry2d const& geom = feature.get_geometry(i); geometry_type const& geom = feature.get_geometry(i);
geom.label_position(&x,&y); geom.label_position(&x,&y);
prj_trans.backward(x,y,z); prj_trans.backward(x,y,z);

View file

@ -47,7 +47,7 @@ void agg_renderer<T>::process(polygon_pattern_symbolizer const& sym,
Feature const& feature, Feature const& feature,
proj_transform const& prj_trans) proj_transform const& prj_trans)
{ {
typedef coord_transform2<CoordTransform,geometry2d> path_type; typedef coord_transform2<CoordTransform,geometry_type> path_type;
typedef agg::renderer_base<agg::pixfmt_rgba32_plain> ren_base; typedef agg::renderer_base<agg::pixfmt_rgba32_plain> ren_base;
typedef agg::wrap_mode_repeat wrap_x_type; typedef agg::wrap_mode_repeat wrap_x_type;
typedef agg::wrap_mode_repeat wrap_y_type; typedef agg::wrap_mode_repeat wrap_y_type;
@ -108,7 +108,7 @@ void agg_renderer<T>::process(polygon_pattern_symbolizer const& sym,
metawriter_with_properties writer = sym.get_metawriter(); metawriter_with_properties writer = sym.get_metawriter();
for (unsigned i=0;i<num_geometries;++i) for (unsigned i=0;i<num_geometries;++i)
{ {
geometry2d const& geom = feature.get_geometry(i); geometry_type const& geom = feature.get_geometry(i);
if (geom.num_points() > 2) if (geom.num_points() > 2)
{ {
path_type path(t_,geom,prj_trans); path_type path(t_,geom,prj_trans);

View file

@ -44,7 +44,7 @@ void agg_renderer<T>::process(polygon_symbolizer const& sym,
Feature const& feature, Feature const& feature,
proj_transform const& prj_trans) proj_transform const& prj_trans)
{ {
typedef coord_transform2<CoordTransform,geometry2d> path_type; typedef coord_transform2<CoordTransform,geometry_type> path_type;
typedef agg::renderer_base<agg::pixfmt_rgba32_plain> ren_base; typedef agg::renderer_base<agg::pixfmt_rgba32_plain> ren_base;
typedef agg::renderer_scanline_aa_solid<ren_base> renderer; typedef agg::renderer_scanline_aa_solid<ren_base> renderer;
@ -66,7 +66,7 @@ void agg_renderer<T>::process(polygon_symbolizer const& sym,
metawriter_with_properties writer = sym.get_metawriter(); metawriter_with_properties writer = sym.get_metawriter();
for (unsigned i=0;i<feature.num_geometries();++i) for (unsigned i=0;i<feature.num_geometries();++i)
{ {
geometry2d const& geom=feature.get_geometry(i); geometry_type const& geom=feature.get_geometry(i);
if (geom.num_points() > 2) if (geom.num_points() > 2)
{ {
path_type path(t_,geom,prj_trans); path_type path(t_,geom,prj_trans);

View file

@ -43,7 +43,7 @@ void agg_renderer<T>::process(shield_symbolizer const& sym,
Feature const& feature, Feature const& feature,
proj_transform const& prj_trans) proj_transform const& prj_trans)
{ {
typedef coord_transform2<CoordTransform,geometry2d> path_type; typedef coord_transform2<CoordTransform,geometry_type> path_type;
typedef agg::pixfmt_rgba32 pixfmt; typedef agg::pixfmt_rgba32 pixfmt;
typedef agg::renderer_base<pixfmt> renderer_base; typedef agg::renderer_base<pixfmt> renderer_base;
typedef agg::renderer_scanline_aa_solid<renderer_base> renderer_solid; typedef agg::renderer_scanline_aa_solid<renderer_base> renderer_solid;
@ -143,7 +143,7 @@ void agg_renderer<T>::process(shield_symbolizer const& sym,
for (unsigned i=0;i<num_geom;++i) for (unsigned i=0;i<num_geom;++i)
{ {
geometry2d const& geom = feature.get_geometry(i); geometry_type const& geom = feature.get_geometry(i);
if (geom.num_points() > 0 ) if (geom.num_points() > 0 )
{ {
path_type path(t_,geom,prj_trans); path_type path(t_,geom,prj_trans);
@ -274,7 +274,7 @@ void agg_renderer<T>::process(shield_symbolizer const& sym,
unsigned num_geom = feature.num_geometries(); unsigned num_geom = feature.num_geometries();
for (unsigned i=0;i<num_geom;++i) for (unsigned i=0;i<num_geom;++i)
{ {
geometry2d const& geom = feature.get_geometry(i); geometry_type const& geom = feature.get_geometry(i);
if (geom.num_points() > 0 ) if (geom.num_points() > 0 )
{ {
path_type path(t_,geom,prj_trans); path_type path(t_,geom,prj_trans);

View file

@ -40,7 +40,7 @@ void agg_renderer<T>::process(text_symbolizer const& sym,
Feature const& feature, Feature const& feature,
proj_transform const& prj_trans) proj_transform const& prj_trans)
{ {
typedef coord_transform2<CoordTransform,geometry2d> path_type; typedef coord_transform2<CoordTransform,geometry_type> path_type;
expression_ptr name_expr = sym.get_name(); expression_ptr name_expr = sym.get_name();
if (!name_expr) return; if (!name_expr) return;
@ -89,7 +89,7 @@ void agg_renderer<T>::process(text_symbolizer const& sym,
unsigned num_geom = feature.num_geometries(); unsigned num_geom = feature.num_geometries();
for (unsigned i=0;i<num_geom;++i) for (unsigned i=0;i<num_geom;++i)
{ {
geometry2d const& geom = feature.get_geometry(i); geometry_type const& geom = feature.get_geometry(i);
if (geom.num_points() > 0) // don't bother with empty geometries if (geom.num_points() > 0) // don't bother with empty geometries
{ {
placement text_placement(info,sym,scale_factor_); placement text_placement(info,sym,scale_factor_);

View file

@ -568,7 +568,7 @@ void cairo_renderer_base::process(polygon_symbolizer const& sym,
Feature const& feature, Feature const& feature,
proj_transform const& prj_trans) proj_transform const& prj_trans)
{ {
typedef coord_transform2<CoordTransform,geometry2d> path_type; typedef coord_transform2<CoordTransform,geometry_type> path_type;
cairo_context context(context_); cairo_context context(context_);
@ -576,7 +576,7 @@ void cairo_renderer_base::process(polygon_symbolizer const& sym,
for (unsigned i = 0; i < feature.num_geometries(); ++i) for (unsigned i = 0; i < feature.num_geometries(); ++i)
{ {
geometry2d const& geom = feature.get_geometry(i); geometry_type const& geom = feature.get_geometry(i);
if (geom.num_points() > 2) if (geom.num_points() > 2)
{ {
@ -600,8 +600,8 @@ void cairo_renderer_base::process(building_symbolizer const& sym,
Feature const& feature, Feature const& feature,
proj_transform const& prj_trans) proj_transform const& prj_trans)
{ {
typedef coord_transform2<CoordTransform,geometry2d> path_type; typedef coord_transform2<CoordTransform,geometry_type> path_type;
typedef coord_transform3<CoordTransform,geometry2d> path_type_roof; typedef coord_transform3<CoordTransform,geometry_type> path_type_roof;
cairo_context context(context_); cairo_context context(context_);
@ -610,12 +610,12 @@ void cairo_renderer_base::process(building_symbolizer const& sym,
for (unsigned i = 0; i < feature.num_geometries(); ++i) for (unsigned i = 0; i < feature.num_geometries(); ++i)
{ {
geometry2d const& geom = feature.get_geometry(i); geometry_type const& geom = feature.get_geometry(i);
if (geom.num_points() > 2) if (geom.num_points() > 2)
{ {
boost::scoped_ptr<geometry2d> frame(new line_string_impl); boost::scoped_ptr<geometry_type> frame(new line_string_impl);
boost::scoped_ptr<geometry2d> roof(new polygon_impl); boost::scoped_ptr<geometry_type> roof(new polygon_impl);
std::deque<segment_t> face_segments; std::deque<segment_t> face_segments;
double x0(0); double x0(0);
double y0(0); double y0(0);
@ -649,7 +649,7 @@ void cairo_renderer_base::process(building_symbolizer const& sym,
std::deque<segment_t>::const_iterator itr = face_segments.begin(); std::deque<segment_t>::const_iterator itr = face_segments.begin();
for (; itr != face_segments.end(); ++itr) for (; itr != face_segments.end(); ++itr)
{ {
boost::scoped_ptr<geometry2d> faces(new polygon_impl); boost::scoped_ptr<geometry_type> faces(new polygon_impl);
faces->move_to(itr->get<0>(), itr->get<1>()); faces->move_to(itr->get<0>(), itr->get<1>());
faces->line_to(itr->get<2>(), itr->get<3>()); faces->line_to(itr->get<2>(), itr->get<3>());
@ -703,7 +703,7 @@ void cairo_renderer_base::process(line_symbolizer const& sym,
Feature const& feature, Feature const& feature,
proj_transform const& prj_trans) proj_transform const& prj_trans)
{ {
typedef coord_transform2<CoordTransform,geometry2d> path_type; typedef coord_transform2<CoordTransform,geometry_type> path_type;
cairo_context context(context_); cairo_context context(context_);
mapnik::stroke const& stroke_ = sym.get_stroke(); mapnik::stroke const& stroke_ = sym.get_stroke();
@ -712,7 +712,7 @@ void cairo_renderer_base::process(line_symbolizer const& sym,
for (unsigned i = 0; i < feature.num_geometries(); ++i) for (unsigned i = 0; i < feature.num_geometries(); ++i)
{ {
geometry2d const& geom = feature.get_geometry(i); geometry_type const& geom = feature.get_geometry(i);
if (geom.num_points() > 1) if (geom.num_points() > 1)
{ {
@ -756,7 +756,7 @@ void cairo_renderer_base::process(point_symbolizer const& sym,
{ {
for (unsigned i = 0; i < feature.num_geometries(); ++i) for (unsigned i = 0; i < feature.num_geometries(); ++i)
{ {
geometry2d const& geom = feature.get_geometry(i); geometry_type const& geom = feature.get_geometry(i);
double x; double x;
double y; double y;
double z = 0; double z = 0;
@ -791,7 +791,7 @@ void cairo_renderer_base::process(shield_symbolizer const& sym,
Feature const& feature, Feature const& feature,
proj_transform const& prj_trans) proj_transform const& prj_trans)
{ {
typedef coord_transform2<CoordTransform,geometry2d> path_type; typedef coord_transform2<CoordTransform,geometry_type> path_type;
expression_ptr name_expr = sym.get_name(); expression_ptr name_expr = sym.get_name();
if (!name_expr) return; if (!name_expr) return;
@ -831,7 +831,7 @@ void cairo_renderer_base::process(shield_symbolizer const& sym,
for (unsigned i = 0; i < feature.num_geometries(); ++i) for (unsigned i = 0; i < feature.num_geometries(); ++i)
{ {
geometry2d const& geom = feature.get_geometry(i); geometry_type const& geom = feature.get_geometry(i);
if (geom.num_points() > 0) // don't bother with empty geometries if (geom.num_points() > 0) // don't bother with empty geometries
{ {
@ -921,7 +921,7 @@ void cairo_renderer_base::process(line_pattern_symbolizer const& sym,
Feature const& feature, Feature const& feature,
proj_transform const& prj_trans) proj_transform const& prj_trans)
{ {
typedef coord_transform2<CoordTransform,geometry2d> path_type; typedef coord_transform2<CoordTransform,geometry_type> path_type;
std::string filename = path_processor_type::evaluate( *sym.get_filename(), feature); std::string filename = path_processor_type::evaluate( *sym.get_filename(), feature);
boost::optional<mapnik::image_ptr> image = mapnik::image_cache::instance()->find(filename,true); boost::optional<mapnik::image_ptr> image = mapnik::image_cache::instance()->find(filename,true);
@ -939,7 +939,7 @@ void cairo_renderer_base::process(line_pattern_symbolizer const& sym,
for (unsigned i = 0; i < feature.num_geometries(); ++i) for (unsigned i = 0; i < feature.num_geometries(); ++i)
{ {
geometry2d const& geom = feature.get_geometry(i); geometry_type const& geom = feature.get_geometry(i);
if (geom.num_points() > 1) if (geom.num_points() > 1)
{ {
@ -990,7 +990,7 @@ void cairo_renderer_base::process(polygon_pattern_symbolizer const& sym,
Feature const& feature, Feature const& feature,
proj_transform const& prj_trans) proj_transform const& prj_trans)
{ {
typedef coord_transform2<CoordTransform,geometry2d> path_type; typedef coord_transform2<CoordTransform,geometry_type> path_type;
cairo_context context(context_); cairo_context context(context_);
std::string filename = path_processor_type::evaluate( *sym.get_filename(), feature); std::string filename = path_processor_type::evaluate( *sym.get_filename(), feature);
@ -1006,7 +1006,7 @@ void cairo_renderer_base::process(polygon_pattern_symbolizer const& sym,
for (unsigned i = 0; i < feature.num_geometries(); ++i) for (unsigned i = 0; i < feature.num_geometries(); ++i)
{ {
geometry2d const& geom = feature.get_geometry(i); geometry_type const& geom = feature.get_geometry(i);
if (geom.num_points() > 2) if (geom.num_points() > 2)
{ {
@ -1067,7 +1067,7 @@ void cairo_renderer_base::process(markers_symbolizer const& sym,
Feature const& feature, Feature const& feature,
proj_transform const& prj_trans) proj_transform const& prj_trans)
{ {
typedef coord_transform2<CoordTransform,geometry2d> path_type; typedef coord_transform2<CoordTransform,geometry_type> path_type;
arrow arrow_; arrow arrow_;
cairo_context context(context_); cairo_context context(context_);
@ -1076,7 +1076,7 @@ void cairo_renderer_base::process(markers_symbolizer const& sym,
for (unsigned i = 0; i < feature.num_geometries(); ++i) for (unsigned i = 0; i < feature.num_geometries(); ++i)
{ {
geometry2d const& geom = feature.get_geometry(i); geometry_type const& geom = feature.get_geometry(i);
if (geom.num_points() > 1) if (geom.num_points() > 1)
{ {
@ -1163,7 +1163,7 @@ void cairo_renderer_base::process(text_symbolizer const& sym,
Feature const& feature, Feature const& feature,
proj_transform const& prj_trans) proj_transform const& prj_trans)
{ {
typedef coord_transform2<CoordTransform,geometry2d> path_type; typedef coord_transform2<CoordTransform,geometry_type> path_type;
expression_ptr name_expr = sym.get_name(); expression_ptr name_expr = sym.get_name();
if (!name_expr) return; if (!name_expr) return;
value_type result = boost::apply_visitor(evaluate<Feature,value_type>(feature),*name_expr); value_type result = boost::apply_visitor(evaluate<Feature,value_type>(feature),*name_expr);
@ -1203,7 +1203,7 @@ void cairo_renderer_base::process(text_symbolizer const& sym,
for (unsigned i = 0; i < feature.num_geometries(); ++i) for (unsigned i = 0; i < feature.num_geometries(); ++i)
{ {
geometry2d const& geom = feature.get_geometry(i); geometry_type const& geom = feature.get_geometry(i);
if (geom.num_points() > 0) // don't bother with empty geometries if (geom.num_points() > 0) // don't bother with empty geometries
{ {

View file

@ -37,7 +37,7 @@ struct accumulate_extent
{ {
for (unsigned i=0;i<feat->num_geometries();++i) for (unsigned i=0;i<feat->num_geometries();++i)
{ {
geometry2d & geom = feat->get_geometry(i); geometry_type & geom = feat->get_geometry(i);
if ( first_ ) if ( first_ )
{ {
first_ = false; first_ = false;
@ -100,4 +100,17 @@ size_t memory_datasource::size() const
{ {
return features_.size(); return features_.size();
} }
// point_datasource
void point_datasource::add_point(double x, double y, const char* key, const char* value)
{
feature_ptr feature(feature_factory::create(feat_id++));
geometry_type * pt = new geometry_type(Point);
pt->move_to(x,y);
feature->add_geometry(pt);
transcoder tr("utf-8");
(*feature)[key] = tr.transcode(value);
this->push(feature);
}
} }

View file

@ -942,7 +942,7 @@ void placement_finder<DetectorT>::clear()
detector_.clear(); detector_.clear();
} }
typedef coord_transform2<CoordTransform,geometry2d> PathType; typedef coord_transform2<CoordTransform,geometry_type> PathType;
typedef label_collision_detector4 DetectorType; typedef label_collision_detector4 DetectorType;
template class placement_finder<DetectorType>; template class placement_finder<DetectorType>;

View file

@ -26,43 +26,43 @@
namespace mapnik { namespace mapnik {
template <typename OutputIterator> template <typename OutputIterator>
bool svg_renderer<OutputIterator>::process(rule_type::symbolizers const& syms, bool svg_renderer<OutputIterator>::process(rule_type::symbolizers const& syms,
Feature const& feature, Feature const& feature,
proj_transform const& prj_trans) proj_transform const& prj_trans)
{
// svg renderer supports processing of multiple symbolizers.
typedef coord_transform2<CoordTransform, geometry_type> path_type;
// process each symbolizer to collect its (path) information.
// path information (attributes from line_ and polygon_ symbolizers)
// is collected with the path_attributes_ data member.
BOOST_FOREACH(symbolizer const& sym, syms)
{ {
// svg renderer supports processing of multiple symbolizers. boost::apply_visitor(symbol_dispatch(*this, feature, prj_trans), sym);
}
typedef coord_transform2<CoordTransform, geometry2d> path_type; // generate path output for each geometry of the current feature.
for(unsigned i=0; i<feature.num_geometries(); ++i)
{
geometry_type const& geom = feature.get_geometry(i);
if(geom.num_points() > 1)
{
path_type path(t_, geom, prj_trans);
generator_.generate_path(path, path_attributes_);
}
}
// process each symbolizer to collect its (path) information. // set the previously collected values back to their defaults
// path information (attributes from line_ and polygon_ symbolizers) // for the feature that will be processed next.
// is collected with the path_attributes_ data member. path_attributes_.reset();
BOOST_FOREACH(symbolizer const& sym, syms)
{
boost::apply_visitor(symbol_dispatch(*this, feature, prj_trans), sym);
}
// generate path output for each geometry of the current feature. return true;
for(unsigned i=0; i<feature.num_geometries(); ++i) };
{
geometry2d const& geom = feature.get_geometry(i);
if(geom.num_points() > 1)
{
path_type path(t_, geom, prj_trans);
generator_.generate_path(path, path_attributes_);
}
}
// set the previously collected values back to their defaults template bool svg_renderer<std::ostream_iterator<char> >::process(rule_type::symbolizers const& syms,
// for the feature that will be processed next. Feature const& feature,
path_attributes_.reset(); proj_transform const& prj_trans);
return true;
};
template bool svg_renderer<std::ostream_iterator<char> >::process(rule_type::symbolizers const& syms,
Feature const& feature,
proj_transform const& prj_trans);
} }

View file

@ -203,7 +203,7 @@ private:
void read_point(Feature & feature) void read_point(Feature & feature)
{ {
geometry2d * pt = new geometry2d;//new point<vertex2d>; geometry_type * pt = new geometry_type(Point);
double x = read_double(); double x = read_double();
double y = read_double(); double y = read_double();
pt->move_to(x,y); pt->move_to(x,y);
@ -222,7 +222,7 @@ private:
void read_multipoint_2(Feature & feature) void read_multipoint_2(Feature & feature)
{ {
geometry2d * pt = new geometry2d;//point<vertex2d>; geometry_type * pt = new geometry_type(Point);
int num_points = read_integer(); int num_points = read_integer();
for (int i=0;i<num_points;++i) for (int i=0;i<num_points;++i)
{ {
@ -236,7 +236,7 @@ private:
void read_linestring(Feature & feature) void read_linestring(Feature & feature)
{ {
geometry2d * line = new geometry2d;//line_string<vertex2d>; geometry_type * line = new geometry_type(LineString);
int num_points=read_integer(); int num_points=read_integer();
CoordinateArray ar(num_points); CoordinateArray ar(num_points);
read_coords(ar); read_coords(ar);
@ -261,7 +261,7 @@ private:
void read_multilinestring_2(Feature & feature) void read_multilinestring_2(Feature & feature)
{ {
geometry2d * line = new geometry2d;//line_string<vertex2d>; geometry_type * line = new geometry_type(LineString);
int num_lines=read_integer(); int num_lines=read_integer();
unsigned capacity = 0; unsigned capacity = 0;
for (int i=0;i<num_lines;++i) for (int i=0;i<num_lines;++i)
@ -283,7 +283,7 @@ private:
void read_polygon(Feature & feature) void read_polygon(Feature & feature)
{ {
geometry2d * poly = new polygon<vertex2d>; geometry_type * poly = new geometry_type(Polygon);
int num_rings=read_integer(); int num_rings=read_integer();
unsigned capacity = 0; unsigned capacity = 0;
for (int i=0;i<num_rings;++i) for (int i=0;i<num_rings;++i)
@ -314,7 +314,7 @@ private:
void read_multipolygon_2(Feature & feature) void read_multipolygon_2(Feature & feature)
{ {
geometry2d * poly = new polygon<vertex2d>; geometry_type * poly = new geometry_type(Polygon);
int num_polys=read_integer(); int num_polys=read_integer();
unsigned capacity = 0; unsigned capacity = 0;
for (int i=0;i<num_polys;++i) for (int i=0;i<num_polys;++i)

View file

@ -364,7 +364,7 @@ void pgsql2sqlite(Connection conn,
geometry_utils::from_wkb(feat,buf,size,false,wkbGeneric); geometry_utils::from_wkb(feat,buf,size,false,wkbGeneric);
if (feat.num_geometries() > 0) if (feat.num_geometries() > 0)
{ {
geometry2d const& geom=feat.get_geometry(0); geometry_type const& geom=feat.get_geometry(0);
box2d<double> bbox = geom.envelope(); box2d<double> bbox = geom.envelope();
if (valid_envelope(bbox)) if (valid_envelope(bbox))
{ {