fix compile error due to ambiguous 'str' variable
This commit is contained in:
parent
3f54120354
commit
8b649f7555
1 changed files with 26 additions and 36 deletions
|
@ -62,7 +62,6 @@ mapnik::layer_descriptor python_datasource::get_descriptor() const
|
|||
void python_datasource::bind() const
|
||||
{
|
||||
using namespace boost;
|
||||
using namespace boost::python;
|
||||
|
||||
if (is_bound_) return;
|
||||
|
||||
|
@ -81,34 +80,34 @@ void python_datasource::bind() const
|
|||
+ factory_ + '"');
|
||||
}
|
||||
// extract the module and the callable
|
||||
str module_name("__main__"), callable_name;
|
||||
boost::python::str module_name("__main__"), callable_name;
|
||||
if (factory_split.size() == 1)
|
||||
{
|
||||
callable_name = str(factory_split[0]);
|
||||
callable_name = boost::python::str(factory_split[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
module_name = str(factory_split[0]);
|
||||
callable_name = str(factory_split[1]);
|
||||
module_name = boost::python::str(factory_split[0]);
|
||||
callable_name = boost::python::str(factory_split[1]);
|
||||
}
|
||||
ensure_gil lock;
|
||||
// import the main module from Python (in case we're embedding the
|
||||
// interpreter directly) and also import the callable.
|
||||
object main_module = import("__main__");
|
||||
object callable_module = import(module_name);
|
||||
object callable = callable_module.attr(callable_name);
|
||||
boost::python::object main_module = boost::python::import("__main__");
|
||||
boost::python::object callable_module = boost::python::import(module_name);
|
||||
boost::python::object callable = callable_module.attr(callable_name);
|
||||
// prepare the arguments
|
||||
dict kwargs;
|
||||
boost::python::dict kwargs;
|
||||
typedef std::map<std::string, std::string>::value_type kv_type;
|
||||
BOOST_FOREACH(const kv_type& kv, kwargs_)
|
||||
{
|
||||
kwargs[str(kv.first)] = str(kv.second);
|
||||
kwargs[boost::python::str(kv.first)] = boost::python::str(kv.second);
|
||||
}
|
||||
|
||||
// get our wrapped data source
|
||||
datasource_ = callable(*boost::python::make_tuple(), **kwargs);
|
||||
}
|
||||
catch ( error_already_set )
|
||||
catch ( boost::python::error_already_set )
|
||||
{
|
||||
throw mapnik::datasource_exception(extractException());
|
||||
}
|
||||
|
@ -118,8 +117,6 @@ void python_datasource::bind() const
|
|||
|
||||
mapnik::datasource::datasource_t python_datasource::type() const
|
||||
{
|
||||
using namespace boost::python;
|
||||
|
||||
typedef boost::optional<mapnik::datasource::geometry_t> return_type;
|
||||
|
||||
if (!is_bound_) bind();
|
||||
|
@ -127,11 +124,11 @@ mapnik::datasource::datasource_t python_datasource::type() const
|
|||
try
|
||||
{
|
||||
ensure_gil lock;
|
||||
object data_type = datasource_.attr("data_type");
|
||||
long data_type_integer = extract<long>(data_type);
|
||||
boost::python::object data_type = datasource_.attr("data_type");
|
||||
long data_type_integer = boost::python::extract<long>(data_type);
|
||||
return mapnik::datasource::datasource_t(data_type_integer);
|
||||
}
|
||||
catch ( error_already_set )
|
||||
catch ( boost::python::error_already_set )
|
||||
{
|
||||
throw mapnik::datasource_exception(extractException());
|
||||
}
|
||||
|
@ -140,16 +137,14 @@ mapnik::datasource::datasource_t python_datasource::type() const
|
|||
|
||||
mapnik::box2d<double> python_datasource::envelope() const
|
||||
{
|
||||
using namespace boost::python;
|
||||
|
||||
if (!is_bound_) bind();
|
||||
|
||||
try
|
||||
{
|
||||
ensure_gil lock;
|
||||
return extract<mapnik::box2d<double> >(datasource_.attr("envelope"));
|
||||
return boost::python::extract<mapnik::box2d<double> >(datasource_.attr("envelope"));
|
||||
}
|
||||
catch ( error_already_set )
|
||||
catch ( boost::python::error_already_set )
|
||||
{
|
||||
throw mapnik::datasource_exception(extractException());
|
||||
}
|
||||
|
@ -157,8 +152,6 @@ mapnik::box2d<double> python_datasource::envelope() const
|
|||
|
||||
boost::optional<mapnik::datasource::geometry_t> python_datasource::get_geometry_type() const
|
||||
{
|
||||
using namespace boost::python;
|
||||
|
||||
typedef boost::optional<mapnik::datasource::geometry_t> return_type;
|
||||
|
||||
if (!is_bound_) bind();
|
||||
|
@ -171,16 +164,16 @@ boost::optional<mapnik::datasource::geometry_t> python_datasource::get_geometry_
|
|||
{
|
||||
return return_type();
|
||||
}
|
||||
object py_geometry_type = datasource_.attr("geometry_type");
|
||||
boost::python::object py_geometry_type = datasource_.attr("geometry_type");
|
||||
// if the attribute value is 'None', return a 'none' value
|
||||
if (py_geometry_type.ptr() == object().ptr())
|
||||
if (py_geometry_type.ptr() == boost::python::object().ptr())
|
||||
{
|
||||
return return_type();
|
||||
}
|
||||
long geom_type_integer = extract<long>(py_geometry_type);
|
||||
long geom_type_integer = boost::python::extract<long>(py_geometry_type);
|
||||
return mapnik::datasource::geometry_t(geom_type_integer);
|
||||
}
|
||||
catch ( error_already_set )
|
||||
catch ( boost::python::error_already_set )
|
||||
{
|
||||
throw mapnik::datasource_exception(extractException());
|
||||
}
|
||||
|
@ -188,8 +181,6 @@ boost::optional<mapnik::datasource::geometry_t> python_datasource::get_geometry_
|
|||
|
||||
mapnik::featureset_ptr python_datasource::features(mapnik::query const& q) const
|
||||
{
|
||||
using namespace boost::python;
|
||||
|
||||
if (!is_bound_) bind();
|
||||
|
||||
try
|
||||
|
@ -198,9 +189,9 @@ mapnik::featureset_ptr python_datasource::features(mapnik::query const& q) const
|
|||
if (envelope().intersects(q.get_bbox()))
|
||||
{
|
||||
ensure_gil lock;
|
||||
object features(datasource_.attr("features")(q));
|
||||
boost::python::object features(datasource_.attr("features")(q));
|
||||
// if 'None' was returned, return an empty feature set
|
||||
if(features.ptr() == object().ptr())
|
||||
if(features.ptr() == boost::python::object().ptr())
|
||||
{
|
||||
return mapnik::featureset_ptr();
|
||||
}
|
||||
|
@ -209,7 +200,7 @@ mapnik::featureset_ptr python_datasource::features(mapnik::query const& q) const
|
|||
// otherwise return an empty featureset pointer
|
||||
return mapnik::featureset_ptr();
|
||||
}
|
||||
catch ( error_already_set )
|
||||
catch ( boost::python::error_already_set )
|
||||
{
|
||||
throw mapnik::datasource_exception(extractException());
|
||||
}
|
||||
|
@ -217,25 +208,24 @@ mapnik::featureset_ptr python_datasource::features(mapnik::query const& q) const
|
|||
|
||||
mapnik::featureset_ptr python_datasource::features_at_point(mapnik::coord2d const& pt) const
|
||||
{
|
||||
using namespace boost::python;
|
||||
|
||||
if (!is_bound_) bind();
|
||||
|
||||
try
|
||||
{
|
||||
ensure_gil lock;
|
||||
object features(datasource_.attr("features_at_point")(pt));
|
||||
boost::python::object features(datasource_.attr("features_at_point")(pt));
|
||||
// if we returned none, return an empty set
|
||||
if(features.ptr() == object().ptr())
|
||||
if(features.ptr() == boost::python::object().ptr())
|
||||
{
|
||||
return mapnik::featureset_ptr();
|
||||
}
|
||||
// otherwise, return a feature set which can iterate over the iterator
|
||||
return boost::make_shared<python_featureset>(features);
|
||||
}
|
||||
catch ( error_already_set )
|
||||
catch ( boost::python::error_already_set )
|
||||
{
|
||||
throw mapnik::datasource_exception(extractException());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue