Lizmap Web Client 3.11.0

GroupIndex
in package

FinalYes

Give a stable position to each distinct value, in order of first appearance.

The index is shared by all the traces of a plot, so that the aggregated values of every trace are aligned on the same X values.

Values are not used directly as PHP array keys: it would cast floats to int ("1.5" and "1.7" in the same group) and numeric strings to int.

Table of Contents

Properties

$positions  : array<string, int>
$values  : array<int, mixed>

Methods

count()  : int
Get the number of distinct values.
keyOf()  : string
Get the key identifying a group value.
positionOf()  : int
Get the position of the given value, adding it if not yet known.
values()  : array<int, mixed>
Get the distinct values.

Properties

$positions

private array<string, int> $positions = array()

$values

private array<int, mixed> $values = array()

Methods

count()

Get the number of distinct values.

public count() : int
Return values
int —

the number of distinct values

keyOf()

Get the key identifying a group value.

public static keyOf(mixed $value) : string

Two values get the same key only if they are the same group: same type and same value. It is used as PHP array key by the index, and to compare the groups of consecutive features when they are sorted.

Parameters
$value : mixed

the group value: a scalar, or an array for groups made of several values

Return values
string —

the key of the value

positionOf()

Get the position of the given value, adding it if not yet known.

public positionOf(mixed $value) : int
Parameters
$value : mixed

the group value: a scalar, or an array for groups made of several values

Return values
int —

the position of the value, starting at 0

values()

Get the distinct values.

public values() : array<int, mixed>
Return values
array<int, mixed> —

the distinct values, in order of first appearance

On this page

Search results