-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathchained_datasource.cpp
58 lines (46 loc) · 1.18 KB
/
chained_datasource.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/*
* chained_datasource.cpp
*
* Created on: Aug 8, 2011
* Author: stella
*/
#include "chained_datasource.hpp"
// Mapnik
#include <mapnik/datasource_cache.hpp>
// Boost
#include <boost/algorithm/string/predicate.hpp>
using mapnik::parameters;
using mapnik::datasource_cache;
chained_datasource::chained_datasource(const parameters& params, bool _bind) :
datasource(params)
{
// Iterate over params and populate m_source_params
// from all parameters that start with "src_"
for (parameters::const_iterator iter=params.begin(); iter!=params.end(); iter++) {
const std::string &name(iter->first);
if (!boost::starts_with(name, "src_")) continue;
const std::string sub_name(name.substr(4));
source_params_[sub_name]=iter->second;
}
if (_bind) {
bind();
}
}
chained_datasource::~chained_datasource()
{
}
mapnik::box2d<double> chained_datasource::envelope() const
{
if (source_) {
return source_->envelope();
} else {
//return mapnik::box2d<double>(-180,-90,180,90); // TODO: Remove/warn
return mapnik::box2d<double>();
}
}
void chained_datasource::bind() const
{
if (is_bound_) return;
source_=datasource_cache::create(source_params_, true);
is_bound_=true;
}