All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Layer.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 Layer.cpp
22 
23  \brief A Layer is a reference to a virtual dataset with/without geometric attributes.
24 */
25 
26 // TerraLib
27 #include "../../geometry/Envelope.h"
28 #include "../../se/FeatureTypeStyle.h"
29 #include "../../se/Style.h"
30 #include "../core/AbstractGraph.h"
31 #include "../core/GraphMetadata.h"
32 #include "Layer.h"
33 #include "LayerRenderer.h"
34 
35 const std::string te::graph::Layer::sm_type("GRAPHLAYER");
36 
37 te::graph::Layer::Layer(const std::string& id, const std::string& title, AbstractLayer* parent) :
38  te::map::AbstractLayer(id, title, parent),
39  m_mbr(0),
40  m_style(0),
41 // m_srid(-1),
42  m_renderer(0)
43 {
44 }
45 
47 {
48 }
49 
50 std::auto_ptr<te::da::DataSetType> te::graph::Layer::getSchema() const
51 {
52  return std::auto_ptr<te::da::DataSetType>();
53 }
54 
55 
56 
57 std::auto_ptr<te::da::DataSet> te::graph::Layer::getData(te::common::TraverseType travType,
58  const te::common::AccessPolicy accessPolicy) const
59 {
60  return std::auto_ptr<te::da::DataSet>();
61 }
62 
63 
64 std::auto_ptr<te::da::DataSet> te::graph::Layer::getData(const std::string& propertyName,
65  const te::gm::Envelope* e,
67  te::common::TraverseType travType,
68  const te::common::AccessPolicy accessPolicy) const
69 {
70  return std::auto_ptr<te::da::DataSet>();
71 }
72 
73 
74 
75 std::auto_ptr<te::da::DataSet> te::graph::Layer::getData(const std::string& propertyName,
76  const te::gm::Geometry* g,
78  te::common::TraverseType travType,
79  const te::common::AccessPolicy accessPolicy) const
80 {
81  return std::auto_ptr<te::da::DataSet>();
82 }
83 
84 
85 
86 std::auto_ptr<te::da::DataSet> te::graph::Layer::getData(te::da::Expression* restriction,
87  te::common::TraverseType travType,
88  const te::common::AccessPolicy accessPolicy) const
89 {
90  return std::auto_ptr<te::da::DataSet>();
91 }
92 
93 
94 
95 std::auto_ptr<te::da::DataSet> te::graph::Layer::getData(const te::da::ObjectIdSet* oids,
96  te::common::TraverseType travType,
97  const te::common::AccessPolicy accessPolicy) const
98 {
99  return std::auto_ptr<te::da::DataSet>();
100 }
101 
102 
103 const std::string& te::graph::Layer::getType() const
104 {
105  return sm_type;
106 }
107 
109 {
110  return true;
111 }
112 
113 void te::graph::Layer::draw(te::map::Canvas* canvas, const te::gm::Envelope& bbox, int srid)
114 {
115  assert(m_renderer.get());
116  m_renderer->draw(this, canvas, bbox, srid);
117 }
118 
120 {
121  return m_graph;
122 }
123 
125 {
126  m_graph = g;
127 
128  //set graph parameters
129  if(m_graph->getMetadata())
130  {
131  this->setSRID(m_graph->getMetadata()->getSRID());
132  this->setExtent(*m_graph->getMetadata()->getEnvelope());
133  }
134 }
135 
137 {
138  return m_renderer.get();
139 }
140 
142 {
143  m_renderer.reset(renderer);
144 }
void setGraph(te::graph::AbstractGraph *ds)
It sets the graph associated to the layer.
Definition: Layer.cpp:124
virtual 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.
Definition: Layer.cpp:57
virtual std::auto_ptr< te::da::DataSetType > getSchema() const
It returns the layer schema.
Definition: Layer.cpp:50
te::graph::AbstractGraph * getGraph() const
It returns the graph associated to the layer.
Definition: Layer.cpp:119
virtual bool isValid() const
It returns true if the layer can be drawn, otherwise, it returns false.
Definition: Layer.cpp:108
SpatialRelation
Spatial relations between geometric objects.
Definition: Enums.h:122
This is an abstract class that models a query expression.
Definition: Expression.h:47
It renders the objects associated to a Layer.
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
~Layer()
Destructor.
Definition: Layer.cpp:46
This class represents a set of unique ids created in the same context. i.e. from the same data set...
Definition: ObjectIdSet.h:55
Abstract class used to define the main functions of graph struct. All graph implementations must used...
Definition: AbstractGraph.h:55
Layer(const std::string &id, const std::string &title, AbstractLayer *parent=0)
It initializes a new Layer.
Definition: Layer.cpp:37
virtual const std::string & getType() const
It returns the layer type.
Definition: Layer.cpp:103
LayerRenderer * getRenderer() const
It returns the renderer used to paint this layer.
Definition: Layer.cpp:136
void setRenderer(LayerRenderer *renderer)
It sets the renderer used to paint this layer.
Definition: Layer.cpp:141
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
Definition: Geometry.h:73
It renders the objects associated to a Layer.
Definition: LayerRenderer.h:57
A canvas is an abstraction of a drawing area.
Definition: Canvas.h:91
virtual 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. ...
Definition: Layer.cpp:113
static const std::string sm_type
A static data member used in the implementation of getType method.
Definition: Layer.h:275