Merge branch 'master' of github.com:mapnik/mapnik

This commit is contained in:
Dane Springmeyer 2011-12-16 06:50:32 -08:00
commit 95264a2dcb
39 changed files with 283 additions and 881 deletions

View file

@ -45,7 +45,7 @@ using mapnik::from_wkt;
void feature_add_geometries_from_wkb(Feature &feature, std::string wkb)
{
geometry_utils::from_wkb(feature.paths(), wkb.c_str(), wkb.size(), true);
geometry_utils::from_wkb(feature.paths(), wkb.c_str(), wkb.size());
}
void feature_add_geometries_from_wkt(Feature &feature, std::string wkt)

View file

@ -62,7 +62,7 @@ void add_wkt_impl(path_type& p, std::string const& wkt)
void add_wkb_impl(path_type& p, std::string const& wkb)
{
mapnik::geometry_utils::from_wkb(p, wkb.c_str(), wkb.size(), true);
mapnik::geometry_utils::from_wkb(p, wkb.c_str(), wkb.size());
}
boost::shared_ptr<path_type> from_wkt_impl(std::string const& wkt)
@ -76,7 +76,7 @@ boost::shared_ptr<path_type> from_wkt_impl(std::string const& wkt)
boost::shared_ptr<path_type> from_wkb_impl(std::string const& wkb)
{
boost::shared_ptr<path_type> paths = boost::make_shared<path_type>();
mapnik::geometry_utils::from_wkb(*paths, wkb.c_str(), wkb.size(), true);
mapnik::geometry_utils::from_wkb(*paths, wkb.c_str(), wkb.size());
return paths;
}
@ -117,6 +117,24 @@ std::string to_wkt( geometry_type const& geom)
#endif
}
std::string to_wkt2( path_type const& geom)
{
#if BOOST_VERSION >= 104700
std::string wkt; // Use Python String directly ?
bool result = mapnik::util::to_wkt(wkt,geom);
if (!result)
{
throw std::runtime_error("Generate WKT failed");
}
return wkt;
#else
std::ostringstream s;
s << BOOST_VERSION/100000 << "." << BOOST_VERSION/100 % 1000 << "." << BOOST_VERSION % 100;
throw std::runtime_error("mapnik::to_wkt() requires at least boost 1.47 while your build was compiled against boost " + s.str());
#endif
}
void export_geometry()
{
using namespace boost::python;
@ -125,9 +143,6 @@ void export_geometry()
.value("Point",mapnik::Point)
.value("LineString",mapnik::LineString)
.value("Polygon",mapnik::Polygon)
.value("MultiPoint",mapnik::MultiPoint)
.value("MultiLineString",mapnik::MultiLineString)
.value("MultiPolygon",mapnik::MultiPolygon)
;
using mapnik::geometry_type;
@ -145,6 +160,7 @@ void export_geometry()
.def("__len__", &path_type::size)
.def("add_wkt",add_wkt_impl)
.def("add_wkb",add_wkb_impl)
.def("to_wkt",&to_wkt2)
.def("from_wkt",from_wkt_impl)
.def("from_wkb",from_wkb_impl)
.staticmethod("from_wkt")

View file

@ -54,7 +54,7 @@ struct layer_pickle_suite : boost::python::pickle_suite
{
s.append(style_names[i]);
}
return boost::python::make_tuple(l.abstract(),l.title(),l.clear_label_cache(),l.getMinZoom(),l.getMaxZoom(),l.isQueryable(),l.datasource()->params(),l.cache_features(),s);
return boost::python::make_tuple(l.clear_label_cache(),l.getMinZoom(),l.getMaxZoom(),l.isQueryable(),l.datasource()->params(),l.cache_features(),s);
}
static void
@ -70,28 +70,24 @@ struct layer_pickle_suite : boost::python::pickle_suite
throw_error_already_set();
}
l.set_abstract(extract<std::string>(state[0]));
l.set_clear_label_cache(extract<bool>(state[0]));
l.set_title(extract<std::string>(state[1]));
l.setMinZoom(extract<double>(state[1]));
l.set_clear_label_cache(extract<bool>(state[2]));
l.setMaxZoom(extract<double>(state[2]));
l.setMinZoom(extract<double>(state[3]));
l.setQueryable(extract<bool>(state[3]));
l.setMaxZoom(extract<double>(state[4]));
l.setQueryable(extract<bool>(state[5]));
mapnik::parameters params = extract<parameters>(state[6]);
mapnik::parameters params = extract<parameters>(state[4]);
l.set_datasource(datasource_cache::instance()->create(params));
boost::python::list s = extract<boost::python::list>(state[7]);
boost::python::list s = extract<boost::python::list>(state[5]);
for (int i=0;i<len(s);++i)
{
l.add_style(extract<std::string>(s[i]));
}
l.set_cache_features(extract<bool>(state[8]));
l.set_cache_features(extract<bool>(state[6]));
}
};
@ -152,21 +148,6 @@ void export_layer()
"False\n"
)
.add_property("abstract",
make_function(&layer::abstract,return_value_policy<copy_const_reference>()),
&layer::set_abstract,
"Get/Set the abstract of the layer.\n"
"\n"
"Usage:\n"
">>> from mapnik import Layer\n"
">>> lyr = Layer('My Layer','+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs')\n"
">>> lyr.abstract\n"
"'' # default is en empty string\n"
">>> lyr.abstract = 'My Shapefile rendered with Mapnik'\n"
">>> lyr.abstract\n"
"'My Shapefile rendered with Mapnik'\n"
)
.add_property("active",
&layer::isActive,
&layer::setActive,
@ -310,20 +291,5 @@ void export_layer()
"'My Style'\n"
)
.add_property("title",
make_function(&layer::title, return_value_policy<copy_const_reference>()),
&layer::set_title,
"Get/Set the title of the layer.\n"
"\n"
"Usage:\n"
">>> from mapnik import layer\n"
">>> lyr = layer('My layer','+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs')\n"
">>> lyr.title\n"
"''\n"
">>> lyr.title = 'My first layer'\n"
">>> lyr.title\n"
"'My first layer'\n"
)
;
}

View file

@ -86,7 +86,7 @@ struct rule_pickle_suite : boost::python::pickle_suite
static boost::python::tuple
getinitargs(const rule& r)
{
return boost::python::make_tuple(r.get_name(),r.get_title(),r.get_min_scale(),r.get_max_scale());
return boost::python::make_tuple(r.get_name(),r.get_min_scale(),r.get_max_scale());
}
static boost::python::tuple
@ -102,7 +102,7 @@ struct rule_pickle_suite : boost::python::pickle_suite
// We serialize filter expressions AST as strings
std::string filter_expr = to_expression_string(*r.get_filter());
return boost::python::make_tuple(r.get_abstract(),filter_expr,r.has_else_filter(),r.has_also_filter(),syms);
return boost::python::make_tuple(filter_expr,r.has_else_filter(),r.has_also_filter(),syms);
}
static void
@ -119,11 +119,6 @@ struct rule_pickle_suite : boost::python::pickle_suite
}
if (state[0])
{
r.set_title(extract<std::string>(state[0]));
}
if (state[1])
{
rule dfl;
std::string filter = extract<std::string>(state[1]);
@ -134,12 +129,12 @@ struct rule_pickle_suite : boost::python::pickle_suite
}
}
if (state[2])
if (state[1])
{
r.set_else(true);
}
if (state[3])
if (state[2])
{
r.set_also(true);
}
@ -176,18 +171,12 @@ void export_rule()
class_<rule>("Rule",init<>("default constructor"))
.def(init<std::string const&,
boost::python::optional<std::string const&,double,double> >())
boost::python::optional<double,double> >())
.def_pickle(rule_pickle_suite())
.add_property("name",make_function
(&rule::get_name,
return_value_policy<copy_const_reference>()),
&rule::set_name)
.add_property("title",make_function
(&rule::get_title,return_value_policy<copy_const_reference>()),
&rule::set_title)
.add_property("abstract",make_function
(&rule::get_abstract,return_value_policy<copy_const_reference>()),
&rule::set_abstract)
.add_property("filter",make_function
(&rule::get_filter,return_value_policy<copy_const_reference>()),
&rule::set_filter)

