~ubuntu-branches/ubuntu/trusty/qgis/trusty

« back to all changes in this revision

Viewing changes to src/analysis/interpolation/qgsinterpolator.h

  • Committer: Bazaar Package Importer
  • Author(s): Johan Van de Wauw
  • Date: 2010-07-11 20:23:24 UTC
  • mfrom: (3.1.4 squeeze)
  • Revision ID: james.westby@ubuntu.com-20100711202324-5ktghxa7hracohmr
Tags: 1.4.0+12730-3ubuntu1
* Merge from Debian unstable (LP: #540941).
* Fix compilation issues with QT 4.7
* Add build-depends on libqt4-webkit-dev 

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/***************************************************************************
 
2
                              qgsinterpolator.h
 
3
                              ------------------------
 
4
  begin                : March 10, 2008
 
5
  copyright            : (C) 2008 by Marco Hugentobler
 
6
  email                : marco dot hugentobler at karto dot baug dot ethz dot ch
 
7
 ***************************************************************************/
 
8
 
 
9
/***************************************************************************
 
10
 *                                                                         *
 
11
 *   This program is free software; you can redistribute it and/or modify  *
 
12
 *   it under the terms of the GNU General Public License as published by  *
 
13
 *   the Free Software Foundation; either version 2 of the License, or     *
 
14
 *   (at your option) any later version.                                   *
 
15
 *                                                                         *
 
16
 ***************************************************************************/
 
17
 
 
18
#ifndef QGSINTERPOLATOR_H
 
19
#define QGSINTERPOLATOR_H
 
20
 
 
21
#include <QVector>
 
22
 
 
23
class QgsVectorLayer;
 
24
class QgsGeometry;
 
25
 
 
26
struct ANALYSIS_EXPORT vertexData
 
27
{
 
28
  double x;
 
29
  double y;
 
30
  double z;
 
31
};
 
32
 
 
33
/**Interface class for interpolations. Interpolators take
 
34
the vertices of a vector layer as base data. The z-Value
 
35
can be an attribute or the z-coordinates in case of 25D types*/
 
36
class ANALYSIS_EXPORT QgsInterpolator
 
37
{
 
38
  public:
 
39
    /**Describes the type of input data*/
 
40
    enum InputType
 
41
    {
 
42
      POINTS,
 
43
      STRUCTURE_LINES,
 
44
      BREAK_LINES
 
45
    };
 
46
 
 
47
    /**A layer together with the information about interpolation attribute / z-coordinate interpolation and the type (point, structure line, breakline)*/
 
48
    struct LayerData
 
49
    {
 
50
      QgsVectorLayer* vectorLayer;
 
51
      bool zCoordInterpolation;
 
52
      int interpolationAttribute;
 
53
      InputType mInputType;
 
54
    };
 
55
 
 
56
    QgsInterpolator( const QList<LayerData>& layerData );
 
57
 
 
58
    virtual ~QgsInterpolator();
 
59
 
 
60
    /**Calculates interpolation value for map coordinates x, y
 
61
       @param x x-coordinate (in map units)
 
62
       @param y y-coordinate (in map units)
 
63
       @param result out: interpolation result
 
64
       @return 0 in case of success*/
 
65
    virtual int interpolatePoint( double x, double y, double& result ) = 0;
 
66
 
 
67
    /**Use a vector attribute as interpolation value*/
 
68
    void enableAttributeValueInterpolation( int attribute );
 
69
 
 
70
  protected:
 
71
    /**Caches the vertex and value data from the provider. All the vertex data
 
72
     will be held in virtual memory
 
73
    @return 0 in case of success*/
 
74
    int cacheBaseData();
 
75
 
 
76
    QVector<vertexData> mCachedBaseData;
 
77
 
 
78
    /**Flag that tells if the cache already has been filled*/
 
79
    bool mDataIsCached;
 
80
 
 
81
    //Information about the input vector layers and the attributes (or z-values) that are used for interpolation
 
82
    QList<LayerData> mLayerData;
 
83
 
 
84
  private:
 
85
    QgsInterpolator(); //forbidden
 
86
    /**Helper method that adds the vertices of a geometry to the mCachedBaseData
 
87
       @param geom the geometry
 
88
       @param zCoord true if the z-coordinate of the geometry is to be interpolated
 
89
       @param attributeValue the attribute value for interpolation (if not interpolated from z-coordinate)
 
90
     @return 0 in case of success*/
 
91
    int addVerticesToCache( QgsGeometry* geom, bool zCoord, double attributeValue );
 
92
 
 
93
 
 
94
};
 
95
 
 
96
#endif