@loaders.gl/geotiff 4.0.0-alpha.12 → 4.0.0-alpha.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6,19 +6,19 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.fromString = fromString;
8
8
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
- var _fastXmlParser = _interopRequireDefault(require("fast-xml-parser"));
9
+ var _fastXmlParser = require("fast-xml-parser");
10
10
  var _tiffUtils = require("../utils/tiff-utils");
11
11
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
12
12
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
13
- var PARSER_OPTIONS = {
13
+ var xmlParser = new _fastXmlParser.XMLParser({
14
14
  attributeNamePrefix: '',
15
- attrNodeName: 'attr',
16
- parseNodeValue: true,
15
+ attributesGroupName: 'attr',
16
+ parseTagValue: true,
17
17
  parseAttributeValue: true,
18
18
  ignoreAttributes: false
19
- };
19
+ });
20
20
  var parse = function parse(str) {
21
- return _fastXmlParser.default.parse(str, PARSER_OPTIONS);
21
+ return xmlParser.parse(str);
22
22
  };
23
23
  function fromString(str) {
24
24
  var res = parse(str);
@@ -1 +1 @@
1
- {"version":3,"file":"omexml.js","names":["_fastXmlParser","_interopRequireDefault","require","_tiffUtils","ownKeys","object","enumerableOnly","keys","Object","getOwnPropertySymbols","symbols","filter","sym","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","target","i","arguments","length","source","forEach","key","_defineProperty2","default","getOwnPropertyDescriptors","defineProperties","defineProperty","PARSER_OPTIONS","attributeNamePrefix","attrNodeName","parseNodeValue","parseAttributeValue","ignoreAttributes","parse","str","parser","fromString","res","OME","Error","ensureArray","Image","map","img","Channels","Pixels","Channel","c","attr","Color","intToRgba","_img$AquisitionDate","AquisitionDate","_img$Description","Description","image","format","sizes","name","size","concat","unit","join","SizeX","SizeY","Type","SizeZ","SizeT","SizeC"],"sources":["../../../../src/lib/ome/omexml.ts"],"sourcesContent":["import parser from 'fast-xml-parser';\nimport {ensureArray, intToRgba} from '../utils/tiff-utils';\n\n// WARNING: Changes to the parser options _will_ effect the types in types/omexml.d.ts.\nconst PARSER_OPTIONS = {\n // Nests attributes withtout prefix under 'attr' key for each node\n attributeNamePrefix: '',\n attrNodeName: 'attr',\n\n // Parses numbers for both attributes and nodes\n parseNodeValue: true,\n parseAttributeValue: true,\n\n // Forces attributes to be parsed\n ignoreAttributes: false\n};\n\nconst parse = (str: string): Root => parser.parse(str, PARSER_OPTIONS);\n\nexport function fromString(str: string) {\n const res = parse(str);\n if (!res.OME) {\n throw Error('Failed to parse OME-XML metadata.');\n }\n return ensureArray(res.OME.Image).map((img) => {\n const Channels = ensureArray(img.Pixels.Channel).map((c) => {\n if ('Color' in c.attr) {\n return {...c.attr, Color: intToRgba(c.attr.Color)};\n }\n return {...c.attr};\n });\n const {AquisitionDate = '', Description = ''} = img;\n const image = {\n ...img.attr,\n AquisitionDate,\n Description,\n Pixels: {\n ...img.Pixels.attr,\n Channels\n }\n };\n return {\n ...image,\n format() {\n const {Pixels} = image;\n\n const sizes = (['X', 'Y', 'Z'] as const)\n .map((name) => {\n const size = Pixels[`PhysicalSize${name}` as const];\n const unit = Pixels[`PhysicalSize${name}Unit` as const];\n return size && unit ? `${size} ${unit}` : '-';\n })\n .join(' x ');\n\n return {\n 'Acquisition Date': image.AquisitionDate,\n 'Dimensions (XY)': `${Pixels.SizeX} x ${Pixels.SizeY}`,\n 'Pixels Type': Pixels.Type,\n 'Pixels Size (XYZ)': sizes,\n 'Z-sections/Timepoints': `${Pixels.SizeZ} x ${Pixels.SizeT}`,\n Channels: Pixels.SizeC\n };\n }\n };\n });\n}\n\nexport type OMEXML = ReturnType<typeof fromString>;\nexport type DimensionOrder = 'XYZCT' | 'XYZTC' | 'XYCTZ' | 'XYCZT' | 'XYTCZ' | 'XYTZC';\n\n// Structure of node is determined by the PARSER_OPTIONS.\ntype Node<T, A> = T & {attr: A};\ntype Attrs<Fields extends string, T = string> = {[K in Fields]: T};\n\ntype OMEAttrs = Attrs<'xmlns' | 'xmlns:xsi' | 'xsi:schemaLocation'>;\ntype OME = Node<{Insturment: Insturment; Image: Image | Image[]}, OMEAttrs>;\n\ntype Insturment = Node<\n {Objective: Node<{}, Attrs<'ID' | 'Model' | 'NominalMagnification'>>},\n Attrs<'ID'>\n>;\n\ninterface ImageNodes {\n AquisitionDate?: string;\n Description?: string;\n Pixels: Pixels;\n InstrumentRef: Node<{}, {ID: string}>;\n ObjectiveSettings: Node<{}, {ID: string}>;\n}\ntype Image = Node<ImageNodes, Attrs<'ID' | 'Name'>>;\n\ntype PixelType =\n | 'int8'\n | 'int16'\n | 'int32'\n | 'uint8'\n | 'uint16'\n | 'uint32'\n | 'float'\n | 'bit'\n | 'double'\n | 'complex'\n | 'double-complex';\n\nexport type UnitsLength =\n | 'Ym'\n | 'Zm'\n | 'Em'\n | 'Pm'\n | 'Tm'\n | 'Gm'\n | 'Mm'\n | 'km'\n | 'hm'\n | 'dam'\n | 'm'\n | 'dm'\n | 'cm'\n | 'mm'\n | 'µm'\n | 'nm'\n | 'pm'\n | 'fm'\n | 'am'\n | 'zm'\n | 'ym'\n | 'Å'\n | 'thou'\n | 'li'\n | 'in'\n | 'ft'\n | 'yd'\n | 'mi'\n | 'ua'\n | 'ly'\n | 'pc'\n | 'pt'\n | 'pixel'\n | 'reference frame';\n\ntype PhysicalSize<Name extends string> = `PhysicalSize${Name}`;\ntype PhysicalSizeUnit<Name extends string> = `PhysicalSize${Name}Unit`;\ntype Size<Names extends string> = `Size${Names}`;\n\ntype PixelAttrs = Attrs<\n PhysicalSize<'X' | 'Y' | 'Z'> | 'SignificantBits' | Size<'T' | 'C' | 'Z' | 'Y' | 'X'>,\n number\n> &\n Attrs<PhysicalSizeUnit<'X' | 'Y' | 'Z'>, UnitsLength> &\n Attrs<'BigEndian' | 'Interleaved', boolean> & {\n ID: string;\n DimensionOrder: DimensionOrder;\n Type: PixelType;\n };\n\ntype Pixels = Node<\n {\n Channel: Channel | Channel[];\n TiffData: Node<{}, Attrs<'IFD' | 'PlaneCount'>>;\n },\n PixelAttrs\n>;\n\ntype ChannelAttrs =\n | {\n ID: string;\n SamplesPerPixel: number;\n Name?: string;\n }\n | {\n ID: string;\n SamplesPerPixel: number;\n Name?: string;\n Color: number;\n };\n\ntype Channel = Node<{}, ChannelAttrs>;\n\ntype Root = {OME: OME};\n"],"mappings":";;;;;;;;AAAA,IAAAA,cAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,UAAA,GAAAD,OAAA;AAA2D,SAAAE,QAAAC,MAAA,EAAAC,cAAA,QAAAC,IAAA,GAAAC,MAAA,CAAAD,IAAA,CAAAF,MAAA,OAAAG,MAAA,CAAAC,qBAAA,QAAAC,OAAA,GAAAF,MAAA,CAAAC,qBAAA,CAAAJ,MAAA,GAAAC,cAAA,KAAAI,OAAA,GAAAA,OAAA,CAAAC,MAAA,WAAAC,GAAA,WAAAJ,MAAA,CAAAK,wBAAA,CAAAR,MAAA,EAAAO,GAAA,EAAAE,UAAA,OAAAP,IAAA,CAAAQ,IAAA,CAAAC,KAAA,CAAAT,IAAA,EAAAG,OAAA,YAAAH,IAAA;AAAA,SAAAU,cAAAC,MAAA,aAAAC,CAAA,MAAAA,CAAA,GAAAC,SAAA,CAA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AAO;UACL,kBAAkB,EAAEP,KAAK,CAACH,cAAc;UACxC,iBAAiB,KAAAQ,MAAA,CAAKf,MAAM,CAACkB,KAAK,SAAAH,MAAA,CAAMf,MAAM,CAACmB,KAAK,CAAE;UACtD,aAAa,EAAEnB,MAAM,CAACoB,IAAI;UAC1B,mBAAmB,EAAER,KAAK;UAC1B,uBAAuB,KAAAG,MAAA,CAAKf,MAAM,CAACqB,KAAK,SAAAN,MAAA,CAAMf,MAAM,CAACsB,KAAK,CAAE;UAC5DvB,QAAQ,EAAEC,MAAM,CAACuB;QACnB,CAAC;MACH;IAAC;EAEL,CAAC,CAAC;AACJ"}
1
+ {"version":3,"file":"omexml.js","names":["_fastXmlParser","require","_tiffUtils","ownKeys","object","enumerableOnly","keys","Object","getOwnPropertySymbols","symbols","filter","sym","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","target","i","arguments","length","source","forEach","key","_defineProperty2","default","getOwnPropertyDescriptors","defineProperties","defineProperty","xmlParser","XMLParser","attributeNamePrefix","attributesGroupName","parseTagValue","parseAttributeValue","ignoreAttributes","parse","str","fromString","res","OME","Error","ensureArray","Image","map","img","Channels","Pixels","Channel","c","attr","Color","intToRgba","_img$AquisitionDate","AquisitionDate","_img$Description","Description","image","format","sizes","name","size","concat","unit","join","SizeX","SizeY","Type","SizeZ","SizeT","SizeC"],"sources":["../../../../src/lib/ome/omexml.ts"],"sourcesContent":["import {XMLParser} from 'fast-xml-parser';\nimport {ensureArray, intToRgba} from '../utils/tiff-utils';\n\n// WARNING: Changes to the parser options _will_ effect the types in types/omexml.d.ts.\nconst xmlParser = new XMLParser({\n // Nests attributes withtout prefix under 'attr' key for each node\n attributeNamePrefix: '',\n attributesGroupName: 'attr',\n\n // Parses numbers for both attributes and nodes\n parseTagValue: true,\n parseAttributeValue: true,\n\n // Forces attributes to be parsed\n ignoreAttributes: false\n});\n\nconst parse = (str: string): Root => xmlParser.parse(str);\n\nexport function fromString(str: string) {\n const res = parse(str);\n if (!res.OME) {\n throw Error('Failed to parse OME-XML metadata.');\n }\n return ensureArray(res.OME.Image).map((img) => {\n const Channels = ensureArray(img.Pixels.Channel).map((c) => {\n if ('Color' in c.attr) {\n return {...c.attr, Color: intToRgba(c.attr.Color)};\n }\n return {...c.attr};\n });\n const {AquisitionDate = '', Description = ''} = img;\n const image = {\n ...img.attr,\n AquisitionDate,\n Description,\n Pixels: {\n ...img.Pixels.attr,\n Channels\n }\n };\n return {\n ...image,\n format() {\n const {Pixels} = image;\n\n const sizes = (['X', 'Y', 'Z'] as const)\n .map((name) => {\n const size = Pixels[`PhysicalSize${name}` as const];\n const unit = Pixels[`PhysicalSize${name}Unit` as const];\n return size && unit ? `${size} ${unit}` : '-';\n })\n .join(' x ');\n\n return {\n 'Acquisition Date': image.AquisitionDate,\n 'Dimensions (XY)': `${Pixels.SizeX} x ${Pixels.SizeY}`,\n 'Pixels Type': Pixels.Type,\n 'Pixels Size (XYZ)': sizes,\n 'Z-sections/Timepoints': `${Pixels.SizeZ} x ${Pixels.SizeT}`,\n Channels: Pixels.SizeC\n };\n }\n };\n });\n}\n\nexport type OMEXML = ReturnType<typeof fromString>;\nexport type DimensionOrder = 'XYZCT' | 'XYZTC' | 'XYCTZ' | 'XYCZT' | 'XYTCZ' | 'XYTZC';\n\n// Structure of node is determined by the PARSER_OPTIONS.\ntype Node<T, A> = T & {attr: A};\ntype Attrs<Fields extends string, T = string> = {[K in Fields]: T};\n\ntype OMEAttrs = Attrs<'xmlns' | 'xmlns:xsi' | 'xsi:schemaLocation'>;\ntype OME = Node<{Insturment: Insturment; Image: Image | Image[]}, OMEAttrs>;\n\ntype Insturment = Node<\n {Objective: Node<{}, Attrs<'ID' | 'Model' | 'NominalMagnification'>>},\n Attrs<'ID'>\n>;\n\ninterface ImageNodes {\n AquisitionDate?: string;\n Description?: string;\n Pixels: Pixels;\n InstrumentRef: Node<{}, {ID: string}>;\n ObjectiveSettings: Node<{}, {ID: string}>;\n}\ntype Image = Node<ImageNodes, Attrs<'ID' | 'Name'>>;\n\ntype PixelType =\n | 'int8'\n | 'int16'\n | 'int32'\n | 'uint8'\n | 'uint16'\n | 'uint32'\n | 'float'\n | 'bit'\n | 'double'\n | 'complex'\n | 'double-complex';\n\nexport type UnitsLength =\n | 'Ym'\n | 'Zm'\n | 'Em'\n | 'Pm'\n | 'Tm'\n | 'Gm'\n | 'Mm'\n | 'km'\n | 'hm'\n | 'dam'\n | 'm'\n | 'dm'\n | 'cm'\n | 'mm'\n | 'µm'\n | 'nm'\n | 'pm'\n | 'fm'\n | 'am'\n | 'zm'\n | 'ym'\n | 'Å'\n | 'thou'\n | 'li'\n | 'in'\n | 'ft'\n | 'yd'\n | 'mi'\n | 'ua'\n | 'ly'\n | 'pc'\n | 'pt'\n | 'pixel'\n | 'reference frame';\n\ntype PhysicalSize<Name extends string> = `PhysicalSize${Name}`;\ntype PhysicalSizeUnit<Name extends string> = `PhysicalSize${Name}Unit`;\ntype Size<Names extends string> = `Size${Names}`;\n\ntype PixelAttrs = Attrs<\n PhysicalSize<'X' | 'Y' | 'Z'> | 'SignificantBits' | Size<'T' | 'C' | 'Z' | 'Y' | 'X'>,\n number\n> &\n Attrs<PhysicalSizeUnit<'X' | 'Y' | 'Z'>, UnitsLength> &\n Attrs<'BigEndian' | 'Interleaved', boolean> & {\n ID: string;\n DimensionOrder: DimensionOrder;\n Type: PixelType;\n };\n\ntype Pixels = Node<\n {\n Channel: Channel | Channel[];\n TiffData: Node<{}, Attrs<'IFD' | 'PlaneCount'>>;\n },\n PixelAttrs\n>;\n\ntype ChannelAttrs =\n | {\n ID: string;\n SamplesPerPixel: number;\n Name?: string;\n }\n | {\n ID: string;\n SamplesPerPixel: number;\n Name?: string;\n Color: number;\n };\n\ntype Channel = Node<{}, ChannelAttrs>;\n\ntype Root = {OME: OME};\n"],"mappings":";;;;;;;;AAAA,IAAAA,cAAA,GAAAC,OAAA;AACA,IAAAC,UAAA,GAAAD,OAAA;AAA2D,SAAAE,QAAAC,MAAA,EAAA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QACP,IAAOX,MAAM,GAAIU,KAAK,CAAfV,MAAM;QAEb,IAAMY,KAAK,GAAI,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAC3Bf,GAAG,CAAC,UAACgB,IAAI,EAAK;UACb,IAAMC,IAAI,GAAGd,MAAM,gBAAAe,MAAA,CAAgBF,IAAI,EAAY;UACnD,IAAMG,IAAI,GAAGhB,MAAM,gBAAAe,MAAA,CAAgBF,IAAI,UAAgB;UACvD,OAAOC,IAAI,IAAIE,IAAI,MAAAD,MAAA,CAAMD,IAAI,OAAAC,MAAA,CAAIC,IAAI,IAAK,GAAG;QAC/C,CAAC,CAAC,CACDC,IAAI,CAAC,KAAK,CAAC;QAEd,OAAO;UACL,kBAAkB,EAAEP,KAAK,CAACH,cAAc;UACxC,iBAAiB,KAAAQ,MAAA,CAAKf,MAAM,CAACkB,KAAK,SAAAH,MAAA,CAAMf,MAAM,CAACmB,KAAK,CAAE;UACtD,aAAa,EAAEnB,MAAM,CAACoB,IAAI;UAC1B,mBAAmB,EAAER,KAAK;UAC1B,uBAAuB,KAAAG,MAAA,CAAKf,MAAM,CAACqB,KAAK,SAAAN,MAAA,CAAMf,MAAM,CAACsB,KAAK,CAAE;UAC5DvB,QAAQ,EAAEC,MAAM,CAACuB;QACnB,CAAC;MACH;IAAC;EAEL,CAAC,CAAC;AACJ"}
@@ -1,13 +1,13 @@
1
- import parser from 'fast-xml-parser';
1
+ import { XMLParser } from 'fast-xml-parser';
2
2
  import { ensureArray, intToRgba } from '../utils/tiff-utils';
3
- const PARSER_OPTIONS = {
3
+ const xmlParser = new XMLParser({
4
4
  attributeNamePrefix: '',
5
- attrNodeName: 'attr',
6
- parseNodeValue: true,
5
+ attributesGroupName: 'attr',
6
+ parseTagValue: true,
7
7
  parseAttributeValue: true,
8
8
  ignoreAttributes: false
9
- };
10
- const parse = str => parser.parse(str, PARSER_OPTIONS);
9
+ });
10
+ const parse = str => xmlParser.parse(str);
11
11
  export function fromString(str) {
12
12
  const res = parse(str);
13
13
  if (!res.OME) {
@@ -1 +1 @@
1
- {"version":3,"file":"omexml.js","names":["parser","ensureArray","intToRgba","PARSER_OPTIONS","attributeNamePrefix","attrNodeName","parseNodeValue","parseAttributeValue","ignoreAttributes","parse","str","fromString","res","OME","Error","Image","map","img","Channels","Pixels","Channel","c","attr","Color","AquisitionDate","Description","image","format","sizes","name","size","concat","unit","join","SizeX","SizeY","Type","SizeZ","SizeT","SizeC"],"sources":["../../../../src/lib/ome/omexml.ts"],"sourcesContent":["import parser from 'fast-xml-parser';\nimport {ensureArray, intToRgba} from '../utils/tiff-utils';\n\n// WARNING: Changes to the parser options _will_ effect the types in types/omexml.d.ts.\nconst PARSER_OPTIONS = {\n // Nests attributes withtout prefix under 'attr' key for each node\n attributeNamePrefix: '',\n attrNodeName: 'attr',\n\n // Parses numbers for both attributes and nodes\n parseNodeValue: true,\n parseAttributeValue: true,\n\n // Forces attributes to be parsed\n ignoreAttributes: false\n};\n\nconst parse = (str: string): Root => parser.parse(str, PARSER_OPTIONS);\n\nexport function fromString(str: string) {\n const res = parse(str);\n if (!res.OME) {\n throw Error('Failed to parse OME-XML metadata.');\n }\n return ensureArray(res.OME.Image).map((img) => {\n const Channels = ensureArray(img.Pixels.Channel).map((c) => {\n if ('Color' in c.attr) {\n return {...c.attr, Color: intToRgba(c.attr.Color)};\n }\n return {...c.attr};\n });\n const {AquisitionDate = '', Description = ''} = img;\n const image = {\n ...img.attr,\n AquisitionDate,\n Description,\n Pixels: {\n ...img.Pixels.attr,\n Channels\n }\n };\n return {\n ...image,\n format() {\n const {Pixels} = image;\n\n const sizes = (['X', 'Y', 'Z'] as const)\n .map((name) => {\n const size = Pixels[`PhysicalSize${name}` as const];\n const unit = Pixels[`PhysicalSize${name}Unit` as const];\n return size && unit ? `${size} ${unit}` : '-';\n })\n .join(' x ');\n\n return {\n 'Acquisition Date': image.AquisitionDate,\n 'Dimensions (XY)': `${Pixels.SizeX} x ${Pixels.SizeY}`,\n 'Pixels Type': Pixels.Type,\n 'Pixels Size (XYZ)': sizes,\n 'Z-sections/Timepoints': `${Pixels.SizeZ} x ${Pixels.SizeT}`,\n Channels: Pixels.SizeC\n };\n }\n };\n });\n}\n\nexport type OMEXML = ReturnType<typeof fromString>;\nexport type DimensionOrder = 'XYZCT' | 'XYZTC' | 'XYCTZ' | 'XYCZT' | 'XYTCZ' | 'XYTZC';\n\n// Structure of node is determined by the PARSER_OPTIONS.\ntype Node<T, A> = T & {attr: A};\ntype Attrs<Fields extends string, T = string> = {[K in Fields]: T};\n\ntype OMEAttrs = Attrs<'xmlns' | 'xmlns:xsi' | 'xsi:schemaLocation'>;\ntype OME = Node<{Insturment: Insturment; Image: Image | Image[]}, OMEAttrs>;\n\ntype Insturment = Node<\n {Objective: Node<{}, Attrs<'ID' | 'Model' | 'NominalMagnification'>>},\n Attrs<'ID'>\n>;\n\ninterface ImageNodes {\n AquisitionDate?: string;\n Description?: string;\n Pixels: Pixels;\n InstrumentRef: Node<{}, {ID: string}>;\n ObjectiveSettings: Node<{}, {ID: string}>;\n}\ntype Image = Node<ImageNodes, Attrs<'ID' | 'Name'>>;\n\ntype PixelType =\n | 'int8'\n | 'int16'\n | 'int32'\n | 'uint8'\n | 'uint16'\n | 'uint32'\n | 'float'\n | 'bit'\n | 'double'\n | 'complex'\n | 'double-complex';\n\nexport type UnitsLength =\n | 'Ym'\n | 'Zm'\n | 'Em'\n | 'Pm'\n | 'Tm'\n | 'Gm'\n | 'Mm'\n | 'km'\n | 'hm'\n | 'dam'\n | 'm'\n | 'dm'\n | 'cm'\n | 'mm'\n | 'µm'\n | 'nm'\n | 'pm'\n | 'fm'\n | 'am'\n | 'zm'\n | 'ym'\n | 'Å'\n | 'thou'\n | 'li'\n | 'in'\n | 'ft'\n | 'yd'\n | 'mi'\n | 'ua'\n | 'ly'\n | 'pc'\n | 'pt'\n | 'pixel'\n | 'reference frame';\n\ntype PhysicalSize<Name extends string> = `PhysicalSize${Name}`;\ntype PhysicalSizeUnit<Name extends string> = `PhysicalSize${Name}Unit`;\ntype Size<Names extends string> = `Size${Names}`;\n\ntype PixelAttrs = Attrs<\n PhysicalSize<'X' | 'Y' | 'Z'> | 'SignificantBits' | Size<'T' | 'C' | 'Z' | 'Y' | 'X'>,\n number\n> &\n Attrs<PhysicalSizeUnit<'X' | 'Y' | 'Z'>, UnitsLength> &\n Attrs<'BigEndian' | 'Interleaved', boolean> & {\n ID: string;\n DimensionOrder: DimensionOrder;\n Type: PixelType;\n };\n\ntype Pixels = Node<\n {\n Channel: Channel | Channel[];\n TiffData: Node<{}, Attrs<'IFD' | 'PlaneCount'>>;\n },\n PixelAttrs\n>;\n\ntype ChannelAttrs =\n | {\n ID: string;\n SamplesPerPixel: number;\n Name?: string;\n }\n | {\n ID: string;\n SamplesPerPixel: number;\n Name?: string;\n Color: number;\n };\n\ntype Channel = Node<{}, ChannelAttrs>;\n\ntype Root = {OME: OME};\n"],"mappings":"AAAA,OAAOA,MAAM,MAAM,iBAAiB;AACpC,SAAQC,WAAW,EAAEC,SAAS,QAAO,qBAAqB;AAG1D,MAAMC,cAAc,GAAG;EAErBC,mBAAmB,EAAE,EAAE;EACvBC,YAAY,EAAE,MAAM;EAGpBC,cAAc,EAAE,IAAI;EACpBC,mBAAmB,EAAE,IAAI;EAGzBC,gBAAgB,EAAE;AACpB,CAAC;AAED,MAAMC,KAAK,GAAIC,GAAW,IAAWV,MAAM,CAACS,KAAK,CAACC,GAAG,EAAEP,cAAc,CAAC;AAEtE,OAAO,SAASQ,UAAUA,CAACD,GAAW,EAAE;EACtC,MAAME,GAAG,GAAGH,KAAK,CAACC,GAAG,CAAC;EACtB,IAAI,CAACE,GAAG,CAACC,GAAG,EAAE;IACZ,MAAMC,KAAK,CAAC,mCAAmC,CAAC;EAClD;EACA,OAAOb,WAAW,CAACW,GAAG,CAACC,GAAG,CAACE,KAAK,CAAC,CAACC,GAAG,CAAEC,GAAG,IAAK;IAC7C,MAAMC,QAAQ,GAAGjB,WAAW,CA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UAC1B,mBAAmB,EAAER,KAAK;UAC1B,uBAAuB,KAAAG,MAAA,CAAKZ,MAAM,CAACkB,KAAK,SAAAN,MAAA,CAAMZ,MAAM,CAACmB,KAAK,CAAE;UAC5DpB,QAAQ,EAAEC,MAAM,CAACoB;QACnB,CAAC;MACH;IACF,CAAC;EACH,CAAC,CAAC;AACJ"}
1
+ {"version":3,"file":"omexml.js","names":["XMLParser","ensureArray","intToRgba","xmlParser","attributeNamePrefix","attributesGroupName","parseTagValue","parseAttributeValue","ignoreAttributes","parse","str","fromString","res","OME","Error","Image","map","img","Channels","Pixels","Channel","c","attr","Color","AquisitionDate","Description","image","format","sizes","name","size","concat","unit","join","SizeX","SizeY","Type","SizeZ","SizeT","SizeC"],"sources":["../../../../src/lib/ome/omexml.ts"],"sourcesContent":["import {XMLParser} from 'fast-xml-parser';\nimport {ensureArray, intToRgba} from '../utils/tiff-utils';\n\n// WARNING: Changes to the parser options _will_ effect the types in types/omexml.d.ts.\nconst xmlParser = new XMLParser({\n // Nests attributes withtout prefix under 'attr' key for each node\n attributeNamePrefix: '',\n attributesGroupName: 'attr',\n\n // Parses numbers for both attributes and nodes\n parseTagValue: true,\n parseAttributeValue: true,\n\n // Forces attributes to be parsed\n ignoreAttributes: false\n});\n\nconst parse = (str: string): Root => xmlParser.parse(str);\n\nexport function fromString(str: string) {\n const res = parse(str);\n if (!res.OME) {\n throw Error('Failed to parse OME-XML metadata.');\n }\n return ensureArray(res.OME.Image).map((img) => {\n const Channels = ensureArray(img.Pixels.Channel).map((c) => {\n if ('Color' in c.attr) {\n return {...c.attr, Color: intToRgba(c.attr.Color)};\n }\n return {...c.attr};\n });\n const {AquisitionDate = '', Description = ''} = img;\n const image = {\n ...img.attr,\n AquisitionDate,\n Description,\n Pixels: {\n ...img.Pixels.attr,\n Channels\n }\n };\n return {\n ...image,\n format() {\n const {Pixels} = image;\n\n const sizes = (['X', 'Y', 'Z'] as const)\n .map((name) => {\n const size = Pixels[`PhysicalSize${name}` as const];\n const unit = Pixels[`PhysicalSize${name}Unit` as const];\n return size && unit ? `${size} ${unit}` : '-';\n })\n .join(' x ');\n\n return {\n 'Acquisition Date': image.AquisitionDate,\n 'Dimensions (XY)': `${Pixels.SizeX} x ${Pixels.SizeY}`,\n 'Pixels Type': Pixels.Type,\n 'Pixels Size (XYZ)': sizes,\n 'Z-sections/Timepoints': `${Pixels.SizeZ} x ${Pixels.SizeT}`,\n Channels: Pixels.SizeC\n };\n }\n };\n });\n}\n\nexport type OMEXML = ReturnType<typeof fromString>;\nexport type DimensionOrder = 'XYZCT' | 'XYZTC' | 'XYCTZ' | 'XYCZT' | 'XYTCZ' | 'XYTZC';\n\n// Structure of node is determined by the PARSER_OPTIONS.\ntype Node<T, A> = T & {attr: A};\ntype Attrs<Fields extends string, T = string> = {[K in Fields]: T};\n\ntype OMEAttrs = Attrs<'xmlns' | 'xmlns:xsi' | 'xsi:schemaLocation'>;\ntype OME = Node<{Insturment: Insturment; Image: Image | Image[]}, OMEAttrs>;\n\ntype Insturment = Node<\n {Objective: Node<{}, Attrs<'ID' | 'Model' | 'NominalMagnification'>>},\n Attrs<'ID'>\n>;\n\ninterface ImageNodes {\n AquisitionDate?: string;\n Description?: string;\n Pixels: Pixels;\n InstrumentRef: Node<{}, {ID: string}>;\n ObjectiveSettings: Node<{}, {ID: string}>;\n}\ntype Image = Node<ImageNodes, Attrs<'ID' | 'Name'>>;\n\ntype PixelType =\n | 'int8'\n | 'int16'\n | 'int32'\n | 'uint8'\n | 'uint16'\n | 'uint32'\n | 'float'\n | 'bit'\n | 'double'\n | 'complex'\n | 'double-complex';\n\nexport type UnitsLength =\n | 'Ym'\n | 'Zm'\n | 'Em'\n | 'Pm'\n | 'Tm'\n | 'Gm'\n | 'Mm'\n | 'km'\n | 'hm'\n | 'dam'\n | 'm'\n | 'dm'\n | 'cm'\n | 'mm'\n | 'µm'\n | 'nm'\n | 'pm'\n | 'fm'\n | 'am'\n | 'zm'\n | 'ym'\n | 'Å'\n | 'thou'\n | 'li'\n | 'in'\n | 'ft'\n | 'yd'\n | 'mi'\n | 'ua'\n | 'ly'\n | 'pc'\n | 'pt'\n | 'pixel'\n | 'reference frame';\n\ntype PhysicalSize<Name extends string> = `PhysicalSize${Name}`;\ntype PhysicalSizeUnit<Name extends string> = `PhysicalSize${Name}Unit`;\ntype Size<Names extends string> = `Size${Names}`;\n\ntype PixelAttrs = Attrs<\n PhysicalSize<'X' | 'Y' | 'Z'> | 'SignificantBits' | Size<'T' | 'C' | 'Z' | 'Y' | 'X'>,\n number\n> &\n Attrs<PhysicalSizeUnit<'X' | 'Y' | 'Z'>, UnitsLength> &\n Attrs<'BigEndian' | 'Interleaved', boolean> & {\n ID: string;\n DimensionOrder: DimensionOrder;\n Type: PixelType;\n };\n\ntype Pixels = Node<\n {\n Channel: Channel | Channel[];\n TiffData: Node<{}, Attrs<'IFD' | 'PlaneCount'>>;\n },\n PixelAttrs\n>;\n\ntype ChannelAttrs =\n | {\n ID: string;\n SamplesPerPixel: number;\n Name?: string;\n }\n | {\n ID: string;\n SamplesPerPixel: number;\n Name?: string;\n Color: number;\n };\n\ntype Channel = Node<{}, ChannelAttrs>;\n\ntype Root = {OME: OME};\n"],"mappings":"AAAA,SAAQA,SAAS,QAAO,iBAAiB;AACzC,SAAQC,WAAW,EAAEC,SAAS,QAAO,qBAAqB;AAG1D,MAAMC,SAAS,GAAG,IAAIH,SAAS,CAAC;EAE9BI,mBAAmB,EAAE,EAAE;EACvBC,mBAAmB,EAAE,MAAM;EAG3BC,aAAa,EAAE,IAAI;EACnBC,mBAAmB,EAAE,IAAI;EAGzBC,gBAAgB,EAAE;AACpB,CAAC,CAAC;AAEF,MAAMC,KAAK,GAAIC,GAAW,IAAWP,SAAS,CAACM,KAAK,CAACC,GAAG,CAAC;AAEzD,OAAO,SAASC,UAAUA,CAACD,GAAW,EAAE;EACtC,MAAME,GAAG,GAAGH,KAAK,CAACC,GAAG,CAAC;EACtB,IAAI,CAACE,GAAG,CAACC,GAA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AAO;UACL,kBAAkB,EAAEP,KAAK,CAACF,cAAc;UACxC,iBAAiB,KAAAO,MAAA,CAAKZ,MAAM,CAACe,KAAK,SAAAH,MAAA,CAAMZ,MAAM,CAACgB,KAAK,CAAE;UACtD,aAAa,EAAEhB,MAAM,CAACiB,IAAI;UAC1B,mBAAmB,EAAER,KAAK;UAC1B,uBAAuB,KAAAG,MAAA,CAAKZ,MAAM,CAACkB,KAAK,SAAAN,MAAA,CAAMZ,MAAM,CAACmB,KAAK,CAAE;UAC5DpB,QAAQ,EAAEC,MAAM,CAACoB;QACnB,CAAC;MACH;IACF,CAAC;EACH,CAAC,CAAC;AACJ"}
@@ -1,23 +1,20 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.fromString = void 0;
7
- const fast_xml_parser_1 = __importDefault(require("fast-xml-parser"));
4
+ const fast_xml_parser_1 = require("fast-xml-parser");
8
5
  const tiff_utils_1 = require("../utils/tiff-utils");
9
6
  // WARNING: Changes to the parser options _will_ effect the types in types/omexml.d.ts.
10
- const PARSER_OPTIONS = {
7
+ const xmlParser = new fast_xml_parser_1.XMLParser({
11
8
  // Nests attributes withtout prefix under 'attr' key for each node
12
9
  attributeNamePrefix: '',
13
- attrNodeName: 'attr',
10
+ attributesGroupName: 'attr',
14
11
  // Parses numbers for both attributes and nodes
15
- parseNodeValue: true,
12
+ parseTagValue: true,
16
13
  parseAttributeValue: true,
17
14
  // Forces attributes to be parsed
18
15
  ignoreAttributes: false
19
- };
20
- const parse = (str) => fast_xml_parser_1.default.parse(str, PARSER_OPTIONS);
16
+ });
17
+ const parse = (str) => xmlParser.parse(str);
21
18
  function fromString(str) {
22
19
  const res = parse(str);
23
20
  if (!res.OME) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loaders.gl/geotiff",
3
- "version": "4.0.0-alpha.12",
3
+ "version": "4.0.0-alpha.14",
4
4
  "description": "Framework-independent loaders for tiff and geotiff",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
@@ -36,8 +36,8 @@
36
36
  "geotiff": "ilan-gold/geotiff.js#ilan-gold/viv_094"
37
37
  },
38
38
  "dependencies": {
39
- "fast-xml-parser": "^3.16.0",
39
+ "fast-xml-parser": "^4.2.5",
40
40
  "geotiff": "^1.0.4"
41
41
  },
42
- "gitHead": "42dfc47a41e3e6089eec22a1e1d4f3387e0cb6e9"
42
+ "gitHead": "dd885592142ad9c26fc38e0eb0a711cf4806345a"
43
43
  }
@@ -1,21 +1,21 @@
1
- import parser from 'fast-xml-parser';
1
+ import {XMLParser} from 'fast-xml-parser';
2
2
  import {ensureArray, intToRgba} from '../utils/tiff-utils';
3
3
 
4
4
  // WARNING: Changes to the parser options _will_ effect the types in types/omexml.d.ts.
5
- const PARSER_OPTIONS = {
5
+ const xmlParser = new XMLParser({
6
6
  // Nests attributes withtout prefix under 'attr' key for each node
7
7
  attributeNamePrefix: '',
8
- attrNodeName: 'attr',
8
+ attributesGroupName: 'attr',
9
9
 
10
10
  // Parses numbers for both attributes and nodes
11
- parseNodeValue: true,
11
+ parseTagValue: true,
12
12
  parseAttributeValue: true,
13
13
 
14
14
  // Forces attributes to be parsed
15
15
  ignoreAttributes: false
16
- };
16
+ });
17
17
 
18
- const parse = (str: string): Root => parser.parse(str, PARSER_OPTIONS);
18
+ const parse = (str: string): Root => xmlParser.parse(str);
19
19
 
20
20
  export function fromString(str: string) {
21
21
  const res = parse(str);