mapnik/include/query.hpp

112 lines
2.9 KiB
C++
Raw Normal View History

2006-03-31 12:32:02 +02:00
/*****************************************************************************
*
* This file is part of Mapnik (c++ mapping toolkit)
2005-06-14 17:06:59 +02:00
*
2006-03-31 12:32:02 +02:00
* Copyright (C) 2006 Artem Pavlenko
2005-06-14 17:06:59 +02:00
*
2006-03-31 12:32:02 +02:00
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
2005-06-14 17:06:59 +02:00
* but WITHOUT ANY WARRANTY; without even the implied warranty of
2006-03-31 12:32:02 +02:00
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
2005-06-14 17:06:59 +02:00
*
2006-03-31 12:32:02 +02:00
*****************************************************************************/
2005-06-14 17:06:59 +02:00
//$Id$
#ifndef QUERY_HPP
#define QUERY_HPP
#include <set>
#include <limits>
#include "filter.hpp"
#include "envelope.hpp"
#include "feature.hpp"
namespace mapnik
{
class query
{
private:
Envelope<double> bbox_;
filter<Feature>* filter_;
std::set<std::string> names_;
2005-06-14 17:06:59 +02:00
public:
query()
: bbox_(std::numeric_limits<double>::min(),
std::numeric_limits<double>::min(),
std::numeric_limits<double>::max(),
std::numeric_limits<double>::max()),
filter_(new all_filter<Feature>)
{}
query(const Envelope<double>& bbox)
: bbox_(bbox),
filter_(new all_filter<Feature>)
{}
2005-06-14 17:06:59 +02:00
query(const Envelope<double>& bbox, const filter<Feature>& f)
: bbox_(bbox),
filter_(f.clone())
{}
2005-06-14 17:06:59 +02:00
query(const query& other)
: bbox_(other.bbox_),
filter_(other.filter_->clone())
{}
query& operator=(const query& other)
{
filter<Feature>* tmp=other.filter_->clone();
delete filter_;
filter_=tmp;
bbox_=other.bbox_;
names_=other.names_;
return *this;
}
2005-06-14 17:06:59 +02:00
const filter<Feature>* get_filter() const
{
return filter_;
}
2005-06-14 17:06:59 +02:00
const Envelope<double>& get_bbox() const
{
return bbox_;
}
2005-11-24 16:51:29 +01:00
void set_filter(const filter<Feature>& f)
{
filter<Feature>* tmp=f.clone();
delete filter_;
filter_=tmp;
}
2005-06-14 17:06:59 +02:00
void add_property_name(const std::string& name)
{
names_.insert(name);
}
2005-06-14 17:06:59 +02:00
const std::set<std::string>& property_names() const
{
return names_;
}
2005-06-14 17:06:59 +02:00
~query()
{
delete filter_;
}
2005-06-14 17:06:59 +02:00
};
}
#endif //QUERY_HPP