src/terralib/graph/maptools/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,
38  AbstractLayer* parent)
39  : te::map::AbstractLayer(id, title, parent),
40 
41  m_graph(nullptr)
42 {
43 }
44 
45 te::graph::Layer::~Layer() = default;
46 
47 std::unique_ptr<te::da::DataSetType> te::graph::Layer::getSchema() const
48 {
49  return std::unique_ptr<te::da::DataSetType>();
50 }
51 
52 std::unique_ptr<te::da::DataSet> te::graph::Layer::getData(
53  te::common::TraverseType /*travType*/,
54  const te::common::AccessPolicy /*accessPolicy*/) const
55 {
56  return std::unique_ptr<te::da::DataSet>();
57 }
58 
59 std::unique_ptr<te::da::DataSet> te::graph::Layer::getData(
60  const std::string& /*propertyName*/, const te::gm::Envelope* /*e*/,
62  const te::common::AccessPolicy /*accessPolicy*/) const
63 {
64  return std::unique_ptr<te::da::DataSet>();
65 }
66 
67 std::unique_ptr<te::da::DataSet> te::graph::Layer::getData(
68  const std::string& /*propertyName*/, const te::gm::Geometry* /*g*/,
70  const te::common::AccessPolicy /*accessPolicy*/) const
71 {
72  return std::unique_ptr<te::da::DataSet>();
73 }
74 
75 std::unique_ptr<te::da::DataSet> te::graph::Layer::getData(
76  te::da::Expression* /*restriction*/, te::common::TraverseType /*travType*/,
77  const te::common::AccessPolicy /*accessPolicy*/) const
78 {
79  return std::unique_ptr<te::da::DataSet>();
80 }
81 
82 std::unique_ptr<te::da::DataSet> te::graph::Layer::getData(
83  const te::da::ObjectIdSet* /*oids*/, te::common::TraverseType /*travType*/,
84  const te::common::AccessPolicy /*accessPolicy*/) const
85 {
86  return std::unique_ptr<te::da::DataSet>();
87 }
88 
89 
90 const std::string& te::graph::Layer::getType() const
91 {
92  return sm_type;
93 }
94 
96 {
97  return true;
98 }
99 
100 void te::graph::Layer::draw(te::map::Canvas* canvas, const te::gm::Envelope& bbox, int srid, const double& scale, bool* cancel)
101 {
102  assert(m_renderer.get());
103  m_renderer->draw(this, canvas, bbox, srid, scale, cancel);
104 }
105 
107 {
108  return m_graph;
109 }
110 
112 {
113  m_graph = g;
114 
115  //set graph parameters
116  if(m_graph->getMetadata())
117  {
118  this->setSRID(m_graph->getMetadata()->getSRID());
120  }
121 }
122 
124 {
125  return m_renderer.get();
126 }
127 
129 {
130  m_renderer.reset(renderer);
131 }
void setGraph(te::graph::AbstractGraph *ds)
It sets the graph associated to the layer.
virtual int getSRID()
Used to get the SRID of the geometry elements associated with this graph.
te::graph::AbstractGraph * getGraph() const
It returns the graph associated to the layer.
virtual bool isValid() const
It returns true if the layer can be drawn, otherwise, it returns false.
SpatialRelation
Spatial relations between geometric objects.
virtual std::unique_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.
virtual te::gm::Envelope * getEnvelope()
Used to get the bounding box of the geometry elements associated with this graph. ...
This is an abstract class that models a query expression.
It renders the objects associated to a Layer.
virtual te::graph::GraphMetadata * getMetadata()=0
Function used to access the graph metadata.
virtual void draw(te::map::Canvas *canvas, const te::gm::Envelope &bbox, int srid, const double &scale, bool *cancel)
It draws the layer geographic objects in the given canvas using the informed SRS. ...
AccessPolicy
Supported data access policies (can be used as bitfield).
TraverseType
A dataset can be traversed in two ways:
An Envelope defines a 2D rectangular region.
~Layer()
Destructor.
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.
Definition: Attributes.h:37
Layer(const std::string &id, const std::string &title, AbstractLayer *parent=0)
It initializes a new Layer.
virtual void setExtent(const te::gm::Envelope &mbr)
It sets the Layer extent (or minimum bounding box).
virtual const std::string & getType() const
It returns the layer type.
LayerRenderer * getRenderer() const
It returns the renderer used to paint this layer.
void setRenderer(LayerRenderer *renderer)
It sets the renderer used to paint this layer.
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
virtual std::unique_ptr< te::da::DataSetType > getSchema() const
It returns the layer schema.
te::graph::AbstractGraph * m_graph
The graph associated to this Layer.
It renders the objects associated to a Layer.
Definition: LayerRenderer.h:57
A canvas is an abstraction of a drawing area.
virtual void setSRID(int srid)
It sets the Spatial Reference System ID associated to the Layer.
static const std::string sm_type
A static data member used in the implementation of getType method.
std::unique_ptr< LayerRenderer > m_renderer
A pointer to the internal renderer used to paint this layer.