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_renderer(0),
40  m_graph(0)
41 {
42 }
43 
45 {
46 }
47 
48 std::auto_ptr<te::da::DataSetType> te::graph::Layer::getSchema() const
49 {
50  return std::auto_ptr<te::da::DataSetType>();
51 }
52 
53 
54 
55 std::auto_ptr<te::da::DataSet> te::graph::Layer::getData(te::common::TraverseType travType,
56  const te::common::AccessPolicy accessPolicy) const
57 {
58  return std::auto_ptr<te::da::DataSet>();
59 }
60 
61 
62 std::auto_ptr<te::da::DataSet> te::graph::Layer::getData(const std::string& propertyName,
63  const te::gm::Envelope* e,
65  te::common::TraverseType travType,
66  const te::common::AccessPolicy accessPolicy) const
67 {
68  return std::auto_ptr<te::da::DataSet>();
69 }
70 
71 
72 
73 std::auto_ptr<te::da::DataSet> te::graph::Layer::getData(const std::string& propertyName,
74  const te::gm::Geometry* g,
76  te::common::TraverseType travType,
77  const te::common::AccessPolicy accessPolicy) const
78 {
79  return std::auto_ptr<te::da::DataSet>();
80 }
81 
82 
83 
84 std::auto_ptr<te::da::DataSet> te::graph::Layer::getData(te::da::Expression* restriction,
85  te::common::TraverseType travType,
86  const te::common::AccessPolicy accessPolicy) const
87 {
88  return std::auto_ptr<te::da::DataSet>();
89 }
90 
91 
92 
93 std::auto_ptr<te::da::DataSet> te::graph::Layer::getData(const te::da::ObjectIdSet* oids,
94  te::common::TraverseType travType,
95  const te::common::AccessPolicy accessPolicy) const
96 {
97  return std::auto_ptr<te::da::DataSet>();
98 }
99 
100 
101 const std::string& te::graph::Layer::getType() const
102 {
103  return sm_type;
104 }
105 
107 {
108  return true;
109 }
110 
111 void te::graph::Layer::draw(te::map::Canvas* canvas, const te::gm::Envelope& bbox, int srid)
112 {
113  assert(m_renderer.get());
114  m_renderer->draw(this, canvas, bbox, srid);
115 }
116 
118 {
119  return m_graph;
120 }
121 
123 {
124  m_graph = g;
125 
126  //set graph parameters
127  if(m_graph->getMetadata())
128  {
129  this->setSRID(m_graph->getMetadata()->getSRID());
130  this->setExtent(*m_graph->getMetadata()->getEnvelope());
131  }
132 }
133 
135 {
136  return m_renderer.get();
137 }
138 
140 {
141  m_renderer.reset(renderer);
142 }
void setGraph(te::graph::AbstractGraph *ds)
It sets the graph associated to the layer.
Definition: Layer.cpp:122
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:55
virtual std::auto_ptr< te::da::DataSetType > getSchema() const
It returns the layer schema.
Definition: Layer.cpp:48
te::graph::AbstractGraph * getGraph() const
It returns the graph associated to the layer.
Definition: Layer.cpp:117
virtual bool isValid() const
It returns true if the layer can be drawn, otherwise, it returns false.
Definition: Layer.cpp:106
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:44
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
URI C++ Library.
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:101
LayerRenderer * getRenderer() const
It returns the renderer used to paint this layer.
Definition: Layer.cpp:134
void setRenderer(LayerRenderer *renderer)
It sets the renderer used to paint this layer.
Definition: Layer.cpp:139
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:111
static const std::string sm_type
A static data member used in the implementation of getType method.
Definition: Layer.h:275