View file

@ -36,29 +36,24 @@ namespace mapnik {
enum eGeomType {
Point = 1,
LineString,
Polygon,
MultiPoint,
MultiLineString,
MultiPolygon
LineString = 2,
Polygon = 3
};
template <typename T, template <typename> class Container=vertex_vector>
class geometry
class geometry : private::boost::noncopyable
{
public:
typedef T coord_type;
typedef Container<coord_type> container_type;
typedef typename container_type::value_type value_type;
private:
container_type cont_;
eGeomType type_;
mutable unsigned itr_;
public:
geometry(eGeomType type)
explicit geometry(eGeomType type)
: type_(type),
itr_(0)
{}
@ -168,7 +163,7 @@ public:
*/
void label_position(double *x, double *y) const
{
if (type_ == LineString || type_ == MultiLineString)
if (type_ == LineString)
{
middle_point(x,y);
return;
@ -232,7 +227,7 @@ public:
/* summarized distance centroid */
void label_position3(double *x, double *y) const
{
if (type_ == LineString || type_ == MultiLineString)
if (type_ == LineString)
{
middle_point(x,y);
return;
@ -392,7 +387,7 @@ public:
typedef geometry<double,vertex_vector> geometry_type;
typedef boost::shared_ptr<geometry_type> geometry_ptr;
typedef boost::ptr_vector<geometry_type> geometry_containter;
typedef boost::ptr_vector<geometry_type> geometry_container;
}

View file

@ -56,28 +56,9 @@ public:
/*!
* @return the name of the layer.
*/
const std::string& name() const;
/*!
* @brief Set the title of the layer.
*/
void set_title(std::string const& title);
/*!
* @return the title of the layer.
*/
const std::string& title() const;
/*!
* @brief Set the abstract of the layer.
*/
void set_abstract(std::string const& abstract);
/*!
* @return the abstract of the layer.
*/
const std::string& abstract() const;
/*!
* @brief Set the SRS of the layer.
*/
@ -212,8 +193,6 @@ private:
void swap(const layer& other);
std::string name_;
std::string title_;
std::string abstract_;
std::string srs_;
double minZoom_;

View file

@ -132,8 +132,6 @@ public:
private:
std::string name_;
std::string title_;
std::string abstract_;
double min_scale_;
double max_scale_;
symbolizers syms_;
@ -143,8 +141,6 @@ private:
public:
rule()
: name_(),
title_(),
abstract_(),
min_scale_(0),
max_scale_(std::numeric_limits<double>::infinity()),
syms_(),
@ -153,11 +149,9 @@ public:
also_filter_(false) {}
rule(const std::string& name,
const std::string& title="",
double min_scale_denominator=0,
double max_scale_denominator=std::numeric_limits<double>::infinity())
: name_(name),
title_(title),
min_scale_(min_scale_denominator),
max_scale_(max_scale_denominator),
syms_(),
@ -167,8 +161,6 @@ public:
rule(const rule& rhs, bool deep_copy = false)
: name_(rhs.name_),
title_(rhs.title_),
abstract_(rhs.abstract_),
min_scale_(rhs.min_scale_),
max_scale_(rhs.max_scale_),
syms_(rhs.syms_),
@ -264,26 +256,6 @@ public:
return name_;
}
std::string const& get_title() const
{
return title_;
}
void set_title(std::string const& title)
{
title_=title;
}
void set_abstract(std::string const& abstract)
{
abstract_=abstract;
}
std::string const& get_abstract() const
{
return abstract_;
}
void append(const symbolizer& sym)
{
syms_.push_back(sym);
@ -362,8 +334,6 @@ private:
void swap(rule& rhs) throw()
{
name_=rhs.name_;
title_=rhs.title_;
abstract_=rhs.abstract_;
min_scale_=rhs.min_scale_;
max_scale_=rhs.max_scale_;
syms_=rhs.syms_;

View file

@ -219,10 +219,6 @@ wkb_buffer_ptr to_wkb(geometry_type const& g, wkbByteOrder byte_order )
case mapnik::Polygon:
wkb = to_polygon_wkb(g, byte_order);
break;
case mapnik::MultiPoint:
case mapnik::MultiLineString:
case mapnik::MultiPolygon:
break;
default:
break;
}

View file

@ -42,7 +42,16 @@ bool to_wkt(std::string & wkt, mapnik::geometry_type const& geom)
{
typedef std::back_insert_iterator<std::string> sink_type;
sink_type sink(wkt);
wkt_generator<sink_type> generator;
wkt_generator<sink_type> generator(true);
bool result = karma::generate(sink, generator, geom);
return result;
}
bool to_wkt(std::string & wkt, mapnik::geometry_container const& geom)
{
typedef std::back_insert_iterator<std::string> sink_type;
sink_type sink(wkt);
wkt_multi_generator<sink_type> generator;
bool result = karma::generate(sink, generator, geom);
return result;
}

View file

@ -30,7 +30,6 @@
#include <mapnik/geometry.hpp>
#include <mapnik/util/vertex_iterator.hpp>
#include <mapnik/util/container_adapter.hpp>
// boost
#include <boost/tuple/tuple.hpp>
#include <boost/spirit/include/karma.hpp>
@ -49,6 +48,8 @@ namespace mapnik { namespace util {
namespace karma = boost::spirit::karma;
namespace phoenix = boost::phoenix;
namespace {
struct get_type
{
template <typename T>
@ -73,21 +74,61 @@ struct get_first
}
};
struct multi_geometry_
{
template <typename T>
struct result { typedef bool type; };
bool operator() (geometry_container const& geom) const
{
return geom.size() > 1 ? true : false;
}
};
struct multi_geometry_type
{
template <typename T>
struct result { typedef boost::tuple<unsigned,bool> type; };
boost::tuple<unsigned,bool> operator() (geometry_container const& geom) const
{
unsigned type = 0u;
bool collection = false;
geometry_container::const_iterator itr = geom.begin();
geometry_container::const_iterator end = geom.end();
for ( ; itr != end; ++itr)
{
if (type != 0 && itr->type() != type)
{
collection = true;
break;
}
type = itr->type();
}
return boost::tuple<unsigned,bool>(type, collection);
}
};
template <typename T>
struct coordinate_policy : karma::real_policies<T>
struct wkt_coordinate_policy : karma::real_policies<T>
{
typedef boost::spirit::karma::real_policies<T> base_type;
static int floatfield(T n) { return base_type::fmtflags::fixed; }
static unsigned precision(T n) { return 6u ;}
static unsigned precision(T n) { return 6 ;}
};
}
template <typename OutputIterator>
struct wkt_generator :
karma::grammar<OutputIterator, geometry_type const& ()>
{
wkt_generator()
wkt_generator(bool single = false)
: wkt_generator::base_type(wkt)
{
using boost::spirit::karma::uint_;
@ -97,22 +138,27 @@ struct wkt_generator :
using boost::spirit::karma::_a;
using boost::spirit::karma::_r1;
using boost::spirit::karma::eps;
using boost::spirit::karma::string;
wkt = point | linestring | polygon
;
point = &uint_(mapnik::Point)[_1 = _type(_val)]
<< lit("Point(") << point_coord [_1 = _first(_val)] << lit(')')
<< string[ phoenix::if_ (single) [_1 = "Point("]
.else_[_1 = "("]]
<< point_coord [_1 = _first(_val)] << lit(')')
;
linestring = &uint_(mapnik::LineString)[_1 = _type(_val)]
<< lit("LineString(")
<< string[ phoenix::if_ (single) [_1 = "LineString("]
.else_[_1 = "("]]
<< coords
<< lit(')')
;
polygon = &uint_(mapnik::Polygon)[_1 = _type(_val)]
<< lit("Polygon(")
<< string[ phoenix::if_ (single) [_1 = "Polygon("]
.else_[_1 = "("]]
<< coords2
<< lit("))")
;
@ -121,8 +167,8 @@ struct wkt_generator :
;
polygon_coord %= ( &uint_(mapnik::SEG_MOVETO) << eps[_r1 += 1]
<< karma::string[ if_ (_r1 > 1) [_1 = "),("]
.else_[_1 = "("] ] | &uint_ << ",")
<< string[ if_ (_r1 > 1) [_1 = "),("]
.else_[_1 = "("] ] | &uint_ << ",")
<< coord_type
<< lit(' ')
<< coord_type
@ -144,16 +190,69 @@ struct wkt_generator :
karma::rule<OutputIterator, geometry_type const& ()> coords;
karma::rule<OutputIterator, karma::locals<unsigned>, geometry_type const& ()> coords2;
karma::rule<OutputIterator, geometry_type::value_type ()> point_coord;
karma::rule<OutputIterator, geometry_type::value_type const& (unsigned& )> polygon_coord;
karma::rule<OutputIterator, geometry_type::value_type (unsigned& )> polygon_coord;
// phoenix functions
phoenix::function<get_type > _type;
phoenix::function<get_first> _first;
//
karma::real_generator<double, coordinate_policy<double> > coord_type;
karma::real_generator<double, wkt_coordinate_policy<double> > coord_type;
};
template <typename OutputIterator>
struct wkt_multi_generator :
karma::grammar<OutputIterator, karma::locals< boost::tuple<unsigned,bool> >, geometry_container const& ()>
{
wkt_multi_generator()
: wkt_multi_generator::base_type(wkt)
{
using boost::spirit::karma::lit;
using boost::spirit::karma::eps;
using boost::spirit::karma::_val;
using boost::spirit::karma::_1;
using boost::spirit::karma::_a;
geometry_types.add
(mapnik::Point,"Point")
(mapnik::LineString,"LineString")
(mapnik::Polygon,"Polygon")
;
wkt = eps(phoenix::at_c<1>(_a))[_a = _multi_type(_val)]
<< lit("GeometryCollection(") << geometry << lit(")")
| eps(is_multi(_val)) << lit("Multi") << geometry_types[_1 = phoenix::at_c<0>(_a)]
<< "(" << multi_geometry << ")"
| geometry
;
geometry = -(single_geometry % lit(','))
;
single_geometry = geometry_types[_1 = _type(_val)] << path
;
multi_geometry = -(path % lit(','))
;
}
// rules
karma::rule<OutputIterator, karma::locals<boost::tuple<unsigned,bool> >, geometry_container const& ()> wkt;
karma::rule<OutputIterator, geometry_container const& ()> geometry;
karma::rule<OutputIterator, geometry_type const& ()> single_geometry;
karma::rule<OutputIterator, geometry_container const& ()> multi_geometry;
wkt_generator<OutputIterator> path;
// phoenix
phoenix::function<multi_geometry_> is_multi;
phoenix::function<multi_geometry_type> _multi_type;
phoenix::function<get_type > _type;
//
karma::symbols<unsigned, char const*> geometry_types;
};
}}

View file

@ -27,6 +27,8 @@
#include <mapnik/geometry.hpp>
#include <mapnik/ctrans.hpp>
#include <mapnik/feature.hpp>
// boost
#include <boost/utility.hpp>
namespace mapnik
{
@ -49,19 +51,14 @@ enum wkbFormat
wkbSpatiaLite=3
};
class MAPNIK_DECL geometry_utils
class MAPNIK_DECL geometry_utils : private boost::noncopyable
{
public:
static void from_wkb (boost::ptr_vector<geometry_type>& paths,
const char* wkb,
unsigned size,
bool multiple_geometries = false,
wkbFormat format = wkbGeneric);
private:
geometry_utils();
geometry_utils(geometry_utils const&);
geometry_utils& operator=(const geometry_utils&);
};
}

View file

@ -98,8 +98,6 @@ geos_datasource::geos_datasource(parameters const& params, bool bind)
if (! geometry) throw datasource_exception("missing <wkt> parameter");
geometry_string_ = *geometry;
multiple_geometries_ = *params_.get<mapnik::boolean>("multiple_geometries",false);
boost::optional<std::string> ext = params_.get<std::string>("extent");
if (ext) extent_initialized_ = extent_.from_string(*ext);
@ -270,8 +268,7 @@ featureset_ptr geos_datasource::features(query const& q) const
geometry_id_,
geometry_data_,
geometry_data_name_,
desc_.get_encoding(),
multiple_geometries_);
desc_.get_encoding());
}
featureset_ptr geos_datasource::features_at_point(coord2d const& pt) const
@ -290,6 +287,5 @@ featureset_ptr geos_datasource::features_at_point(coord2d const& pt) const
geometry_id_,
geometry_data_,
geometry_data_name_,
desc_.get_encoding(),
multiple_geometries_);
desc_.get_encoding());
}

View file

@ -56,7 +56,6 @@ private:
mutable std::string geometry_data_name_;
mutable int geometry_id_;
std::string geometry_string_;
bool multiple_geometries_;
};
#endif // GEOS_DATASOURCE_HPP

View file

@ -53,15 +53,13 @@ geos_featureset::geos_featureset(GEOSGeometry* geometry,
int identifier,
const std::string& field,
const std::string& field_name,
const std::string& encoding,
bool multiple_geometries)
const std::string& encoding)
: geometry_(geometry),
tr_(new transcoder(encoding)),
extent_(extent),
identifier_(identifier),
field_(field),
field_name_(field_name),
multiple_geometries_(multiple_geometries),
already_rendered_(false)
{
}
@ -120,9 +118,7 @@ feature_ptr geos_featureset::next()
geometry_utils::from_wkb(feature->paths(),
wkb.data(),
wkb.size(),
multiple_geometries_);
wkb.size());
if (field_ != "")
{
boost::put(*feature, field_name_, tr_->transcode(field_.c_str()));

View file

@ -44,8 +44,7 @@ public:
int identifier,
const std::string& field,
const std::string& field_name,
const std::string& encoding,
bool multiple_geometries);
const std::string& encoding);
virtual ~geos_featureset();
mapnik::feature_ptr next();

View file

@ -50,7 +50,6 @@ private:
const std::list<kismet_network_data>& knd_list_;
boost::scoped_ptr<mapnik::transcoder> tr_;
mapnik::wkbFormat format_;
bool multiple_geometries_;
int feature_id_;
std::list<kismet_network_data>::const_iterator knd_list_it;
mapnik::projection source_;

View file

@ -94,7 +94,6 @@ occi_datasource::occi_datasource(parameters const& params, bool bind)
table_ = *table;
}
multiple_geometries_ = *params_.get<mapnik::boolean>("multiple_geometries",false);
use_spatial_index_ = *params_.get<mapnik::boolean>("use_spatial_index",true);
use_connection_pool_ = *params_.get<mapnik::boolean>("use_connection_pool",true);
@ -560,7 +559,6 @@ featureset_ptr occi_datasource::features(query const& q) const
conn_,
s.str(),
desc_.get_encoding(),
multiple_geometries_,
use_connection_pool_,
row_prefetch_,
props.size());
@ -642,7 +640,6 @@ featureset_ptr occi_datasource::features_at_point(coord2d const& pt) const
conn_,
s.str(),
desc_.get_encoding(),
multiple_geometries_,
use_connection_pool_,
row_prefetch_,
size);

View file

@ -64,7 +64,6 @@ private:
mutable oracle::occi::StatelessConnectionPool* pool_;
mutable oracle::occi::Connection* conn_;
bool use_connection_pool_;
bool multiple_geometries_;
bool use_spatial_index_;
static const std::string METADATA_TABLE;
};

View file

@ -59,12 +59,10 @@ occi_featureset::occi_featureset(StatelessConnectionPool* pool,
Connection* conn,
std::string const& sqlstring,
std::string const& encoding,
bool multiple_geometries,
bool use_connection_pool,
unsigned prefetch_rows,
unsigned num_attrs)
: tr_(new transcoder(encoding)),
multiple_geometries_(multiple_geometries),
num_attrs_(num_attrs),
feature_id_(1)
{
@ -101,7 +99,7 @@ feature_ptr occi_featureset::next()
boost::scoped_ptr<SDOGeometry> geom(dynamic_cast<SDOGeometry*>(rs_->getObject(1)));
if (geom.get())
{
convert_geometry(geom.get(), feature, multiple_geometries_);
convert_geometry(geom.get(), feature);
}
std::vector<MetaData> listOfColumns = rs_->getColumnListMetaData();
@ -204,7 +202,7 @@ feature_ptr occi_featureset::next()
}
void occi_featureset::convert_geometry(SDOGeometry* geom, feature_ptr feature, bool multiple_geometries)
void occi_featureset::convert_geometry(SDOGeometry* geom, feature_ptr feature)
{
int gtype = (int)geom->getSdo_gtype();
int dimensions = gtype / 1000;
@ -248,16 +246,13 @@ void occi_featureset::convert_geometry(SDOGeometry* geom, feature_ptr feature, b
{
const bool is_single_geom = true;
const bool is_point_type = false;
const bool multiple_geoms = false;
convert_ordinates(feature,
mapnik::LineString,
elem_info,
ordinates,
dimensions,
is_single_geom,
is_point_type,
multiple_geoms);
is_point_type);
}
}
break;
@ -267,16 +262,13 @@ void occi_featureset::convert_geometry(SDOGeometry* geom, feature_ptr feature, b
{
const bool is_single_geom = true;
const bool is_point_type = false;
const bool multiple_geoms = false;
convert_ordinates(feature,
mapnik::Polygon,
elem_info,
ordinates,
dimensions,
is_single_geom,
is_point_type,
multiple_geoms);
is_point_type);
}
}
break;
@ -286,19 +278,15 @@ void occi_featureset::convert_geometry(SDOGeometry* geom, feature_ptr feature, b
{
const bool is_single_geom = false;
const bool is_point_type = true;
const bool multiple_geoms = true;
// Todo - force using true as multiple_geometries until we have proper multipoint handling
// http://trac.mapnik.org/ticket/458
// FIXME :http://trac.mapnik.org/ticket/458
convert_ordinates(feature,
mapnik::Point,
elem_info,
ordinates,
dimensions,
is_single_geom,
is_point_type,
multiple_geoms);
is_point_type);
}
}
break;
@ -315,8 +303,7 @@ void occi_featureset::convert_geometry(SDOGeometry* geom, feature_ptr feature, b
ordinates,
dimensions,
is_single_geom,
is_point_type,
multiple_geometries);
is_point_type);
}
}
break;
@ -333,8 +320,7 @@ void occi_featureset::convert_geometry(SDOGeometry* geom, feature_ptr feature, b
ordinates,
dimensions,
is_single_geom,
is_point_type,
multiple_geometries);
is_point_type);
}
}
@ -352,8 +338,7 @@ void occi_featureset::convert_geometry(SDOGeometry* geom, feature_ptr feature, b
ordinates,
dimensions,
is_single_geom,
is_point_type,
multiple_geometries);
is_point_type);
}
}
break;
@ -374,8 +359,7 @@ void occi_featureset::convert_ordinates(mapnik::feature_ptr feature,
const std::vector<Number>& ordinates,
const int dimensions,
const bool is_single_geom,
const bool is_point_geom,
const bool multiple_geometries)
const bool is_point_geom)
{
const int elem_size = elem_info.size();
const int ord_size = ordinates.size();
@ -388,7 +372,7 @@ void occi_featureset::convert_ordinates(mapnik::feature_ptr feature,
if (! is_single_geom && elem_size > SDO_ELEM_INFO_SIZE)
{
geometry_type* geom = multiple_geometries ? 0 : new geometry_type(geom_type);
geometry_type* geom = new geometry_type(geom_type);
if (geom) geom->set_capacity(ord_size);
for (int i = SDO_ELEM_INFO_SIZE; i < elem_size; i+=3)
@ -444,17 +428,14 @@ void occi_featureset::convert_ordinates(mapnik::feature_ptr feature,
if (is_linear_element)
{
if (multiple_geometries)
if (geom)
{
if (geom)
{
feature->add_geometry(geom);
}
geom = new geometry_type(gtype);
geom->set_capacity((next_offset - 1) - (offset - 1 - dimensions));
feature->add_geometry(geom);
}
geom = new geometry_type(gtype);
geom->set_capacity((next_offset - 1) - (offset - 1 - dimensions));
fill_geometry_type(geom,
offset - 1,
next_offset - 1,

View file

@ -42,7 +42,6 @@ public:
oracle::occi::Connection* conn,
std::string const& sqlstring,
std::string const& encoding,
bool multiple_geometries,
bool use_connection_pool,
unsigned prefetch_rows,
unsigned num_attrs);
@ -50,15 +49,14 @@ public:
mapnik::feature_ptr next();
private:
void convert_geometry (SDOGeometry* geom, mapnik::feature_ptr feature, bool multiple_geometries);
void convert_geometry (SDOGeometry* geom, mapnik::feature_ptr feature);
void convert_ordinates (mapnik::feature_ptr feature,
const mapnik::eGeomType& geom_type,
const std::vector<oracle::occi::Number>& elem_info,
const std::vector<oracle::occi::Number>& ordinates,
const int dimensions,
const bool is_single_geom,
const bool is_point_geom,
const bool multiple_geometries);
const bool is_point_geom);
void fill_geometry_type (mapnik::geometry_type* geom,
const int real_offset,
const int next_offset,
@ -70,7 +68,6 @@ private:
oracle::occi::ResultSet* rs_;
boost::scoped_ptr<mapnik::transcoder> tr_;
const char* fidcolumn_;
bool multiple_geometries_;
unsigned num_attrs_;
mutable int feature_id_;
};

View file

@ -87,8 +87,6 @@ postgis_datasource::postgis_datasource(parameters const& params, bool bind)
{
if (table_.empty()) throw mapnik::datasource_exception("Postgis Plugin: missing <table> parameter");
multiple_geometries_ = *params_.get<mapnik::boolean>("multiple_geometries",false);
boost::optional<std::string> ext = params_.get<std::string>("extent");
if (ext) extent_initialized_ = extent_.from_string(*ext);
@ -517,7 +515,7 @@ featureset_ptr postgis_datasource::features(const query& q) const
unsigned num_attr = props.size();
if (!key_field_.empty())
++num_attr;
return boost::make_shared<postgis_featureset>(rs,desc_.get_encoding(),multiple_geometries_,!key_field_.empty(),num_attr);
return boost::make_shared<postgis_featureset>(rs,desc_.get_encoding(), !key_field_.empty(),num_attr);
}
else
{
@ -585,7 +583,7 @@ featureset_ptr postgis_datasource::features_at_point(coord2d const& pt) const
}
boost::shared_ptr<IResultSet> rs = get_resultset(conn, s.str());
return boost::make_shared<postgis_featureset>(rs,desc_.get_encoding(),multiple_geometries_,!key_field_.empty(),size);
return boost::make_shared<postgis_featureset>(rs,desc_.get_encoding(), !key_field_.empty(),size);
}
}
return featureset_ptr();

View file

@ -69,7 +69,6 @@ class postgis_datasource : public datasource
mutable mapnik::box2d<double> extent_;
mutable layer_descriptor desc_;
ConnectionCreator<Connection> creator_;
bool multiple_geometries_;
const std::string bbox_token_;
const std::string scale_denom_token_;
bool persist_connection_;

View file

@ -49,11 +49,9 @@ using mapnik::feature_factory;
postgis_featureset::postgis_featureset(boost::shared_ptr<IResultSet> const& rs,
std::string const& encoding,
bool multiple_geometries,
bool key_field=false,
unsigned num_attrs=0)
: rs_(rs),
multiple_geometries_(multiple_geometries),
num_attrs_(num_attrs),
tr_(new transcoder(encoding)),
totalGeomSize_(0),
@ -103,7 +101,7 @@ feature_ptr postgis_featureset::next()
// parse geometry
int size = rs_->getFieldLength(0);
const char *data = rs_->getValue(0);
geometry_utils::from_wkb(feature->paths(),data,size,multiple_geometries_);
geometry_utils::from_wkb(feature->paths(), data, size);
totalGeomSize_+=size;
for ( ;pos<num_attrs_+1;++pos)

View file

@ -44,7 +44,6 @@ class postgis_featureset : public mapnik::Featureset
{
private:
boost::shared_ptr<IResultSet> rs_;
bool multiple_geometries_;
unsigned num_attrs_;
boost::scoped_ptr<mapnik::transcoder> tr_;
int totalGeomSize_;
@ -53,7 +52,6 @@ private:
public:
postgis_featureset(boost::shared_ptr<IResultSet> const& rs,
std::string const& encoding,
bool multiple_geometries,
bool key_field,
unsigned num_attrs);
mapnik::feature_ptr next();

View file

@ -248,49 +248,19 @@ feature_ptr shape_featureset<filterT>::next()
}
case shape_io::shape_polyline:
{
geometry_type* line = shape_.read_polyline();
feature->add_geometry(line);
++count_;
break;
}
case shape_io::shape_polylinem:
{
geometry_type* line = shape_.read_polylinem();
feature->add_geometry(line);
++count_;
break;
}
case shape_io::shape_polylinez:
{
geometry_type* line = shape_.read_polylinez();
feature->add_geometry(line);
shape_.read_polyline(feature->paths());
++count_;
break;
}
case shape_io::shape_polygon:
{
geometry_type* poly = shape_.read_polygon();
feature->add_geometry(poly);
++count_;
break;
}
case shape_io::shape_polygonm:
{
geometry_type* poly = shape_.read_polygonm();
feature->add_geometry(poly);
++count_;
break;
}
case shape_io::shape_polygonz:
{
geometry_type* poly = shape_.read_polygonz();
feature->add_geometry(poly);
shape_.read_polygon(feature->paths());
++count_;
break;
}

View file

@ -193,49 +193,18 @@ feature_ptr shape_index_featureset<filterT>::next()
}
case shape_io::shape_polyline:
{
geometry_type* line = shape_.read_polyline();
feature->add_geometry(line);
++count_;
break;
}
case shape_io::shape_polylinem:
{
geometry_type* line = shape_.read_polylinem();
feature->add_geometry(line);
++count_;
break;
}
case shape_io::shape_polylinez:
{
geometry_type* line = shape_.read_polylinez();
feature->add_geometry(line);
shape_.read_polyline(feature->paths());
++count_;
break;
}
case shape_io::shape_polygon:
{
geometry_type* poly = shape_.read_polygon();
feature->add_geometry(poly);
++count_;
break;
}
case shape_io::shape_polygonm:
{
geometry_type* poly = shape_.read_polygonm();
feature->add_geometry(poly);
++count_;
break;
}
case shape_io::shape_polygonz:
{
geometry_type* poly = shape_.read_polygonz();
feature->add_geometry(poly);
shape_.read_polygon(feature->paths());
++count_;
break;
}

View file

@ -106,18 +106,16 @@ dbf_file& shape_io::dbf()
return dbf_;
}
geometry_type* shape_io::read_polyline()
void shape_io::read_polyline(mapnik::geometry_container & geom)
{
shape_file::record_type record(reclength_ * 2 - 36);
shp_.read_record(record);
int num_parts = record.read_ndr_integer();
int num_points = record.read_ndr_integer();
geometry_type* line = new geometry_type(mapnik::LineString);
line->set_capacity(num_points + num_parts);
if (num_parts == 1)
{
line->set_capacity(num_points + 1);
geometry_type* line = new geometry_type(mapnik::LineString);
record.skip(4);
double x = record.read_double();
double y = record.read_double();
@ -128,6 +126,7 @@ geometry_type* shape_io::read_polyline()
y = record.read_double();
line->line_to(x, y);
}
geom.push_back(line);
}
else
{
@ -140,6 +139,7 @@ geometry_type* shape_io::read_polyline()
int start, end;
for (int k = 0; k < num_parts; ++k)
{
geometry_type* line = new geometry_type(mapnik::LineString);
start = parts[k];
if (k == num_parts - 1)
{
@ -160,135 +160,9 @@ geometry_type* shape_io::read_polyline()
y = record.read_double();
line->line_to(x, y);
}
geom.push_back(line);
}
}
return line;
}
geometry_type* shape_io::read_polylinem()
{
shape_file::record_type record(reclength_ * 2 - 36);
shp_.read_record(record);
int num_parts = record.read_ndr_integer();
int num_points = record.read_ndr_integer();
geometry_type* line = new geometry_type(mapnik::LineString);
line->set_capacity(num_points + num_parts);
if (num_parts == 1)
{
record.skip(4);
double x = record.read_double();
double y = record.read_double();
line->move_to(x, y);
for (int i = 1; i < num_points; ++i)
{
x = record.read_double();
y = record.read_double();
line->line_to(x, y);
}
}
else
{
std::vector<int> parts(num_parts);
for (int i = 0; i < num_parts; ++i)
{
parts[i] = record.read_ndr_integer();
}
int start, end;
for (int k = 0; k < num_parts; ++k)
{
start = parts[k];
if (k == num_parts - 1)
{
end = num_points;
}
else
{
end = parts[k + 1];
}
double x = record.read_double();
double y = record.read_double();
line->move_to(x, y);
for (int j = start + 1; j < end; ++j)
{
x = record.read_double();
y = record.read_double();
line->line_to(x, y);
}
}
}
// m-range
//double m0=record.read_double();
//double m1=record.read_double();
//for (int i=0;i<num_points;++i)
//{
// double m=record.read_double();
//}
return line;
}
geometry_type* shape_io::read_polylinez()
{
shape_file::record_type record(reclength_ * 2 - 36);
shp_.read_record(record);
int num_parts = record.read_ndr_integer();
int num_points = record.read_ndr_integer();
geometry_type* line = new geometry_type(mapnik::LineString);
line->set_capacity(num_points + num_parts);
if (num_parts == 1)
{
record.skip(4);
double x = record.read_double();
double y = record.read_double();
line->move_to(x, y);
for (int i = 1; i < num_points; ++i)
{
x = record.read_double();
y = record.read_double();
line->line_to(x, y);
}
}
else
{
std::vector<int> parts(num_parts);
for (int i = 0; i < num_parts; ++i)
{
parts[i] = record.read_ndr_integer();
}
int start, end;
for (int k = 0; k < num_parts; ++k)
{
start = parts[k];
if (k == num_parts - 1)
{
end = num_points;
}
else
{
end = parts[k + 1];
}
double x = record.read_double();
double y = record.read_double();
line->move_to(x, y);
for (int j = start + 1; j < end; ++j)
{
x = record.read_double();
y = record.read_double();
line->line_to(x, y);
}
}
}
// z-range
//double z0=record.read_double();
//double z1=record.read_double();
@ -306,10 +180,9 @@ geometry_type* shape_io::read_polylinez()
// double m=record.read_double();
//}
return line;
}
geometry_type* shape_io::read_polygon()
void shape_io::read_polygon(mapnik::geometry_container & geom)
{
shape_file::record_type record(reclength_ * 2 - 36);
shp_.read_record(record);
@ -317,8 +190,7 @@ geometry_type* shape_io::read_polygon()
int num_parts = record.read_ndr_integer();
int num_points = record.read_ndr_integer();
std::vector<int> parts(num_parts);
geometry_type* poly = new geometry_type(mapnik::Polygon);
poly->set_capacity(num_points + num_parts);
for (int i = 0; i < num_parts; ++i)
{
parts[i] = record.read_ndr_integer();
@ -326,6 +198,7 @@ geometry_type* shape_io::read_polygon()
for (int k = 0; k < num_parts; k++)
{
geometry_type* poly = new geometry_type(mapnik::Polygon);
int start = parts[k];
int end;
if (k == num_parts - 1)
@ -347,101 +220,8 @@ geometry_type* shape_io::read_polygon()
y = record.read_double();
poly->line_to(x, y);
}
geom.push_back(poly);
}
return poly;
}
geometry_type* shape_io::read_polygonm()
{
shape_file::record_type record(reclength_ * 2 - 36);
shp_.read_record(record);
int num_parts = record.read_ndr_integer();
int num_points = record.read_ndr_integer();
std::vector<int> parts(num_parts);
geometry_type* poly = new geometry_type(mapnik::Polygon);
poly->set_capacity(num_points + num_parts);
for (int i = 0; i < num_parts; ++i)
{
parts[i] = record.read_ndr_integer();
}
for (int k = 0; k < num_parts; k++)
{
int start = parts[k];
int end;
if (k == num_parts - 1)
{
end = num_points;
}
else
{
end = parts[k + 1];
}
double x = record.read_double();
double y = record.read_double();
poly->move_to(x, y);
for (int j = start + 1; j < end; j++)
{
x = record.read_double();
y = record.read_double();
poly->line_to(x, y);
}
}
// m-range
//double m0=record.read_double();
//double m1=record.read_double();
//for (int i=0;i<num_points;++i)
//{
// double m=record.read_double();
//}
return poly;
}
geometry_type* shape_io::read_polygonz()
{
shape_file::record_type record(reclength_ * 2 - 36);
shp_.read_record(record);
int num_parts = record.read_ndr_integer();
int num_points = record.read_ndr_integer();
std::vector<int> parts(num_parts);
geometry_type* poly = new geometry_type(mapnik::Polygon);
poly->set_capacity(num_points + num_parts);
for (int i = 0; i < num_parts; ++i)
{
parts[i] = record.read_ndr_integer();
}
for (int k = 0; k < num_parts; k++)
{
int start = parts[k];
int end;
if (k == num_parts - 1)
{
end = num_points;
}
else
{
end = parts[k + 1];
}
double x = record.read_double();
double y = record.read_double();
poly->move_to(x, y);
for (int j = start + 1; j < end; j++)
{
x = record.read_double();
y = record.read_double();
poly->line_to(x, y);
}
}
// z-range
//double z0=record.read_double();
//double z1=record.read_double();
@ -458,6 +238,6 @@ geometry_type* shape_io::read_polygonz()
//{
// double m=record.read_double();
//}
return poly;
}

