Subset

relational-functions subset

⚠️ OBSOLETE: This function is deprecated in GeoDMS 19.x and obsolete in GeoDMS 20.x. It will be removed in a future version.

Use instead: select_with_org_rel or select, combined with collect_by_cond for collecting selected attribute values.

syntax

  • subset(condition)

definition

subset(condition) results in a new domain-unit with a relation to the entries of the domain unit of the condition, for which the values of the condition argument are true.

The resulting value-type of the domain unit is derived from the domain unit of the condition argument:

  • uint32 for conditions with uint32, boolean, spoint or wpoint value-type
  • uint8 for conditions with uint8 value type
  • uint16 for conditions with uint16 value type
  • uint64 for conditions with uint64, ipoint or upoint value type

The explicit subset_uint32, subset_uint16 and subset_uint8 functions can be used in the same manner as the subset function, to create a new domain unit with an explicit value type.

description

The subset function generates a subitem, named Nr_OrgEntity. This data-item contains the relation towards the domain unit of the condition argument.

The Nr_OrgEntity data-item can be used in a lookup function to relate attributes to the new domain unit, see the example.

See this overview for when to choose which selection operator is feasable.

applies to

  • condition must be a boolean attribute or subexpression resulting in boolean values.

performance

O(n) where n = number of elements in the domain of condition. Single pass counting true values, then allocating result domain and populating Nr_OrgEntity.

selecting attributes of a table

The subset function results in a new domain unit. Attributes for this new domain need to be configured explicitly, see the example.

It is possible to configure all attributes (e.g. read from a .csv file) for the Subset domain unit with a script example presented below in the example, selecting all attributes paragraph.

example

unit<uint32> ZHCities := subset(City/RegionCode == 200)
{
   attribute<string> name := City/Name[Nr_OrgEntity];
}
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

ZHCities/nr_OrgEntity ZHCities/name
1 Rotterdam
3 Den Haag

domain ZHCities, nr of rows = 2

example, selecting all attributes

For this purpose we advice the new select_with_attr_by_org_rel or select_with_attr_by_cond functions.

see also