collect_by_cond
relational-functions collect_by_cond
syntax
- collect_by_cond(selection unit: S, condition: D -> Bool, values-attribute: D -> V)
- collect_by_cond(selection unit: S, values-attribute: D -> V)
definition
ad 1: collect_by_cond(selection unit: S, condition: D -> Bool, values-attribute: D -> V) results in an attribute S-> V with those values in values-attribute than correspond with the true-values of condition. Note that the cardinality of S must correspond with the number of true values in condition. This is always the case when S is defined as select(condition), or select_with_org_rel(condition).
ad 2: collect_by_cond(selection unit: S, values-attribute: D -> V) is defined as 1 when S has a calculation rule that resolves to select(condition), or select_with_org_rel(condition). If S has been defined otherwise, an error message will indicate that no operator could be found.
applies to
- selection domain unit: a unit with value-type of the group CanbeDomainUnit
- condition: must be a boolean attribute or subexpression resulting in boolean values.
- attribute: can be any attribute with the same domain unit as the condition argument
since version
8.8.0
example
unit<uint32> City: StorageName = "city.csv", StorageType = "gdal.vect", StorageReadOnly = "True"
{
attribute<string> name;
attribute<uint32> RegionCode;
}
unit<uint32> ZHCities := select_with_attr_by_cond(City, City/RegionCode == 200);
attribute<string> name (ZHCities) := collect_by_cond(ZHCities, City/RegionCode == 200, City/name);
City/RegionCode | City/Name |
---|---|
100 | Amsterdam |
200 | Rotterdam |
300 | Utrecht |
200 | Den Haag |
400 | Eindhoven |
null | Haarlem |
400 | Tilburg |
domain City, nr of rows = 7
name |
---|
Rotterdam |
Den Haag |
domain ZHCities, nr of rows = 2