mapnik/include/query.hpp

130 lines
2.8 KiB
C++
Raw Normal View History

2005-06-14 17:06:59 +02:00
/* This file is part of Mapnik (c++ mapping toolkit)
* Copyright (C) 2005 Artem Pavlenko
*
* Mapnik is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
//$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_;
2005-11-24 16:51:29 +01:00
unsigned width_;
unsigned height_;
2005-06-14 17:06:59 +02:00
filter<Feature>* filter_;
std::set<std::string> names_;
public:
2005-11-24 16:51:29 +01:00
query(unsigned width,unsigned height)
2005-06-14 17:06:59 +02:00
: bbox_(std::numeric_limits<double>::min(),
std::numeric_limits<double>::min(),
std::numeric_limits<double>::max(),
std::numeric_limits<double>::max()),
2005-11-24 16:51:29 +01:00
width_(width),
height_(height),
filter_(new all_filter<Feature>)
2005-06-14 17:06:59 +02:00
{}
2005-11-24 16:51:29 +01:00
query(const Envelope<double>& bbox,unsigned width,unsigned height)
2005-06-14 17:06:59 +02:00
: bbox_(bbox),
2005-11-24 16:51:29 +01:00
width_(width),
height_(height),
filter_(new all_filter<Feature>)
2005-06-14 17:06:59 +02:00
{}
2005-11-24 16:51:29 +01:00
query(const Envelope<double>& bbox,unsigned width,unsigned height,const filter<Feature>& f)
2005-06-14 17:06:59 +02:00
: bbox_(bbox),
2005-11-24 16:51:29 +01:00
width_(width),
height_(height),
2005-06-14 17:06:59 +02:00
filter_(f.clone())
{}
query(const query& other)
: bbox_(other.bbox_),
2005-11-24 16:51:29 +01:00
width_(other.width_),
height_(other.height_),
2005-06-14 17:06:59 +02:00
filter_(other.filter_->clone())
{}
query& operator=(const query& other)
{
filter<Feature>* tmp=other.filter_->clone();
delete filter_;
filter_=tmp;
bbox_=other.bbox_;
2005-11-24 16:51:29 +01:00
width_=other.width_;
height_=other.height_;
2005-06-14 17:06:59 +02:00
names_=other.names_;
return *this;
}
const filter<Feature>* get_filter() const
{
return filter_;
}
const Envelope<double>& get_bbox() const
{
return bbox_;
}
2005-11-24 16:51:29 +01:00
unsigned get_width() const
{
return width_;
}
unsigned get_height() const
{
return height_;
}
2005-06-14 17:06:59 +02:00
void set_filter(const filter<Feature>& f)
{
filter<Feature>* tmp=f.clone();
delete filter_;
filter_=tmp;
}
void add_property_name(const std::string& name)
{
names_.insert(name);
}
const std::set<std::string>& property_names() const
{
return names_;
}
~query()
{
delete filter_;
}
};
}
#endif //QUERY_HPP