CreateIsolinesCore.h
Go to the documentation of this file.
1 /* Copyright (C) 2001-2009 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/mnt/core/CreateIsolines.h
22 
23  \brief This file contains a class that represents the create isolines.
24 
25  \reference Adapted from TerraLib4.
26 */
27 
28 #ifndef __TERRALIB_MNT_INTERNAL_CREATEISOLINES_H
29 #define __TERRALIB_MNT_INTERNAL_CREATEISOLINES_H
30 
31 // Terralib Includes
32 #include "Config.h"
33 #include "CreateIsolinesParams.h"
34 
35 #include "../../../../src/terralib/dataaccess.h"
36 #include "../../../../src/terralib/dataaccess/datasource/DataSourceFactory.h"
37 #include "../../../../src/terralib/memory/DataSet.h"
38 #include "../../../../src/terralib/common/Holder.h"
39 #include "../../../../src/terralib/statistics/core/Enums.h"
40 
41 // STL Includes
42 #include <map>
43 #include <memory>
44 
45 
46 namespace te
47 {
48  //forward declarations
49  namespace da { class DataSetType; }
50  namespace gm { class Geometry; }
51  namespace mem { class DataSet; }
52 }
53 
55 {
57  int m_numRows;
60  RasterBlockSize() : m_idThread(0),
61  m_numRows(0),
62  m_initalRow(0),
63  m_finalRow(0) {}
64 };
65 
67 {
68  public:
69 
70  /*! \brief Default constructor. */
72 
73  /*! \brief Virtual destructor. */
75 
76  public:
77 
78  double m_quota;
79  int m_srid;
80  std::vector<te::gm::LineString*> m_vecSegments;
81  std::vector<te::gm::LineString*> m_lsOut;
82 };
83 
85 {
86  public:
87 
88  /*! \brief Default constructor. */
90 
91  /*! \brief Virtual destructor. */
93 
94  public:
95 
96  std::auto_ptr<te::rst::Raster> m_rasterPtr;
97  std::vector< std::vector<te::gm::LineString*> > m_vecSegments;
98  std::vector<double> m_nvals;
99 };
100 
101 namespace te
102 {
103  namespace mnt
104  {
106  {
107  /*!
108  \class CreateIsolines
109 
110  \brief Class used to execute the create isolines
111 
112  */
113 
114  public:
115 
116  /*! \brief Default constructor. */
117  CreateIsolines();
118 
119  /*! \brief Virtual destructor. */
120  ~CreateIsolines();
121 
122  public:
123 
124  void setInput(te::da::DataSourcePtr inRasterDsrc,
125  std::string inRasterName,
126  std::auto_ptr<te::da::DataSetType> inDsetType);
127 
128  std::auto_ptr<te::rst::Raster> getPrepareRaster();
129 
130  void setParams(std::vector<double> &nval, std::vector<double> &gval, double vmax, double vmin, double dummy, bool hasDummy);
131 
132  void setOutput(te::da::DataSourcePtr outDsrc, std::string dsname);
133 
134  bool run(std::auto_ptr<te::rst::Raster> raster);
135 
136  static bool generateSegments(std::auto_ptr<te::rst::Raster> raster, std::vector<double> nvals, std::vector< std::vector<te::gm::LineString*> >& vecSegments);
137 
138  static bool connectLines(std::vector<te::gm::LineString*> vec, int srid, std::vector<te::gm::LineString*>& lsOut);
139 
140  static void interpolacao(int direction, te::gm::LineString* line, double quota, double coord, double c_inf, double c_sup, double z_inf, double z_sup);
141 
142  static bool connectLinesThreaded(ConnectLinesParams* params);
143 
144  static void firstCaseSpecial(double quota, double& lineSupLeft, double& lineSupRigth, double& lineInfLeft, double& lineInfRigth);
145 
146  static void segments(int idQuota, te::gm::LineString* line, double quota, double ylg_sup, double xlg_ant, double xlg_pos, double ylg_inf,
147  double& lineSupLeft, double& lineSupRigth, double& lineInfLeft, double& lineInfRigth, std::vector< std::vector<te::gm::LineString*> >& vecSegments);
148 
149  static bool generateSegmentsThreaded(GenerateSegmentsParams* params);
150 
151  std::vector<RasterBlockSize> calculateBlocks(unsigned int numRows, unsigned int numThreads);
152 
153  void rstMemoryBlock(std::auto_ptr<te::rst::Raster> raster, std::vector<RasterBlockSize> vecBlocks, std::vector<GenerateSegmentsParams*>& vecGenerateParams);
154 
155  bool connectLines1(std::vector<te::gm::LineString*> vecSegments, double scale, std::vector<te::gm::LineString*>& lsOut);
156  bool connectLines(std::vector<te::gm::LineString*> vecSegments, std::vector<te::gm::LineString*>& lsOut);
157 
158  protected:
159 
160  /*! Function used to create the output dataset */
161  std::auto_ptr<te::mem::DataSet> createDataSet(te::da::DataSet* inputDataSet, te::da::DataSetType* dsType);
162 
164  std::string m_inRasterName;
165  std::auto_ptr<te::da::DataSetType> m_inRasterDsType;
166 
168  std::string m_outDsetName;
169 
170  std::vector<double> m_values;
171  std::vector<double> m_guidevalues;
172  int m_srid;
173 
174  static double m_vmax;
175  static double m_vmin;
176  static double m_dummy;
177  static bool m_hasDummy;
178  };
179  }
180 }
181 
182 #endif //__TERRALIB_MNT_INTERNAL_CREATEISOLINES_H
std::vector< double > m_guidevalues
~GenerateSegmentsParams()
Virtual destructor.
ConnectLinesParams()
Default constructor.
boost::shared_ptr< DataSource > DataSourcePtr
Definition: DataSource.h:1438
std::vector< te::gm::LineString * > m_vecSegments
A class that models the description of a dataset.
Definition: DataSetType.h:72
#define TEMNTEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:41
std::vector< double > m_values
te::da::DataSourcePtr m_inRasterDsrc
std::vector< std::vector< te::gm::LineString * > > m_vecSegments
LineString is a curve with linear interpolation between points.
Definition: LineString.h:62
URI C++ Library.
std::vector< te::gm::LineString * > m_lsOut
A dataset is the unit of information manipulated by the data access module of TerraLib.
Definition: DataSet.h:112
GenerateSegmentsParams()
Default constructor.
te::da::DataSourcePtr m_outDsrc
std::auto_ptr< te::rst::Raster > m_rasterPtr
std::vector< double > m_nvals
~ConnectLinesParams()
Virtual destructor.
std::auto_ptr< te::da::DataSetType > m_inRasterDsType