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: feature.hpp 40 2005-04-13 20:20:46Z pavlenko $
|
|
|
|
|
|
|
|
#ifndef FEATURE_HPP
|
|
|
|
#define FEATURE_HPP
|
|
|
|
|
|
|
|
#include "geometry.hpp"
|
|
|
|
#include "raster.hpp"
|
|
|
|
#include "value.hpp"
|
2006-02-10 18:13:02 +01:00
|
|
|
#include <map>
|
|
|
|
|
|
|
|
#include <boost/property_map.hpp>
|
|
|
|
#include <boost/utility.hpp>
|
2005-06-14 17:06:59 +02:00
|
|
|
|
|
|
|
namespace mapnik
|
|
|
|
{
|
2005-12-12 14:15:33 +01:00
|
|
|
typedef boost::shared_ptr<raster> raster_ptr;
|
2006-02-10 18:13:02 +01:00
|
|
|
//typedef std::vector<value> properties;
|
|
|
|
typedef boost::associative_property_map<std::map<std::string,value> > properties;
|
2005-06-14 17:06:59 +02:00
|
|
|
|
|
|
|
template <typename T1,typename T2>
|
2006-02-10 18:13:02 +01:00
|
|
|
struct feature : public properties,
|
|
|
|
private boost::noncopyable
|
2005-06-14 17:06:59 +02:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
typedef T1 geometry_type;
|
|
|
|
typedef T2 raster_type;
|
|
|
|
private:
|
|
|
|
int id_;
|
|
|
|
geometry_type geom_;
|
|
|
|
raster_type raster_;
|
2006-02-10 18:13:02 +01:00
|
|
|
std::map<std::string,value> props_;
|
2005-06-14 17:06:59 +02:00
|
|
|
public:
|
|
|
|
explicit feature(int id)
|
2006-02-10 18:13:02 +01:00
|
|
|
: properties(props_),
|
|
|
|
id_(id),
|
2005-06-14 17:06:59 +02:00
|
|
|
geom_(),
|
|
|
|
raster_() {}
|
|
|
|
|
|
|
|
feature(int id,const geometry_type& geom)
|
2006-02-10 18:13:02 +01:00
|
|
|
: properties(props_),
|
|
|
|
id_(id),
|
2005-06-14 17:06:59 +02:00
|
|
|
geom_(geom),
|
|
|
|
raster_() {}
|
|
|
|
|
|
|
|
int id() const
|
|
|
|
{
|
|
|
|
return id_;
|
|
|
|
}
|
|
|
|
|
|
|
|
void set_geometry(geometry_type& geom)
|
|
|
|
{
|
|
|
|
geom_=geom;
|
|
|
|
}
|
|
|
|
|
2006-01-23 23:33:37 +01:00
|
|
|
geometry_type const& get_geometry() const
|
2005-06-14 17:06:59 +02:00
|
|
|
{
|
|
|
|
return geom_;
|
|
|
|
}
|
|
|
|
|
|
|
|
const raster_type& get_raster() const
|
|
|
|
{
|
|
|
|
return raster_;
|
|
|
|
}
|
2005-11-24 16:51:29 +01:00
|
|
|
void set_raster(raster_type const& raster)
|
|
|
|
{
|
|
|
|
raster_=raster;
|
|
|
|
}
|
2005-06-14 17:06:59 +02:00
|
|
|
|
|
|
|
const properties& get_properties() const
|
|
|
|
{
|
|
|
|
return props_;
|
|
|
|
}
|
2006-02-10 18:13:02 +01:00
|
|
|
|
|
|
|
std::string to_string() const
|
2005-06-14 17:06:59 +02:00
|
|
|
{
|
2006-02-10 18:13:02 +01:00
|
|
|
std::stringstream ss;
|
|
|
|
ss << "feature (" << std::endl;
|
|
|
|
for (std::map<std::string,value>::const_iterator itr=props_.begin();
|
|
|
|
itr != props_.end();++itr)
|
|
|
|
{
|
|
|
|
ss << " " << itr->first << ":" << itr->second << std::endl;
|
|
|
|
}
|
|
|
|
ss << ")" << std::endl;
|
|
|
|
return ss.str();
|
2005-06-14 17:06:59 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef feature<geometry_ptr,raster_ptr> Feature;
|
|
|
|
|
2006-02-10 18:13:02 +01:00
|
|
|
inline std::ostream& operator<< (std::ostream & out,Feature const& f)
|
|
|
|
{
|
|
|
|
out << f.to_string();
|
|
|
|
return out;
|
|
|
|
}
|
2005-06-14 17:06:59 +02:00
|
|
|
}
|
|
|
|
#endif //FEATURE_HPP
|