/usr/include/osgEarthSymbology/Expression is in libosgearth-dev 2.9.0+dfsg-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 | /* -*-c++-*- */
/* osgEarth - Dynamic map generation toolkit for OpenSceneGraph
* Copyright 2016 Pelican Mapping
* http://osgearth.org
*
* osgEarth is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
#ifndef OSGEARTHSYMBOLOGY_EXPRESSION_H
#define OSGEARTHSYMBOLOGY_EXPRESSION_H 1
#include <osgEarthSymbology/Common>
#include <osgEarth/Config>
#include <osgEarth/URI>
#include <osgEarth/GeoData>
#include <osgEarth/TileKey>
namespace osgEarth { namespace Symbology
{
/**
* Simple numeric expression evaluator with variables.
*/
class OSGEARTHSYMBOLOGY_EXPORT NumericExpression
{
public:
typedef std::pair<std::string,unsigned> Variable;
typedef std::vector<Variable> Variables;
public:
NumericExpression();
NumericExpression( const Config& conf );
/** Construct a new expression from the infix string. */
NumericExpression( const std::string& expr );
/** Construct a new static expression from a value */
NumericExpression( double staticValue );
/** Copy ctor. */
NumericExpression( const NumericExpression& rhs );
/** dtor */
virtual ~NumericExpression() { }
/** Set the result to a literal value. */
void setLiteral( double staticValue );
/** Access the expression variables. */
const Variables& variables() const { return _vars; }
/** Set the value of a variable. */
void set( const Variable& var, double value );
/** Evaluate the expression. */
double eval() const;
/** Gets the expression string. */
const std::string& expr() const { return _src; }
/** Whether the expression is empty */
bool empty() const { return _src.empty(); }
public:
Config getConfig() const;
void mergeConfig( const Config& conf );
private:
enum Op { OPERAND, VARIABLE, ADD, SUB, MULT, DIV, MOD, MIN, MAX, LPAREN, RPAREN, COMMA }; // in low-high precedence order
typedef std::pair<Op,double> Atom;
typedef std::vector<Atom> AtomVector;
typedef std::stack<Atom> AtomStack;
std::string _src;
AtomVector _rpn;
Variables _vars;
double _value;
bool _dirty;
void init();
};
//--------------------------------------------------------------------
/**
* Simple string expression evaluator with variables.
*/
class OSGEARTHSYMBOLOGY_EXPORT StringExpression
{
public:
typedef std::pair<std::string,unsigned> Variable;
typedef std::vector<Variable> Variables;
public:
StringExpression();
StringExpression( const Config& conf );
/** Construct a new expression from the infix string. */
StringExpression( const std::string& expr );
/** Construct an expression from the infix string and a URI context. */
StringExpression( const std::string& expr, const URIContext& uriContext );
/** Copy ctor. */
StringExpression( const StringExpression& rhs );
/** dtor */
virtual ~StringExpression() { }
/** Set the infix expr. */
void setInfix( const std::string& infix );
/** Set the infix expr to a literal string */
void setLiteral( const std::string& value );
/** Access the expression variables. */
const Variables& variables() const { return _vars; }
/** Set the value of a variable. */
void set( const Variable& var, const std::string& value );
/** Set the value of a names variable if it exists */
void set( const std::string& varName, const std::string& value );
/** Evaluate the expression. */
const std::string& eval() const;
/** Evaluate the expression as a URI.
TODO: it would be better to have a whole new subclass URIExpression */
URI evalURI() const;
/** Gets the expression string. */
const std::string& expr() const { return _src; }
/** Whether the expression is empty */
bool empty() const { return _src.empty(); }
void setURIContext( const URIContext& uriContext ) { _uriContext = uriContext; }
const URIContext& uriContext() const { return _uriContext; }
public:
Config getConfig() const;
void mergeConfig( const Config& conf );
private:
enum Op { OPERAND, VARIABLE }; // in low-high precedence order
typedef std::pair<Op,std::string> Atom;
typedef std::vector<Atom> AtomVector;
std::string _src;
AtomVector _infix;
Variables _vars;
std::string _value;
bool _dirty;
URIContext _uriContext;
void init();
};
} } // namespace osgEarth::Symbology
#endif // OSGEARTHSYMBOLOGY_EXPRESSION_H
|