KernelFunctions.h
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/sa/core/KernelFunctions.h
22 
23  \brief This file contains a functions used by the kernel operation.
24 
25  \reference Adapted from TerraLib4.
26 */
27 
28 #ifndef __TERRALIB_SA_INTERNAL_KERNELFUNCTIONS_H
29 #define __TERRALIB_SA_INTERNAL_KERNELFUNCTIONS_H
30 
31 //TerraLib
32 #include "../../geometry/Geometry.h"
33 #include "../../raster/Raster.h"
34 #include "../../sam/rtree/Index.h"
35 #include "../Config.h"
36 #include "KernelParams.h"
37 
38 //STL
39 #include <map>
40 
41 namespace te
42 {
43  //forward declarations
44  namespace mem { class DataSet; }
45 
46  namespace sa
47  {
48  ///< Tree used to store the dataset geometries MBR and its id value
50 
51  ///< Map with id, associated with geometry and its attribute (intensity value)
52  typedef std::map<int, std::pair<te::gm::Geometry*, double> > KernelMap;
53 
54  /*!
55  \brief Evaluates kernel value using a raster as output data and a fixed value for radius.
56 
57  \param params Pointer to a Kernel Params
58  \param kTree Reference to tree with all geometries from input data
59  \param kMap Reference to the kernel Map
60  \param raster Pointer to raster to set the kernel values
61  \param radius Radius used to calculate the kernel
62 
63  */
65 
66  /*!
67  \brief Evaluates kernel value using a raster as output data and a adaptative value for radius.
68 
69  \param params Pointer to a Kernel Params
70  \param kTree Reference to tree with all geometries from input data
71  \param kMap Reference to the kernel Map
72  \param raster Pointer to raster to set the kernel values
73 
74  */
76 
77  /*!
78  \brief Evaluates kernel ratio value using a raster as output data.
79 
80  \param params Pointer to a Kernel Params
81  \param rasterA Pointer to a raster A with kernel information
82  \param rasterB Pointer to a raster B with kernel information
83  \param raster Pointer to raster to set the kernel ratio values
84 
85  */
87 
88  /*!
89  \brief Evaluates kernel value using a dataset as output data and a fixed value for radius.
90 
91  \param params Pointer to a Kernel Params
92  \param kTree Reference to tree with all geometries from input data
93  \param kMap Reference to the kernel Map
94  \param ds Pointer to dataset to set the kernel values
95  \param kernelIdx Attribute index to save the kernel information
96  \param geomIdx Attribute index with geometry information
97  \param radius Radius used to calculate the kernel
98 
99  */
100  TESAEXPORT void DataSetStatRadiusKernel(te::sa::KernelInputParams* params, te::sa::KernelTree& kTree, te::sa::KernelMap& kMap, te::mem::DataSet* ds, int kernelIdx, int geomIdx, double radius);
101 
102  /*!
103  \brief Evaluates kernel value using a dataset as output data and a adaptative value for radius.
104 
105  \param params Pointer to a Kernel Params
106  \param kTree Reference to tree with all geometries from input data
107  \param kMap Reference to the kernel Map
108  \param ds Pointer to dataset to set the kernel values
109  \param kernelIdx Attribute index to save the kernel information
110  \param geomIdx Attribute index with geometry information
111 
112  */
113  TESAEXPORT void DataSetAdaptRadiusKernel(te::sa::KernelInputParams* params, te::sa::KernelTree& kTree, te::sa::KernelMap& kMap, te::mem::DataSet* ds, int kernelIdx, int geomIdx);
114 
115  /*!
116  \brief Evaluates kernel ratio value using a dataset as output data.
117 
118  \param params Pointer to a Kernel Params
119  \param dsA Pointer to a dataset A with kernel information
120  \param dsB Pointer to a dataset B with kernel information
121  \param dsOut Pointer to dataset to set the kernel ratio values
122  \param kernelIdx Attribute index to save the kernel information
123  \param geomIdx Attribute index with geometry information
124 
125  */
126  TESAEXPORT void DataSetRatioKernel(te::sa::KernelOutputParams* params, te::mem::DataSet* dsA, te::mem::DataSet* dsB, te::mem::DataSet* dsOut, int kernelIdx, int geomIdx);
127 
128  /*!
129  \brief Normalizes kernel values based on type of estimation.
130 
131  \param params Pointer to a Kernel Params (used to get the estimation type)
132  \param kMap Reference to the kernel Map
133  \param raster Pointer to raster with the kernel values
134  \param totKernel Sum of all kernel values from each raster pixel
135 
136  */
137  TESAEXPORT void GridKernelNormalize(te::sa::KernelInputParams* params, te::sa::KernelMap& kMap, te::rst::Raster* raster, double totKernel);
138 
139  /*!
140  \brief Normalizes kernel values based on type of estimation.
141 
142  \param params Pointer to a Kernel Params (used to get the estimation type)
143  \param kMap Reference to the kernel Map
144  \param ds Pointer to dataset to set the kernel values
145  \param kernelIdx Attribute index to save the kernel information
146  \param geomIdx Attribute index with geometry information
147  \param totKernel Sum of all kernel values from each raster pixel
148 
149  */
150  TESAEXPORT void DataSetKernelNormalize(te::sa::KernelInputParams* params, te::sa::KernelMap& kMap, te::mem::DataSet* ds, int kernelIdx, int geomIdx, double totKernel);
151 
152  /*!
153  \brief Evaluates kernel value of events with intensity
154 
155  \param params Pointer to a Kernel Params
156  \param kMap Reference to the kernel Map
157  \param radius Double value with radius information
158  \param coord Coord of the element to calculate the kernel value
159  \param idxVec Index of all elements that interects the box created by coord with radius value
160 
161  \return Kernel value for one element.
162  */
163  TESAEXPORT double KernelValue(te::sa::KernelInputParams* params, te::sa::KernelMap& kMap, double radius, te::gm::Coord2D& coord, std::vector<int> idxVec);
164 
165  /*!
166  \brief Evaluates kernel ratio value
167 
168  \param params Pointer to a Kernel Params
169  \param area Value to represent the area of the element
170  \param kernelA Double value with kernel value from A element
171  \param kernelB Double value with kernel value from B element
172 
173  \return Kernel value for one element.
174  */
175  TESAEXPORT double KernelRatioValue(te::sa::KernelOutputParams* params, double area, double kernelA, double kernelB);
176 
177  /*!
178  \brief Kernel functions for Quartic type
179 
180  \param tau spatial threshold to define neighboorhood
181  \param distance distance between event and region centroid
182  \param intensity attribute value for event
183 
184  \return Kernel value
185  */
186  TESAEXPORT double KernelQuartic(double tau, double distance, double intensity);
187 
188  /*!
189  \brief Kernel functions for Normal type
190 
191  \param tau spatial threshold to define neighboorhood
192  \param distance distance between event and region centroid
193  \param intensity attribute value for event
194 
195  \return Kernel value
196  */
197  TESAEXPORT double KernelNormal(double tau, double distance, double intensity);
198 
199  /*!
200  \brief Kernel functions for Uniform type
201 
202  \param tau spatial threshold to define neighboorhood
203  \param distance distance between event and region centroid
204  \param intensity attribute value for event
205 
206  \return Kernel value
207  */
208  TESAEXPORT double KernelUniform(double tau, double distance, double intensity);
209 
210  /*!
211  \brief Kernel functions for Triangular type
212 
213  \param tau spatial threshold to define neighboorhood
214  \param distance distance between event and region centroid
215  \param intensity attribute value for event
216 
217  \return Kernel value
218  */
219  TESAEXPORT double KernelTriangular(double tau, double distance, double intensity);
220 
221  /*!
222  \brief Kernel functions for Negative Exponential type
223 
224  \param tau spatial threshold to define neighboorhood
225  \param distance distance between event and region centroid
226  \param intensity attribute value for event
227 
228  \return Kernel value
229  */
230  TESAEXPORT double KernelNegExponential(double tau, double distance, double intensity);
231 
232  /*!
233  \brief Calculates the geometric mean from kernel map (intensity value) using log.
234 
235  \param kMap Reference to the kernel Map
236 
237  \return Double value with the geometric mean
238 
239  */
241  }
242 }
243 
244 #endif //__TERRALIB_SA_INTERNAL_KERNELFUNCTIONS_H
Class that represents the kernel input parameters.
Definition: KernelParams.h:54
TESAEXPORT void DataSetAdaptRadiusKernel(te::sa::KernelInputParams *params, te::sa::KernelTree &kTree, te::sa::KernelMap &kMap, te::mem::DataSet *ds, int kernelIdx, int geomIdx)
Evaluates kernel value using a dataset as output data and a adaptative value for radius.
TESAEXPORT double KernelNegExponential(double tau, double distance, double intensity)
Kernel functions for Negative Exponential type.
std::map< int, std::pair< te::gm::Geometry *, double > > KernelMap
An utility struct for representing 2D coordinates.
Definition: Coord2D.h:40
This file contains a class that represents the kernel parameters.
Class that represents the kernel output parameters.
Definition: KernelParams.h:95
Implementation of a random-access dataset class for the TerraLib In-Memory Data Access driver...
Definition: DataSet.h:65
TESAEXPORT double KernelValue(te::sa::KernelInputParams *params, te::sa::KernelMap &kMap, double radius, te::gm::Coord2D &coord, std::vector< int > idxVec)
Evaluates kernel value of events with intensity.
TESAEXPORT double KernelUniform(double tau, double distance, double intensity)
Kernel functions for Uniform type.
TESAEXPORT double KernelQuartic(double tau, double distance, double intensity)
Kernel functions for Quartic type.
An abstract class for raster data strucutures.
Definition: Raster.h:71
URI C++ Library.
TESAEXPORT double KernelTriangular(double tau, double distance, double intensity)
Kernel functions for Triangular type.
TESAEXPORT void GridKernelNormalize(te::sa::KernelInputParams *params, te::sa::KernelMap &kMap, te::rst::Raster *raster, double totKernel)
Normalizes kernel values based on type of estimation.
#define TESAEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:133
TESAEXPORT double KernelNormal(double tau, double distance, double intensity)
Kernel functions for Normal type.
TESAEXPORT void GridAdaptRadiusKernel(te::sa::KernelInputParams *params, te::sa::KernelTree &kTree, te::sa::KernelMap &kMap, te::rst::Raster *raster)
Evaluates kernel value using a raster as output data and a adaptative value for radius.
TESAEXPORT double KernelGeometricMean(te::sa::KernelMap &kMap)
Calculates the geometric mean from kernel map (intensity value) using log.
TESAEXPORT void DataSetKernelNormalize(te::sa::KernelInputParams *params, te::sa::KernelMap &kMap, te::mem::DataSet *ds, int kernelIdx, int geomIdx, double totKernel)
Normalizes kernel values based on type of estimation.
TESAEXPORT void GridStatRadiusKernel(te::sa::KernelInputParams *params, te::sa::KernelTree &kTree, te::sa::KernelMap &kMap, te::rst::Raster *raster, double radius)
Evaluates kernel value using a raster as output data and a fixed value for radius.
TESAEXPORT void GridRatioKernel(te::sa::KernelOutputParams *params, te::rst::Raster *rasterA, te::rst::Raster *rasterB, te::rst::Raster *rasterOut)
Evaluates kernel ratio value using a raster as output data.
te::sam::rtree::Index< int > KernelTree
< Tree used to store the dataset geometries MBR and its id value
TESAEXPORT double KernelRatioValue(te::sa::KernelOutputParams *params, double area, double kernelA, double kernelB)
Evaluates kernel ratio value.
TESAEXPORT void DataSetRatioKernel(te::sa::KernelOutputParams *params, te::mem::DataSet *dsA, te::mem::DataSet *dsB, te::mem::DataSet *dsOut, int kernelIdx, int geomIdx)
Evaluates kernel ratio value using a dataset as output data.
TESAEXPORT void DataSetStatRadiusKernel(te::sa::KernelInputParams *params, te::sa::KernelTree &kTree, te::sa::KernelMap &kMap, te::mem::DataSet *ds, int kernelIdx, int geomIdx, double radius)
Evaluates kernel value using a dataset as output data and a fixed value for radius.