@itwin/map-layers-formats 5.9.0-dev.9 → 5.9.1

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.
package/CHANGELOG.md CHANGED
@@ -1,6 +1,31 @@
1
1
  # Change Log - @itwin/map-layers-formats
2
2
 
3
- This log was last generated on Fri, 10 Apr 2026 13:03:16 GMT and should not be manually modified.
3
+ This log was last generated on Tue, 05 May 2026 17:43:30 GMT and should not be manually modified.
4
+
5
+ ## 5.9.1
6
+ Tue, 05 May 2026 17:43:30 GMT
7
+
8
+ _Version update only_
9
+
10
+ ## 5.9.0
11
+ Mon, 04 May 2026 16:32:08 GMT
12
+
13
+ _Version update only_
14
+
15
+ ## 5.8.4
16
+ Thu, 23 Apr 2026 18:05:14 GMT
17
+
18
+ _Version update only_
19
+
20
+ ## 5.8.3
21
+ Thu, 23 Apr 2026 14:52:42 GMT
22
+
23
+ _Version update only_
24
+
25
+ ## 5.8.2
26
+ Thu, 16 Apr 2026 11:05:01 GMT
27
+
28
+ _Version update only_
4
29
 
5
30
  ## 5.8.1
6
31
  Fri, 10 Apr 2026 13:02:00 GMT
