Maptitude GISDK Help

Vectors

Vectors are very much like arrays, except that all the elements are of the same type, allowing for efficient storage and for vector operations. They are also like compound variables, since they have a GISDK function for creating them, Vector(), and selectors for getting and setting values.

The current types are double, float, long, short and string.

Vectors can be created from view|sets or other vectors. Here are some examples:

view = GetView()

v2 = GetDataVector(view + "|", "ID", )

v3 = v1 + sin(v2)

v4 = if (v1 > 0) then v1 else v2

All vector operations are done element by element. For example, v4 above is a vector of the same length as v1 and v2. Element v4[i] gets the value of the equivalent v1 element if that is greater than zero, otherwise it gets the value of the v2 element.

Although the length and row-based properties of the resulting vector are the same, the vector type may end up being different.  For example, v2 above is a vector of integer values, whereas v3 will have real values, because of the sin() operation.

Two vectors of different length or with a different base cannot be mixed. For example,

v = v1 + v2 

will fail if the vectors have different lengths or a different base. You can change the RowBased property and the values of individual elements, but not the length of the vector:

v.rowbased = False

v[3] = -5.2

v.length = 10 // Causes an error

When a vector is passed as an argument to a function that takes numeric arguments the function is applied element-wise, resulting in a vector of the same length as the input vector.

Vectors have the same selectors as arrays:

len = v.length // Get the length of the vector

x = v[1] + v[len] // Add the first and last elements in the vector

Vectors also have the following selectors:

Selector

Type

Description

Type

String

The vector element type: double, float, long, short, or string

RowBased

Boolean

True if the vector is row-based (1xN) or False if it is column-based (Nx1)

ColumnBased

Boolean

True if the vector is column-based (Nx1) or False if it is row-based (1xN)

Here are some examples:

ShowMessage("Vector is of type " + v.type)

if (v.rowbased) then ShowMessage("Row Based Vector")

else ShowMessage("Column Based Vector") 

Using object-oriented programming, arrays now have several methods that can be called on them; see Vector Methods.

A set of GISDK functions is available for working with vectors; see Vector Functions

See also:

Vector Methods

Vector Functions

 

 

©2025 Caliper Corporation www.caliper.com