Ilwis-Objects  1.0
GIS and Remote Sensing framework for data access and processing
 All Classes Functions Enumerations Pages
numericoperation.h
1 #ifndef NUMERICOPERATION_H
2 #define NUMERICOPERATION_H
3 
4 namespace Ilwis {
5 class KERNELSHARED_EXPORT NumericOperation : public OperationImplementation
6 {
7 public:
8  enum OperatorType{ otPLUS, otMINUS, otMULT, otDIV};
9 
11 
12 
13 
14 protected:
15  NumericOperation(quint64 metaid,const Ilwis::OperationExpression &expr);
16 
17  NumericRange *constructRangeFrom(const SPNumericRange& range1, const SPNumericRange& range2) const;
18  NumericRange *constructRangeFrom(const SPNumericRange& range, double number) const;
19  void mathoperator(const QString& oper);
20  double calc(double v1, double v2) const{
21  if ( v1 != rUNDEF && v2 != rUNDEF) {
22  switch(_operator) {
23  case otPLUS:
24  return v1 + v2;
25  case otMINUS:
26  return v1 - v2;
27  case otDIV:
28  if ( v2 != 0)
29  return v1 / v2;
30  else
31  return rUNDEF;
32  break;
33  case otMULT:
34  return v1 * v2;break;
35  }
36  }
37  return rUNDEF;
38  }
39 
40  double _number1 = rUNDEF;
41  double _number2 = rUNDEF;
42  OperatorType _operator;
43 };
44 }
45 
46 #endif // NUMERICOPERATION_H