support for user defined 'extent' parameter (for example : -180,-90,180,90)

This commit is contained in:
Artem Pavlenko 2008-01-29 16:59:51 +00:00
parent af1c576593
commit c63c2efe42
2 changed files with 36 additions and 1 deletions

View file

@ -28,7 +28,6 @@
#include <boost/optional.hpp> #include <boost/optional.hpp>
#include <boost/none.hpp> #include <boost/none.hpp>
#include <boost/lexical_cast.hpp> #include <boost/lexical_cast.hpp>
//#include <boost/iterator/transform_iterator.hpp>
#include <string> #include <string>
#include <map> #include <map>

View file

@ -29,6 +29,7 @@
// boost // boost
#include <boost/lexical_cast.hpp> #include <boost/lexical_cast.hpp>
#include <boost/tokenizer.hpp>
// stl // stl
#include <string> #include <string>
@ -71,6 +72,40 @@ postgis_datasource::postgis_datasource(parameters const& params)
multiple_geometries_ = *params_.get<mapnik::boolean>("multiple_geometries",false); multiple_geometries_ = *params_.get<mapnik::boolean>("multiple_geometries",false);
boost::optional<std::string> ext = params_.get<std::string>("extent");
if (ext)
{
boost::char_separator<char> sep(",");
boost::tokenizer<boost::char_separator<char> > tok(*ext,sep);
unsigned i = 0;
bool success = false;
double d[4];
for (boost::tokenizer<boost::char_separator<char> >::iterator beg=tok.begin();
beg!=tok.end();++beg)
{
try
{
d[i] = boost::lexical_cast<double>(*beg);
}
catch (boost::bad_lexical_cast & ex)
{
std::clog << ex.what() << "\n";
break;
}
if (i==3)
{
success = true;
break;
}
++i;
}
if (success)
{
extent_.init(d[0],d[1],d[2],d[3]);
extent_initialized_ = true;
}
}
ConnectionManager *mgr=ConnectionManager::instance(); ConnectionManager *mgr=ConnectionManager::instance();
mgr->registerPool(creator_, *initial_size, *max_size); mgr->registerPool(creator_, *initial_size, *max_size);
@ -123,6 +158,7 @@ postgis_datasource::postgis_datasource(parameters const& params)
break; break;
case 700: // float4 case 700: // float4
case 701: // float8 case 701: // float8
case 1700: // numeric ??
desc_.add_descriptor(attribute_descriptor(fld_name,mapnik::Double)); desc_.add_descriptor(attribute_descriptor(fld_name,mapnik::Double));
case 1042: // bpchar case 1042: // bpchar
case 1043: // varchar case 1043: // varchar