Attribute Expressions

GeoCrew

Each attribute has Expression property. It's provided for situations where property value gets expressed as mathematical formula, in other words - when property value depends on some other feature property/ies, both geometric and non-geometric. Expressions can be of unlimited size and depth, i.e. one property expression may include other property whose value may also evaluate as expression, etc. Here, we say evaluate to describe GeoView's "solving" an expression and producing some finite value out of it. Evaluated result gets cast (converted) into the hosting type, i.e. if attribute type is Double then evaluated result gets cast into a double value.


One should always have in mind atomicity of a feature - one feature can not relate to other feature, at least not by definition (by schema). This is due to the fact that, in real-world, no one guarantees there will be two features at all. Maybe there's one, maybe two, maybe hundred... and maybe none. No one can tell in advance how many features will be there and what form of spatial and non-spatial relations they'll get into (there's another topic covering this). As for attribute expression - it can not relate to some other feature's property, it may relate only to the current feature instance.


For example, based on the following element definition:


ELEMENT NAME="e"

ATTRIBUTE NAME="a", TYPE=String

ATTRIBUTE NAME="b", TYPE=Double

ATTRIBUTE NAME="c", TYPE=Double, EXPRESSION="b + 5"


there's a feature instance with following properties:


FEATURE NAME="e"

PROPERTY NAME="a", VALUE="Some string"

PROPERTY NAME="b", VALUE=100


Once evaluated, feature will carry following property values:


FEATURE NAME="e"

PROPERTY NAME="a", VALUE="Some string"

PROPERTY NAME="b", VALUE=100

PROPERTY NAME="c", VALUE=105 <<< Value evaluated using expression formula


Mathematical Formulas


Expressions support following mathematical formulas:


Function

Description

abs()

Returns absolute value given the specified value.

acos()

Returns angle whose cosine is the specified value.

asin()

Returns angle whose sine is the specified value.

atan()

Returns angle whose tangent is the specified value.

ceiling()

Returns the largest whole number greater than or equal to specified value.

cos()

Returns the cosine of the specified angle.

cosh()

Returns the hyperbolic cosine of the specified angle.

exp()

Returns e raised to the specified power.

floor()

Returns the largest whole number less than or equal to the specified value.

if()

Provides if(condition, then, else) branching.

log()

Returns the logarithm of a specified value.

log10()

Returns the base 10 logarithm of a specified value.

max()

Returns the maximum value among provided parameters.

min()

Returns the minimum value among provided parameters.

round()

Returns specified value rounded to the nearest whole number.

sign()

Returns a value indicating sign of the specified value (n<0=-1, n=0=0, n>0=1).

sin()

Returns the sine of the specified angle.

sinh()

Returns the hyperbolic sine of the specified angle.

sqrt()

Returns the square root of the specified value.

tan()

Returns the tagent of the specified angle.

tanh()

Returns the hyperbolic tangent of the specified angle.


Geometric Expressions


Geometric expressions are valid only if there's feature geometry present. Expressions support following geometric keywords:


Keyword

Description

[LENGTH]

Returns geometry length. In case of point geometry returns 0, in case of polygon geometry returns total perimeter.

[AREA]

Returns geometry area. In case of point and curve geometries returns 0.

[ELEVATION]

Returns geometry elevation. In case of point geometry returns Z ordinate value, otherwise returns 0.

[ROTATION]

Returns rotation (direction vector) of point geometry. Persisting rotation geometric property depends on FDO providers.


Other Expressions


Expressions also support following keywords:


Keyword

Description

[DATETIME]

Returns string representing DateTime in UTC format.

[YEAR]

Returns integer representing a year portion of DateTime.

[USERNAME]

Returns string representing registered user name for a package (not OS).