@@ -1 +1 @@
1
- {"version":3,"file":"OgcApiFeaturesReader.js","sourceRoot":"","sources":["../../../src/OgcApiFeatures/OgcApiFeaturesReader.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F,0DAA+F;AAK/F,0EAAoE;AACpE,kFAA4E;AAa5E,gBAAgB;AAChB,MAAa,oBAAqB,SAAQ,wCAAiB;IAClD,SAAS,CAAwB;IAExC;QACE,KAAK,EAAE,CAAC;IACV,CAAC;IAEO,wBAAwB,CAAC,aAA8C,EAAE,OAAY;QAC3F,IAAI,aAAa,IAAI,OAAO,EAAE,CAAC;YAC7B,MAAM,YAAY,GAAG,aAAa,CAAC,cAAc,CAAC;YAClD,IAAI,YAAY,IAAI,YAAY,CAAC,MAAM,GAAG,CAAC,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC;gBA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O,GAAoB,EAAC,UAAU,EAAE,EAAE,EAAC,CAAC;YAElD,IAAI,eAAe,CAAC,UAAU,EAAE,CAAC;gBAC/B,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,eAAe,CAAC,UAAU,CAAC;oBACnE,OAAO,CAAC,UAAU,EAAE,IAAI,CAAC,aAAa,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC;YACxD,CAAC;YAED,IAAI,UAAU,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;gBACpC,MAAM,UAAU,CAAC,YAAY,CAAC,eAAe,CAAC,QAAe,CAAC,CAAC;gBAC/D,MAAM,QAAQ,GAAG,IAAI,CAAC,YAAY,CAAC,YAAY,EAAE,CAAC;gBAClD,OAAO,CAAC,UAAU,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAyB,EAAE,EAAE;oBAC9D,OAAO,EAAC,OAAO,EAAC,CAAC;gBACnB,CAAC,CAAC,CAAC;YACL,CAAC;YACD,YAAY,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACtC,CAAC;QAED,IAAI,SAAS,CAAC,aAAa,KAAK,SAAS;YACvC,SAAS,CAAC,aAAa,GAAG,EAAE,CAAC;QAC/B,SAAS,CAAC,aAAa,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QAE3C,YAAY,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IAC/B,CAAC;CAEF;AAnJD,oDAmJC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n\nimport { PrimitiveValue, PropertyValueFormat, StandardTypeNames } from \"@itwin/appui-abstract\";\nimport { ImageMapLayerSettings } from \"@itwin/core-common\";\nimport { FeatureAttributeDrivenSymbology, FeatureGeometryRenderer, GraphicPrimitive, GraphicsGeometryRenderer, MapLayerFeature, MapLayerFeatureAttribute, MapLayerFeatureInfo, MapSubLayerFeatureInfo } from \"@itwin/core-frontend\";\nimport { Transform } from \"@itwin/core-geometry\";\nimport Geojson from \"geojson\";\nimport { FeatureInfoReader } from \"../Feature/FeatureInfoReader.js\";\nimport { GeoJSONGeometryReader } from \"../GeoJSON/GeoJSONGeometryReader.js\";\n\n/** @internal */\nexport type OgcFeaturePropertyType = \"string\" | \"number\" | \"integer\" | \"datetime\" | \"geometry\" | \"boolean\";\n\n/** @internal */\nexport interface ReadOgcApiFeaturesInfoOptions {\n collection: Geojson.FeatureCollection;\n layerSettings: ImageMapLayerSettings;\n queryables?: any;\n geomRenderer?: GraphicsGeometryRenderer;\n}\n\n/** @internal */\nexport class OgcApiFeaturesReader extends FeatureInfoReader {\n public transform: Transform | undefined;\n\n public constructor() {\n super();\n }\n\n private applySymbologyAttributes(attrSymbology: FeatureAttributeDrivenSymbology, feature: any) {\n if (attrSymbology && feature) {\n const symbolFields = attrSymbology.rendererFields;\n if (symbolFields && symbolFields.length > 0 && feature.properties) {\n const featureAttr: {[key: string]: any} = {};\n for (const [attrKey, attrValue] of Object.entries(feature.properties))\n if (symbolFields.includes(attrKey)) {\n featureAttr[attrKey] = attrValue;\n }\n attrSymbology.setActiveFeatureAttributes(featureAttr);\n }\n }\n }\n\n public async readAndRender(data: Geojson.FeatureCollection, renderer: FeatureGeometryRenderer) {\n const responseObj = data;\n if (responseObj.type === \"FeatureCollection\") {\n\n const geomReader = new GeoJSONGeometryReader(renderer);\n\n for (const feature of responseObj.features) {\n // Each feature has potentially a different geometry type, so we need to inform the geometry renderer\n if (renderer.hasSymbologyRenderer()) {\n renderer.symbolRenderer.activeGeometryType = feature.geometry.type;\n // Read attributes if needed (attribute driven symbology)\n if (renderer.symbolRenderer.isAttributeDriven()) {\n this.applySymbologyAttributes(renderer.symbolRenderer, feature);\n }\n }\n\n await geomReader.readGeometry(feature.geometry);\n }\n }\n }\n\n public async readFeatureInfo(opts: ReadOgcApiFeaturesInfoOptions, featureInfos: MapLayerFeatureInfo[]) {\n if (!Array.isArray(opts.collection.features))\n return;\n\n const layerInfo: MapLayerFeatureInfo = { layerName: opts.layerSettings.name };\n\n // Create a signature index for every field name / type.\n let fieldsType: { [key: string]: OgcFeaturePropertyType } | undefined;\n if (Array.isArray(opts.queryables?.properties)) {\n fieldsType = {};\n for (const fieldInfo of opts.queryables) {\n fieldsType[fieldInfo.name] = fieldInfo.type;\n }\n }\n\n const getStandardTypeName = (fieldType: OgcFeaturePropertyType) => {\n switch (fieldType) {\n case \"number\":\n return StandardTypeNames.Double;\n case \"integer\":\n return StandardTypeNames.Integer;\n case \"boolean\":\n return StandardTypeNames.Boolean;\n case \"datetime\":\n return StandardTypeNames.DateTime;\n default:\n return StandardTypeNames.String;\n }\n };\n\n const getRecordInfo = (fieldName: string, value: any): MapLayerFeatureAttribute => {\n let typename = StandardTypeNames.String;\n const propertyValue: PrimitiveValue = {valueFormat: PropertyValueFormat.Primitive};\n\n if (value === null) {\n value = undefined;\n }\n\n const strValue = `${value}`;\n if (fieldsType) {\n const fieldType = fieldsType[fieldName];\n switch (fieldType) {\n case \"integer\":\n propertyValue.value = value as number;\n break;\n case \"number\":\n propertyValue.value = this.toFixedWithoutPadding(value);\n break;\n case \"datetime\":\n propertyValue.value = new Date(value);\n break;\n default:\n if (value !== undefined)\n propertyValue.value = strValue;\n break;\n }\n typename = getStandardTypeName(fieldType);\n propertyValue.displayValue = this.getDisplayValue(typename, propertyValue.value);\n } else {\n // Queryables are optional with OGC Features, in this case everything is string.\n propertyValue.value = strValue;\n propertyValue.displayValue = strValue;\n }\n\n return {value: propertyValue, property: { name: fieldName, displayLabel: fieldName, typename }};\n };\n\n let geomReader: GeoJSONGeometryReader|undefined;\n if (opts.geomRenderer) {\n geomReader = new GeoJSONGeometryReader(opts.geomRenderer);\n }\n\n // Each feature response represent a single sub-layer, no need to check for existing entry.\n const subLayerInfo: MapSubLayerFeatureInfo = {\n subLayerName: opts.layerSettings.name,\n displayFieldName: opts.layerSettings.name,\n features: [],\n };\n\n // Read all features attributes / geometries\n for (const responseFeature of opts.collection.features) {\n const feature: MapLayerFeature = {attributes: []};\n\n if (responseFeature.properties) {\n for (const [key, value] of Object.entries(responseFeature.properties))\n feature.attributes?.push(getRecordInfo(key, value));\n }\n\n if (geomReader && opts.geomRenderer) {\n await geomReader.readGeometry(responseFeature.geometry as any);\n const graphics = opts.geomRenderer.moveGraphics();\n feature.geometries = graphics.map((graphic: GraphicPrimitive) => {\n return {graphic};\n });\n }\n subLayerInfo.features.push(feature);\n }\n\n if (layerInfo.subLayerInfos === undefined)\n layerInfo.subLayerInfos = [];\n layerInfo.subLayerInfos.push(subLayerInfo);\n\n featureInfos.push(layerInfo);\n }\n\n}\n"]}
1
+ {"version":3,"file":"OgcApiFeaturesReader.js","sourceRoot":"","sources":["../../../src/OgcApiFeatures/OgcApiFeaturesReader.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F,0DAA+F;AAK/F,0EAAoE;AACpE,kFAA4E;AAa5E,gBAAgB;AAChB,MAAa,oBAAqB,SAAQ,wCAAiB;IAClD,SAAS,CAAwB;IAExC;QACE,KAAK,EAAE,CAAC;IACV,CAAC;IAEO,wBAAwB,CAAC,aAA8C,EAAE,OAAY;QAC3F,IAAI,aAAa,IAAI,OAAO,EAAE,CAAC;YAC7B,MAAM,YAAY,GAAG,aAAa,CAAC,cAAc,CAAC;YAClD,IAAI,YAAY,IAAI,YAAY,CAAC,MAAM,GAAG,CAAC,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC;gBAClE,MAAM,WAAW,GAAyB,EAAE,CAAC;gBAC7C,KAAK,MAAM,CAAC,OAAO,EAAE,SAAS,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC;oBACnE,IAAI,YAAY,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;wBACnC,WAAW,CAAC,OAAO,CAAC,GAAG,SA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CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC;YACxD,CAAC;YAED,IAAI,UAAU,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;gBACpC,MAAM,UAAU,CAAC,YAAY,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC;gBACxD,MAAM,QAAQ,GAAG,IAAI,CAAC,YAAY,CAAC,YAAY,EAAE,CAAC;gBAClD,OAAO,CAAC,UAAU,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAyB,EAAE,EAAE;oBAC9D,OAAO,EAAC,OAAO,EAAC,CAAC;gBACnB,CAAC,CAAC,CAAC;YACL,CAAC;YACD,YAAY,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACtC,CAAC;QAED,IAAI,SAAS,CAAC,aAAa,KAAK,SAAS;YACvC,SAAS,CAAC,aAAa,GAAG,EAAE,CAAC;QAC/B,SAAS,CAAC,aAAa,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QAE3C,YAAY,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IAC/B,CAAC;CAEF;AAnJD,oDAmJC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n\nimport { PrimitiveValue, PropertyValueFormat, StandardTypeNames } from \"@itwin/appui-abstract\";\nimport { ImageMapLayerSettings } from \"@itwin/core-common\";\nimport { FeatureAttributeDrivenSymbology, FeatureGeometryRenderer, GraphicPrimitive, GraphicsGeometryRenderer, MapLayerFeature, MapLayerFeatureAttribute, MapLayerFeatureInfo, MapSubLayerFeatureInfo } from \"@itwin/core-frontend\";\nimport { Transform } from \"@itwin/core-geometry\";\nimport Geojson from \"geojson\";\nimport { FeatureInfoReader } from \"../Feature/FeatureInfoReader.js\";\nimport { GeoJSONGeometryReader } from \"../GeoJSON/GeoJSONGeometryReader.js\";\n\n/** @internal */\nexport type OgcFeaturePropertyType = \"string\" | \"number\" | \"integer\" | \"datetime\" | \"geometry\" | \"boolean\";\n\n/** @internal */\nexport interface ReadOgcApiFeaturesInfoOptions {\n collection: Geojson.FeatureCollection;\n layerSettings: ImageMapLayerSettings;\n queryables?: any;\n geomRenderer?: GraphicsGeometryRenderer;\n}\n\n/** @internal */\nexport class OgcApiFeaturesReader extends FeatureInfoReader {\n public transform: Transform | undefined;\n\n public constructor() {\n super();\n }\n\n private applySymbologyAttributes(attrSymbology: FeatureAttributeDrivenSymbology, feature: any) {\n if (attrSymbology && feature) {\n const symbolFields = attrSymbology.rendererFields;\n if (symbolFields && symbolFields.length > 0 && feature.properties) {\n const featureAttr: {[key: string]: any} = {};\n for (const [attrKey, attrValue] of Object.entries(feature.properties))\n if (symbolFields.includes(attrKey)) {\n featureAttr[attrKey] = attrValue;\n }\n attrSymbology.setActiveFeatureAttributes(featureAttr);\n }\n }\n }\n\n public async readAndRender(data: Geojson.FeatureCollection, renderer: FeatureGeometryRenderer) {\n const responseObj = data;\n if (responseObj.type === \"FeatureCollection\") {\n\n const geomReader = new GeoJSONGeometryReader(renderer);\n\n for (const feature of responseObj.features) {\n // Each feature has potentially a different geometry type, so we need to inform the geometry renderer\n if (renderer.hasSymbologyRenderer()) {\n renderer.symbolRenderer.activeGeometryType = feature.geometry.type;\n // Read attributes if needed (attribute driven symbology)\n if (renderer.symbolRenderer.isAttributeDriven()) {\n this.applySymbologyAttributes(renderer.symbolRenderer, feature);\n }\n }\n\n await geomReader.readGeometry(feature.geometry);\n }\n }\n }\n\n public async readFeatureInfo(opts: ReadOgcApiFeaturesInfoOptions, featureInfos: MapLayerFeatureInfo[]) {\n if (!Array.isArray(opts.collection.features))\n return;\n\n const layerInfo: MapLayerFeatureInfo = { layerName: opts.layerSettings.name };\n\n // Create a signature index for every field name / type.\n let fieldsType: { [key: string]: OgcFeaturePropertyType } | undefined;\n if (Array.isArray(opts.queryables?.properties)) {\n fieldsType = {};\n for (const fieldInfo of opts.queryables) {\n fieldsType[fieldInfo.name] = fieldInfo.type;\n }\n }\n\n const getStandardTypeName = (fieldType: OgcFeaturePropertyType) => {\n switch (fieldType) {\n case \"number\":\n return StandardTypeNames.Double;\n case \"integer\":\n return StandardTypeNames.Integer;\n case \"boolean\":\n return StandardTypeNames.Boolean;\n case \"datetime\":\n return StandardTypeNames.DateTime;\n default:\n return StandardTypeNames.String;\n }\n };\n\n const getRecordInfo = (fieldName: string, value: any): MapLayerFeatureAttribute => {\n let typename = StandardTypeNames.String;\n const propertyValue: PrimitiveValue = {valueFormat: PropertyValueFormat.Primitive};\n\n if (value === null) {\n value = undefined;\n }\n\n const strValue = `${value}`;\n if (fieldsType) {\n const fieldType = fieldsType[fieldName];\n switch (fieldType) {\n case \"integer\":\n propertyValue.value = value as number;\n break;\n case \"number\":\n propertyValue.value = this.toFixedWithoutPadding(value);\n break;\n case \"datetime\":\n propertyValue.value = new Date(value);\n break;\n default:\n if (value !== undefined)\n propertyValue.value = strValue;\n break;\n }\n typename = getStandardTypeName(fieldType);\n propertyValue.displayValue = this.getDisplayValue(typename, propertyValue.value);\n } else {\n // Queryables are optional with OGC Features, in this case everything is string.\n propertyValue.value = strValue;\n propertyValue.displayValue = strValue;\n }\n\n return {value: propertyValue, property: { name: fieldName, displayLabel: fieldName, typename }};\n };\n\n let geomReader: GeoJSONGeometryReader|undefined;\n if (opts.geomRenderer) {\n geomReader = new GeoJSONGeometryReader(opts.geomRenderer);\n }\n\n // Each feature response represent a single sub-layer, no need to check for existing entry.\n const subLayerInfo: MapSubLayerFeatureInfo = {\n subLayerName: opts.layerSettings.name,\n displayFieldName: opts.layerSettings.name,\n features: [],\n };\n\n // Read all features attributes / geometries\n for (const responseFeature of opts.collection.features) {\n const feature: MapLayerFeature = {attributes: []};\n\n if (responseFeature.properties) {\n for (const [key, value] of Object.entries(responseFeature.properties))\n feature.attributes?.push(getRecordInfo(key, value));\n }\n\n if (geomReader && opts.geomRenderer) {\n await geomReader.readGeometry(responseFeature.geometry);\n const graphics = opts.geomRenderer.moveGraphics();\n feature.geometries = graphics.map((graphic: GraphicPrimitive) => {\n return {graphic};\n });\n }\n subLayerInfo.features.push(feature);\n }\n\n if (layerInfo.subLayerInfos === undefined)\n layerInfo.subLayerInfos = [];\n layerInfo.subLayerInfos.push(subLayerInfo);\n\n featureInfos.push(layerInfo);\n }\n\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"OgcApiFeaturesReader.js","sourceRoot":"","sources":["../../../src/OgcApiFeatures/OgcApiFeaturesReader.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAE/F,OAAO,EAAkB,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAK/F,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACpE,OAAO,EAAE,qBAAqB,EAAE,MAAM,qCAAqC,CAAC;AAa5E,gBAAgB;AAChB,MAAM,OAAO,oBAAqB,SAAQ,iBAAiB;IAClD,SAAS,CAAwB;IAExC;QACE,KAAK,EAAE,CAAC;IACV,CAAC;IAEO,wBAAwB,CAAC,aAA8C,EAAE,OAAY;QAC3F,IAAI,aAAa,IAAI,OAAO,EAAE,CAAC;YAC7B,MAAM,YAAY,GAAG,aAAa,CAAC,cAAc,CAAC;YAClD,IAAI,YAAY,IAAI,YAAY,CAAC,MAAM,GAAG,CAAC,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC;gBAClE,MAAM,WAAW,GAAyB,EAAE,CAAC;gBAC7C,KAAK,MAAM,CAAC,OAAO,EAAE,SAAS,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC;oBACnE,IAAI,YAAY,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;wBACnC,WAAW,CAAC,OAAO,CAAC,GAAG,SAAS,CAAC;oBACnC,CAAC;gBACH,aAAa,CAAC,0BAA0B,CAAC,WAAW,CAAC,CAAC;YACxD,CAAC;QACH,CAAC;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AAE,CAAC;gBACpC,MAAM,UAAU,CAAC,YAAY,CAAC,eAAe,CAAC,QAAe,CAAC,CAAC;gBAC/D,MAAM,QAAQ,GAAG,IAAI,CAAC,YAAY,CAAC,YAAY,EAAE,CAAC;gBAClD,OAAO,CAAC,UAAU,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAyB,EAAE,EAAE;oBAC9D,OAAO,EAAC,OAAO,EAAC,CAAC;gBACnB,CAAC,CAAC,CAAC;YACL,CAAC;YACD,YAAY,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACtC,CAAC;QAED,IAAI,SAAS,CAAC,aAAa,KAAK,SAAS;YACvC,SAAS,CAAC,aAAa,GAAG,EAAE,CAAC;QAC/B,SAAS,CAAC,aAAa,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QAE3C,YAAY,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IAC/B,CAAC;CAEF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n\nimport { PrimitiveValue, PropertyValueFormat, StandardTypeNames } from \"@itwin/appui-abstract\";\nimport { ImageMapLayerSettings } from \"@itwin/core-common\";\nimport { FeatureAttributeDrivenSymbology, FeatureGeometryRenderer, GraphicPrimitive, GraphicsGeometryRenderer, MapLayerFeature, MapLayerFeatureAttribute, MapLayerFeatureInfo, MapSubLayerFeatureInfo } from \"@itwin/core-frontend\";\nimport { Transform } from \"@itwin/core-geometry\";\nimport Geojson from \"geojson\";\nimport { FeatureInfoReader } from \"../Feature/FeatureInfoReader.js\";\nimport { GeoJSONGeometryReader } from \"../GeoJSON/GeoJSONGeometryReader.js\";\n\n/** @internal */\nexport type OgcFeaturePropertyType = \"string\" | \"number\" | \"integer\" | \"datetime\" | \"geometry\" | \"boolean\";\n\n/** @internal */\nexport interface ReadOgcApiFeaturesInfoOptions {\n collection: Geojson.FeatureCollection;\n layerSettings: ImageMapLayerSettings;\n queryables?: any;\n geomRenderer?: GraphicsGeometryRenderer;\n}\n\n/** @internal */\nexport class OgcApiFeaturesReader extends FeatureInfoReader {\n public transform: Transform | undefined;\n\n public constructor() {\n super();\n }\n\n private applySymbologyAttributes(attrSymbology: FeatureAttributeDrivenSymbology, feature: any) {\n if (attrSymbology && feature) {\n const symbolFields = attrSymbology.rendererFields;\n if (symbolFields && symbolFields.length > 0 && feature.properties) {\n const featureAttr: {[key: string]: any} = {};\n for (const [attrKey, attrValue] of Object.entries(feature.properties))\n if (symbolFields.includes(attrKey)) {\n featureAttr[attrKey] = attrValue;\n }\n attrSymbology.setActiveFeatureAttributes(featureAttr);\n }\n }\n }\n\n public async readAndRender(data: Geojson.FeatureCollection, renderer: FeatureGeometryRenderer) {\n const responseObj = data;\n if (responseObj.type === \"FeatureCollection\") {\n\n const geomReader = new GeoJSONGeometryReader(renderer);\n\n for (const feature of responseObj.features) {\n // Each feature has potentially a different geometry type, so we need to inform the geometry renderer\n if (renderer.hasSymbologyRenderer()) {\n renderer.symbolRenderer.activeGeometryType = feature.geometry.type;\n // Read attributes if needed (attribute driven symbology)\n if (renderer.symbolRenderer.isAttributeDriven()) {\n this.applySymbologyAttributes(renderer.symbolRenderer, feature);\n }\n }\n\n await geomReader.readGeometry(feature.geometry);\n }\n }\n }\n\n public async readFeatureInfo(opts: ReadOgcApiFeaturesInfoOptions, featureInfos: MapLayerFeatureInfo[]) {\n if (!Array.isArray(opts.collection.features))\n return;\n\n const layerInfo: MapLayerFeatureInfo = { layerName: opts.layerSettings.name };\n\n // Create a signature index for every field name / type.\n let fieldsType: { [key: string]: OgcFeaturePropertyType } | undefined;\n if (Array.isArray(opts.queryables?.properties)) {\n fieldsType = {};\n for (const fieldInfo of opts.queryables) {\n fieldsType[fieldInfo.name] = fieldInfo.type;\n }\n }\n\n const getStandardTypeName = (fieldType: OgcFeaturePropertyType) => {\n switch (fieldType) {\n case \"number\":\n return StandardTypeNames.Double;\n case \"integer\":\n return StandardTypeNames.Integer;\n case \"boolean\":\n return StandardTypeNames.Boolean;\n case \"datetime\":\n return StandardTypeNames.DateTime;\n default:\n return StandardTypeNames.String;\n }\n };\n\n const getRecordInfo = (fieldName: string, value: any): MapLayerFeatureAttribute => {\n let typename = StandardTypeNames.String;\n const propertyValue: PrimitiveValue = {valueFormat: PropertyValueFormat.Primitive};\n\n if (value === null) {\n value = undefined;\n }\n\n const strValue = `${value}`;\n if (fieldsType) {\n const fieldType = fieldsType[fieldName];\n switch (fieldType) {\n case \"integer\":\n propertyValue.value = value as number;\n break;\n case \"number\":\n propertyValue.value = this.toFixedWithoutPadding(value);\n break;\n case \"datetime\":\n propertyValue.value = new Date(value);\n break;\n default:\n if (value !== undefined)\n propertyValue.value = strValue;\n break;\n }\n typename = getStandardTypeName(fieldType);\n propertyValue.displayValue = this.getDisplayValue(typename, propertyValue.value);\n } else {\n // Queryables are optional with OGC Features, in this case everything is string.\n propertyValue.value = strValue;\n propertyValue.displayValue = strValue;\n }\n\n return {value: propertyValue, property: { name: fieldName, displayLabel: fieldName, typename }};\n };\n\n let geomReader: GeoJSONGeometryReader|undefined;\n if (opts.geomRenderer) {\n geomReader = new GeoJSONGeometryReader(opts.geomRenderer);\n }\n\n // Each feature response represent a single sub-layer, no need to check for existing entry.\n const subLayerInfo: MapSubLayerFeatureInfo = {\n subLayerName: opts.layerSettings.name,\n displayFieldName: opts.layerSettings.name,\n features: [],\n };\n\n // Read all features attributes / geometries\n for (const responseFeature of opts.collection.features) {\n const feature: MapLayerFeature = {attributes: []};\n\n if (responseFeature.properties) {\n for (const [key, value] of Object.entries(responseFeature.properties))\n feature.attributes?.push(getRecordInfo(key, value));\n }\n\n if (geomReader && opts.geomRenderer) {\n await geomReader.readGeometry(responseFeature.geometry as any);\n const graphics = opts.geomRenderer.moveGraphics();\n feature.geometries = graphics.map((graphic: GraphicPrimitive) => {\n return {graphic};\n });\n }\n subLayerInfo.features.push(feature);\n }\n\n if (layerInfo.subLayerInfos === undefined)\n layerInfo.subLayerInfos = [];\n layerInfo.subLayerInfos.push(subLayerInfo);\n\n featureInfos.push(layerInfo);\n }\n\n}\n"]}
1
+ {"version":3,"file":"OgcApiFeaturesReader.js","sourceRoot":"","sources":["../../../src/OgcApiFeatures/OgcApiFeaturesReader.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAE/F,OAAO,EAAkB,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAK/F,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACpE,OAAO,EAAE,qBAAqB,EAAE,MAAM,qCAAqC,CAAC;AAa5E,gBAAgB;AAChB,MAAM,OAAO,oBAAqB,SAAQ,iBAAiB;IAClD,SAAS,CAAwB;IAExC;QACE,KAAK,EAAE,CAAC;IACV,CAAC;IAEO,wBAAwB,CAAC,aAA8C,EAAE,OAAY;QAC3F,IAAI,aAAa,IAAI,OAAO,EAAE,CAAC;YAC7B,MAAM,YAAY,GAAG,aAAa,CAAC,cAAc,CAAC;YAClD,IAAI,YAAY,IAAI,YAAY,CAAC,MAAM,GAAG,CAAC,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC;gBAClE,MAAM,WAAW,GAAyB,EAAE,CAAC;gBAC7C,KAAK,MAAM,CAAC,OAAO,EAAE,SAAS,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC;oBACnE,IAAI,YAAY,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;wBACnC,WAAW,CAAC,OAAO,CAAC,GAAG,SAAS,CAAC;oBACnC,CAAC;gBACH,aAAa,CAAC,0BAA0B,CAAC,WAAW,CAAC,CAAC;YACxD,CAAC;QACH,CAAC;IACH,CAAC;IAEM,KAAK,CAAC,aAAa,CAAC,IAA+B,EAAE,QAAiC;QAC3F,MAAM,WAAW,GAAG,IAAI,CAAC;QACzB,IAAI,WAAW,CAAC,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,CAAC,YAAY,EAAE,CAAC;gBAClD,OAAO,CAAC,UAAU,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAyB,EAAE,EAAE;oBAC9D,OAAO,EAAC,OAAO,EAAC,CAAC;gBACnB,CAAC,CAAC,CAAC;YACL,CAAC;YACD,YAAY,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACtC,CAAC;QAED,IAAI,SAAS,CAAC,aAAa,KAAK,SAAS;YACvC,SAAS,CAAC,aAAa,GAAG,EAAE,CAAC;QAC/B,SAAS,CAAC,aAAa,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QAE3C,YAAY,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IAC/B,CAAC;CAEF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n\nimport { PrimitiveValue, PropertyValueFormat, StandardTypeNames } from \"@itwin/appui-abstract\";\nimport { ImageMapLayerSettings } from \"@itwin/core-common\";\nimport { FeatureAttributeDrivenSymbology, FeatureGeometryRenderer, GraphicPrimitive, GraphicsGeometryRenderer, MapLayerFeature, MapLayerFeatureAttribute, MapLayerFeatureInfo, MapSubLayerFeatureInfo } from \"@itwin/core-frontend\";\nimport { Transform } from \"@itwin/core-geometry\";\nimport Geojson from \"geojson\";\nimport { FeatureInfoReader } from \"../Feature/FeatureInfoReader.js\";\nimport { GeoJSONGeometryReader } from \"../GeoJSON/GeoJSONGeometryReader.js\";\n\n/** @internal */\nexport type OgcFeaturePropertyType = \"string\" | \"number\" | \"integer\" | \"datetime\" | \"geometry\" | \"boolean\";\n\n/** @internal */\nexport interface ReadOgcApiFeaturesInfoOptions {\n collection: Geojson.FeatureCollection;\n layerSettings: ImageMapLayerSettings;\n queryables?: any;\n geomRenderer?: GraphicsGeometryRenderer;\n}\n\n/** @internal */\nexport class OgcApiFeaturesReader extends FeatureInfoReader {\n public transform: Transform | undefined;\n\n public constructor() {\n super();\n }\n\n private applySymbologyAttributes(attrSymbology: FeatureAttributeDrivenSymbology, feature: any) {\n if (attrSymbology && feature) {\n const symbolFields = attrSymbology.rendererFields;\n if (symbolFields && symbolFields.length > 0 && feature.properties) {\n const featureAttr: {[key: string]: any} = {};\n for (const [attrKey, attrValue] of Object.entries(feature.properties))\n if (symbolFields.includes(attrKey)) {\n featureAttr[attrKey] = attrValue;\n }\n attrSymbology.setActiveFeatureAttributes(featureAttr);\n }\n }\n }\n\n public async readAndRender(data: Geojson.FeatureCollection, renderer: FeatureGeometryRenderer) {\n const responseObj = data;\n if (responseObj.type === \"FeatureCollection\") {\n\n const geomReader = new GeoJSONGeometryReader(renderer);\n\n for (const feature of responseObj.features) {\n // Each feature has potentially a different geometry type, so we need to inform the geometry renderer\n if (renderer.hasSymbologyRenderer()) {\n renderer.symbolRenderer.activeGeometryType = feature.geometry.type;\n // Read attributes if needed (attribute driven symbology)\n if (renderer.symbolRenderer.isAttributeDriven()) {\n this.applySymbologyAttributes(renderer.symbolRenderer, feature);\n }\n }\n\n await geomReader.readGeometry(feature.geometry);\n }\n }\n }\n\n public async readFeatureInfo(opts: ReadOgcApiFeaturesInfoOptions, featureInfos: MapLayerFeatureInfo[]) {\n if (!Array.isArray(opts.collection.features))\n return;\n\n const layerInfo: MapLayerFeatureInfo = { layerName: opts.layerSettings.name };\n\n // Create a signature index for every field name / type.\n let fieldsType: { [key: string]: OgcFeaturePropertyType } | undefined;\n if (Array.isArray(opts.queryables?.properties)) {\n fieldsType = {};\n for (const fieldInfo of opts.queryables) {\n fieldsType[fieldInfo.name] = fieldInfo.type;\n }\n }\n\n const getStandardTypeName = (fieldType: OgcFeaturePropertyType) => {\n switch (fieldType) {\n case \"number\":\n return StandardTypeNames.Double;\n case \"integer\":\n return StandardTypeNames.Integer;\n case \"boolean\":\n return StandardTypeNames.Boolean;\n case \"datetime\":\n return StandardTypeNames.DateTime;\n default:\n return StandardTypeNames.String;\n }\n };\n\n const getRecordInfo = (fieldName: string, value: any): MapLayerFeatureAttribute => {\n let typename = StandardTypeNames.String;\n const propertyValue: PrimitiveValue = {valueFormat: PropertyValueFormat.Primitive};\n\n if (value === null) {\n value = undefined;\n }\n\n const strValue = `${value}`;\n if (fieldsType) {\n const fieldType = fieldsType[fieldName];\n switch (fieldType) {\n case \"integer\":\n propertyValue.value = value as number;\n break;\n case \"number\":\n propertyValue.value = this.toFixedWithoutPadding(value);\n break;\n case \"datetime\":\n propertyValue.value = new Date(value);\n break;\n default:\n if (value !== undefined)\n propertyValue.value = strValue;\n break;\n }\n typename = getStandardTypeName(fieldType);\n propertyValue.displayValue = this.getDisplayValue(typename, propertyValue.value);\n } else {\n // Queryables are optional with OGC Features, in this case everything is string.\n propertyValue.value = strValue;\n propertyValue.displayValue = strValue;\n }\n\n return {value: propertyValue, property: { name: fieldName, displayLabel: fieldName, typename }};\n };\n\n let geomReader: GeoJSONGeometryReader|undefined;\n if (opts.geomRenderer) {\n geomReader = new GeoJSONGeometryReader(opts.geomRenderer);\n }\n\n // Each feature response represent a single sub-layer, no need to check for existing entry.\n const subLayerInfo: MapSubLayerFeatureInfo = {\n subLayerName: opts.layerSettings.name,\n displayFieldName: opts.layerSettings.name,\n features: [],\n };\n\n // Read all features attributes / geometries\n for (const responseFeature of opts.collection.features) {\n const feature: MapLayerFeature = {attributes: []};\n\n if (responseFeature.properties) {\n for (const [key, value] of Object.entries(responseFeature.properties))\n feature.attributes?.push(getRecordInfo(key, value));\n }\n\n if (geomReader && opts.geomRenderer) {\n await geomReader.readGeometry(responseFeature.geometry);\n const graphics = opts.geomRenderer.moveGraphics();\n feature.geometries = graphics.map((graphic: GraphicPrimitive) => {\n return {graphic};\n });\n }\n subLayerInfo.features.push(feature);\n }\n\n if (layerInfo.subLayerInfos === undefined)\n layerInfo.subLayerInfos = [];\n layerInfo.subLayerInfos.push(subLayerInfo);\n\n featureInfos.push(layerInfo);\n }\n\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itwin/map-layers-formats",
3
- "version": "5.9.0-dev.9",
3
+ "version": "5.9.1",
4
4
  "description": "Enables additional map-layers formats in iTwin.js",
5
5
  "main": "lib/cjs/map-layers-formats.js",
6
6
  "module": "lib/esm/map-layers-formats.js",
@@ -52,20 +52,20 @@
52
52
  "source-map-support": "^0.5.6",
53
53
  "typescript": "~5.6.2",
54
54
  "fetch-mock": "~11.1.3",
55
- "@itwin/appui-abstract": "5.9.0-dev.9",
56
- "@itwin/core-geometry": "5.9.0-dev.9",
57
- "@itwin/build-tools": "5.9.0-dev.9",
58
- "@itwin/core-bentley": "5.9.0-dev.9",
59
- "@itwin/core-frontend": "5.9.0-dev.9",
60
- "@itwin/core-common": "5.9.0-dev.9",
61
- "internal-tools": "3.0.0-dev.69"
55
+ "@itwin/appui-abstract": "5.9.1",
56
+ "@itwin/core-geometry": "5.9.1",
57
+ "@itwin/core-bentley": "5.9.1",
58
+ "@itwin/core-frontend": "5.9.1",
59
+ "@itwin/core-common": "5.9.1",
60
+ "internal-tools": "3.0.0-dev.69",
61
+ "@itwin/build-tools": "5.9.1"
62
62
  },
63
63
  "peerDependencies": {
64
- "@itwin/appui-abstract": "5.9.0-dev.9",
65
- "@itwin/core-common": "5.9.0-dev.9",
66
- "@itwin/core-bentley": "5.9.0-dev.9",
67
- "@itwin/core-frontend": "5.9.0-dev.9",
68
- "@itwin/core-geometry": "5.9.0-dev.9"
64
+ "@itwin/appui-abstract": "5.9.1",
65
+ "@itwin/core-common": "5.9.1",
66
+ "@itwin/core-frontend": "5.9.1",
67
+ "@itwin/core-bentley": "5.9.1",
68
+ "@itwin/core-geometry": "5.9.1"
69
69
  },
70
70
  "dependencies": {
71
71
  "google-protobuf": "~3.20.1",