select_with_attr_by_cond

selection-functions select_with_attr_by_cond

syntax

  • select_with_attr_by_cond(src_tree_item, condition)
  • select_uint8_with_attr_by_cond(src_tree_item, condition)
  • select_uint16_with_attr_by_cond(src_tree_item, condition)
  • select_uint32_with_attr_by_cond(src_tree_item, condition)
  • select_uint64_with_attr_by_cond(src_tree_item, condition)

    definition

select_with_attr_by_cond(src_tree_item, condition) results in a new domain-unit for which the values of the condition argument are true. Additionally, all subitems from the src_tree_item argument with the same domain unit as the condition become subitems of the resulting select_with_attr_by_cond unit and with this resulting unit as new domain unit.

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 select_uint8_with_attr_by_cond, select_uint16_with_attr_by_cond, select_uint32_with_attr_by_cond and select_uint64_with_attr_by_cond functions can be used in the same manner as the select_with_attr_by_cond function, to create a new domain unit with the explicit value type.

Between versions 8.6.0 and 8.7.2 the name select_many was used for the select_with_attr_by_cond function.

description

The select_with_attr_by_cond function does not generate a relation to the original domain, as the select_with_attr_by_org_rel function does.

The select_with_attr_by_cond function is efficient for larger selections, think about selection with 3% or more of the entries of the original domain. For smaller selections, the select_with_attr_by_org_rel function is advised.

The select_data function can be used in to relate attributes to the new domain unit.

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

If you want to also collect attributes from a container with the same domain unit of the condition. You can use the collect_attr_by_org_rel.

applies to

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

since version

8.8.0

example

unit<uint32> City: StorageName = "city.csv", StorageType = "gdal.vect", StoragReadOnly = "True"
{
   attribute<string> name
   attribute<uint32> RegionCode;
}

unit<uint32> ZHCities := select_with_attr_by_cond(City, City/RegionCode == 200)
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/name ZHCities/regionCode
Rotterdam 200
Den Haag 200

domain ZHCities, nr of rows = 2

The subitems: name, regionCode are generated by the configured select_with_attr_by_cond function.

see also