00001 /***************************************************************************** 00002 * 00003 * This file is part of Mapnik (c++ mapping toolkit) 00004 * 00005 * Copyright (C) 2006 Artem Pavlenko 00006 * 00007 * This library is free software; you can redistribute it and/or 00008 * modify it under the terms of the GNU Lesser General Public 00009 * License as published by the Free Software Foundation; either 00010 * version 2.1 of the License, or (at your option) any later version. 00011 * 00012 * This library is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00015 * Lesser General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU Lesser General Public 00018 * License along with this library; if not, write to the Free Software 00019 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00020 * 00021 *****************************************************************************/ 00022 00023 //$Id$ 00024 00025 #ifndef QUERY_HPP 00026 #define QUERY_HPP 00027 // stl 00028 #include <set> 00029 #include <limits> 00030 //mapnik 00031 #include <mapnik/filter.hpp> 00032 #include <mapnik/envelope.hpp> 00033 #include <mapnik/feature.hpp> 00034 00035 namespace mapnik 00036 { 00037 class query 00038 { 00039 private: 00040 Envelope<double> bbox_; 00041 filter<Feature>* filter_; 00042 std::set<std::string> names_; 00043 public: 00044 query() 00045 : bbox_(std::numeric_limits<double>::min(), 00046 std::numeric_limits<double>::min(), 00047 std::numeric_limits<double>::max(), 00048 std::numeric_limits<double>::max()), 00049 filter_(new all_filter<Feature>) 00050 {} 00051 00052 query(const Envelope<double>& bbox) 00053 : bbox_(bbox), 00054 filter_(new all_filter<Feature>) 00055 {} 00056 00057 query(const Envelope<double>& bbox, const filter<Feature>& f) 00058 : bbox_(bbox), 00059 filter_(f.clone()) 00060 {} 00061 00062 query(const query& other) 00063 : bbox_(other.bbox_), 00064 filter_(other.filter_->clone()) 00065 {} 00066 00067 query& operator=(const query& other) 00068 { 00069 filter<Feature>* tmp=other.filter_->clone(); 00070 delete filter_; 00071 filter_=tmp; 00072 bbox_=other.bbox_; 00073 names_=other.names_; 00074 return *this; 00075 } 00076 00077 const filter<Feature>* get_filter() const 00078 { 00079 return filter_; 00080 } 00081 00082 const Envelope<double>& get_bbox() const 00083 { 00084 return bbox_; 00085 } 00086 00087 void set_filter(const filter<Feature>& f) 00088 { 00089 filter<Feature>* tmp=f.clone(); 00090 delete filter_; 00091 filter_=tmp; 00092 } 00093 00094 void add_property_name(const std::string& name) 00095 { 00096 names_.insert(name); 00097 } 00098 00099 const std::set<std::string>& property_names() const 00100 { 00101 return names_; 00102 } 00103 00104 ~query() 00105 { 00106 delete filter_; 00107 } 00108 }; 00109 } 00110 00111 00112 #endif //QUERY_HPP