View file

@ -23,6 +23,8 @@
#ifndef SHAPE_IO_HPP
#define SHAPE_IO_HPP
// mapnik
#include <mapnik/geometry.hpp>
// boost
#include <boost/utility.hpp>
#include <boost/shared_ptr.hpp>
@ -56,7 +58,6 @@ public:
~shape_io();
shape_file& shp();
//shape_file& shx();
dbf_file& dbf();
inline boost::shared_ptr<shape_file>& index()
@ -72,16 +73,10 @@ public:
void move_to(int id);
int type() const;
const box2d<double>& current_extent() const;
mapnik::geometry_type* read_polyline();
mapnik::geometry_type* read_polylinem();
mapnik::geometry_type* read_polylinez();
mapnik::geometry_type* read_polygon();
mapnik::geometry_type* read_polygonm();
mapnik::geometry_type* read_polygonz();
void read_polyline(mapnik::geometry_container & geom);
void read_polygon(mapnik::geometry_container & geom);
unsigned type_;
shape_file shp_;
//shape_file shx_;
dbf_file dbf_;
boost::shared_ptr<shape_file> index_;
unsigned reclength_;
@ -89,7 +84,6 @@ public:
box2d<double> cur_extent_;
static const std::string SHP;
//static const std::string SHX;
static const std::string DBF;
static const std::string INDEX;
};

View file

@ -102,7 +102,6 @@ void sqlite_datasource::bind() const
throw datasource_exception("Sqlite Plugin: " + dataset_name_ + " does not exist");
}
multiple_geometries_ = *params_.get<mapnik::boolean>("multiple_geometries", false);
use_spatial_index_ = *params_.get<mapnik::boolean>("use_spatial_index", true);
// TODO - remove this option once all datasources have an indexing api
@ -502,7 +501,6 @@ featureset_ptr sqlite_datasource::features(query const& q) const
return boost::make_shared<sqlite_featureset>(rs,
desc_.get_encoding(),
format_,
multiple_geometries_,
using_subquery_);
}
@ -577,7 +575,6 @@ featureset_ptr sqlite_datasource::features_at_point(coord2d const& pt) const
return boost::make_shared<sqlite_featureset>(rs,
desc_.get_encoding(),
format_,
multiple_geometries_,
using_subquery_);
}

View file

@ -51,6 +51,11 @@ public:
void bind() const;
private:
// FIXME: remove mutable qualifier from data members
// by factoring out bind() logic out from
// datasource impl !!!
mutable mapnik::box2d<double> extent_;
mutable bool extent_initialized_;
int type_;
@ -67,7 +72,6 @@ private:
mutable int row_limit_;
mutable mapnik::layer_descriptor desc_;
mutable mapnik::wkbFormat format_;
mutable bool multiple_geometries_;
mutable bool use_spatial_index_;
mutable bool has_spatial_index_;
mutable bool using_subquery_;

View file

@ -47,12 +47,10 @@ using mapnik::feature_factory;
sqlite_featureset::sqlite_featureset(boost::shared_ptr<sqlite_resultset> rs,
std::string const& encoding,
mapnik::wkbFormat format,
bool multiple_geometries,
bool using_subquery)
: rs_(rs),
tr_(new transcoder(encoding)),
format_(format),
multiple_geometries_(multiple_geometries),
using_subquery_(using_subquery)
{
}
@ -75,7 +73,7 @@ feature_ptr sqlite_featureset::next()
int feature_id = rs_->column_integer(1);
feature_ptr feature(feature_factory::create(feature_id));
geometry_utils::from_wkb(feature->paths(), data, size, multiple_geometries_, format_);
geometry_utils::from_wkb(feature->paths(), data, size, format_);
for (int i = 2; i < rs_->column_count(); ++i)
{

View file

@ -42,7 +42,6 @@ public:
sqlite_featureset(boost::shared_ptr<sqlite_resultset> rs,
std::string const& encoding,
mapnik::wkbFormat format,
bool multiple_geometries,
bool using_subquery);
virtual ~sqlite_featureset();
mapnik::feature_ptr next();
@ -51,7 +50,6 @@ private:
boost::shared_ptr<sqlite_resultset> rs_;
boost::scoped_ptr<mapnik::transcoder> tr_;
mapnik::wkbFormat format_;
bool multiple_geometries_;
bool using_subquery_;
};

View file

@ -151,11 +151,11 @@ public:
while (rs->is_valid() && rs->step_next())
{
int size;
const char* data = (const char*) rs->column_blob(0, size);
const char* data = static_cast<const char*>(rs->column_blob(0, size));
if (data)
{
boost::ptr_vector<mapnik::geometry_type> paths;
mapnik::geometry_utils::from_wkb(paths, data, size, false, mapnik::wkbAuto);
mapnik::geometry_utils::from_wkb(paths, data, size, mapnik::wkbAuto);
for (unsigned i=0; i<paths.size(); ++i)
{
mapnik::box2d<double> const& bbox = paths[i].envelope();
@ -241,41 +241,47 @@ public:
if (data)
{
boost::ptr_vector<mapnik::geometry_type> paths;
// TODO - contraint fails if multiple_geometries = true
bool multiple_geometries = false;
mapnik::geometry_utils::from_wkb(paths, data, size, multiple_geometries, mapnik::wkbAuto);
mapnik::geometry_utils::from_wkb(paths, data, size, mapnik::wkbAuto);
mapnik::box2d<double> bbox;
for (unsigned i=0; i<paths.size(); ++i)
{
mapnik::box2d<double> const& bbox = paths[i].envelope();
if (bbox.valid())
if (i==0)
{
ps.bind(bbox);
const int type_oid = rs->column_type(1);
if (type_oid != SQLITE_INTEGER)
{
std::ostringstream error_msg;
error_msg << "Sqlite Plugin: invalid type for key field '"
<< rs->column_name(1) << "' when creating index '" << index_table
<< "' type was: " << type_oid << "";
throw mapnik::datasource_exception(error_msg.str());
}
const sqlite_int64 pkid = rs->column_integer64(1);
ps.bind(pkid);
bbox = paths[i].envelope();
}
else
{
bbox.expand_to_include(paths[i].envelope());
}
}
if (bbox.valid())
{
ps.bind(bbox);
const int type_oid = rs->column_type(1);
if (type_oid != SQLITE_INTEGER)
{
std::ostringstream error_msg;
error_msg << "SQLite Plugin: encountered invalid bbox at '"
<< rs->column_name(1) << "' == " << rs->column_integer64(1);
error_msg << "Sqlite Plugin: invalid type for key field '"
<< rs->column_name(1) << "' when creating index '" << index_table
<< "' type was: " << type_oid << "";
throw mapnik::datasource_exception(error_msg.str());
}
ps.step_next();
one_success = true;
const sqlite_int64 pkid = rs->column_integer64(1);
ps.bind(pkid);
}
else
{
std::ostringstream error_msg;
error_msg << "SQLite Plugin: encountered invalid bbox at '"
<< rs->column_name(1) << "' == " << rs->column_integer64(1);
throw mapnik::datasource_exception(error_msg.str());
}
ps.step_next();
one_success = true;
}
}
}
@ -320,13 +326,11 @@ public:
while (rs->is_valid() && rs->step_next())
{
int size;
const char* data = (const char*) rs->column_blob(0, size);
const char* data = static_cast<const char*>(rs->column_blob(0, size));
if (data)
{
boost::ptr_vector<mapnik::geometry_type> paths;
// TODO - contraint fails if multiple_geometries = true
bool multiple_geometries = false;
mapnik::geometry_utils::from_wkb(paths, data, size, multiple_geometries, mapnik::wkbAuto);
mapnik::geometry_utils::from_wkb(paths, data, size, mapnik::wkbAuto);
for (unsigned i=0; i<paths.size(); ++i)
{
mapnik::box2d<double> const& bbox = paths[i].envelope();

View file

@ -44,7 +44,7 @@ void agg_renderer<T>::process(text_symbolizer const& sym,
if (geom.num_points() == 0) continue; // don't bother with empty geometries
if ((geom.type() == Polygon || geom.type() == MultiPolygon) && sym.get_minimum_path_length() > 0)
if ((geom.type() == Polygon) && sym.get_minimum_path_length() > 0)
{
// TODO - find less costly method than fetching full envelope
box2d<double> gbox = t_.forward(geom.envelope(),prj_trans);

View file

@ -37,8 +37,6 @@ namespace mapnik
{
layer::layer(std::string const& name, std::string const& srs)
: name_(name),
title_(""),
abstract_(""),
srs_(srs),
minZoom_(0),
maxZoom_(std::numeric_limits<double>::max()),
@ -51,8 +49,6 @@ layer::layer(std::string const& name, std::string const& srs)
layer::layer(const layer& rhs)
: name_(rhs.name_),
title_(rhs.title_),
abstract_(rhs.abstract_),
srs_(rhs.srs_),
minZoom_(rhs.minZoom_),
maxZoom_(rhs.maxZoom_),
@ -79,8 +75,6 @@ bool layer::operator==(layer const& other) const
void layer::swap(const layer& rhs)
{
name_=rhs.name_;
title_=rhs.title_;
abstract_=rhs.abstract_;
srs_ = rhs.srs_;
minZoom_=rhs.minZoom_;
maxZoom_=rhs.maxZoom_;
@ -105,26 +99,6 @@ std::string const& layer::name() const
return name_;
}
void layer::set_title( std::string const& title)
{
title_ = title;
}
std::string const& layer::title() const
{
return title_;
}
void layer::set_abstract( std::string const& abstract)
{
abstract_ = abstract;
}
std::string const& layer::abstract() const
{
return abstract_;
}
void layer::set_srs(std::string const& srs)
{
srs_ = srs;

View file

@ -577,8 +577,6 @@ void map_parser::parse_layer( Map & map, ptree const & lay )
s << "name,"
<< "srs,"
<< "status,"
<< "title,"
<< "abstract,"
<< "minzoom,"
<< "maxzoom,"
<< "queryable,"
@ -601,18 +599,6 @@ void map_parser::parse_layer( Map & map, ptree const & lay )
lyr.setActive( * status );
}
optional<std::string> title = get_opt_attr<std::string>(lay, "title");
if (title)
{
lyr.set_title( * title );
}
optional<std::string> abstract = get_opt_attr<std::string>(lay, "abstract");
if (abstract)
{
lyr.set_abstract( * abstract );
}
optional<double> minZoom = get_opt_attr<double>(lay, "minzoom");
if (minZoom)
{
@ -765,14 +751,12 @@ void map_parser::parse_layer( Map & map, ptree const & lay )
void map_parser::parse_rule( feature_type_style & style, ptree const & r )
{
ensure_attrs(r, "Rule", "name,title");
ensure_attrs(r, "Rule", "name");
std::string name;
try
{
name = get_attr( r, "name", std::string());
std::string title = get_attr( r, "title", std::string());
rule rule(name,title);
rule rule(name);
optional<std::string> filter_expr =
get_opt_child<std::string>( r, "Filter");

View file

@ -646,10 +646,6 @@ void serialize_rule( ptree & style_node, const rule & r, bool explicit_defaults)
{
set_attr(rule_node, "name", r.get_name());
}
if ( r.get_title() != dfl.get_title() )
{
set_attr(rule_node, "title", r.get_title());
}
if ( r.has_else_filter() )
{
@ -814,21 +810,12 @@ void serialize_layer( ptree & map_node, const layer & layer, bool explicit_defau
{
ptree & layer_node = map_node.push_back(
ptree::value_type("Layer", ptree()))->second;
if ( layer.name() != "" )
{
set_attr( layer_node, "name", layer.name() );
}
if ( layer.abstract() != "" )
{
set_attr( layer_node, "abstract", layer.abstract() );
}
if ( layer.title() != "" )
{
set_attr( layer_node, "title", layer.title() );
}
if ( layer.srs() != "" )
{
set_attr( layer_node, "srs", layer.srs() );

View file

@ -115,15 +115,12 @@ public:
#endif
}
~wkb_reader() {}
void read_multi(boost::ptr_vector<geometry_type> & paths)
void read(boost::ptr_vector<geometry_type> & paths)
{
int type = read_integer();
#ifdef MAPNIK_DEBUG_WKB
std::clog << "wkb_reader: read_multi "
<< wkb_geometry_type_string(type) << " " << type << std::endl;
std::clog << "wkb_reader: read " << wkb_geometry_type_string(type) << " " << type << std::endl;
#endif
switch (type)
@ -175,63 +172,6 @@ public:
}
}
void read(boost::ptr_vector<geometry_type> & paths)
{
int type = read_integer();
#ifdef MAPNIK_DEBUG_WKB
std::clog << "wkb_reader: read " << wkb_geometry_type_string(type) << " " << type << std::endl;
#endif
switch (type)
{
case wkbPoint:
read_point(paths);
break;
case wkbLineString:
read_linestring(paths);
break;
case wkbPolygon:
read_polygon(paths);
break;
case wkbMultiPoint:
read_multipoint_2(paths);
break;
case wkbMultiLineString:
read_multilinestring_2(paths);
break;
case wkbMultiPolygon:
read_multipolygon_2(paths);
break;
case wkbGeometryCollection:
read_collection_2(paths);
break;
case wkbPointZ:
read_point_xyz(paths);
break;
case wkbLineStringZ:
read_linestring_xyz(paths);
break;
case wkbPolygonZ:
read_polygon_xyz(paths);
break;
case wkbMultiPointZ:
read_multipoint_xyz_2(paths);
break;
case wkbMultiLineStringZ:
read_multilinestring_xyz_2(paths);
break;
case wkbMultiPolygonZ:
read_multipolygon_xyz_2(paths);
break;
case wkbGeometryCollectionZ:
read_collection_2(paths);
break;
default:
break;
}
}
private:
int read_integer()
@ -330,20 +270,6 @@ private:
}
}
void read_multipoint_2(boost::ptr_vector<geometry_type> & paths)
{
geometry_type* pt = new geometry_type(MultiPoint);
int num_points = read_integer();
for (int i = 0; i < num_points; ++i)
{
pos_ += 5;
double x = read_double();
double y = read_double();
pt->move_to(x, y);
}
paths.push_back(pt);
}
void read_point_xyz(boost::ptr_vector<geometry_type> & paths)
{
geometry_type* pt = new geometry_type(Point);
@ -364,22 +290,6 @@ private:
}
}
void read_multipoint_xyz_2(boost::ptr_vector<geometry_type> & paths)
{
geometry_type* pt = new geometry_type(MultiPoint);
int num_points = read_integer();
for (int i = 0; i < num_points; ++i)
{
pos_ += 5;
double x = read_double();
double y = read_double();
pos_ += 8; // double z = read_double();
pt->move_to(x, y);
}
paths.push_back(pt);
}
void read_linestring(boost::ptr_vector<geometry_type> & paths)
{
geometry_type* line = new geometry_type(LineString);
@ -405,28 +315,6 @@ private:
}
}
void read_multilinestring_2(boost::ptr_vector<geometry_type> & paths)
{
geometry_type* line = new geometry_type(MultiLineString);
int num_lines = read_integer();
unsigned capacity = 0;
for (int i = 0; i < num_lines; ++i)
{
pos_ += 5;
int num_points = read_integer();
capacity += num_points;
CoordinateArray ar(num_points);
read_coords(ar);
line->set_capacity(capacity);
line->move_to(ar[0].x, ar[0].y);
for (int j = 1; j < num_points; ++j)
{
line->line_to(ar[j].x, ar[j].y);
}
}
paths.push_back(line);
}
void read_linestring_xyz(boost::ptr_vector<geometry_type> & paths)
{
geometry_type* line = new geometry_type(LineString);
@ -452,28 +340,6 @@ private:
}
}
void read_multilinestring_xyz_2(boost::ptr_vector<geometry_type> & paths)
{
geometry_type* line = new geometry_type(MultiLineString);
int num_lines = read_integer();
unsigned capacity = 0;
for (int i = 0; i < num_lines; ++i)
{
pos_ += 5;
int num_points = read_integer();
capacity += num_points;
CoordinateArray ar(num_points);
read_coords_xyz(ar);
line->set_capacity(capacity);
line->move_to(ar[0].x, ar[0].y);
for (int j = 1; j < num_points; ++j)
{
line->line_to(ar[j].x, ar[j].y);
}
}
paths.push_back(line);
}
void read_polygon(boost::ptr_vector<geometry_type> & paths)
{
@ -506,33 +372,6 @@ private:
}
}
void read_multipolygon_2(boost::ptr_vector<geometry_type> & paths)
{
geometry_type* poly = new geometry_type(MultiPolygon);
int num_polys = read_integer();
unsigned capacity = 0;
for (int i = 0; i < num_polys; ++i)
{
pos_ += 5;
int num_rings = read_integer();
for (int r = 0; r < num_rings; ++r)
{
int num_points = read_integer();
capacity += num_points;
CoordinateArray ar(num_points);
read_coords(ar);
poly->set_capacity(capacity);
poly->move_to(ar[0].x, ar[0].y);
for (int j = 1; j < num_points; ++j)
{
poly->line_to(ar[j].x, ar[j].y);
}
poly->line_to(ar[0].x, ar[0].y);
}
}
paths.push_back(poly);
}
void read_polygon_xyz(boost::ptr_vector<geometry_type> & paths)
{
geometry_type* poly = new geometry_type(Polygon);
@ -564,34 +403,6 @@ private:
}
}
void read_multipolygon_xyz_2(boost::ptr_vector<geometry_type> & paths)
{
geometry_type* poly = new geometry_type(MultiPolygon);
int num_polys = read_integer();
unsigned capacity = 0;
for (int i = 0; i < num_polys; ++i)
{
pos_ += 5;
int num_rings = read_integer();
for (int r = 0; r < num_rings; ++r)
{
int num_points = read_integer();
capacity += num_points;
CoordinateArray ar(num_points);
read_coords_xyz(ar);
poly->set_capacity(capacity);
poly->move_to(ar[0].x, ar[0].y);
for (int j = 1; j < num_points; ++j)
{
poly->line_to(ar[j].x, ar[j].y);
}
poly->line_to(ar[0].x, ar[0].y);
}
}
paths.push_back(poly);
}
void read_collection(boost::ptr_vector<geometry_type> & paths)
{
int num_geometries = read_integer();
@ -602,16 +413,6 @@ private:
}
}
void read_collection_2(boost::ptr_vector<geometry_type> & paths)
{
int num_geometries = read_integer();
for (int i = 0; i < num_geometries; ++i)
{
pos_ += 1; // skip byte order
read_multi(paths);
}
}
#ifdef MAPNIK_DEBUG_WKB
std::string wkb_geometry_type_string(int type)
{
@ -645,17 +446,10 @@ private:
void geometry_utils::from_wkb (boost::ptr_vector<geometry_type>& paths,
const char* wkb,
unsigned size,
bool multiple_geometries,
wkbFormat format)
{
wkb_reader reader(wkb, size, format);
if (multiple_geometries)
{
return reader.read_multi(paths);
}
else
{
return reader.read(paths);
}
return reader.read(paths);
}
}

View file

@ -47,27 +47,6 @@
namespace mapnik {
/*
struct blob_to_hex
{
std::string operator() (const char* blob, unsigned size)
{
std::string buf;
buf.reserve(size*2);
std::ostringstream s(buf);
s.seekp(0);
char hex[3];
std::memset(hex,0,3);
for ( unsigned pos=0; pos < size; ++pos)
{
std::sprintf (hex, "%02X", int(blob[pos]) & 0xff);
s << hex;
}
return s.str();
}
};
*/
template <typename Connection>
void pgsql2sqlite(Connection conn,
std::string const& query,
@ -297,7 +276,7 @@ void pgsql2sqlite(Connection conn,
if (oid == geometry_oid)
{
mapnik::Feature feat(pkid);
geometry_utils::from_wkb(feat.paths(),buf,size,false,wkbGeneric);
geometry_utils::from_wkb(feat.paths(),buf,size,wkbGeneric);
if (feat.num_geometries() > 0)
{
geometry_type const& geom=feat.get_geometry(0);
@ -316,8 +295,6 @@ void pgsql2sqlite(Connection conn,
empty_geom = false;
}
}
//output_rec.push_back(sqlite::value_type("X'" + hex(buf,size) + "'"));
output_rec.push_back(sqlite::blob(buf,size));
}
else