UNPKG

@grafana/ui

Version:
1 lines 1.49 kB
{"version":3,"file":"utils.cjs","sources":["../../../../../src/components/Table/geo/utils.ts"],"sourcesContent":["import { type Geometry } from 'ol/geom';\n\nimport { type DataFrame, FieldType } from '@grafana/data';\n\n/**\n * Type guard to check if a value is an OpenLayers Geometry object.\n * Avoids importing the entire OpenLayers library in files that just need to check for Geometry types.\n * @param value the value to check.\n * @returns true if the value is a Geometry object\n */\nexport function isGeometry(value: unknown): value is Geometry {\n return typeof value === 'object' && value != null && 'intersectsCoordinate' in value;\n}\n\n/**\n * Checks if a DataFrame contains at least one geo field with at least one non-null Geometry value.\n * @param frame the DataFrame to check.\n * @returns true if the DataFrame contains geo fields\n */\nexport function hasGeoCell(frame: DataFrame): boolean {\n return frame.fields.some((field) => {\n if (field.type !== FieldType.geo) {\n return false;\n }\n\n return field.values.some(isGeometry);\n });\n}\n"],"names":["FieldType"],"mappings":";;;;;;;AAUO,SAAS,WAAW,KAAA,EAAmC;AAC5D,EAAA,OAAO,OAAO,KAAA,KAAU,QAAA,IAAY,KAAA,IAAS,QAAQ,sBAAA,IAA0B,KAAA;AACjF;AAOO,SAAS,WAAW,KAAA,EAA2B;AACpD,EAAA,OAAO,KAAA,CAAM,MAAA,CAAO,IAAA,CAAK,CAAC,KAAA,KAAU;AAClC,IAAA,IAAI,KAAA,CAAM,IAAA,KAASA,cAAA,CAAU,GAAA,EAAK;AAChC,MAAA,OAAO,KAAA;AAAA,IACT;AAEA,IAAA,OAAO,KAAA,CAAM,MAAA,CAAO,IAAA,CAAK,UAAU,CAAA;AAAA,EACrC,CAAC,CAAA;AACH;;;;;"}