All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
EditionLayer.cpp
Go to the documentation of this file.
1 /* Copyright (C) 2008 National Institute For Space Research (INPE) - Brazil.
2 
3  This file is part of the TerraLib - a Framework for building GIS enabled applications.
4 
5  TerraLib is free software: you can redistribute it and/or modify
6  it under the terms of the GNU Lesser General Public License as published by
7  the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  TerraLib is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public License
16  along with TerraLib. See COPYING. If not, write to
17  TerraLib Team at <terralib-team@terralib.org>.
18  */
19 
20 /*!
21  \file terralib/edit/EditionLayer.cpp
22 
23  \brief This class represents a layer being created from user-edition.
24 */
25 
26 // TerraLib
27 #include "../common/Exception.h"
28 #include "../common/Translator.h"
29 #include "../maptools/RendererFactory.h"
30 #include "EditionLayer.h"
31 
32 // Boost
33 #include <boost/format.hpp>
34 
35 // STL
36 #include <memory>
37 
38 const std::string te::edit::EditionLayer::sm_type("EDITIONLAYER");
39 
41  : te::map::AbstractLayer(parent),
42  m_schema(0)
43 {
44 }
45 
47  : te::map::AbstractLayer(id, parent),
48  m_schema(0)
49 {
50 }
51 
53  const std::string& title,
54  te::map::AbstractLayer* parent)
55  : te::map::AbstractLayer(id, title, parent),
56  m_schema(0)
57 {
58 }
59 
61 {
62 }
63 
64 std::auto_ptr<te::map::LayerSchema> te::edit::EditionLayer::getSchema() const
65 {
66  return std::auto_ptr<te::map::LayerSchema>(static_cast<te::map::LayerSchema*>(m_schema->clone()));
67 }
68 
70 {
71  delete m_schema;
72  m_schema = schema;
73 }
74 
75 std::auto_ptr<te::da::DataSet> te::edit::EditionLayer::getData(te::common::TraverseType travType,
76  const te::common::AccessPolicy accessPolicy) const
77 {
78  throw(te::common::Exception("Under development!"));
79 }
80 
81 std::auto_ptr<te::da::DataSet> te::edit::EditionLayer::getData(const std::string& propertyName,
82  const te::gm::Envelope* e,
84  te::common::TraverseType travType,
85  const te::common::AccessPolicy accessPolicy) const
86 {
87  throw(te::common::Exception("Under development!"));
88 }
89 
90 std::auto_ptr<te::da::DataSet> te::edit::EditionLayer::getData(const std::string& propertyName,
91  const te::gm::Geometry* g,
93  te::common::TraverseType travType,
94  const te::common::AccessPolicy accessPolicy) const
95 {
96  throw(te::common::Exception("Under development!"));
97 }
98 
99 std::auto_ptr<te::da::DataSet> te::edit::EditionLayer::getData(te::da::Expression* restriction,
100  te::common::TraverseType travType,
101  const te::common::AccessPolicy accessPolicy) const
102 {
103  throw(te::common::Exception("Under development!"));
104 }
105 
106 std::auto_ptr<te::da::DataSet> te::edit::EditionLayer::getData(const te::da::ObjectIdSet* oids,
107  te::common::TraverseType travType,
108  const te::common::AccessPolicy accessPolicy) const
109 {
110  throw(te::common::Exception("Under development!"));
111 }
112 
114 {
115  return false;
116 }
117 
119 {
120  if(m_rendererType.empty())
121  throw te::common::Exception((boost::format(TE_TR("Could not draw the layer %1%. The renderer type is empty!")) % getTitle()).str());
122 
123  // Try get the defined renderer
124  std::auto_ptr<te::map::AbstractRenderer> renderer(te::map::RendererFactory::make(m_rendererType));
125  if(renderer.get() == 0)
126  throw te::common::Exception((boost::format(TE_TR("Could not draw the layer %1%. The renderer %2% could not be created!")) % getTitle() % m_rendererType).str());
127 
128  renderer->draw(this, canvas, bbox, srid);
129 }
130 
131 const std::string& te::edit::EditionLayer::getType() const
132 {
133  return sm_type;
134 }
135 
136 const std::string& te::edit::EditionLayer::getRendererType() const
137 {
138  return m_rendererType;
139 }
140 
141 void te::edit::EditionLayer::setRendererType(const std::string& t)
142 {
143  m_rendererType = t;
144 }
void setSchema(te::map::LayerSchema *schema)
std::auto_ptr< te::da::DataSet > getData(te::common::TraverseType travType=te::common::FORWARDONLY, const te::common::AccessPolicy accessPolicy=te::common::RAccess) const
It gets the dataset identified by the layer name.
This is the base class for layers.
Definition: AbstractLayer.h:76
void setRendererType(const std::string &t)
A class that models the description of a dataset.
Definition: DataSetType.h:72
SpatialRelation
Spatial relations between geometric objects.
Definition: Enums.h:122
#define TE_TR(message)
It marks a string in order to get translated.
Definition: Translator.h:347
This is an abstract class that models a query expression.
Definition: Expression.h:47
const std::string & getRendererType() const
AccessPolicy
Supported data access policies (can be used as bitfield).
Definition: Enums.h:40
TraverseType
A dataset can be traversed in two ways:
Definition: Enums.h:53
An Envelope defines a 2D rectangular region.
Definition: Envelope.h:51
This class represents a set of unique ids created in the same context. i.e. from the same data set...
Definition: ObjectIdSet.h:55
static const std::string sm_type
A static data member used in the implementation of getType method.
Definition: EditionLayer.h:119
This class is designed to declare objects to be thrown as exceptions by TerraLib. ...
Definition: Exception.h:58
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
Definition: Geometry.h:73
static AbstractRenderer * make(const std::string &factoryKey)
It creates an object with the appropriated factory.
This class represents a layer being created from user-edition.
A canvas is an abstraction of a drawing area.
Definition: Canvas.h:91
bool isValid() const
It returns true if the layer can be used for instance to draw, otherwise, it returns false...
~EditionLayer()
Destructor.
EditionLayer(te::map::AbstractLayer *parent=0)
It initializes a new layer.
void draw(te::map::Canvas *canvas, const te::gm::Envelope &bbox, int srid)
It draws the layer geographic objects in the given canvas using the informed SRS. ...
const std::string & getType() const
It returns the layer type: EDITIONLAYER.
std::auto_ptr< te::map::LayerSchema > getSchema() const
It returns the layer schema.