diff --git a/CHANGELOG b/CHANGELOG index ba2380754..49aa4e399 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -14,6 +14,8 @@ For a complete change history, see the SVN log. Mapnik 2.1.0 ------------ +- SQLite - Added support for !intersects! token in sql subselects (#809) allow custom positioning of rtree spatial filter. + - New CSV plugin - reads tabular files - autodetecting geo columns, newlines, and delimiters. Uses in-memory featureset for fast rendering and is not designed for large files (#902) - Fixed bug in shield line placement when dx/dy are used to shift the label relative to the placement point (Matt Amos) (#908) diff --git a/bindings/python/build.py b/bindings/python/build.py index caea79ce0..7ad2385a1 100644 --- a/bindings/python/build.py +++ b/bindings/python/build.py @@ -142,7 +142,11 @@ paths += "__all__ = [mapniklibpath,inputpluginspath,fontscollectionpath]\n" if not os.path.exists('mapnik'): os.mkdir('mapnik') -file('mapnik/paths.py','w').write(paths % (os.path.relpath(env['MAPNIK_LIB_DIR'],target_path))) + +if hasattr(os.path,'relpath'): # python 2.6 and above + file('mapnik/paths.py','w').write(paths % (os.path.relpath(env['MAPNIK_LIB_DIR'],target_path))) +else: + file('mapnik/paths.py','w').write(paths % (env['MAPNIK_LIB_DIR'])) # force open perms temporarily so that `sudo scons install` # does not later break simple non-install non-sudo rebuild diff --git a/bindings/python/mapnik/printing.py b/bindings/python/mapnik/printing.py index 58f18b653..5e6456bd9 100644 --- a/bindings/python/mapnik/printing.py +++ b/bindings/python/mapnik/printing.py @@ -593,7 +593,7 @@ class PDFPrinter: for l in m.layers: # extract the layer names for naming layers if we use OCG - self._layer_names.append(l.title or l.name) + self._layer_names.append(l.name) layer_map = Map(m.width,m.height,m.srs) layer_map.layers.append(l) @@ -884,7 +884,7 @@ class PDFPrinter: for l in reversed(m.layers): have_layer_header = False added_styles={} - layer_title = l.title or l.name + layer_title = l.name if layer_title in processed_layers: continue processed_layers.append(layer_title) @@ -906,8 +906,8 @@ class PDFPrinter: if r.filter and str(r.filter) != "true": if len(rule_text) > 0: rule_text += " AND " - if r.title: - rule_text += r.title + if r.name: + rule_text += r.name else: rule_text += str(r.filter) active_rules = tuple(active_rules) diff --git a/bindings/python/mapnik_feature.cpp b/bindings/python/mapnik_feature.cpp index 57cdec88c..4bc392af4 100644 --- a/bindings/python/mapnik_feature.cpp +++ b/bindings/python/mapnik_feature.cpp @@ -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) diff --git a/bindings/python/mapnik_geometry.cpp b/bindings/python/mapnik_geometry.cpp index c30005438..22a68eba5 100644 --- a/bindings/python/mapnik_geometry.cpp +++ b/bindings/python/mapnik_geometry.cpp @@ -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 from_wkt_impl(std::string const& wkt) @@ -76,7 +76,7 @@ boost::shared_ptr from_wkt_impl(std::string const& wkt) boost::shared_ptr from_wkb_impl(std::string const& wkb) { boost::shared_ptr paths = boost::make_shared(); - 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,11 +143,8 @@ 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; class_, boost::noncopyable>("Geometry2d",no_init) .def("envelope",&geometry_type::envelope) @@ -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") diff --git a/bindings/python/mapnik_layer.cpp b/bindings/python/mapnik_layer.cpp index 916f8f602..a37843b7f 100644 --- a/bindings/python/mapnik_layer.cpp +++ b/bindings/python/mapnik_layer.cpp @@ -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(state[0])); + l.set_clear_label_cache(extract(state[0])); - l.set_title(extract(state[1])); + l.setMinZoom(extract(state[1])); - l.set_clear_label_cache(extract(state[2])); + l.setMaxZoom(extract(state[2])); - l.setMinZoom(extract(state[3])); + l.setQueryable(extract(state[3])); - l.setMaxZoom(extract(state[4])); - - l.setQueryable(extract(state[5])); - - mapnik::parameters params = extract(state[6]); + mapnik::parameters params = extract(state[4]); l.set_datasource(datasource_cache::instance()->create(params)); - boost::python::list s = extract(state[7]); + boost::python::list s = extract(state[5]); for (int i=0;i(s[i])); } - l.set_cache_features(extract(state[8])); + l.set_cache_features(extract(state[6])); } }; @@ -152,21 +148,6 @@ void export_layer() "False\n" ) - .add_property("abstract", - make_function(&layer::abstract,return_value_policy()), - &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()), - &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" - ) - ; } diff --git a/bindings/python/mapnik_rule.cpp b/bindings/python/mapnik_rule.cpp index b226dc865..b6f3e4bc8 100644 --- a/bindings/python/mapnik_rule.cpp +++ b/bindings/python/mapnik_rule.cpp @@ -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(state[0])); - } - - if (state[1]) { rule dfl; std::string filter = extract(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",init<>("default constructor")) .def(init >()) + boost::python::optional >()) .def_pickle(rule_pickle_suite()) .add_property("name",make_function (&rule::get_name, return_value_policy()), &rule::set_name) - .add_property("title",make_function - (&rule::get_title,return_value_policy()), - &rule::set_title) - .add_property("abstract",make_function - (&rule::get_abstract,return_value_policy()), - &rule::set_abstract) .add_property("filter",make_function (&rule::get_filter,return_value_policy()), &rule::set_filter) diff --git a/include/mapnik/geometry.hpp b/include/mapnik/geometry.hpp index 965bc4ee8..6ae01d179 100644 --- a/include/mapnik/geometry.hpp +++ b/include/mapnik/geometry.hpp @@ -36,29 +36,24 @@ namespace mapnik { enum eGeomType { Point = 1, - LineString, - Polygon, - MultiPoint, - MultiLineString, - MultiPolygon + LineString = 2, + Polygon = 3 }; - template class Container=vertex_vector> -class geometry +class geometry : private::boost::noncopyable { public: typedef T coord_type; typedef Container 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,12 +163,12 @@ public: */ void label_position(double *x, double *y) const { - if (type_ == LineString || type_ == MultiLineString) + if (type_ == LineString) { middle_point(x,y); return; } - + unsigned size = cont_.size(); if (size < 3) { @@ -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 geometry_type; typedef boost::shared_ptr geometry_ptr; -typedef boost::ptr_vector geometry_containter; +typedef boost::ptr_vector geometry_container; } diff --git a/include/mapnik/layer.hpp b/include/mapnik/layer.hpp index 4ed7e477e..98d3b6fd9 100644 --- a/include/mapnik/layer.hpp +++ b/include/mapnik/layer.hpp @@ -52,32 +52,13 @@ public: * @brief Set the name of the layer. */ void set_name(std::string const& name); - + /*! * @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,10 +193,8 @@ private: void swap(const layer& other); std::string name_; - std::string title_; - std::string abstract_; std::string srs_; - + double minZoom_; double maxZoom_; bool active_; diff --git a/include/mapnik/rule.hpp b/include/mapnik/rule.hpp index 9664d1173..eb5a02c7e 100644 --- a/include/mapnik/rule.hpp +++ b/include/mapnik/rule.hpp @@ -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::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::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_), @@ -263,27 +255,7 @@ 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_; diff --git a/include/mapnik/util/geometry_to_wkb.hpp b/include/mapnik/util/geometry_to_wkb.hpp index aa226ce96..ffcdf9ef7 100644 --- a/include/mapnik/util/geometry_to_wkb.hpp +++ b/include/mapnik/util/geometry_to_wkb.hpp @@ -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; } diff --git a/include/mapnik/util/geometry_to_wkt.hpp b/include/mapnik/util/geometry_to_wkt.hpp index 962909f00..80c77fec1 100644 --- a/include/mapnik/util/geometry_to_wkt.hpp +++ b/include/mapnik/util/geometry_to_wkt.hpp @@ -42,8 +42,19 @@ bool to_wkt(std::string & wkt, mapnik::geometry_type const& geom) { typedef std::back_insert_iterator sink_type; sink_type sink(wkt); - wkt_generator generator; - bool result = karma::generate(sink, generator, geom); + // disable temporarily until compile works with g++ + //wkt_generator generator(true); + bool result = false;//karma::generate(sink, generator, geom); + return result; +} + +bool to_wkt(std::string & wkt, mapnik::geometry_container const& geom) +{ + typedef std::back_insert_iterator sink_type; + sink_type sink(wkt); + // disable temporarily until compile works with g++ + //wkt_multi_generator generator; + bool result = false;//karma::generate(sink, generator, geom); return result; } diff --git a/include/mapnik/util/geometry_wkt_generator.hpp b/include/mapnik/util/geometry_wkt_generator.hpp index 7ff923ce0..dfb191e72 100644 --- a/include/mapnik/util/geometry_wkt_generator.hpp +++ b/include/mapnik/util/geometry_wkt_generator.hpp @@ -30,7 +30,6 @@ #include #include #include - // boost #include #include @@ -49,6 +48,8 @@ namespace mapnik { namespace util { namespace karma = boost::spirit::karma; namespace phoenix = boost::phoenix; +namespace { + struct get_type { template @@ -56,7 +57,7 @@ struct get_type int operator() (geometry_type const& geom) const { - return (int)geom.type(); + return static_cast(geom.type()); } }; @@ -73,21 +74,61 @@ struct get_first } }; + +struct multi_geometry_ +{ + template + struct result { typedef bool type; }; + + bool operator() (geometry_container const& geom) const + { + return geom.size() > 1 ? true : false; + } +}; + +struct multi_geometry_type +{ + template + struct result { typedef boost::tuple type; }; + + boost::tuple 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(type, collection); + } +}; + + template -struct coordinate_policy : karma::real_policies +struct wkt_coordinate_policy : karma::real_policies { typedef boost::spirit::karma::real_policies 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 struct wkt_generator : karma::grammar { - 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 coords; karma::rule, geometry_type const& ()> coords2; karma::rule point_coord; - karma::rule polygon_coord; + karma::rule polygon_coord; // phoenix functions phoenix::function _type; phoenix::function _first; // - karma::real_generator > coord_type; + karma::real_generator > coord_type; }; + + +template +struct wkt_multi_generator : + karma::grammar >, 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 >, geometry_container const& ()> wkt; + karma::rule geometry; + karma::rule single_geometry; + karma::rule multi_geometry; + wkt_generator path; + // phoenix + phoenix::function is_multi; + phoenix::function _multi_type; + phoenix::function _type; + // + karma::symbols geometry_types; +}; + }} diff --git a/include/mapnik/wkb.hpp b/include/mapnik/wkb.hpp index 77c7c04c6..55df4d102 100644 --- a/include/mapnik/wkb.hpp +++ b/include/mapnik/wkb.hpp @@ -27,6 +27,8 @@ #include #include #include +// boost +#include 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& 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&); }; } diff --git a/plugins/input/geos/geos_datasource.cpp b/plugins/input/geos/geos_datasource.cpp index cfa4e1cf4..f09670a46 100644 --- a/plugins/input/geos/geos_datasource.cpp +++ b/plugins/input/geos/geos_datasource.cpp @@ -97,9 +97,7 @@ geos_datasource::geos_datasource(parameters const& params, bool bind) boost::optional geometry = params.get("wkt"); if (! geometry) throw datasource_exception("missing parameter"); geometry_string_ = *geometry; - - multiple_geometries_ = *params_.get("multiple_geometries",false); - + boost::optional ext = params_.get("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()); } diff --git a/plugins/input/geos/geos_datasource.hpp b/plugins/input/geos/geos_datasource.hpp index 3d2385776..79e846c41 100644 --- a/plugins/input/geos/geos_datasource.hpp +++ b/plugins/input/geos/geos_datasource.hpp @@ -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 diff --git a/plugins/input/geos/geos_featureset.cpp b/plugins/input/geos/geos_featureset.cpp index bbcbb832d..afd2d71af 100644 --- a/plugins/input/geos/geos_featureset.cpp +++ b/plugins/input/geos/geos_featureset.cpp @@ -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,14 +118,12 @@ 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())); } - + return feature; } } diff --git a/plugins/input/geos/geos_featureset.hpp b/plugins/input/geos/geos_featureset.hpp index 2b777efaa..d68352329 100644 --- a/plugins/input/geos/geos_featureset.hpp +++ b/plugins/input/geos/geos_featureset.hpp @@ -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(); diff --git a/plugins/input/kismet/kismet_featureset.hpp b/plugins/input/kismet/kismet_featureset.hpp index 424d39fd0..363f3425a 100644 --- a/plugins/input/kismet/kismet_featureset.hpp +++ b/plugins/input/kismet/kismet_featureset.hpp @@ -50,7 +50,6 @@ private: const std::list& knd_list_; boost::scoped_ptr tr_; mapnik::wkbFormat format_; - bool multiple_geometries_; int feature_id_; std::list::const_iterator knd_list_it; mapnik::projection source_; diff --git a/plugins/input/occi/occi_datasource.cpp b/plugins/input/occi/occi_datasource.cpp index f1fd158ca..335146174 100644 --- a/plugins/input/occi/occi_datasource.cpp +++ b/plugins/input/occi/occi_datasource.cpp @@ -94,7 +94,6 @@ occi_datasource::occi_datasource(parameters const& params, bool bind) table_ = *table; } - multiple_geometries_ = *params_.get("multiple_geometries",false); use_spatial_index_ = *params_.get("use_spatial_index",true); use_connection_pool_ = *params_.get("use_connection_pool",true); @@ -559,8 +558,7 @@ featureset_ptr occi_datasource::features(query const& q) const return boost::make_shared(pool_, conn_, s.str(), - desc_.get_encoding(), - multiple_geometries_, + desc_.get_encoding(), 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); diff --git a/plugins/input/occi/occi_datasource.hpp b/plugins/input/occi/occi_datasource.hpp index 4e751eb60..72096ae9e 100644 --- a/plugins/input/occi/occi_datasource.hpp +++ b/plugins/input/occi/occi_datasource.hpp @@ -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; }; diff --git a/plugins/input/occi/occi_featureset.cpp b/plugins/input/occi/occi_featureset.cpp index 76e092bc2..b4ea397ad 100644 --- a/plugins/input/occi/occi_featureset.cpp +++ b/plugins/input/occi/occi_featureset.cpp @@ -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 geom(dynamic_cast(rs_->getObject(1))); if (geom.get()) { - convert_geometry(geom.get(), feature, multiple_geometries_); + convert_geometry(geom.get(), feature); } std::vector 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& 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,16 +428,13 @@ 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, diff --git a/plugins/input/occi/occi_featureset.hpp b/plugins/input/occi/occi_featureset.hpp index 88977d678..4c2a0db67 100644 --- a/plugins/input/occi/occi_featureset.hpp +++ b/plugins/input/occi/occi_featureset.hpp @@ -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& elem_info, const std::vector& 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 tr_; const char* fidcolumn_; - bool multiple_geometries_; unsigned num_attrs_; mutable int feature_id_; }; diff --git a/plugins/input/postgis/postgis_datasource.cpp b/plugins/input/postgis/postgis_datasource.cpp index 9b2c641c1..2d0d642f9 100644 --- a/plugins/input/postgis/postgis_datasource.cpp +++ b/plugins/input/postgis/postgis_datasource.cpp @@ -87,8 +87,6 @@ postgis_datasource::postgis_datasource(parameters const& params, bool bind) { if (table_.empty()) throw mapnik::datasource_exception("Postgis Plugin: missing parameter"); - multiple_geometries_ = *params_.get("multiple_geometries",false); - boost::optional ext = params_.get("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(rs,desc_.get_encoding(),multiple_geometries_,!key_field_.empty(),num_attr); + return boost::make_shared(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 rs = get_resultset(conn, s.str()); - return boost::make_shared(rs,desc_.get_encoding(),multiple_geometries_,!key_field_.empty(),size); + return boost::make_shared(rs,desc_.get_encoding(), !key_field_.empty(),size); } } return featureset_ptr(); diff --git a/plugins/input/postgis/postgis_datasource.hpp b/plugins/input/postgis/postgis_datasource.hpp index 8ad42e4f9..0ad00df9c 100644 --- a/plugins/input/postgis/postgis_datasource.hpp +++ b/plugins/input/postgis/postgis_datasource.hpp @@ -69,7 +69,6 @@ class postgis_datasource : public datasource mutable mapnik::box2d extent_; mutable layer_descriptor desc_; ConnectionCreator creator_; - bool multiple_geometries_; const std::string bbox_token_; const std::string scale_denom_token_; bool persist_connection_; diff --git a/plugins/input/postgis/postgis_featureset.cpp b/plugins/input/postgis/postgis_featureset.cpp index 84a877248..087047ce5 100644 --- a/plugins/input/postgis/postgis_featureset.cpp +++ b/plugins/input/postgis/postgis_featureset.cpp @@ -49,11 +49,9 @@ using mapnik::feature_factory; postgis_featureset::postgis_featureset(boost::shared_ptr 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 rs_; - bool multiple_geometries_; unsigned num_attrs_; boost::scoped_ptr tr_; int totalGeomSize_; @@ -53,7 +52,6 @@ private: public: postgis_featureset(boost::shared_ptr const& rs, std::string const& encoding, - bool multiple_geometries, bool key_field, unsigned num_attrs); mapnik::feature_ptr next(); diff --git a/plugins/input/shape/shape_featureset.cpp b/plugins/input/shape/shape_featureset.cpp index 9a6753b52..779c3869d 100644 --- a/plugins/input/shape/shape_featureset.cpp +++ b/plugins/input/shape/shape_featureset.cpp @@ -248,55 +248,25 @@ feature_ptr shape_featureset::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; } } } - + feature->set_id(shape_.id_); if (attr_ids_.size()) { diff --git a/plugins/input/shape/shape_index_featureset.cpp b/plugins/input/shape/shape_index_featureset.cpp index b25e8c644..0c0fcadc5 100644 --- a/plugins/input/shape/shape_index_featureset.cpp +++ b/plugins/input/shape/shape_index_featureset.cpp @@ -193,49 +193,18 @@ feature_ptr shape_index_featureset::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; } diff --git a/plugins/input/shape/shape_io.cpp b/plugins/input/shape/shape_io.cpp index 04aa48814..54b7f32fc 100644 --- a/plugins/input/shape/shape_io.cpp +++ b/plugins/input/shape/shape_io.cpp @@ -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 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;iset_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 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,19 +180,17 @@ 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); - + int num_parts = record.read_ndr_integer(); int num_points = record.read_ndr_integer(); std::vector 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 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 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; } + + diff --git a/plugins/input/shape/shape_io.hpp b/plugins/input/shape/shape_io.hpp index 1623402df..1421ec0ab 100644 --- a/plugins/input/shape/shape_io.hpp +++ b/plugins/input/shape/shape_io.hpp @@ -23,6 +23,8 @@ #ifndef SHAPE_IO_HPP #define SHAPE_IO_HPP +// mapnik +#include // boost #include #include @@ -56,9 +58,8 @@ public: ~shape_io(); shape_file& shp(); - //shape_file& shx(); dbf_file& dbf(); - + inline boost::shared_ptr& index() { return index_; @@ -72,16 +73,10 @@ public: void move_to(int id); int type() const; const box2d& 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 index_; unsigned reclength_; @@ -89,7 +84,6 @@ public: box2d cur_extent_; static const std::string SHP; - //static const std::string SHX; static const std::string DBF; static const std::string INDEX; }; diff --git a/plugins/input/sqlite/sqlite_datasource.cpp b/plugins/input/sqlite/sqlite_datasource.cpp index 7946dfead..14b6a068c 100644 --- a/plugins/input/sqlite/sqlite_datasource.cpp +++ b/plugins/input/sqlite/sqlite_datasource.cpp @@ -62,6 +62,7 @@ sqlite_datasource::sqlite_datasource(parameters const& params, bool bind) key_field_(*params_.get("key_field", "")), row_offset_(*params_.get("row_offset", 0)), row_limit_(*params_.get("row_limit", 0)), + intersects_token_("!intersects!"), desc_(*params_.get("type"), *params_.get("encoding", "utf-8")), format_(mapnik::wkbAuto) { @@ -102,7 +103,6 @@ void sqlite_datasource::bind() const throw datasource_exception("Sqlite Plugin: " + dataset_name_ + " does not exist"); } - multiple_geometries_ = *params_.get("multiple_geometries", false); use_spatial_index_ = *params_.get("use_spatial_index", true); // TODO - remove this option once all datasources have an indexing api @@ -186,7 +186,8 @@ void sqlite_datasource::bind() const if (using_subquery_) { std::ostringstream s; - s << "SELECT " << fields_ << " FROM (" << table_ << ") LIMIT 1"; + std::string query = populate_tokens(table_); + s << "SELECT " << fields_ << " FROM (" << query << ") LIMIT 1"; found_types_via_subquery = sqlite_utils::detect_types_from_subquery(s.str(),geometry_field_,desc_,dataset_); } @@ -225,7 +226,12 @@ void sqlite_datasource::bind() const if (geometry_field_.empty()) { - throw datasource_exception("Sqlite Plugin: cannot detect geometry_field, please supply the name of the geometry_field to use."); + std::ostringstream s; + s << "Sqlite Plugin: unable to detect the column " + << "containing a valid geometry on table '" << geometry_table_ << "'. " + << "Please provide a column name by passing the 'geometry_field' option " + << "or indicate a different spatial table to use by passing the 'geometry_table' option"; + throw datasource_exception(s.str()); } if (index_table_.empty()) @@ -302,6 +308,7 @@ void sqlite_datasource::bind() const { // TODO - clean this up - reducing arguments + std::string query = populate_tokens(table_); if (!sqlite_utils::detect_extent(dataset_, has_spatial_index_, extent_, @@ -310,7 +317,7 @@ void sqlite_datasource::bind() const geometry_field_, geometry_table_, key_field_, - table_)) + query)) { std::ostringstream s; s << "Sqlite Plugin: extent could not be determined for table '" @@ -324,6 +331,17 @@ void sqlite_datasource::bind() const is_bound_ = true; } +std::string sqlite_datasource::populate_tokens(const std::string& sql) const +{ + std::string populated_sql = sql; + if (boost::algorithm::ifind_first(populated_sql, intersects_token_)) + { + // replace with dummy comparison that is true + boost::algorithm::ireplace_first(populated_sql, intersects_token_, "1=1"); + } + return populated_sql; +} + sqlite_datasource::~sqlite_datasource() { } @@ -461,23 +479,21 @@ featureset_ptr sqlite_datasource::features(query const& q) const s << " FROM "; - std::string query (table_); + std::string query(table_); if (! key_field_.empty() && has_spatial_index_) { - std::ostringstream spatial_sql; - spatial_sql << std::setprecision(16); - spatial_sql << " WHERE " << key_field_ << " IN (SELECT pkid FROM " << index_table_; - spatial_sql << " WHERE xmax>=" << e.minx() << " AND xmin<=" << e.maxx() ; - spatial_sql << " AND ymax>=" << e.miny() << " AND ymin<=" << e.maxy() << ")"; - if (boost::algorithm::ifind_first(query, "WHERE")) - { - boost::algorithm::ireplace_first(query, "WHERE", spatial_sql.str() + " AND "); - } - else if (boost::algorithm::ifind_first(query, geometry_table_)) - { - boost::algorithm::ireplace_first(query, table_, table_ + " " + spatial_sql.str()); - } + // TODO - debug warn if fails + sqlite_utils::apply_spatial_filter(query, + e, + table_, + key_field_, + index_table_, + geometry_table_, + intersects_token_); } + else + { + query = populate_tokens(table_); } s << query ; @@ -502,7 +518,6 @@ featureset_ptr sqlite_datasource::features(query const& q) const return boost::make_shared(rs, desc_.get_encoding(), format_, - multiple_geometries_, using_subquery_); } @@ -541,19 +556,18 @@ featureset_ptr sqlite_datasource::features_at_point(coord2d const& pt) const if (! key_field_.empty() && has_spatial_index_) { - std::ostringstream spatial_sql; - spatial_sql << std::setprecision(16); - spatial_sql << " WHERE " << key_field_ << " IN (SELECT pkid FROM " << index_table_; - spatial_sql << " WHERE xmax>=" << e.minx() << " AND xmin<=" << e.maxx() ; - spatial_sql << " AND ymax>=" << e.miny() << " AND ymin<=" << e.maxy() << ")"; - if (boost::algorithm::ifind_first(query, "WHERE")) - { - boost::algorithm::ireplace_first(query, "WHERE", spatial_sql.str() + " AND "); - } - else if (boost::algorithm::ifind_first(query, geometry_table_)) - { - boost::algorithm::ireplace_first(query, table_, table_ + " " + spatial_sql.str()); - } + // TODO - debug warn if fails + sqlite_utils::apply_spatial_filter(query, + e, + table_, + key_field_, + index_table_, + geometry_table_, + intersects_token_); + } + else + { + query = populate_tokens(table_); } s << query ; @@ -577,9 +591,8 @@ featureset_ptr sqlite_datasource::features_at_point(coord2d const& pt) const return boost::make_shared(rs, desc_.get_encoding(), format_, - multiple_geometries_, using_subquery_); } - + return featureset_ptr(); } diff --git a/plugins/input/sqlite/sqlite_datasource.hpp b/plugins/input/sqlite/sqlite_datasource.hpp index afecfcb89..f705f762d 100644 --- a/plugins/input/sqlite/sqlite_datasource.hpp +++ b/plugins/input/sqlite/sqlite_datasource.hpp @@ -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 extent_; mutable bool extent_initialized_; int type_; @@ -65,9 +70,10 @@ private: mutable std::string key_field_; mutable int row_offset_; mutable int row_limit_; + // TODO - also add to postgis.input + const std::string intersects_token_; 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_; @@ -76,6 +82,7 @@ private: // Fill init_statements with any statements // needed to attach auxillary databases void parse_attachdb(std::string const& attachdb) const; + std::string populate_tokens(const std::string& sql) const; }; #endif // MAPNIK_SQLITE_DATASOURCE_HPP diff --git a/plugins/input/sqlite/sqlite_featureset.cpp b/plugins/input/sqlite/sqlite_featureset.cpp index 1cf0d8110..f92a8ba46 100644 --- a/plugins/input/sqlite/sqlite_featureset.cpp +++ b/plugins/input/sqlite/sqlite_featureset.cpp @@ -47,12 +47,10 @@ using mapnik::feature_factory; sqlite_featureset::sqlite_featureset(boost::shared_ptr 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,8 +73,8 @@ 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) { const int type_oid = rs_->column_type(i); diff --git a/plugins/input/sqlite/sqlite_featureset.hpp b/plugins/input/sqlite/sqlite_featureset.hpp index 313cadb38..4ec7472ba 100644 --- a/plugins/input/sqlite/sqlite_featureset.hpp +++ b/plugins/input/sqlite/sqlite_featureset.hpp @@ -42,7 +42,6 @@ public: sqlite_featureset(boost::shared_ptr 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 rs_; boost::scoped_ptr tr_; mapnik::wkbFormat format_; - bool multiple_geometries_; bool using_subquery_; }; diff --git a/plugins/input/sqlite/sqlite_utils.hpp b/plugins/input/sqlite/sqlite_utils.hpp index 1e3ede064..6021d26ca 100644 --- a/plugins/input/sqlite/sqlite_utils.hpp +++ b/plugins/input/sqlite/sqlite_utils.hpp @@ -108,6 +108,42 @@ public: //} } + static bool apply_spatial_filter(std::string & query, + mapnik::box2d const& e, + std::string const& table, + std::string const& key_field, + std::string const& index_table, + std::string const& geometry_table, + std::string const& intersects_token) + { + std::ostringstream spatial_sql; + spatial_sql << std::setprecision(16); + spatial_sql << key_field << " IN (SELECT pkid FROM " << index_table; + spatial_sql << " WHERE xmax>=" << e.minx() << " AND xmin<=" << e.maxx() ; + spatial_sql << " AND ymax>=" << e.miny() << " AND ymin<=" << e.maxy() << ")"; + if (boost::algorithm::ifind_first(query, intersects_token)) + { + boost::algorithm::ireplace_all(query, intersects_token, spatial_sql.str()); + return true; + } + // substitute first WHERE found if not using JOIN + // (because we can't know the WHERE is on the right table) + else if (boost::algorithm::ifind_first(query, "WHERE") + && !boost::algorithm::ifind_first(query, "JOIN")) + { + std::string replace(" WHERE " + spatial_sql.str() + " AND "); + boost::algorithm::ireplace_first(query, "WHERE", replace); + return true; + } + // fallback to appending spatial filter at end of query + else if (boost::algorithm::ifind_first(query, geometry_table)) + { + query = table + " WHERE " + spatial_sql.str(); + return true; + } + return false; + } + static void get_tables(boost::shared_ptr ds, std::vector & tables) { @@ -151,11 +187,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(rs->column_blob(0, size)); if (data) { boost::ptr_vector 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 const& bbox = paths[i].envelope(); @@ -241,41 +277,47 @@ public: if (data) { boost::ptr_vector 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 bbox; for (unsigned i=0; i 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 +362,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(rs->column_blob(0, size)); if (data) { boost::ptr_vector 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 const& bbox = paths[i].envelope(); @@ -568,6 +608,7 @@ public: // PRAGMA table_info is used so here we assume the column is a string // which is a lesser evil than altogether dropping the column desc.add_descriptor(mapnik::attribute_descriptor(fld_name, mapnik::String)); + break; case SQLITE_BLOB: if (geometry_field.empty() diff --git a/src/agg/process_text_symbolizer.cpp b/src/agg/process_text_symbolizer.cpp index a127a19ee..e460fa322 100644 --- a/src/agg/process_text_symbolizer.cpp +++ b/src/agg/process_text_symbolizer.cpp @@ -44,7 +44,7 @@ void agg_renderer::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 gbox = t_.forward(geom.envelope(),prj_trans); diff --git a/src/layer.cpp b/src/layer.cpp index a185cac7f..3d88e17e6 100644 --- a/src/layer.cpp +++ b/src/layer.cpp @@ -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::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; diff --git a/src/load_map.cpp b/src/load_map.cpp index 7b0d04f35..055948f3d 100644 --- a/src/load_map.cpp +++ b/src/load_map.cpp @@ -577,8 +577,6 @@ void map_parser::parse_layer( Map & map, ptree const & lay ) s << "name," << "srs," << "status," - << "title," - << "abstract," << "minzoom," << "maxzoom," << "queryable," @@ -600,19 +598,7 @@ void map_parser::parse_layer( Map & map, ptree const & lay ) { lyr.setActive( * status ); } - - optional title = get_opt_attr(lay, "title"); - if (title) - { - lyr.set_title( * title ); - } - - optional abstract = get_opt_attr(lay, "abstract"); - if (abstract) - { - lyr.set_abstract( * abstract ); - } - + optional minZoom = get_opt_attr(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 filter_expr = get_opt_child( r, "Filter"); diff --git a/src/placement_finder.cpp b/src/placement_finder.cpp index b0dafd56b..c965d03cf 100644 --- a/src/placement_finder.cpp +++ b/src/placement_finder.cpp @@ -293,7 +293,7 @@ void placement_finder::find_point_placement(placement & p, // wrap text at first wrap_char after (default) the wrap width or immediately before the current word if ((c == '\n') || (line_width > 0 && (((line_width - character_spacing) > wrap_at && !p.wrap_before) || - ((line_width + word_width - character_spacing) > wrap_at && p.wrap_before)) )) + ((line_width + word_width - character_spacing) > wrap_at && p.wrap_before)) )) { // Remove width of breaking space character since it is not rendered and the character_spacing for the last character on the line line_width -= (last_wrap_char_width + character_spacing); @@ -381,12 +381,12 @@ void placement_finder::find_point_placement(placement & p, x = -(line_width / 2.0); if (p.info.get_rtl()==false) { - y = (0.5 * (string_height + (line_spacing * (total_lines-1)))) - max_character_height; - } - else - { - y = -(0.5 * (string_height + (line_spacing * (total_lines-1)))) + max_character_height; - } + y = (0.5 * (string_height + (line_spacing * (total_lines-1)))) - max_character_height; + } + else + { + y = -(0.5 * (string_height + (line_spacing * (total_lines-1)))) + max_character_height; + } // if needed, adjust for desired justification (J_MIDDLE is the default) if( po->jalign == J_LEFT ) @@ -411,14 +411,14 @@ void placement_finder::find_point_placement(placement & p, index_to_wrap_at = line_breaks[++line_number]; line_width = line_widths[line_number]; - if (p.info.get_rtl()==false) - { - y -= (max_character_height + line_spacing); // move position down to line start - } - else - { - y += (max_character_height + line_spacing); // move position up to line start - } + if (p.info.get_rtl()==false) + { + y -= (max_character_height + line_spacing); // move position down to line start + } + else + { + y += (max_character_height + line_spacing); // move position up to line start + } // reset to begining of line position x = ((po->jalign == J_LEFT)? -(string_width / 2.0): ((po->jalign == J_RIGHT)? ((string_width /2.0) - line_width): -(line_width / 2.0))); @@ -467,9 +467,9 @@ void placement_finder::find_point_placement(placement & p, if (p.minimum_padding > 0) { box2d epad(e.minx()-p.minimum_padding, - e.miny()-p.minimum_padding, - e.maxx()+p.minimum_padding, - e.maxy()+p.minimum_padding); + e.miny()-p.minimum_padding, + e.maxx()+p.minimum_padding, + e.maxy()+p.minimum_padding); if (!dimensions_.contains(epad)) { return; @@ -485,18 +485,18 @@ void placement_finder::find_point_placement(placement & p, // check the placement of any additional envelopes if (!p.allow_overlap && !p.additional_boxes.empty()) { - BOOST_FOREACH(box2d box, p.additional_boxes) - { - box2d pt(box.minx() + current_placement->starting_x, - box.miny() + current_placement->starting_y, - box.maxx() + current_placement->starting_x, - box.maxy() + current_placement->starting_y); + BOOST_FOREACH(box2d box, p.additional_boxes) + { + box2d pt(box.minx() + current_placement->starting_x, + box.miny() + current_placement->starting_y, + box.maxx() + current_placement->starting_x, + box.maxy() + current_placement->starting_y); - // abort the whole placement if the additional envelopes can't be placed. - if (!detector_.has_point_placement(pt, p.minimum_distance)) return; + // abort the whole placement if the additional envelopes can't be placed. + if (!detector_.has_point_placement(pt, p.minimum_distance)) return; - c_envelopes.push(pt); - } + c_envelopes.push(pt); + } } // since there was no early exit, add the character envelopes to the placements' envelopes diff --git a/src/save_map.cpp b/src/save_map.cpp index 63f1b84ff..a26fd3d93 100644 --- a/src/save_map.cpp +++ b/src/save_map.cpp @@ -646,11 +646,7 @@ 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() ) { rule_node.push_back( ptree::value_type( @@ -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() ); diff --git a/src/wkb.cpp b/src/wkb.cpp index f704971b7..158311cc4 100644 --- a/src/wkb.cpp +++ b/src/wkb.cpp @@ -114,16 +114,13 @@ public: needSwap_ = byteOrder_ ? wkbNDR : wkbXDR; #endif } - - ~wkb_reader() {} - - void read_multi(boost::ptr_vector & paths) + + void read(boost::ptr_vector & 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) @@ -174,63 +171,6 @@ public: break; } } - - void read(boost::ptr_vector & 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: @@ -329,21 +269,7 @@ private: read_point(paths); } } - - void read_multipoint_2(boost::ptr_vector & 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 & paths) { geometry_type* pt = new geometry_type(Point); @@ -364,22 +290,6 @@ private: } } - void read_multipoint_xyz_2(boost::ptr_vector & 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 & paths) { geometry_type* line = new geometry_type(LineString); @@ -404,29 +314,7 @@ private: read_linestring(paths); } } - - void read_multilinestring_2(boost::ptr_vector & 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 & paths) { geometry_type* line = new geometry_type(LineString); @@ -452,29 +340,7 @@ private: } } - void read_multilinestring_xyz_2(boost::ptr_vector & 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 & paths) { geometry_type* poly = new geometry_type(Polygon); @@ -506,33 +372,6 @@ private: } } - void read_multipolygon_2(boost::ptr_vector & 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 & paths) { geometry_type* poly = new geometry_type(Polygon); @@ -564,34 +403,6 @@ private: } } - void read_multipolygon_xyz_2(boost::ptr_vector & 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 & paths) { int num_geometries = read_integer(); @@ -602,16 +413,6 @@ private: } } - void read_collection_2(boost::ptr_vector & 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& 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); } + } diff --git a/tests/data/good_maps/markers_symbolizer_lines.xml b/tests/data/good_maps/markers_symbolizer_lines.xml index d3adaefb6..1336f56bc 100644 --- a/tests/data/good_maps/markers_symbolizer_lines.xml +++ b/tests/data/good_maps/markers_symbolizer_lines.xml @@ -1,7 +1,7 @@