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: layer.cpp 17 2005-03-08 23:58:43Z pavlenko $
|
|
|
|
|
2006-10-04 13:22:18 +02:00
|
|
|
// mapnik
|
2007-10-08 19:42:41 +02:00
|
|
|
#include <mapnik/layer.hpp>
|
|
|
|
|
2006-10-04 13:22:18 +02:00
|
|
|
#include <mapnik/style.hpp>
|
|
|
|
#include <mapnik/datasource.hpp>
|
|
|
|
#include <mapnik/datasource_cache.hpp>
|
2007-10-08 19:42:41 +02:00
|
|
|
// boost
|
|
|
|
#include <boost/shared_ptr.hpp>
|
|
|
|
// stl
|
|
|
|
#include <string>
|
|
|
|
#include <iostream>
|
2006-10-04 13:22:18 +02:00
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
using boost::shared_ptr;
|
2005-12-14 18:01:09 +01:00
|
|
|
|
2005-06-14 17:06:59 +02:00
|
|
|
namespace mapnik
|
2006-10-04 13:22:18 +02:00
|
|
|
{
|
2010-06-02 13:03:30 +02:00
|
|
|
layer::layer(std::string const& name, std::string const& srs)
|
|
|
|
: name_(name),
|
|
|
|
title_(""),
|
|
|
|
abstract_(""),
|
|
|
|
srs_(srs),
|
|
|
|
minZoom_(0),
|
|
|
|
maxZoom_(std::numeric_limits<double>::max()),
|
|
|
|
active_(true),
|
|
|
|
queryable_(false),
|
|
|
|
clear_label_cache_(false),
|
|
|
|
ds_() {}
|
2005-12-12 14:15:33 +01:00
|
|
|
|
2010-06-02 13:03:30 +02:00
|
|
|
layer::layer(const layer& rhs)
|
|
|
|
: name_(rhs.name_),
|
|
|
|
title_(rhs.title_),
|
|
|
|
abstract_(rhs.abstract_),
|
|
|
|
srs_(rhs.srs_),
|
|
|
|
minZoom_(rhs.minZoom_),
|
|
|
|
maxZoom_(rhs.maxZoom_),
|
|
|
|
active_(rhs.active_),
|
|
|
|
queryable_(rhs.queryable_),
|
|
|
|
clear_label_cache_(rhs.clear_label_cache_),
|
|
|
|
styles_(rhs.styles_),
|
|
|
|
ds_(rhs.ds_) {}
|
2005-06-14 17:06:59 +02:00
|
|
|
|
2010-06-02 13:03:30 +02:00
|
|
|
layer& layer::operator=(const layer& rhs)
|
|
|
|
{
|
|
|
|
layer tmp(rhs);
|
|
|
|
swap(tmp);
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool layer::operator==(layer const& other) const
|
|
|
|
{
|
|
|
|
return (this == &other);
|
|
|
|
}
|
2005-09-08 15:20:37 +02:00
|
|
|
|
2010-06-02 13:03:30 +02:00
|
|
|
void layer::swap(const layer& rhs)
|
|
|
|
{
|
|
|
|
name_=rhs.name_;
|
|
|
|
title_=rhs.title_;
|
|
|
|
abstract_=rhs.abstract_;
|
|
|
|
srs_ = rhs.srs_;
|
|
|
|
minZoom_=rhs.minZoom_;
|
|
|
|
maxZoom_=rhs.maxZoom_;
|
|
|
|
active_=rhs.active_;
|
|
|
|
queryable_=rhs.queryable_;
|
|
|
|
clear_label_cache_ = rhs.clear_label_cache_;
|
|
|
|
styles_=rhs.styles_;
|
|
|
|
ds_=rhs.ds_;
|
|
|
|
}
|
|
|
|
|
|
|
|
layer::~layer() {}
|
2005-06-14 17:06:59 +02:00
|
|
|
|
2010-06-02 13:03:30 +02:00
|
|
|
void layer::set_name( std::string const& name)
|
|
|
|
{
|
|
|
|
name_ = name;
|
|
|
|
}
|
2006-05-19 18:07:13 +02:00
|
|
|
|
2010-06-02 13:03:30 +02:00
|
|
|
string const& layer::name() const
|
|
|
|
{
|
|
|
|
return name_;
|
|
|
|
}
|
|
|
|
|
|
|
|
void layer::set_title( std::string const& title)
|
|
|
|
{
|
|
|
|
title_ = title;
|
|
|
|
}
|
2006-05-25 00:15:04 +02:00
|
|
|
|
2010-06-02 13:03:30 +02:00
|
|
|
string const& layer::title() const
|
|
|
|
{
|
|
|
|
return title_;
|
|
|
|
}
|
2006-10-03 10:44:04 +02:00
|
|
|
|
2010-06-02 13:03:30 +02:00
|
|
|
void layer::set_abstract( std::string const& abstract)
|
|
|
|
{
|
|
|
|
abstract_ = abstract;
|
|
|
|
}
|
2006-05-25 00:15:04 +02:00
|
|
|
|
2010-06-02 13:03:30 +02:00
|
|
|
string const& layer::abstract() const
|
|
|
|
{
|
|
|
|
return abstract_;
|
|
|
|
}
|
|
|
|
|
|
|
|
void layer::set_srs(std::string const& srs)
|
|
|
|
{
|
|
|
|
srs_ = srs;
|
|
|
|
}
|
2006-10-16 15:44:52 +02:00
|
|
|
|
2010-06-02 13:03:30 +02:00
|
|
|
std::string const& layer::srs() const
|
|
|
|
{
|
|
|
|
return srs_;
|
|
|
|
}
|
2006-10-16 15:44:52 +02:00
|
|
|
|
2010-06-02 13:03:30 +02:00
|
|
|
void layer::add_style(std::string const& stylename)
|
|
|
|
{
|
|
|
|
styles_.push_back(stylename);
|
|
|
|
}
|
2006-10-16 15:44:52 +02:00
|
|
|
|
2010-06-02 13:03:30 +02:00
|
|
|
std::vector<std::string> const& layer::styles() const
|
|
|
|
{
|
|
|
|
return styles_;
|
|
|
|
}
|
2006-12-20 01:22:45 +01:00
|
|
|
|
2010-06-02 13:03:30 +02:00
|
|
|
std::vector<std::string> & layer::styles()
|
|
|
|
{
|
|
|
|
return styles_;
|
|
|
|
}
|
|
|
|
|
|
|
|
void layer::setMinZoom(double minZoom)
|
|
|
|
{
|
|
|
|
minZoom_=minZoom;
|
|
|
|
}
|
|
|
|
|
|
|
|
void layer::setMaxZoom(double maxZoom)
|
|
|
|
{
|
|
|
|
maxZoom_=maxZoom;
|
|
|
|
}
|
|
|
|
|
|
|
|
double layer::getMinZoom() const
|
|
|
|
{
|
|
|
|
return minZoom_;
|
|
|
|
}
|
|
|
|
|
|
|
|
double layer::getMaxZoom() const
|
|
|
|
{
|
|
|
|
return maxZoom_;
|
|
|
|
}
|
|
|
|
|
|
|
|
void layer::setActive(bool active)
|
|
|
|
{
|
|
|
|
active_=active;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool layer::isActive() const
|
|
|
|
{
|
|
|
|
return active_;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool layer::isVisible(double scale) const
|
|
|
|
{
|
|
|
|
return isActive() && scale >= minZoom_ - 1e-6 && scale < maxZoom_ + 1e-6;
|
|
|
|
}
|
|
|
|
|
|
|
|
void layer::setQueryable(bool queryable)
|
|
|
|
{
|
|
|
|
queryable_=queryable;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool layer::isQueryable() const
|
|
|
|
{
|
|
|
|
return queryable_;
|
|
|
|
}
|
|
|
|
|
|
|
|
datasource_ptr layer::datasource() const
|
|
|
|
{
|
|
|
|
return ds_;
|
|
|
|
}
|
2006-10-03 10:44:04 +02:00
|
|
|
|
2010-06-02 13:03:30 +02:00
|
|
|
void layer::set_datasource(datasource_ptr const& ds)
|
|
|
|
{
|
|
|
|
ds_ = ds;
|
|
|
|
}
|
2006-03-28 10:29:36 +02:00
|
|
|
|
2010-06-02 13:03:30 +02:00
|
|
|
box2d<double> layer::envelope() const
|
|
|
|
{
|
|
|
|
if (ds_) return ds_->envelope();
|
|
|
|
return box2d<double>();
|
|
|
|
}
|
2006-10-03 10:44:04 +02:00
|
|
|
|
2010-06-02 13:03:30 +02:00
|
|
|
void layer::set_clear_label_cache(bool clear)
|
|
|
|
{
|
|
|
|
clear_label_cache_ = clear;
|
|
|
|
}
|
2007-05-01 09:53:20 +02:00
|
|
|
|
2010-06-02 13:03:30 +02:00
|
|
|
bool layer::clear_label_cache() const
|
|
|
|
{
|
|
|
|
return clear_label_cache_;
|
|
|
|
}
|
2005-06-14 17:06:59 +02:00
|
|
|
}
|