1.removed debug printing from filter_parser
2.to_string method in Envelope 3.filter_factory - static method 4.mapnik_envelope.cpp - more bindings TODO - fix __str__ , .def(str(self)) - doesn't compile at the moment
This commit is contained in:
parent
eb7890cfe8
commit
e01a831850
6 changed files with 50 additions and 13 deletions
|
@ -62,8 +62,16 @@ namespace mapnik
|
||||||
bool operator==(const EnvelopeType &other) const;
|
bool operator==(const EnvelopeType &other) const;
|
||||||
void re_center(T cx,T cy);
|
void re_center(T cx,T cy);
|
||||||
void init(T x0,T y0,T x1,T y1);
|
void init(T x0,T y0,T x1,T y1);
|
||||||
|
std::string to_string() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
inline std::string Envelope<T>::to_string() const
|
||||||
|
{
|
||||||
|
return "envelope - TODO";
|
||||||
|
}
|
||||||
|
|
||||||
template <class charT,class traits,class T>
|
template <class charT,class traits,class T>
|
||||||
inline std::basic_ostream<charT,traits>&
|
inline std::basic_ostream<charT,traits>&
|
||||||
operator << (std::basic_ostream<charT,traits>& out,
|
operator << (std::basic_ostream<charT,traits>& out,
|
||||||
|
|
|
@ -28,8 +28,7 @@ namespace mapnik
|
||||||
class filter_factory
|
class filter_factory
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
filter_factory() {}
|
static filter_ptr compile(string const& str)
|
||||||
filter_ptr compile(string const& str) const
|
|
||||||
{
|
{
|
||||||
stack<ref_ptr<filter<FeatureT> > > filters;
|
stack<ref_ptr<filter<FeatureT> > > filters;
|
||||||
stack<ref_ptr<expression<FeatureT> > > exps;
|
stack<ref_ptr<expression<FeatureT> > > exps;
|
||||||
|
@ -38,14 +37,12 @@ namespace mapnik
|
||||||
parse_info<> info = parse(text,text+strlen(text),grammar,space_p);
|
parse_info<> info = parse(text,text+strlen(text),grammar,space_p);
|
||||||
if (info.full && !filters.empty())
|
if (info.full && !filters.empty())
|
||||||
{
|
{
|
||||||
cout<<"success parsing filter expression:\n";
|
|
||||||
cout<<filters.top()->to_string()<<"\n";
|
|
||||||
return filters.top();
|
return filters.top();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cout << "failed at :" << info.stop << "\n";
|
cerr << "failed at :" << info.stop << "\n";
|
||||||
return filter_ptr(new all_filter<FeatureT>());
|
return filter_ptr(new none_filter<FeatureT>());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -38,7 +38,6 @@
|
||||||
|
|
||||||
using namespace boost::spirit;
|
using namespace boost::spirit;
|
||||||
using std::string;
|
using std::string;
|
||||||
using std::cout;
|
|
||||||
using std::cerr;
|
using std::cerr;
|
||||||
using std::stack;
|
using std::stack;
|
||||||
|
|
||||||
|
@ -87,7 +86,6 @@ namespace mapnik
|
||||||
str.erase(idx,1);
|
str.erase(idx,1);
|
||||||
idx = str.find(quote);
|
idx = str.find(quote);
|
||||||
}
|
}
|
||||||
cout << "string(\""<<str<<"\")\n";
|
|
||||||
exprs_.push(ref_ptr<expression<FeatureT> >(new literal<FeatureT>(str)));
|
exprs_.push(ref_ptr<expression<FeatureT> >(new literal<FeatureT>(str)));
|
||||||
}
|
}
|
||||||
stack<ref_ptr<expression<FeatureT> > >& exprs_;
|
stack<ref_ptr<expression<FeatureT> > >& exprs_;
|
||||||
|
@ -153,9 +151,9 @@ namespace mapnik
|
||||||
{
|
{
|
||||||
filters_.push(ref_ptr<filter<FeatureT> >(new regex_filter<FeatureT>(*exp,pattern)));
|
filters_.push(ref_ptr<filter<FeatureT> >(new regex_filter<FeatureT>(*exp,pattern)));
|
||||||
}
|
}
|
||||||
catch (boost::regex_error& ex)
|
catch (...)//boost::regex_error& ex)
|
||||||
{
|
{
|
||||||
cerr<<ex.what()<<"\n";
|
cerr<<"error\n";//ex.what()<<"\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -421,7 +421,7 @@ namespace mapnik { namespace impl {
|
||||||
|
|
||||||
value& operator-=(value const& other)
|
value& operator-=(value const& other)
|
||||||
{
|
{
|
||||||
v_ = apply_visitor(sub(),v_,other.get());
|
v_ = apply_visitor(sub(),v_,other.get()); //cout << "string(\""<<str<<"\")\n";
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,6 +34,26 @@ struct envelope_pickle_suite : boost::python::pickle_suite
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//define overloads here
|
||||||
|
void (Envelope<double>::*width_p1)(double) = &Envelope<double>::width;
|
||||||
|
double (Envelope<double>::*width_p2)() const = &Envelope<double>::width;
|
||||||
|
|
||||||
|
void (Envelope<double>::*height_p1)(double) = &Envelope<double>::height;
|
||||||
|
double (Envelope<double>::*height_p2)() const = &Envelope<double>::height;
|
||||||
|
|
||||||
|
void (Envelope<double>::*expand_to_include_p1)(double,double) = &Envelope<double>::expand_to_include;
|
||||||
|
void (Envelope<double>::*expand_to_include_p2)(coord<double,2> const& ) = &Envelope<double>::expand_to_include;
|
||||||
|
void (Envelope<double>::*expand_to_include_p3)(Envelope<double> const& ) = &Envelope<double>::expand_to_include;
|
||||||
|
|
||||||
|
bool (Envelope<double>::*contains_p1)(double,double) const = &Envelope<double>::contains;
|
||||||
|
bool (Envelope<double>::*contains_p2)(coord<double,2> const&) const = &Envelope<double>::contains;
|
||||||
|
bool (Envelope<double>::*contains_p3)(Envelope<double> const&) const = &Envelope<double>::contains;
|
||||||
|
|
||||||
|
bool (Envelope<double>::*intersects_p1)(double,double) const = &Envelope<double>::intersects;
|
||||||
|
bool (Envelope<double>::*intersects_p2)(coord<double,2> const&) const = &Envelope<double>::intersects;
|
||||||
|
bool (Envelope<double>::*intersects_p3)(Envelope<double> const&) const = &Envelope<double>::intersects;
|
||||||
|
|
||||||
|
|
||||||
void export_envelope()
|
void export_envelope()
|
||||||
{
|
{
|
||||||
using namespace boost::python;
|
using namespace boost::python;
|
||||||
|
@ -45,6 +65,21 @@ void export_envelope()
|
||||||
.add_property("maxx",&Envelope<double>::maxx)
|
.add_property("maxx",&Envelope<double>::maxx)
|
||||||
.add_property("maxy",&Envelope<double>::maxy)
|
.add_property("maxy",&Envelope<double>::maxy)
|
||||||
.def("center",&Envelope<double>::center)
|
.def("center",&Envelope<double>::center)
|
||||||
|
.def("center",&Envelope<double>::re_center)
|
||||||
|
.def("width",width_p1)
|
||||||
|
.def("width",width_p2)
|
||||||
|
.def("height",height_p1)
|
||||||
|
.def("height",height_p2)
|
||||||
|
.def("expand_to_include",expand_to_include_p1)
|
||||||
|
.def("expand_to_include",expand_to_include_p2)
|
||||||
|
.def("expand_to_include",expand_to_include_p3)
|
||||||
|
.def("contains",contains_p1)
|
||||||
|
.def("contains",contains_p2)
|
||||||
|
.def("contains",contains_p3)
|
||||||
|
.def("intersects",intersects_p1)
|
||||||
|
.def("intersects",intersects_p2)
|
||||||
|
.def("intersects",intersects_p3)
|
||||||
|
.def(self == self)
|
||||||
.def_pickle(envelope_pickle_suite())
|
.def_pickle(envelope_pickle_suite())
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,8 +32,7 @@ namespace
|
||||||
using namespace boost::python;
|
using namespace boost::python;
|
||||||
filter_ptr create_filter(string const& filter_text)
|
filter_ptr create_filter(string const& filter_text)
|
||||||
{
|
{
|
||||||
filter_factory<Feature> factory;
|
return filter_factory<Feature>::compile(filter_text);
|
||||||
return factory.compile(filter_text);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue