![]() |
C++ API DOCUMENTATION |
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 #ifndef SPATIAL_HPP 00023 #define SPATIAL_HPP 00024 00025 #include <mapnik/filter.hpp> 00026 #include <mapnik/filter_visitor.hpp> 00027 00028 namespace mapnik 00029 { 00030 00031 template <typename FeatureT> 00032 struct equals_ : public filter<FeatureT> 00033 { 00034 00035 bool pass(const FeatureT& feature) const 00036 { 00037 return false; 00038 } 00039 00040 void accept(const filter_visitor<FeatureT>& v) 00041 { 00042 v.visit(*this); 00043 } 00044 }; 00045 00046 template <typename FeatureT> 00047 struct disjoint : public filter<FeatureT> 00048 { 00049 00050 00051 bool pass(const FeatureT& feature) const 00052 { 00053 return false; 00054 } 00055 00056 void accept(const filter_visitor<FeatureT>& v) 00057 { 00058 v.visit(*this); 00059 } 00060 }; 00061 00062 template <typename FeatureT> 00063 struct touches : public filter<FeatureT> 00064 { 00065 00066 00067 bool pass(const FeatureT& feature) const 00068 { 00069 return false; 00070 } 00071 00072 void accept(const filter_visitor<FeatureT>& v) 00073 { 00074 v.visit(*this); 00075 } 00076 }; 00077 00078 template <typename FeatureT> 00079 struct within : public filter<FeatureT> 00080 { 00081 00082 bool pass(const FeatureT& feature) const 00083 { 00084 return false; 00085 } 00086 00087 void accept(const filter_visitor<FeatureT>& v) 00088 { 00089 v.visit(*this); 00090 } 00091 }; 00092 00093 template <typename FeatureT> 00094 struct overlaps : public filter<FeatureT> 00095 { 00096 00097 bool pass(const FeatureT& feature) const 00098 { 00099 return false; 00100 } 00101 00102 void accept(const filter_visitor<FeatureT>& v) 00103 { 00104 v.visit(*this); 00105 } 00106 }; 00107 00108 template <typename FeatureT> 00109 struct crosses : public filter<FeatureT> 00110 { 00111 00112 00113 bool pass(const FeatureT& feature) const 00114 { 00115 return false; 00116 } 00117 00118 void accept(const filter_visitor<FeatureT>& v) 00119 { 00120 v.visit(*this); 00121 } 00122 }; 00123 00124 template <typename FeatureT> 00125 struct bbox : public filter<FeatureT> 00126 { 00127 private: 00128 Envelope<double> box_; 00129 public: 00130 bbox(const Envelope<double>& box) 00131 : box_(box) {} 00132 00133 00134 bool pass(const FeatureT& feature) const 00135 { 00136 return box_.contains(feature.get_geometry()->bbox()); 00137 } 00138 00139 00140 filter<FeatureT>* clone() const 00141 { 00142 return new bbox<FeatureT>(box_); 00143 } 00144 void accept(const filter_visitor<FeatureT>& v) 00145 { 00146 v.visit(*this); 00147 } 00148 00149 virtual ~bbox() {} 00150 }; 00151 } 00152 00153 #endif //SPATIAL_HPP