diff --git a/include/mapnik/agg_renderer.hpp b/include/mapnik/agg_renderer.hpp index 516e8e6da..12f30f5a3 100644 --- a/include/mapnik/agg_renderer.hpp +++ b/include/mapnik/agg_renderer.hpp @@ -24,34 +24,34 @@ #define MAPNIK_AGG_RENDERER_HPP // mapnik -#include +#include // for MAPNIK_DECL #include -#include -#include -#include +#include // for face_manager, etc +#include // for noncopyable +#include // for rule, symbolizers +#include // for box2d #include -#include // for all symbolizers -#include +#include // for color +#include // for CoordTransform +#include // for composite_mode_e // boost #include #include -#include -// FIXME -// forward declare so that -// apps using mapnik do not -// need agg headers -namespace agg { -struct trans_affine; -} +namespace agg { struct trans_affine; } +namespace mapnik { class Map; } +namespace mapnik { class feature_impl; } +namespace mapnik { class feature_type_style; } +namespace mapnik { class label_collision_detector4; } +namespace mapnik { class layer; } +namespace mapnik { class marker; } +namespace mapnik { class proj_transform; } +namespace mapnik { struct rasterizer; } +struct pixel_position; namespace mapnik { -class marker; - -struct rasterizer; - template class MAPNIK_DECL agg_renderer : public feature_style_processor >, private mapnik::noncopyable diff --git a/include/mapnik/filter_featureset.hpp b/include/mapnik/filter_featureset.hpp index faa049b02..b02cf3507 100644 --- a/include/mapnik/filter_featureset.hpp +++ b/include/mapnik/filter_featureset.hpp @@ -24,7 +24,8 @@ #define MAPNIK_FILTER_FEATURESET_HPP // mapnik -#include +#include // for featureset_ptr +#include namespace mapnik { diff --git a/include/mapnik/grid/grid_renderer.hpp b/include/mapnik/grid/grid_renderer.hpp index 41d4426f8..cd1acda59 100644 --- a/include/mapnik/grid/grid_renderer.hpp +++ b/include/mapnik/grid/grid_renderer.hpp @@ -27,30 +27,32 @@ #include #include #include -#include -#include -#include // for all symbolizers #include #include #include +#include // for rule, symbolizers +#include // for box2d +#include // for color +#include // for CoordTransform +#include // for composite_mode_e // boost #include +#include -// FIXME -// forward declare so that -// apps using mapnik do not -// need agg headers -namespace agg { -struct trans_affine; -} +namespace agg { struct trans_affine; } +namespace mapnik { class Map; } +namespace mapnik { class feature_impl; } +namespace mapnik { class feature_type_style; } +namespace mapnik { class label_collision_detector4; } +namespace mapnik { class layer; } +namespace mapnik { class marker; } +namespace mapnik { class proj_transform; } +namespace mapnik { struct grid_rasterizer; } +struct pixel_position; namespace mapnik { -class marker; - -struct grid_rasterizer; - template class MAPNIK_DECL grid_renderer : public feature_style_processor >, private mapnik::noncopyable diff --git a/include/mapnik/map.hpp b/include/mapnik/map.hpp index d4ee4d60a..780126720 100644 --- a/include/mapnik/map.hpp +++ b/include/mapnik/map.hpp @@ -24,9 +24,10 @@ #define MAPNIK_MAP_HPP // mapnik +#include +#include #include -#include -#include +#include // for featureset_ptr #include #include #include @@ -37,6 +38,7 @@ namespace mapnik { +class feature_type_style; class CoordTransform; class MAPNIK_DECL Map diff --git a/include/mapnik/params.hpp b/include/mapnik/params.hpp index 07e62a9a9..a75bdcf83 100644 --- a/include/mapnik/params.hpp +++ b/include/mapnik/params.hpp @@ -24,10 +24,8 @@ #define MAPNIK_PARAMS_HPP // boost -#include +#include #include -#include -#include // mapnik #include @@ -42,67 +40,16 @@ typedef boost::variant value_ typedef std::pair parameter; typedef std::map param_map; -template -struct value_extractor_visitor : public boost::static_visitor<> -{ - value_extractor_visitor(boost::optional & var) - :var_(var) {} - - void operator () (T val) const - { - var_ = val; - } - - template - void operator () (T1 val) const - { - try - { - var_ = boost::lexical_cast(val); - } - catch (boost::bad_lexical_cast & ) {} - } - - boost::optional & var_; -}; - - class parameters : public param_map { - template - struct converter - { - typedef boost::optional return_type; - static return_type extract(parameters const& params, - std::string const& name, - boost::optional const& default_opt_value) - { - boost::optional result(default_opt_value); - parameters::const_iterator itr = params.find(name); - if (itr != params.end()) - { - boost::apply_visitor(value_extractor_visitor(result),itr->second); - } - return result; - } - }; - public: - - parameters() {} - + parameters(); template - boost::optional get(std::string const& key) const - { - return converter::extract(*this,key, boost::none); - } - + boost::optional get(std::string const& key) const; template - boost::optional get(std::string const& key, T const& default_opt_value) const - { - return converter::extract(*this,key,boost::optional(default_opt_value)); - } + boost::optional get(std::string const& key, T const& default_opt_value) const; }; + } #endif // MAPNIK_PARAMS_HPP diff --git a/include/mapnik/rule.hpp b/include/mapnik/rule.hpp index cbf6a1751..68a48c67e 100644 --- a/include/mapnik/rule.hpp +++ b/include/mapnik/rule.hpp @@ -41,9 +41,6 @@ #include // MAPNIK_DECL // boost -#include -#include -#include #include // stl diff --git a/include/mapnik/sql_utils.hpp b/include/mapnik/sql_utils.hpp index 300f3de07..419c35150 100644 --- a/include/mapnik/sql_utils.hpp +++ b/include/mapnik/sql_utils.hpp @@ -23,37 +23,36 @@ #ifndef MAPNIK_SQL_UTILS_HPP #define MAPNIK_SQL_UTILS_HPP +// mapnik +#include // for trim + // boost -#include -#include +#include "boost/algorithm/string/replace.hpp" // for ireplace_all, etc + +// stl +#include +#include +#include namespace mapnik { namespace sql_utils { inline std::string unquote_double(std::string const& sql) { std::string table_name = sql; - boost::algorithm::trim_if(table_name,boost::algorithm::is_any_of("\"")); + util::unquote_double(table_name); return table_name; } inline std::string unquote(std::string const& sql) { std::string table_name = sql; - boost::algorithm::trim_if(table_name,boost::algorithm::is_any_of("\"\'")); + util::unquote(table_name); return table_name; } - inline void quote_attr(std::ostringstream& s, std::string const& field) + inline void quote_attr(std::ostringstream & s, std::string const& field) { - if (boost::algorithm::icontains(field,".")) { - std::vector parts; - boost::split(parts, field, boost::is_any_of(".")); - s << ",\"" << parts[0] << "\".\"" << parts[1] << "\""; - } - else - { - s << ",\"" + field + "\""; - } + s << ",\"" << field << "\""; } inline std::string table_from_sql(std::string const& sql) @@ -78,120 +77,6 @@ namespace mapnik { namespace sql_utils { } return table_name; } - - inline std::string numeric2string(const char* buf) - { - int16_t ndigits = int2net(buf); - int16_t weight = int2net(buf+2); - int16_t sign = int2net(buf+4); - int16_t dscale = int2net(buf+6); - - boost::scoped_array digits(new int16_t[ndigits]); - for (int n=0; n < ndigits ;++n) - { - digits[n] = int2net(buf+8+n*2); - } - - std::ostringstream ss; - - if (sign == 0x4000) ss << "-"; - - int i = std::max(weight,int16_t(0)); - int d = 0; - - // Each numeric "digit" is actually a value between 0000 and 9999 stored in a 16 bit field. - // For example, the number 1234567809990001 is stored as four digits: [1234] [5678] [999] [1]. - // Note that the last two digits show that the leading 0's are lost when the number is split. - // We must be careful to re-insert these 0's when building the string. - - while ( i >= 0) - { - if (i <= weight && d < ndigits) - { - // All digits after the first must be padded to make the field 4 characters long - if (d != 0) - { -#ifdef _WINDOWS - int dig = digits[d]; - if (dig < 10) - { - ss << "000"; // 0000 - 0009 - } - else if (dig < 100) - { - ss << "00"; // 0010 - 0099 - } - else - { - ss << "0"; // 0100 - 0999; - } -#else - switch(digits[d]) - { - case 0 ... 9: - ss << "000"; // 0000 - 0009 - break; - case 10 ... 99: - ss << "00"; // 0010 - 0099 - break; - case 100 ... 999: - ss << "0"; // 0100 - 0999 - break; - } -#endif - } - ss << digits[d++]; - } - else - { - if (d == 0) - ss << "0"; - else - ss << "0000"; - } - - i--; - } - if (dscale > 0) - { - ss << '.'; - // dscale counts the number of decimal digits following the point, not the numeric digits - while (dscale > 0) - { - int value; - if (i <= weight && d < ndigits) - value = digits[d++]; - else - value = 0; - - // Output up to 4 decimal digits for this value - if (dscale > 0) { - ss << (value / 1000); - value %= 1000; - dscale--; - } - if (dscale > 0) { - ss << (value / 100); - value %= 100; - dscale--; - } - if (dscale > 0) { - ss << (value / 10); - value %= 10; - dscale--; - } - if (dscale > 0) { - ss << value; - dscale--; - } - - i--; - } - } - return ss.str(); - } - } - -} +}} #endif // MAPNIK_SQL_UTILS_HPP diff --git a/include/mapnik/svg/output/svg_renderer.hpp b/include/mapnik/svg/output/svg_renderer.hpp index 0461fb909..d2d82b12d 100644 --- a/include/mapnik/svg/output/svg_renderer.hpp +++ b/include/mapnik/svg/output/svg_renderer.hpp @@ -24,15 +24,37 @@ #define MAPNIK_SVG_RENDERER_HPP // mapnik +#include #include -#include +#include #include #include #include +#include // for rule, symbolizers +#include // for box2d +#include // for color +#include // for CoordTransform +#include // for composite_mode_e + +// boost +#include +#include // stl #include +namespace agg { struct trans_affine; } +namespace mapnik { class Map; } +namespace mapnik { class feature_impl; } +namespace mapnik { class feature_type_style; } +namespace mapnik { class label_collision_detector4; } +namespace mapnik { class layer; } +namespace mapnik { class marker; } +namespace mapnik { class proj_transform; } +namespace mapnik { struct grid_rasterizer; } +struct pixel_position; + + namespace mapnik { // parameterized with the type of output iterator it will use for output. diff --git a/include/mapnik/text/text_properties.hpp b/include/mapnik/text/text_properties.hpp index dd423e5b9..9ef2e1679 100644 --- a/include/mapnik/text/text_properties.hpp +++ b/include/mapnik/text/text_properties.hpp @@ -25,6 +25,7 @@ // mapnik #include #include +#include #include #include #include @@ -143,7 +144,7 @@ struct text_symbolizer_properties /** Takes a feature and produces formated text as output. * The output object has to be created by the caller and passed in for thread safety. */ - void process(text_layout &output, Feature const& feature) const; + void process(text_layout &output, feature_impl const& feature) const; /** Automatically create processing instructions for a single expression. */ void set_old_style_expression(expression_ptr expr); /** Sets new format tree. */ diff --git a/include/mapnik/transform_processor.hpp b/include/mapnik/transform_processor.hpp index 307ec1b3a..0cf603010 100644 --- a/include/mapnik/transform_processor.hpp +++ b/include/mapnik/transform_processor.hpp @@ -25,7 +25,9 @@ // mapnik #include +#ifdef MAPNIK_LOG #include +#endif #include #include #include @@ -225,7 +227,7 @@ struct transform_processor } }; -typedef mapnik::transform_processor transform_processor_type; +typedef mapnik::transform_processor transform_processor_type; } // namespace mapnik diff --git a/include/mapnik/util/container_adapter.hpp b/include/mapnik/util/container_adapter.hpp index ae985a837..a931b17fb 100644 --- a/include/mapnik/util/container_adapter.hpp +++ b/include/mapnik/util/container_adapter.hpp @@ -24,13 +24,11 @@ #define CONTAINER_ADAPTER_HPP // mapnik -#include #include #include // boost -#include -#include +#include namespace boost { namespace spirit { namespace traits { diff --git a/include/mapnik/util/trim.hpp b/include/mapnik/util/trim.hpp index 4803f2f31..48ec7e018 100644 --- a/include/mapnik/util/trim.hpp +++ b/include/mapnik/util/trim.hpp @@ -68,6 +68,29 @@ static inline std::string trim_copy(std::string s) return ltrim(rtrim(s)); } +static inline bool not_double_quote(int ch) +{ + if (ch == '"') return false; + return true; +} + +static inline void unquote_double(std::string & s) +{ + s.erase(s.begin(), std::find_if(s.begin(), s.end(), not_double_quote)); + s.erase(std::find_if(s.rbegin(), s.rend(), not_double_quote).base(), s.end()); +} + +static inline bool not_quoted(int ch) +{ + if (ch == '"' || ch == '\'') return false; + return true; +} + +static inline void unquote(std::string & s) +{ + s.erase(s.begin(), std::find_if(s.begin(), s.end(), not_quoted)); + s.erase(std::find_if(s.rbegin(), s.rend(), not_quoted).base(), s.end()); +} }} // end of namespace mapnik diff --git a/include/mapnik/value.hpp b/include/mapnik/value.hpp index e6ab8e87b..69f6c3b63 100644 --- a/include/mapnik/value.hpp +++ b/include/mapnik/value.hpp @@ -24,6 +24,7 @@ #define MAPNIK_VALUE_HPP // mapnik +#include #include #include #include @@ -69,54 +70,6 @@ inline void to_utf8(UnicodeString const& input, std::string & target) } } -struct value_null -{ - template - value_null operator+ (T const& other) const - { - boost::ignore_unused_variable_warning(other); - return *this; - } - - template - value_null operator- (T const& other) const - { - boost::ignore_unused_variable_warning(other); - return *this; - } - - template - value_null operator* (T const& other) const - { - boost::ignore_unused_variable_warning(other); - return *this; - } - - template - value_null operator/ (T const& other) const - { - boost::ignore_unused_variable_warning(other); - return *this; - } - - template - value_null operator% (T const& other) const - { - boost::ignore_unused_variable_warning(other); - return *this; - } -}; - -#ifdef BIGINT -typedef long long value_integer; -#else -typedef int value_integer; -#endif - -typedef double value_double; -typedef UnicodeString value_unicode_string; -typedef bool value_bool; - typedef boost::variant value_base; namespace impl { @@ -798,11 +751,7 @@ struct to_int : public boost::static_visitor value_integer operator() (std::string const& val) const { value_integer result; -#ifdef BIGINT - if (util::string2longlong(val,result)) -#else if (util::string2int(val,result)) -#endif return result; return value_integer(0); } @@ -912,7 +861,6 @@ public: { return boost::apply_visitor(impl::to_int(),base_); } - }; inline const value operator+(value const& p1,value const& p2) diff --git a/include/mapnik/value_types.hpp b/include/mapnik/value_types.hpp new file mode 100644 index 000000000..7a73a8721 --- /dev/null +++ b/include/mapnik/value_types.hpp @@ -0,0 +1,88 @@ +/***************************************************************************** + * + * This file is part of Mapnik (c++ mapping toolkit) + * + * Copyright (C) 2012 Artem Pavlenko + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + *****************************************************************************/ + +#ifndef MAPNIK_VALUE_TYPES_HPP +#define MAPNIK_VALUE_TYPES_HPP + +// icu +#include // for UnicodeString + +// boost +//#include + +// stl +#include // for ostream + +namespace mapnik { + +#ifdef BIGINT +//typedef boost::long_long_type value_integer; +typedef long long value_integer; +#else +typedef int value_integer; +#endif + +typedef double value_double; +typedef UnicodeString value_unicode_string; +typedef bool value_bool; + +struct value_null +{ + template + value_null operator+ (T const& /*other*/) const + { + return *this; + } + + template + value_null operator- (T const& /*other*/) const + { + return *this; + } + + template + value_null operator* (T const& /*other*/) const + { + return *this; + } + + template + value_null operator/ (T const& /*other*/) const + { + return *this; + } + + template + value_null operator% (T const& /*other*/) const + { + return *this; + } +}; + +inline std::ostream& operator<< (std::ostream & out,value_null const& v) +{ + return out; +} + +} // namespace mapnik + +#endif // MAPNIK_VALUE_TYPES_HPP diff --git a/include/mapnik/xml_tree.hpp b/include/mapnik/xml_tree.hpp index c941383ea..966e034b0 100644 --- a/include/mapnik/xml_tree.hpp +++ b/include/mapnik/xml_tree.hpp @@ -31,6 +31,7 @@ #include #include #include +#include // boost #include diff --git a/plugins/input/csv/csv_datasource.cpp b/plugins/input/csv/csv_datasource.cpp index e23b19d74..6e799d638 100644 --- a/plugins/input/csv/csv_datasource.cpp +++ b/plugins/input/csv/csv_datasource.cpp @@ -41,6 +41,7 @@ #include #include #include +#include // stl #include @@ -62,7 +63,7 @@ csv_datasource::csv_datasource(parameters const& params) filename_(), inline_string_(), file_length_(0), - row_limit_(*params.get("row_limit", 0)), + row_limit_(*params.get("row_limit", 0)), features_(), escape_(*params.get("escape", "")), separator_(*params.get("separator", "")), @@ -70,7 +71,7 @@ csv_datasource::csv_datasource(parameters const& params) headers_(), manual_headers_(mapnik::util::trim_copy(*params.get("headers", ""))), strict_(*params.get("strict", false)), - filesize_max_(*params.get("filesize_max", 20.0)), // MB + filesize_max_(*params.get("filesize_max", 20.0)), // MB ctx_(boost::make_shared()) { /* TODO: @@ -701,7 +702,7 @@ void csv_datasource::parse_csv(T & stream, else { mapnik::value_integer int_val = 0; - if (mapnik::util::string2longlong(value,int_val)) + if (mapnik::util::string2int(value,int_val)) { matched = true; feature->put(fld_name,int_val); diff --git a/plugins/input/csv/csv_datasource.hpp b/plugins/input/csv/csv_datasource.hpp index b29632fc3..c01caefe8 100644 --- a/plugins/input/csv/csv_datasource.hpp +++ b/plugins/input/csv/csv_datasource.hpp @@ -31,6 +31,7 @@ #include #include #include +#include // boost #include @@ -64,7 +65,7 @@ private: std::string filename_; std::string inline_string_; unsigned file_length_; - int row_limit_; + mapnik::value_integer row_limit_; std::vector features_; std::string escape_; std::string separator_; diff --git a/plugins/input/gdal/gdal_datasource.cpp b/plugins/input/gdal/gdal_datasource.cpp index 69d49a229..82c2e6489 100644 --- a/plugins/input/gdal/gdal_datasource.cpp +++ b/plugins/input/gdal/gdal_datasource.cpp @@ -28,6 +28,7 @@ #include #include #include +#include #include diff --git a/plugins/input/gdal/gdal_featureset.cpp b/plugins/input/gdal/gdal_featureset.cpp index a649435ca..3e04e5eb1 100644 --- a/plugins/input/gdal/gdal_featureset.cpp +++ b/plugins/input/gdal/gdal_featureset.cpp @@ -23,11 +23,15 @@ // mapnik #include #include +#include +#include #include +#include #include // boost #include +#include #include "gdal_featureset.hpp" #include @@ -35,7 +39,6 @@ using mapnik::query; using mapnik::coord2d; using mapnik::box2d; -using mapnik::Feature; using mapnik::feature_ptr; using mapnik::CoordTransform; using mapnik::geometry_type; diff --git a/plugins/input/gdal/gdal_featureset.hpp b/plugins/input/gdal/gdal_featureset.hpp index 129f9132b..cb6c0b0ff 100644 --- a/plugins/input/gdal/gdal_featureset.hpp +++ b/plugins/input/gdal/gdal_featureset.hpp @@ -25,7 +25,6 @@ // mapnik #include -#include // boost #include diff --git a/plugins/input/geojson/geojson_datasource.cpp b/plugins/input/geojson/geojson_datasource.cpp index 0e32fb585..153597cda 100644 --- a/plugins/input/geojson/geojson_datasource.cpp +++ b/plugins/input/geojson/geojson_datasource.cpp @@ -36,7 +36,11 @@ #include #include #include + // mapnik +#include +#include +#include #include #include #include diff --git a/plugins/input/geojson/geojson_datasource.hpp b/plugins/input/geojson/geojson_datasource.hpp index c953fcae9..7cad44b08 100644 --- a/plugins/input/geojson/geojson_datasource.hpp +++ b/plugins/input/geojson/geojson_datasource.hpp @@ -31,6 +31,7 @@ #include #include #include +#include // boost #include diff --git a/plugins/input/geojson/geojson_featureset.hpp b/plugins/input/geojson/geojson_featureset.hpp index d10919ef8..f8b37d66d 100644 --- a/plugins/input/geojson/geojson_featureset.hpp +++ b/plugins/input/geojson/geojson_featureset.hpp @@ -1,7 +1,7 @@ #ifndef GEOJSON_FEATURESET_HPP #define GEOJSON_FEATURESET_HPP -#include +#include #include "geojson_datasource.hpp" #include diff --git a/plugins/input/geos/geos_datasource.cpp b/plugins/input/geos/geos_datasource.cpp index 9e44d7e7d..b26048759 100644 --- a/plugins/input/geos/geos_datasource.cpp +++ b/plugins/input/geos/geos_datasource.cpp @@ -34,6 +34,7 @@ #include #include #include +#include // boost #include diff --git a/plugins/input/geos/geos_featureset.cpp b/plugins/input/geos/geos_featureset.cpp index 78f85234c..339cb46a5 100644 --- a/plugins/input/geos/geos_featureset.cpp +++ b/plugins/input/geos/geos_featureset.cpp @@ -23,7 +23,6 @@ // mapnik #include #include -#include #include #include #include @@ -34,9 +33,11 @@ #include "geos_featureset.hpp" +// boost +#include + using mapnik::query; using mapnik::box2d; -using mapnik::Feature; using mapnik::feature_ptr; using mapnik::geometry_utils; using mapnik::transcoder; diff --git a/plugins/input/geos/geos_featureset.hpp b/plugins/input/geos/geos_featureset.hpp index 3a9ccd97d..3180449ed 100644 --- a/plugins/input/geos/geos_featureset.hpp +++ b/plugins/input/geos/geos_featureset.hpp @@ -24,6 +24,7 @@ #define GEOS_FEATURESET_HPP // mapnik +#include #include #include #include diff --git a/plugins/input/kismet/kismet_datasource.cpp b/plugins/input/kismet/kismet_datasource.cpp index 209bd9a20..96348e151 100644 --- a/plugins/input/kismet/kismet_datasource.cpp +++ b/plugins/input/kismet/kismet_datasource.cpp @@ -85,10 +85,10 @@ kismet_datasource::kismet_datasource(parameters const& params) throw datasource_exception("Kismet Plugin: missing parameter"); } - boost::optional port = params.get("port", 2501); + boost::optional port = params.get("port", 2501); if (port) { - port_ = *port; + port_ = static_cast(*port); } boost::optional srs = params.get("srs"); diff --git a/plugins/input/kismet/kismet_featureset.cpp b/plugins/input/kismet/kismet_featureset.cpp index 5a1642b64..edd4ec95c 100644 --- a/plugins/input/kismet/kismet_featureset.cpp +++ b/plugins/input/kismet/kismet_featureset.cpp @@ -22,7 +22,6 @@ // mapnik #include -#include #include #include #include @@ -33,7 +32,9 @@ #include "kismet_featureset.hpp" -using mapnik::Feature; +// boost +#include + using mapnik::feature_ptr; using mapnik::geometry_type; using mapnik::geometry_utils; diff --git a/plugins/input/kismet/kismet_featureset.hpp b/plugins/input/kismet/kismet_featureset.hpp index 2be6c2e40..91e6afef7 100644 --- a/plugins/input/kismet/kismet_featureset.hpp +++ b/plugins/input/kismet/kismet_featureset.hpp @@ -24,6 +24,7 @@ #define KISMET_FEATURESET_HPP // mapnik +#include #include #include #include diff --git a/plugins/input/kismet/kismet_types.hpp b/plugins/input/kismet/kismet_types.hpp index 8e3829e8b..ea9ff856a 100644 --- a/plugins/input/kismet/kismet_types.hpp +++ b/plugins/input/kismet/kismet_types.hpp @@ -24,7 +24,6 @@ #define KISMET_TYPES_HPP // mapnik -#include #include // boost diff --git a/plugins/input/occi/occi_datasource.cpp b/plugins/input/occi/occi_datasource.cpp index 93d01c725..72da797c0 100644 --- a/plugins/input/occi/occi_datasource.cpp +++ b/plugins/input/occi/occi_datasource.cpp @@ -28,6 +28,7 @@ #include #include #include +#include // boost #include @@ -77,7 +78,7 @@ occi_datasource::occi_datasource(parameters const& params) extent_initialized_(false), desc_(*params.get("type"), *params.get("encoding", "utf-8")), use_wkb_(*params.get("use_wkb", false)), - row_limit_(*params.get("row_limit", 0)), + row_limit_(*params.get("row_limit", 0)), row_prefetch_(*params.get("row_prefetch", 100)), pool_(0), conn_(0) diff --git a/plugins/input/occi/occi_datasource.hpp b/plugins/input/occi/occi_datasource.hpp index 5a191449e..92b1c8c08 100644 --- a/plugins/input/occi/occi_datasource.hpp +++ b/plugins/input/occi/occi_datasource.hpp @@ -31,6 +31,7 @@ #include #include #include +#include // boost #include @@ -70,7 +71,7 @@ private: mutable mapnik::box2d extent_; mapnik::layer_descriptor desc_; bool use_wkb_; - int row_limit_; + mapnik::value_integer row_limit_; int row_prefetch_; oracle::occi::StatelessConnectionPool* pool_; oracle::occi::Connection* conn_; diff --git a/plugins/input/occi/occi_featureset.cpp b/plugins/input/occi/occi_featureset.cpp index b00eae9a2..81f14dc44 100644 --- a/plugins/input/occi/occi_featureset.cpp +++ b/plugins/input/occi/occi_featureset.cpp @@ -23,7 +23,6 @@ // mapnik #include #include -#include #include #include #include @@ -37,7 +36,6 @@ using mapnik::query; using mapnik::box2d; -using mapnik::Feature; using mapnik::feature_ptr; using mapnik::geometry_type; using mapnik::geometry_utils; diff --git a/plugins/input/occi/occi_featureset.hpp b/plugins/input/occi/occi_featureset.hpp index 42710b80f..cb4e7cb9e 100644 --- a/plugins/input/occi/occi_featureset.hpp +++ b/plugins/input/occi/occi_featureset.hpp @@ -24,6 +24,7 @@ #define OCCI_FEATURESET_HPP // mapnik +#include #include #include #include diff --git a/plugins/input/ogr/ogr_datasource.cpp b/plugins/input/ogr/ogr_datasource.cpp index 6a1561211..d52ae60f4 100644 --- a/plugins/input/ogr/ogr_datasource.cpp +++ b/plugins/input/ogr/ogr_datasource.cpp @@ -139,7 +139,7 @@ void ogr_datasource::init(mapnik::parameters const& params) // initialize layer boost::optional layer_by_name = params.get("layer"); - boost::optional layer_by_index = params.get("layer_by_index"); + boost::optional layer_by_index = params.get("layer_by_index"); boost::optional layer_by_sql = params.get("layer_by_sql"); int passed_parameters = 0; diff --git a/plugins/input/ogr/ogr_featureset.cpp b/plugins/input/ogr/ogr_featureset.cpp index 202fe78e6..b2cd7ba56 100644 --- a/plugins/input/ogr/ogr_featureset.cpp +++ b/plugins/input/ogr/ogr_featureset.cpp @@ -22,8 +22,8 @@ // mapnik #include +#include #include -#include #include #include #include @@ -38,7 +38,6 @@ using mapnik::query; using mapnik::box2d; -using mapnik::Feature; using mapnik::feature_ptr; using mapnik::geometry_utils; using mapnik::transcoder; diff --git a/plugins/input/ogr/ogr_featureset.hpp b/plugins/input/ogr/ogr_featureset.hpp index fdeb20c29..29f707f7f 100644 --- a/plugins/input/ogr/ogr_featureset.hpp +++ b/plugins/input/ogr/ogr_featureset.hpp @@ -24,6 +24,7 @@ #define OGR_FEATURESET_HPP // mapnik +#include #include #include #include diff --git a/plugins/input/ogr/ogr_index_featureset.cpp b/plugins/input/ogr/ogr_index_featureset.cpp index e74aec06b..9fa9d75e7 100644 --- a/plugins/input/ogr/ogr_index_featureset.cpp +++ b/plugins/input/ogr/ogr_index_featureset.cpp @@ -21,9 +21,9 @@ *****************************************************************************/ // mapnik +#include #include #include -#include #include #include #include @@ -43,7 +43,6 @@ using mapnik::query; using mapnik::box2d; -using mapnik::Feature; using mapnik::feature_ptr; using mapnik::geometry_utils; using mapnik::transcoder; diff --git a/plugins/input/ogr/ogr_index_featureset.hpp b/plugins/input/ogr/ogr_index_featureset.hpp index a285ad3b9..5e4c6cbc5 100644 --- a/plugins/input/ogr/ogr_index_featureset.hpp +++ b/plugins/input/ogr/ogr_index_featureset.hpp @@ -26,6 +26,7 @@ #include #include #include +#include #include "ogr_featureset.hpp" template diff --git a/plugins/input/osm/osm_featureset.cpp b/plugins/input/osm/osm_featureset.cpp index d2f06001a..e72c597ff 100644 --- a/plugins/input/osm/osm_featureset.cpp +++ b/plugins/input/osm/osm_featureset.cpp @@ -23,12 +23,16 @@ // mapnik #include +#include #include #include +#include + +// boost +#include #include "osm_featureset.hpp" -using mapnik::Feature; using mapnik::feature_ptr; using mapnik::geometry_type; using mapnik::feature_factory; diff --git a/plugins/input/postgis/postgis_datasource.cpp b/plugins/input/postgis/postgis_datasource.cpp index 5197fa6e6..21bf69d31 100644 --- a/plugins/input/postgis/postgis_datasource.cpp +++ b/plugins/input/postgis/postgis_datasource.cpp @@ -31,6 +31,7 @@ #include #include #include +#include // boost #include @@ -62,7 +63,7 @@ postgis_datasource::postgis_datasource(parameters const& params) geometry_table_(*params.get("geometry_table", "")), geometry_field_(*params.get("geometry_field", "")), key_field_(*params.get("key_field", "")), - cursor_fetch_size_(*params.get("cursor_size", 0)), + cursor_fetch_size_(*params.get("cursor_size", 0)), row_limit_(*params.get("row_limit", 0)), type_(datasource::Vector), srid_(*params.get("srid", 0)), diff --git a/plugins/input/postgis/postgis_datasource.hpp b/plugins/input/postgis/postgis_datasource.hpp index b61611864..d4ed1e9be 100644 --- a/plugins/input/postgis/postgis_datasource.hpp +++ b/plugins/input/postgis/postgis_datasource.hpp @@ -31,6 +31,8 @@ #include #include #include +#include +#include // boost #include @@ -72,7 +74,6 @@ private: std::string sql_bbox(box2d const& env) const; std::string populate_tokens(std::string const& sql, double scale_denom, box2d const& env, double pixel_width, double pixel_height) const; std::string populate_tokens(std::string const& sql) const; - static std::string unquote(std::string const& sql); boost::shared_ptr get_resultset(boost::shared_ptr const &conn, std::string const& sql) const; static const std::string GEOMETRY_COLUMNS; @@ -87,8 +88,8 @@ private: std::string geometry_table_; const std::string geometry_field_; std::string key_field_; - const int cursor_fetch_size_; - const int row_limit_; + mapnik::value_integer cursor_fetch_size_; + mapnik::value_integer row_limit_; std::string geometryColumn_; mapnik::datasource::datasource_t type_; int srid_; diff --git a/plugins/input/postgis/postgis_featureset.cpp b/plugins/input/postgis/postgis_featureset.cpp index 5526038b6..9ec75aa4e 100644 --- a/plugins/input/postgis/postgis_featureset.cpp +++ b/plugins/input/postgis/postgis_featureset.cpp @@ -29,13 +29,16 @@ #include #include #include -#include +#include #include #include #include +#include // for int2net +#include + // boost -#include +#include // for boost::int16_t // stl #include @@ -60,6 +63,8 @@ postgis_featureset::postgis_featureset(boost::shared_ptr const& rs, { } +std::string numeric2string(const char* buf); + feature_ptr postgis_featureset::next() { while (rs_->next()) @@ -156,7 +161,7 @@ feature_ptr postgis_featureset::next() { float val; float4net(val, buf); - feature->put(name, val); + feature->put(name, static_cast(val)); break; } @@ -186,7 +191,7 @@ feature_ptr postgis_featureset::next() case 1700: //numeric { double val; - std::string str = mapnik::sql_utils::numeric2string(buf); + std::string str = numeric2string(buf); if (mapnik::util::string2double(str, val)) { feature->put(name, val); @@ -213,3 +218,115 @@ postgis_featureset::~postgis_featureset() { rs_->close(); } + +std::string numeric2string(const char* buf) +{ + boost::int16_t ndigits = int2net(buf); + boost::int16_t weight = int2net(buf+2); + boost::int16_t sign = int2net(buf+4); + boost::int16_t dscale = int2net(buf+6); + + boost::scoped_array digits(new boost::int16_t[ndigits]); + for (int n=0; n < ndigits ;++n) + { + digits[n] = int2net(buf+8+n*2); + } + + std::ostringstream ss; + + if (sign == 0x4000) ss << "-"; + + int i = std::max(weight,boost::int16_t(0)); + int d = 0; + + // Each numeric "digit" is actually a value between 0000 and 9999 stored in a 16 bit field. + // For example, the number 1234567809990001 is stored as four digits: [1234] [5678] [999] [1]. + // Note that the last two digits show that the leading 0's are lost when the number is split. + // We must be careful to re-insert these 0's when building the string. + + while ( i >= 0) + { + if (i <= weight && d < ndigits) + { + // All digits after the first must be padded to make the field 4 characters long + if (d != 0) + { +#ifdef _WINDOWS + int dig = digits[d]; + if (dig < 10) + { + ss << "000"; // 0000 - 0009 + } + else if (dig < 100) + { + ss << "00"; // 0010 - 0099 + } + else + { + ss << "0"; // 0100 - 0999; + } +#else + switch(digits[d]) + { + case 0 ... 9: + ss << "000"; // 0000 - 0009 + break; + case 10 ... 99: + ss << "00"; // 0010 - 0099 + break; + case 100 ... 999: + ss << "0"; // 0100 - 0999 + break; + } +#endif + } + ss << digits[d++]; + } + else + { + if (d == 0) + ss << "0"; + else + ss << "0000"; + } + + i--; + } + if (dscale > 0) + { + ss << '.'; + // dscale counts the number of decimal digits following the point, not the numeric digits + while (dscale > 0) + { + int value; + if (i <= weight && d < ndigits) + value = digits[d++]; + else + value = 0; + + // Output up to 4 decimal digits for this value + if (dscale > 0) { + ss << (value / 1000); + value %= 1000; + dscale--; + } + if (dscale > 0) { + ss << (value / 100); + value %= 100; + dscale--; + } + if (dscale > 0) { + ss << (value / 10); + value %= 10; + dscale--; + } + if (dscale > 0) { + ss << value; + dscale--; + } + + i--; + } + } + return ss.str(); +} diff --git a/plugins/input/postgis/postgis_featureset.hpp b/plugins/input/postgis/postgis_featureset.hpp index 754b42388..e4ead4ab6 100644 --- a/plugins/input/postgis/postgis_featureset.hpp +++ b/plugins/input/postgis/postgis_featureset.hpp @@ -28,9 +28,9 @@ #include #include #include +#include // boost - #include using mapnik::Featureset; diff --git a/plugins/input/python/python_featureset.hpp b/plugins/input/python/python_featureset.hpp index ae7525af3..645e9f9b7 100644 --- a/plugins/input/python/python_featureset.hpp +++ b/plugins/input/python/python_featureset.hpp @@ -1,6 +1,9 @@ #ifndef PYTHON_FEATURESET_HPP #define PYTHON_FEATURESET_HPP +// mapnik +#include + // boost #include #include @@ -8,7 +11,6 @@ // mapnik #include -// extend the mapnik::Featureset defined in include/mapnik/datasource.hpp class python_featureset : public mapnik::Featureset { public: diff --git a/plugins/input/raster/raster_datasource.cpp b/plugins/input/raster/raster_datasource.cpp index 125c2eac1..110211251 100644 --- a/plugins/input/raster/raster_datasource.cpp +++ b/plugins/input/raster/raster_datasource.cpp @@ -61,9 +61,9 @@ raster_datasource::raster_datasource(parameters const& params) else filename_ = *file; - multi_tiles_ = *params.get("multi", false); - tile_size_ = *params.get("tile_size", 256); - tile_stride_ = *params.get("tile_stride", 1); + multi_tiles_ = *params.get("multi", false); + tile_size_ = *params.get("tile_size", 256); + tile_stride_ = *params.get("tile_stride", 1); format_ = *params.get("format","tiff"); @@ -91,8 +91,8 @@ raster_datasource::raster_datasource(parameters const& params) if (multi_tiles_) { - boost::optional x_width = params.get("x_width"); - boost::optional y_width = params.get("y_width"); + boost::optional x_width = params.get("x_width"); + boost::optional y_width = params.get("y_width"); if (! x_width) { diff --git a/plugins/input/raster/raster_featureset.cpp b/plugins/input/raster/raster_featureset.cpp index ea4942bd8..a9460ed62 100644 --- a/plugins/input/raster/raster_featureset.cpp +++ b/plugins/input/raster/raster_featureset.cpp @@ -22,6 +22,8 @@ // mapnik #include +#include +#include #include #include #include @@ -29,12 +31,12 @@ // boost #include +#include #include "raster_featureset.hpp" using mapnik::query; using mapnik::image_reader; -using mapnik::Feature; using mapnik::feature_ptr; using mapnik::image_data_32; using mapnik::raster; diff --git a/plugins/input/raster/raster_featureset.hpp b/plugins/input/raster/raster_featureset.hpp index d4db2e3c6..5085d3199 100644 --- a/plugins/input/raster/raster_featureset.hpp +++ b/plugins/input/raster/raster_featureset.hpp @@ -27,6 +27,7 @@ #include "raster_info.hpp" // mapnik +#include #include // stl diff --git a/plugins/input/rasterlite/rasterlite_featureset.cpp b/plugins/input/rasterlite/rasterlite_featureset.cpp index 46817784a..93327764e 100644 --- a/plugins/input/rasterlite/rasterlite_featureset.cpp +++ b/plugins/input/rasterlite/rasterlite_featureset.cpp @@ -25,6 +25,7 @@ // mapnik #include #include +#include #include // boost @@ -34,7 +35,6 @@ using mapnik::query; using mapnik::coord2d; using mapnik::box2d; -using mapnik::Feature; using mapnik::feature_ptr; using mapnik::geometry_type; using mapnik::query; diff --git a/plugins/input/rasterlite/rasterlite_featureset.hpp b/plugins/input/rasterlite/rasterlite_featureset.hpp index d033e478d..ce6677582 100644 --- a/plugins/input/rasterlite/rasterlite_featureset.hpp +++ b/plugins/input/rasterlite/rasterlite_featureset.hpp @@ -24,7 +24,7 @@ #define RASTERLITE_FEATURESET_HPP // mapnik -#include +#include // boost #include diff --git a/plugins/input/shape/dbfile.cpp b/plugins/input/shape/dbfile.cpp index ff8a0d14e..ee7578f33 100644 --- a/plugins/input/shape/dbfile.cpp +++ b/plugins/input/shape/dbfile.cpp @@ -20,6 +20,7 @@ * *****************************************************************************/ // mapnik +#include #include #include #include @@ -124,7 +125,7 @@ const field_descriptor& dbf_file::descriptor(int col) const } -void dbf_file::add_attribute(int col, mapnik::transcoder const& tr, Feature & f) const throw() +void dbf_file::add_attribute(int col, mapnik::transcoder const& tr, mapnik::feature_impl & f) const throw() { using namespace boost::spirit; diff --git a/plugins/input/shape/dbfile.hpp b/plugins/input/shape/dbfile.hpp index 423409e3e..b4a0a9bbe 100644 --- a/plugins/input/shape/dbfile.hpp +++ b/plugins/input/shape/dbfile.hpp @@ -26,6 +26,7 @@ // mapnik #include #include +#include // boost #include @@ -36,9 +37,6 @@ #include #include -using mapnik::transcoder; -using mapnik::Feature; - struct field_descriptor { int index_; @@ -73,7 +71,7 @@ public: field_descriptor const& descriptor(int col) const; void move_to(int index); std::string string_value(int col) const; - void add_attribute(int col, transcoder const& tr, Feature & f) const throw(); + void add_attribute(int col, mapnik::transcoder const& tr, mapnik::feature_impl & f) const throw(); private: void read_header(); int read_short(); diff --git a/plugins/input/shape/shape_datasource.cpp b/plugins/input/shape/shape_datasource.cpp index a42aa94ab..f62e26ac4 100644 --- a/plugins/input/shape/shape_datasource.cpp +++ b/plugins/input/shape/shape_datasource.cpp @@ -35,10 +35,10 @@ #include #include #include -#include #include #include #include +#include // stl #include @@ -60,7 +60,7 @@ shape_datasource::shape_datasource(const parameters ¶ms) type_(datasource::Vector), file_length_(0), indexed_(false), - row_limit_(*params.get("row_limit",0)), + row_limit_(*params.get("row_limit",0)), desc_(*params.get("type"), *params.get("encoding","utf-8")) { #ifdef MAPNIK_STATS diff --git a/plugins/input/shape/shape_datasource.hpp b/plugins/input/shape/shape_datasource.hpp index f194572b8..43d2572e9 100644 --- a/plugins/input/shape/shape_datasource.hpp +++ b/plugins/input/shape/shape_datasource.hpp @@ -31,6 +31,7 @@ #include #include #include +#include // boost #include diff --git a/plugins/input/shape/shape_featureset.cpp b/plugins/input/shape/shape_featureset.cpp index 0ccf8aef6..4550d832b 100644 --- a/plugins/input/shape/shape_featureset.cpp +++ b/plugins/input/shape/shape_featureset.cpp @@ -26,6 +26,10 @@ // mapnik #include #include +#include + +// boost +#include #include "shape_featureset.hpp" #include "shape_utils.hpp" diff --git a/plugins/input/shape/shape_featureset.hpp b/plugins/input/shape/shape_featureset.hpp index 9a140e099..bb362de13 100644 --- a/plugins/input/shape/shape_featureset.hpp +++ b/plugins/input/shape/shape_featureset.hpp @@ -25,7 +25,9 @@ //mapnik #include -#include +#include +#include +#include #include "shape_io.hpp" @@ -60,7 +62,7 @@ private: boost::scoped_ptr tr_; long file_length_; std::vector attr_ids_; - const int row_limit_; + mapnik::value_integer row_limit_; mutable int count_; context_ptr ctx_; }; diff --git a/plugins/input/shape/shape_index_featureset.cpp b/plugins/input/shape/shape_index_featureset.cpp index 39aef2469..d7b2f2d5b 100644 --- a/plugins/input/shape/shape_index_featureset.cpp +++ b/plugins/input/shape/shape_index_featureset.cpp @@ -30,6 +30,7 @@ // boost #include #include +#include #include "shape_index_featureset.hpp" #include "shape_utils.hpp" @@ -47,7 +48,7 @@ shape_index_featureset::shape_index_featureset(filterT const& filter, : filter_(filter), ctx_(boost::make_shared()), shape_(shape), - tr_(new transcoder(encoding)), + tr_(new mapnik::transcoder(encoding)), row_limit_(row_limit), count_(0), feature_bbox_() diff --git a/plugins/input/shape/shape_index_featureset.hpp b/plugins/input/shape/shape_index_featureset.hpp index 9aeb0b0de..1f8a81944 100644 --- a/plugins/input/shape/shape_index_featureset.hpp +++ b/plugins/input/shape/shape_index_featureset.hpp @@ -29,6 +29,9 @@ // mapnik #include +#include +#include +#include // boost #include @@ -59,11 +62,11 @@ private: filterT filter_; context_ptr ctx_; shape_io & shape_; - boost::scoped_ptr tr_; + boost::scoped_ptr tr_; std::vector offsets_; std::vector::iterator itr_; std::vector attr_ids_; - const int row_limit_; + mapnik::value_integer row_limit_; mutable int count_; mutable box2d feature_bbox_; }; diff --git a/plugins/input/sqlite/sqlite_connection.hpp b/plugins/input/sqlite/sqlite_connection.hpp index 11a8dc2f9..7518f816b 100644 --- a/plugins/input/sqlite/sqlite_connection.hpp +++ b/plugins/input/sqlite/sqlite_connection.hpp @@ -29,7 +29,6 @@ // mapnik #include #include -#include #include // boost diff --git a/plugins/input/sqlite/sqlite_datasource.cpp b/plugins/input/sqlite/sqlite_datasource.cpp index e6da0a1e9..3814622f8 100644 --- a/plugins/input/sqlite/sqlite_datasource.cpp +++ b/plugins/input/sqlite/sqlite_datasource.cpp @@ -65,8 +65,8 @@ sqlite_datasource::sqlite_datasource(parameters const& params) geometry_field_(*params.get("geometry_field", "")), index_table_(*params.get("index_table", "")), key_field_(*params.get("key_field", "")), - row_offset_(*params.get("row_offset", 0)), - row_limit_(*params.get("row_limit", 0)), + 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) @@ -142,7 +142,7 @@ sqlite_datasource::sqlite_datasource(parameters const& params) // now actually create the connection and start executing setup sql dataset_ = boost::make_shared(dataset_name_); - boost::optional table_by_index = params.get("table_by_index"); + boost::optional table_by_index = params.get("table_by_index"); int passed_parameters = 0; passed_parameters += params.get("table") ? 1 : 0; diff --git a/plugins/input/sqlite/sqlite_datasource.hpp b/plugins/input/sqlite/sqlite_datasource.hpp index 868fa8e14..5d504ceaf 100644 --- a/plugins/input/sqlite/sqlite_datasource.hpp +++ b/plugins/input/sqlite/sqlite_datasource.hpp @@ -32,6 +32,7 @@ #include #include #include +#include // boost #include @@ -77,7 +78,7 @@ private: std::string index_table_; std::string key_field_; int row_offset_; - int row_limit_; + mapnik::value_integer row_limit_; // TODO - also add to postgis.input const std::string intersects_token_; mapnik::layer_descriptor desc_; diff --git a/plugins/input/sqlite/sqlite_featureset.cpp b/plugins/input/sqlite/sqlite_featureset.cpp index 4fd8729b2..e5860b677 100644 --- a/plugins/input/sqlite/sqlite_featureset.cpp +++ b/plugins/input/sqlite/sqlite_featureset.cpp @@ -23,7 +23,6 @@ // mapnik #include #include -#include #include #include #include @@ -38,7 +37,6 @@ using mapnik::query; using mapnik::box2d; -using mapnik::Feature; using mapnik::feature_ptr; using mapnik::geometry_utils; using mapnik::transcoder; diff --git a/plugins/input/sqlite/sqlite_featureset.hpp b/plugins/input/sqlite/sqlite_featureset.hpp index c0dbb7cd0..9fc5356a7 100644 --- a/plugins/input/sqlite/sqlite_featureset.hpp +++ b/plugins/input/sqlite/sqlite_featureset.hpp @@ -24,7 +24,7 @@ #define MAPNIK_SQLITE_FEATURESET_HPP // mapnik -#include +#include #include #include diff --git a/plugins/input/sqlite/sqlite_utils.hpp b/plugins/input/sqlite/sqlite_utils.hpp index 5463dac2c..6caee666c 100644 --- a/plugins/input/sqlite/sqlite_utils.hpp +++ b/plugins/input/sqlite/sqlite_utils.hpp @@ -644,7 +644,6 @@ public: std::string fld_type(rs->column_text(2)); sqlite_int64 fld_pk = rs->column_integer64(5); std::transform(fld_type.begin(), fld_type.end(), fld_type.begin(), ::tolower); - // TODO - how to handle primary keys on multiple columns ? if (key_field.empty() && ! found_pk && fld_pk != 0) { diff --git a/plugins/input/templates/helloworld/hello_featureset.cpp b/plugins/input/templates/helloworld/hello_featureset.cpp index b24d4d37e..c98b0e461 100644 --- a/plugins/input/templates/helloworld/hello_featureset.cpp +++ b/plugins/input/templates/helloworld/hello_featureset.cpp @@ -2,6 +2,9 @@ #include #include +// boost +#include + #include "hello_featureset.hpp" hello_featureset::hello_featureset(mapnik::box2d const& box, std::string const& encoding) diff --git a/plugins/input/templates/helloworld/hello_featureset.hpp b/plugins/input/templates/helloworld/hello_featureset.hpp index 65d4643d2..b73f15070 100644 --- a/plugins/input/templates/helloworld/hello_featureset.hpp +++ b/plugins/input/templates/helloworld/hello_featureset.hpp @@ -3,11 +3,12 @@ // mapnik #include +#include +#include // boost #include // needed for wrapping the transcoder -// extend the mapnik::Featureset defined in include/mapnik/datasource.hpp class hello_featureset : public mapnik::Featureset { public: diff --git a/src/build.py b/src/build.py index f733eb618..2998d6aa9 100644 --- a/src/build.py +++ b/src/build.py @@ -100,6 +100,7 @@ else: # unix, non-macos source = Split( """ + params.cpp image_filter_types.cpp miniz_png.cpp color.cpp diff --git a/src/params.cpp b/src/params.cpp new file mode 100644 index 000000000..ab744a08a --- /dev/null +++ b/src/params.cpp @@ -0,0 +1,109 @@ +/***************************************************************************** + * + * This file is part of Mapnik (c++ mapping toolkit) + * + * Copyright (C) 2012 Artem Pavlenko + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + *****************************************************************************/ + +// mapnik +#include +#include +#include + +// boost +#include +#include +#include +#include +#include + +namespace mapnik { + +namespace params_detail { + + // TODO - rewrite to avoid usage of lexical_cast + template + struct value_extractor_visitor : public boost::static_visitor<> + { + value_extractor_visitor(boost::optional & var) + :var_(var) {} + + void operator () (T val) const + { + var_ = val; + } + + template + void operator () (T1 val) const + { + try + { + var_ = boost::lexical_cast(val); + } + catch (boost::bad_lexical_cast & ) {} + } + + boost::optional & var_; + }; + + template + struct converter + { + typedef boost::optional return_type; + static return_type extract(parameters const& params, + std::string const& name, + boost::optional const& default_opt_value) + { + boost::optional result(default_opt_value); + parameters::const_iterator itr = params.find(name); + if (itr != params.end()) + { + boost::apply_visitor(value_extractor_visitor(result),itr->second); + } + return result; + } + }; +} // end namespace params_detail + +// parameters + +parameters::parameters() {} + +template +boost::optional parameters::get(std::string const& key) const +{ + return params_detail::converter::extract(*this,key, boost::none); +} + +template +boost::optional parameters::get(std::string const& key, T const& default_opt_value) const +{ + return params_detail::converter::extract(*this,key,boost::optional(default_opt_value)); +} + +#define compile_params_get(T) template boost::optional parameters::get(std::string const& key) const; template boost::optional parameters::get(std::string const& key, T const& default_opt_value) const + +compile_params_get(std::string); +compile_params_get(value_double); +compile_params_get(int); +#ifdef BIGINT +compile_params_get(value_integer); +#endif +compile_params_get(mapnik::boolean); + +}