diff --git a/src/box2d.cpp b/src/box2d.cpp index c6061dc06..68cda38c3 100644 --- a/src/box2d.cpp +++ b/src/box2d.cpp @@ -21,6 +21,7 @@ *****************************************************************************/ //$Id: envelope.cpp 17 2005-03-08 23:58:43Z pavlenko $ +// mapnik #include // stl @@ -28,8 +29,8 @@ // boost #include -#include #include +#include namespace mapnik { @@ -332,31 +333,31 @@ inline #endif bool box2d::from_string(const std::string& s) { - bool success = false; - - boost::char_separator sep(", "); - boost::tokenizer > tok(s, sep); - unsigned i = 0; double d[4]; + bool success = false; + boost::char_separator sep(", "); + boost::tokenizer > tok(s, sep); for (boost::tokenizer >::iterator beg = tok.begin(); beg != tok.end(); ++beg) { - try - { - d[i] = boost::lexical_cast(boost::trim_copy(*beg)); - } - catch (boost::bad_lexical_cast & ex) + std::string item(*beg); + boost::trim(item); + // note: we intentionally do not use mapnik::util::conversions::string2double + // here to ensure that shapeindex can statically compile mapnik::box2d without + // needing to link to libmapnik + std::string::const_iterator str_beg = item.begin(); + std::string::const_iterator str_end = item.end(); + bool r = boost::spirit::qi::phrase_parse(str_beg,str_end,boost::spirit::qi::double_,boost::spirit::ascii::space,d[i]); + if (!(r && (str_beg == str_end))) { break; } - if (i == 3) { success = true; break; } - ++i; } diff --git a/src/load_map.cpp b/src/load_map.cpp index 68239b48a..901098411 100644 --- a/src/load_map.cpp +++ b/src/load_map.cpp @@ -50,12 +50,12 @@ #include #include #include +#include // boost #include #include #include -#include #include #include #include @@ -69,8 +69,6 @@ #include #include -using boost::lexical_cast; -using boost::bad_lexical_cast; using boost::tokenizer; using std::endl; @@ -260,13 +258,12 @@ void map_parser::parse_map(Map & map, xml_node const& pt, std::string const& bas for (boost::tokenizer >::iterator beg = tokens.begin(); beg != tokens.end(); ++beg) { - try + std::string item(*beg); + boost::trim(item); + if (!mapnik::util::string2int(item,n[i])) { - n[i] = boost::lexical_cast(boost::trim_copy(*beg)); - } - catch (boost::bad_lexical_cast & ex) - { - std::clog << *beg << " : " << ex.what() << "\n"; + throw config_error(std::string("Invalid version string encountered: '") + + *beg + "' in '" + *min_version_string + "'"); break; } if (i==2) diff --git a/src/projection.cpp b/src/projection.cpp index 5fc97e150..4c6ec153a 100644 --- a/src/projection.cpp +++ b/src/projection.cpp @@ -149,7 +149,8 @@ std::string projection::expanded() const if (proj_) { std::string def(pj_get_def( proj_, 0 )); //boost::algorithm::ireplace_first(def,params_,""); - return boost::trim_copy(def); + boost::trim(def); + return def; } return std::string(""); } diff --git a/src/rapidxml_loader.cpp b/src/rapidxml_loader.cpp index 4a9293f54..4c8398a69 100644 --- a/src/rapidxml_loader.cpp +++ b/src/rapidxml_loader.cpp @@ -144,7 +144,8 @@ private: case rapidxml::node_data: case rapidxml::node_cdata: { - std::string trimmed = boost::algorithm::trim_copy(std::string(cur_node->value())); + std::string trimmed(cur_node->value()); + boost::trim(trimmed); if (trimmed.empty()) break; //Don't add empty text nodes node.add_child(trimmed, 0, true); }