Files
grafana/public/app/plugins/panel/geomap/utils/checkFeatureMatchesStyleRule.ts
Leon Sorokin 18e3e0ca8d FieldMatchers: Add match by value (reducer) (#64477)
Co-authored-by: Ryan McKinley <ryantxu@gmail.com>
2023-03-10 17:17:29 -06:00

17 lines
592 B
TypeScript

import { FeatureLike } from 'ol/Feature';
import { compareValues } from '@grafana/data/src/transformations/matchers/compareValues';
import { FeatureRuleConfig } from '../types';
/**
* Check whether feature has property value that matches rule
* @param rule - style rule with an operation, property, and value
* @param feature - feature with properties and values
* @returns boolean
*/
export const checkFeatureMatchesStyleRule = (rule: FeatureRuleConfig, feature: FeatureLike) => {
const val = feature.get(rule.property);
return compareValues(val, rule.operation, rule.value);
};