@itwin/map-layers-formats 4.6.0-dev.9 → 4.7.0-dev.3

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.
Files changed (175) hide show
  1. package/CHANGELOG.md +13 -1
  2. package/lib/cjs/ArcGisFeature/ArcGisFeatureFormat.js +1 -1
  3. package/lib/cjs/ArcGisFeature/ArcGisFeatureFormat.js.map +1 -1
  4. package/lib/cjs/ArcGisFeature/ArcGisFeatureProvider.d.ts +15 -6
  5. package/lib/cjs/ArcGisFeature/ArcGisFeatureProvider.d.ts.map +1 -1
  6. package/lib/cjs/ArcGisFeature/ArcGisFeatureProvider.js +64 -54
  7. package/lib/cjs/ArcGisFeature/ArcGisFeatureProvider.js.map +1 -1
  8. package/lib/cjs/ArcGisFeature/ArcGisFeatureQuery.js.map +1 -1
  9. package/lib/cjs/ArcGisFeature/ArcGisFeatureReader.d.ts +7 -11
  10. package/lib/cjs/ArcGisFeature/ArcGisFeatureReader.d.ts.map +1 -1
  11. package/lib/cjs/ArcGisFeature/ArcGisFeatureReader.js +3 -19
  12. package/lib/cjs/ArcGisFeature/ArcGisFeatureReader.js.map +1 -1
  13. package/lib/cjs/ArcGisFeature/ArcGisFeatureResponse.js.map +1 -1
  14. package/lib/cjs/ArcGisFeature/ArcGisJsonFeatureReader.d.ts +3 -3
  15. package/lib/cjs/ArcGisFeature/ArcGisJsonFeatureReader.d.ts.map +1 -1
  16. package/lib/cjs/ArcGisFeature/ArcGisJsonFeatureReader.js +3 -4
  17. package/lib/cjs/ArcGisFeature/ArcGisJsonFeatureReader.js.map +1 -1
  18. package/lib/cjs/ArcGisFeature/ArcGisPbfFeatureReader.d.ts +3 -3
  19. package/lib/cjs/ArcGisFeature/ArcGisPbfFeatureReader.d.ts.map +1 -1
  20. package/lib/cjs/ArcGisFeature/ArcGisPbfFeatureReader.js +2 -3
  21. package/lib/cjs/ArcGisFeature/ArcGisPbfFeatureReader.js.map +1 -1
  22. package/lib/cjs/ArcGisFeature/ArcGisSymbologyRenderer.d.ts +35 -15
  23. package/lib/cjs/ArcGisFeature/ArcGisSymbologyRenderer.d.ts.map +1 -1
  24. package/lib/cjs/ArcGisFeature/ArcGisSymbologyRenderer.js +54 -48
  25. package/lib/cjs/ArcGisFeature/ArcGisSymbologyRenderer.js.map +1 -1
  26. package/lib/cjs/ArcGisFeature/EsriSymbology.d.ts +2 -1
  27. package/lib/cjs/ArcGisFeature/EsriSymbology.d.ts.map +1 -1
  28. package/lib/cjs/ArcGisFeature/EsriSymbology.js +2 -1
  29. package/lib/cjs/ArcGisFeature/EsriSymbology.js.map +1 -1
  30. package/lib/cjs/ArcGisFeature/esriPBuffer.gen.js +1 -1
  31. package/lib/cjs/ArcGisFeature/esriPBuffer.gen.js.map +1 -1
  32. package/lib/cjs/Feature/DefaultMarkerIcon.d.ts +10 -0
  33. package/lib/cjs/Feature/DefaultMarkerIcon.d.ts.map +1 -0
  34. package/lib/cjs/Feature/DefaultMarkerIcon.js +31 -0
  35. package/lib/cjs/Feature/DefaultMarkerIcon.js.map +1 -0
  36. package/lib/cjs/Feature/FeatureCanvasRenderer.d.ts +20 -0
  37. package/lib/cjs/Feature/FeatureCanvasRenderer.d.ts.map +1 -0
  38. package/lib/cjs/{ArcGisFeature/ArcGisCanvasRenderer.js → Feature/FeatureCanvasRenderer.js} +7 -6
  39. package/lib/cjs/Feature/FeatureCanvasRenderer.js.map +1 -0
  40. package/lib/cjs/Feature/FeatureInfoReader.d.ts +11 -0
  41. package/lib/cjs/Feature/FeatureInfoReader.d.ts.map +1 -0
  42. package/lib/cjs/Feature/FeatureInfoReader.js +35 -0
  43. package/lib/cjs/Feature/FeatureInfoReader.js.map +1 -0
  44. package/lib/cjs/Feature/FeatureSymbology.d.ts +8 -0
  45. package/lib/cjs/Feature/FeatureSymbology.d.ts.map +1 -0
  46. package/lib/cjs/Feature/FeatureSymbology.js +12 -0
  47. package/lib/cjs/Feature/FeatureSymbology.js.map +1 -0
  48. package/lib/cjs/Feature/RandomMapColor.d.ts +8 -0
  49. package/lib/cjs/Feature/RandomMapColor.d.ts.map +1 -0
  50. package/lib/cjs/Feature/RandomMapColor.js +29 -0
  51. package/lib/cjs/Feature/RandomMapColor.js.map +1 -0
  52. package/lib/cjs/GeoJSON/GeoJSONGeometry.d.ts +18 -0
  53. package/lib/cjs/GeoJSON/GeoJSONGeometry.d.ts.map +1 -0
  54. package/lib/cjs/GeoJSON/GeoJSONGeometry.js +11 -0
  55. package/lib/cjs/GeoJSON/GeoJSONGeometry.js.map +1 -0
  56. package/lib/cjs/GeoJSON/GeoJSONGeometryReader.d.ts +11 -0
  57. package/lib/cjs/GeoJSON/GeoJSONGeometryReader.d.ts.map +1 -0
  58. package/lib/cjs/GeoJSON/GeoJSONGeometryReader.js +83 -0
  59. package/lib/cjs/GeoJSON/GeoJSONGeometryReader.js.map +1 -0
  60. package/lib/cjs/OgcApiFeatures/OgcApiFeaturesFormat.d.ts +9 -0
  61. package/lib/cjs/OgcApiFeatures/OgcApiFeaturesFormat.d.ts.map +1 -0
  62. package/lib/cjs/OgcApiFeatures/OgcApiFeaturesFormat.js +94 -0
  63. package/lib/cjs/OgcApiFeatures/OgcApiFeaturesFormat.js.map +1 -0
  64. package/lib/cjs/OgcApiFeatures/OgcApiFeaturesProvider.d.ts +54 -0
  65. package/lib/cjs/OgcApiFeatures/OgcApiFeaturesProvider.d.ts.map +1 -0
  66. package/lib/cjs/OgcApiFeatures/OgcApiFeaturesProvider.js +477 -0
  67. package/lib/cjs/OgcApiFeatures/OgcApiFeaturesProvider.js.map +1 -0
  68. package/lib/cjs/OgcApiFeatures/OgcApiFeaturesReader.d.ts +23 -0
  69. package/lib/cjs/OgcApiFeatures/OgcApiFeaturesReader.d.ts.map +1 -0
  70. package/lib/cjs/OgcApiFeatures/OgcApiFeaturesReader.js +139 -0
  71. package/lib/cjs/OgcApiFeatures/OgcApiFeaturesReader.js.map +1 -0
  72. package/lib/cjs/Tools/GeometryTerrainDraper.d.ts +20 -0
  73. package/lib/cjs/Tools/GeometryTerrainDraper.d.ts.map +1 -0
  74. package/lib/cjs/Tools/GeometryTerrainDraper.js +153 -0
  75. package/lib/cjs/Tools/GeometryTerrainDraper.js.map +1 -0
  76. package/lib/cjs/Tools/MapFeatureInfoDecorator.d.ts +15 -10
  77. package/lib/cjs/Tools/MapFeatureInfoDecorator.d.ts.map +1 -1
  78. package/lib/cjs/Tools/MapFeatureInfoDecorator.js +191 -150
  79. package/lib/cjs/Tools/MapFeatureInfoDecorator.js.map +1 -1
  80. package/lib/cjs/Tools/MapFeatureInfoTool.d.ts.map +1 -1
  81. package/lib/cjs/Tools/MapFeatureInfoTool.js +7 -4
  82. package/lib/cjs/Tools/MapFeatureInfoTool.js.map +1 -1
  83. package/lib/cjs/mapLayersFormats.d.ts.map +1 -1
  84. package/lib/cjs/mapLayersFormats.js +5 -2
  85. package/lib/cjs/mapLayersFormats.js.map +1 -1
  86. package/lib/esm/ArcGisFeature/ArcGisFeatureFormat.js +1 -2
  87. package/lib/esm/ArcGisFeature/ArcGisFeatureFormat.js.map +1 -1
  88. package/lib/esm/ArcGisFeature/ArcGisFeatureProvider.d.ts +15 -6
  89. package/lib/esm/ArcGisFeature/ArcGisFeatureProvider.d.ts.map +1 -1
  90. package/lib/esm/ArcGisFeature/ArcGisFeatureProvider.js +63 -55
  91. package/lib/esm/ArcGisFeature/ArcGisFeatureProvider.js.map +1 -1
  92. package/lib/esm/ArcGisFeature/ArcGisFeatureQuery.js.map +1 -1
  93. package/lib/esm/ArcGisFeature/ArcGisFeatureReader.d.ts +7 -11
  94. package/lib/esm/ArcGisFeature/ArcGisFeatureReader.d.ts.map +1 -1
  95. package/lib/esm/ArcGisFeature/ArcGisFeatureReader.js +3 -19
  96. package/lib/esm/ArcGisFeature/ArcGisFeatureReader.js.map +1 -1
  97. package/lib/esm/ArcGisFeature/ArcGisFeatureResponse.js.map +1 -1
  98. package/lib/esm/ArcGisFeature/ArcGisJsonFeatureReader.d.ts +3 -3
  99. package/lib/esm/ArcGisFeature/ArcGisJsonFeatureReader.d.ts.map +1 -1
  100. package/lib/esm/ArcGisFeature/ArcGisJsonFeatureReader.js +3 -4
  101. package/lib/esm/ArcGisFeature/ArcGisJsonFeatureReader.js.map +1 -1
  102. package/lib/esm/ArcGisFeature/ArcGisPbfFeatureReader.d.ts +3 -3
  103. package/lib/esm/ArcGisFeature/ArcGisPbfFeatureReader.d.ts.map +1 -1
  104. package/lib/esm/ArcGisFeature/ArcGisPbfFeatureReader.js +2 -3
  105. package/lib/esm/ArcGisFeature/ArcGisPbfFeatureReader.js.map +1 -1
  106. package/lib/esm/ArcGisFeature/ArcGisSymbologyRenderer.d.ts +35 -15
  107. package/lib/esm/ArcGisFeature/ArcGisSymbologyRenderer.d.ts.map +1 -1
  108. package/lib/esm/ArcGisFeature/ArcGisSymbologyRenderer.js +52 -47
  109. package/lib/esm/ArcGisFeature/ArcGisSymbologyRenderer.js.map +1 -1
  110. package/lib/esm/ArcGisFeature/EsriSymbology.d.ts +2 -1
  111. package/lib/esm/ArcGisFeature/EsriSymbology.d.ts.map +1 -1
  112. package/lib/esm/ArcGisFeature/EsriSymbology.js +2 -1
  113. package/lib/esm/ArcGisFeature/EsriSymbology.js.map +1 -1
  114. package/lib/esm/ArcGisFeature/esriPBuffer.gen.js.map +1 -1
  115. package/lib/esm/Feature/DefaultMarkerIcon.d.ts +10 -0
  116. package/lib/esm/Feature/DefaultMarkerIcon.d.ts.map +1 -0
  117. package/lib/esm/Feature/DefaultMarkerIcon.js +27 -0
  118. package/lib/esm/Feature/DefaultMarkerIcon.js.map +1 -0
  119. package/lib/esm/Feature/FeatureCanvasRenderer.d.ts +20 -0
  120. package/lib/esm/Feature/FeatureCanvasRenderer.d.ts.map +1 -0
  121. package/lib/esm/{ArcGisFeature/ArcGisCanvasRenderer.js → Feature/FeatureCanvasRenderer.js} +6 -5
  122. package/lib/esm/Feature/FeatureCanvasRenderer.js.map +1 -0
  123. package/lib/esm/Feature/FeatureInfoReader.d.ts +11 -0
  124. package/lib/esm/Feature/FeatureInfoReader.d.ts.map +1 -0
  125. package/lib/esm/Feature/FeatureInfoReader.js +31 -0
  126. package/lib/esm/Feature/FeatureInfoReader.js.map +1 -0
  127. package/lib/esm/Feature/FeatureSymbology.d.ts +8 -0
  128. package/lib/esm/Feature/FeatureSymbology.d.ts.map +1 -0
  129. package/lib/esm/Feature/FeatureSymbology.js +8 -0
  130. package/lib/esm/Feature/FeatureSymbology.js.map +1 -0
  131. package/lib/esm/Feature/RandomMapColor.d.ts +8 -0
  132. package/lib/esm/Feature/RandomMapColor.d.ts.map +1 -0
  133. package/lib/esm/Feature/RandomMapColor.js +25 -0
  134. package/lib/esm/Feature/RandomMapColor.js.map +1 -0
  135. package/lib/esm/GeoJSON/GeoJSONGeometry.d.ts +18 -0
  136. package/lib/esm/GeoJSON/GeoJSONGeometry.d.ts.map +1 -0
  137. package/lib/esm/GeoJSON/GeoJSONGeometry.js +7 -0
  138. package/lib/esm/GeoJSON/GeoJSONGeometry.js.map +1 -0
  139. package/lib/esm/GeoJSON/GeoJSONGeometryReader.d.ts +11 -0
  140. package/lib/esm/GeoJSON/GeoJSONGeometryReader.d.ts.map +1 -0
  141. package/lib/esm/GeoJSON/GeoJSONGeometryReader.js +79 -0
  142. package/lib/esm/GeoJSON/GeoJSONGeometryReader.js.map +1 -0
  143. package/lib/esm/OgcApiFeatures/OgcApiFeaturesFormat.d.ts +9 -0
  144. package/lib/esm/OgcApiFeatures/OgcApiFeaturesFormat.d.ts.map +1 -0
  145. package/lib/esm/OgcApiFeatures/OgcApiFeaturesFormat.js +90 -0
  146. package/lib/esm/OgcApiFeatures/OgcApiFeaturesFormat.js.map +1 -0
  147. package/lib/esm/OgcApiFeatures/OgcApiFeaturesProvider.d.ts +54 -0
  148. package/lib/esm/OgcApiFeatures/OgcApiFeaturesProvider.d.ts.map +1 -0
  149. package/lib/esm/OgcApiFeatures/OgcApiFeaturesProvider.js +472 -0
  150. package/lib/esm/OgcApiFeatures/OgcApiFeaturesProvider.js.map +1 -0
  151. package/lib/esm/OgcApiFeatures/OgcApiFeaturesReader.d.ts +23 -0
  152. package/lib/esm/OgcApiFeatures/OgcApiFeaturesReader.d.ts.map +1 -0
  153. package/lib/esm/OgcApiFeatures/OgcApiFeaturesReader.js +135 -0
  154. package/lib/esm/OgcApiFeatures/OgcApiFeaturesReader.js.map +1 -0
  155. package/lib/esm/Tools/GeometryTerrainDraper.d.ts +20 -0
  156. package/lib/esm/Tools/GeometryTerrainDraper.d.ts.map +1 -0
  157. package/lib/esm/Tools/GeometryTerrainDraper.js +149 -0
  158. package/lib/esm/Tools/GeometryTerrainDraper.js.map +1 -0
  159. package/lib/esm/Tools/MapFeatureInfoDecorator.d.ts +15 -10
  160. package/lib/esm/Tools/MapFeatureInfoDecorator.d.ts.map +1 -1
  161. package/lib/esm/Tools/MapFeatureInfoDecorator.js +193 -152
  162. package/lib/esm/Tools/MapFeatureInfoDecorator.js.map +1 -1
  163. package/lib/esm/Tools/MapFeatureInfoTool.d.ts.map +1 -1
  164. package/lib/esm/Tools/MapFeatureInfoTool.js +7 -5
  165. package/lib/esm/Tools/MapFeatureInfoTool.js.map +1 -1
  166. package/lib/esm/mapLayersFormats.d.ts.map +1 -1
  167. package/lib/esm/mapLayersFormats.js +5 -3
  168. package/lib/esm/mapLayersFormats.js.map +1 -1
  169. package/package.json +18 -15
  170. package/lib/cjs/ArcGisFeature/ArcGisCanvasRenderer.d.ts +0 -19
  171. package/lib/cjs/ArcGisFeature/ArcGisCanvasRenderer.d.ts.map +0 -1
  172. package/lib/cjs/ArcGisFeature/ArcGisCanvasRenderer.js.map +0 -1
  173. package/lib/esm/ArcGisFeature/ArcGisCanvasRenderer.d.ts +0 -19
  174. package/lib/esm/ArcGisFeature/ArcGisCanvasRenderer.d.ts.map +0 -1
  175. package/lib/esm/ArcGisFeature/ArcGisCanvasRenderer.js.map +0 -1
@@ -0,0 +1,139 @@
1
+ "use strict";
2
+ /*---------------------------------------------------------------------------------------------
3
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
4
+ * See LICENSE.md in the project root for license terms and full copyright notice.
5
+ *--------------------------------------------------------------------------------------------*/
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.OgcApiFeaturesReader = void 0;
8
+ const GeoJSONGeometryReader_1 = require("../GeoJSON/GeoJSONGeometryReader");
9
+ const appui_abstract_1 = require("@itwin/appui-abstract");
10
+ const FeatureInfoReader_1 = require("../Feature/FeatureInfoReader");
11
+ /** @internal */
12
+ class OgcApiFeaturesReader extends FeatureInfoReader_1.FeatureInfoReader {
13
+ constructor() {
14
+ super();
15
+ }
16
+ applySymbologyAttributes(attrSymbology, feature) {
17
+ if (attrSymbology && feature) {
18
+ const symbolFields = attrSymbology.rendererFields;
19
+ if (symbolFields && symbolFields.length > 0 && feature.properties) {
20
+ const featureAttr = {};
21
+ for (const [attrKey, attrValue] of Object.entries(feature.properties))
22
+ if (symbolFields.includes(attrKey)) {
23
+ featureAttr[attrKey] = attrValue;
24
+ }
25
+ attrSymbology.setActiveFeatureAttributes(featureAttr);
26
+ }
27
+ }
28
+ }
29
+ async readAndRender(data, renderer) {
30
+ const responseObj = data;
31
+ if (responseObj.type === "FeatureCollection") {
32
+ const geomReader = new GeoJSONGeometryReader_1.GeoJSONGeometryReader(renderer);
33
+ for (const feature of responseObj.features) {
34
+ // Each feature has potentially a different geometry type, so we need to inform the geometry renderer
35
+ if (renderer.hasSymbologyRenderer()) {
36
+ renderer.symbolRenderer.activeGeometryType = feature.geometry.type;
37
+ // Read attributes if needed (attribute driven symbology)
38
+ if (renderer.symbolRenderer.isAttributeDriven()) {
39
+ this.applySymbologyAttributes(renderer.symbolRenderer, feature);
40
+ }
41
+ }
42
+ await geomReader.readGeometry(feature.geometry);
43
+ }
44
+ }
45
+ }
46
+ async readFeatureInfo(opts, featureInfos) {
47
+ if (!Array.isArray(opts.collection.features))
48
+ return;
49
+ const layerInfo = { layerName: opts.layerSettings.name };
50
+ // Create a signature index for every field name / type.
51
+ let fieldsType;
52
+ if (Array.isArray(opts.queryables?.properties)) {
53
+ fieldsType = {};
54
+ for (const fieldInfo of opts.queryables) {
55
+ fieldsType[fieldInfo.name] = fieldInfo.type;
56
+ }
57
+ }
58
+ const getStandardTypeName = (fieldType) => {
59
+ switch (fieldType) {
60
+ case "number":
61
+ return appui_abstract_1.StandardTypeNames.Double;
62
+ case "integer":
63
+ return appui_abstract_1.StandardTypeNames.Integer;
64
+ case "boolean":
65
+ return appui_abstract_1.StandardTypeNames.Boolean;
66
+ case "datetime":
67
+ return appui_abstract_1.StandardTypeNames.DateTime;
68
+ default:
69
+ return appui_abstract_1.StandardTypeNames.String;
70
+ }
71
+ };
72
+ const getRecordInfo = (fieldName, value) => {
73
+ let typename = appui_abstract_1.StandardTypeNames.String;
74
+ const propertyValue = { valueFormat: appui_abstract_1.PropertyValueFormat.Primitive };
75
+ if (value === null) {
76
+ value = undefined;
77
+ }
78
+ const strValue = `${value}`;
79
+ if (fieldsType) {
80
+ const fieldType = fieldsType[fieldName];
81
+ switch (fieldType) {
82
+ case "integer":
83
+ propertyValue.value = value;
84
+ break;
85
+ case "number":
86
+ propertyValue.value = this.toFixedWithoutPadding(value);
87
+ break;
88
+ case "datetime":
89
+ propertyValue.value = new Date(value);
90
+ break;
91
+ default:
92
+ if (value !== undefined)
93
+ propertyValue.value = strValue;
94
+ break;
95
+ }
96
+ typename = getStandardTypeName(fieldType);
97
+ propertyValue.displayValue = this.getDisplayValue(typename, propertyValue.value);
98
+ }
99
+ else {
100
+ // Queryables are optional with OGC Features, in this case everything is string.
101
+ propertyValue.value = strValue;
102
+ propertyValue.displayValue = strValue;
103
+ }
104
+ return { value: propertyValue, property: { name: fieldName, displayLabel: fieldName, typename } };
105
+ };
106
+ let geomReader;
107
+ if (opts.geomRenderer) {
108
+ geomReader = new GeoJSONGeometryReader_1.GeoJSONGeometryReader(opts.geomRenderer);
109
+ }
110
+ // Each feature response represent a single sub-layer, no need to check for existing entry.
111
+ const subLayerInfo = {
112
+ subLayerName: opts.layerSettings.name,
113
+ displayFieldName: opts.layerSettings.name,
114
+ features: [],
115
+ };
116
+ // Read all features attributes / geometries
117
+ for (const responseFeature of opts.collection.features) {
118
+ const feature = { attributes: [] };
119
+ if (responseFeature.properties) {
120
+ for (const [key, value] of Object.entries(responseFeature.properties))
121
+ feature.attributes?.push(getRecordInfo(key, value));
122
+ }
123
+ if (geomReader && opts.geomRenderer) {
124
+ await geomReader.readGeometry(responseFeature.geometry);
125
+ const graphics = opts.geomRenderer.moveGraphics();
126
+ feature.geometries = graphics.map((graphic) => {
127
+ return { graphic };
128
+ });
129
+ }
130
+ subLayerInfo.features.push(feature);
131
+ }
132
+ if (layerInfo.subLayerInfos === undefined)
133
+ layerInfo.subLayerInfos = [];
134
+ layerInfo.subLayerInfos.push(subLayerInfo);
135
+ featureInfos.push(layerInfo);
136
+ }
137
+ }
138
+ exports.OgcApiFeaturesReader = OgcApiFeaturesReader;
139
+ //# sourceMappingURL=OgcApiFeaturesReader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OgcApiFeaturesReader.js","sourceRoot":"","sources":["../../../src/OgcApiFeatures/OgcApiFeaturesReader.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAG/F,4EAAyE;AAEzE,0DAA+F;AAE/F,oEAAiE;AAcjE,gBAAgB;AAChB,MAAa,oBAAqB,SAAQ,qCAAiB;IAGzD;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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AE,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":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\nimport { Transform } from \"@itwin/core-geometry\";\r\nimport { GeoJSONGeometryReader } from \"../GeoJSON/GeoJSONGeometryReader\";\r\nimport * as Geojson from \"geojson\";\r\nimport { PrimitiveValue, PropertyValueFormat, StandardTypeNames } from \"@itwin/appui-abstract\";\r\nimport { ImageMapLayerSettings } from \"@itwin/core-common\";\r\nimport { FeatureInfoReader } from \"../Feature/FeatureInfoReader\";\r\nimport { FeatureAttributeDrivenSymbology, FeatureGeometryRenderer, GraphicPrimitive, GraphicsGeometryRenderer, MapLayerFeature, MapLayerFeatureAttribute, MapLayerFeatureInfo, MapSubLayerFeatureInfo } from \"@itwin/core-frontend\";\r\n\r\n/** @internal */\r\nexport type OgcFeaturePropertyType = \"string\" | \"number\" | \"integer\" | \"datetime\" | \"geometry\" | \"boolean\";\r\n\r\n/** @internal */\r\nexport interface ReadOgcApiFeaturesInfoOptions {\r\n collection: Geojson.FeatureCollection;\r\n layerSettings: ImageMapLayerSettings;\r\n queryables?: any;\r\n geomRenderer?: GraphicsGeometryRenderer;\r\n}\r\n\r\n/** @internal */\r\nexport class OgcApiFeaturesReader extends FeatureInfoReader {\r\n public transform: Transform | undefined;\r\n\r\n public constructor() {\r\n super();\r\n }\r\n\r\n private applySymbologyAttributes(attrSymbology: FeatureAttributeDrivenSymbology, feature: any) {\r\n if (attrSymbology && feature) {\r\n const symbolFields = attrSymbology.rendererFields;\r\n if (symbolFields && symbolFields.length > 0 && feature.properties) {\r\n const featureAttr: {[key: string]: any} = {};\r\n for (const [attrKey, attrValue] of Object.entries(feature.properties))\r\n if (symbolFields.includes(attrKey)) {\r\n featureAttr[attrKey] = attrValue;\r\n }\r\n attrSymbology.setActiveFeatureAttributes(featureAttr);\r\n }\r\n }\r\n }\r\n\r\n public async readAndRender(data: Geojson.FeatureCollection, renderer: FeatureGeometryRenderer) {\r\n const responseObj = data;\r\n if (responseObj.type === \"FeatureCollection\") {\r\n\r\n const geomReader = new GeoJSONGeometryReader(renderer);\r\n\r\n for (const feature of responseObj.features) {\r\n // Each feature has potentially a different geometry type, so we need to inform the geometry renderer\r\n if (renderer.hasSymbologyRenderer()) {\r\n renderer.symbolRenderer.activeGeometryType = feature.geometry.type;\r\n // Read attributes if needed (attribute driven symbology)\r\n if (renderer.symbolRenderer.isAttributeDriven()) {\r\n this.applySymbologyAttributes(renderer.symbolRenderer, feature);\r\n }\r\n }\r\n\r\n await geomReader.readGeometry(feature.geometry);\r\n }\r\n }\r\n }\r\n\r\n public async readFeatureInfo(opts: ReadOgcApiFeaturesInfoOptions, featureInfos: MapLayerFeatureInfo[]) {\r\n if (!Array.isArray(opts.collection.features))\r\n return;\r\n\r\n const layerInfo: MapLayerFeatureInfo = { layerName: opts.layerSettings.name };\r\n\r\n // Create a signature index for every field name / type.\r\n let fieldsType: { [key: string]: OgcFeaturePropertyType } | undefined;\r\n if (Array.isArray(opts.queryables?.properties)) {\r\n fieldsType = {};\r\n for (const fieldInfo of opts.queryables) {\r\n fieldsType[fieldInfo.name] = fieldInfo.type;\r\n }\r\n }\r\n\r\n const getStandardTypeName = (fieldType: OgcFeaturePropertyType) => {\r\n switch (fieldType) {\r\n case \"number\":\r\n return StandardTypeNames.Double;\r\n case \"integer\":\r\n return StandardTypeNames.Integer;\r\n case \"boolean\":\r\n return StandardTypeNames.Boolean;\r\n case \"datetime\":\r\n return StandardTypeNames.DateTime;\r\n default:\r\n return StandardTypeNames.String;\r\n }\r\n };\r\n\r\n const getRecordInfo = (fieldName: string, value: any): MapLayerFeatureAttribute => {\r\n let typename = StandardTypeNames.String;\r\n const propertyValue: PrimitiveValue = {valueFormat: PropertyValueFormat.Primitive};\r\n\r\n if (value === null) {\r\n value = undefined;\r\n }\r\n\r\n const strValue = `${value}`;\r\n if (fieldsType) {\r\n const fieldType = fieldsType[fieldName];\r\n switch (fieldType) {\r\n case \"integer\":\r\n propertyValue.value = value as number;\r\n break;\r\n case \"number\":\r\n propertyValue.value = this.toFixedWithoutPadding(value);\r\n break;\r\n case \"datetime\":\r\n propertyValue.value = new Date(value);\r\n break;\r\n default:\r\n if (value !== undefined)\r\n propertyValue.value = strValue;\r\n break;\r\n }\r\n typename = getStandardTypeName(fieldType);\r\n propertyValue.displayValue = this.getDisplayValue(typename, propertyValue.value);\r\n } else {\r\n // Queryables are optional with OGC Features, in this case everything is string.\r\n propertyValue.value = strValue;\r\n propertyValue.displayValue = strValue;\r\n }\r\n\r\n return {value: propertyValue, property: { name: fieldName, displayLabel: fieldName, typename }};\r\n };\r\n\r\n let geomReader: GeoJSONGeometryReader|undefined;\r\n if (opts.geomRenderer) {\r\n geomReader = new GeoJSONGeometryReader(opts.geomRenderer);\r\n }\r\n\r\n // Each feature response represent a single sub-layer, no need to check for existing entry.\r\n const subLayerInfo: MapSubLayerFeatureInfo = {\r\n subLayerName: opts.layerSettings.name,\r\n displayFieldName: opts.layerSettings.name,\r\n features: [],\r\n };\r\n\r\n // Read all features attributes / geometries\r\n for (const responseFeature of opts.collection.features) {\r\n const feature: MapLayerFeature = {attributes: []};\r\n\r\n if (responseFeature.properties) {\r\n for (const [key, value] of Object.entries(responseFeature.properties))\r\n feature.attributes?.push(getRecordInfo(key, value));\r\n }\r\n\r\n if (geomReader && opts.geomRenderer) {\r\n await geomReader.readGeometry(responseFeature.geometry as any);\r\n const graphics = opts.geomRenderer.moveGraphics();\r\n feature.geometries = graphics.map((graphic: GraphicPrimitive) => {\r\n return {graphic};\r\n });\r\n }\r\n subLayerInfo.features.push(feature);\r\n }\r\n\r\n if (layerInfo.subLayerInfos === undefined)\r\n layerInfo.subLayerInfos = [];\r\n layerInfo.subLayerInfos.push(subLayerInfo);\r\n\r\n featureInfos.push(layerInfo);\r\n }\r\n\r\n}\r\n"]}
@@ -0,0 +1,20 @@
1
+ import { DisclosedTileTreeSet, GeometryTileTreeReference, TileUser, Viewport } from "@itwin/core-frontend";
2
+ import { Angle, CurvePrimitive, GrowableXYZArray, IndexedPolyface, IndexedPolyfaceSubsetVisitor, Loop, Point3d, Polyface, Range3d } from "@itwin/core-geometry";
3
+ /** @internal */
4
+ export declare class GeometryTerrainDraper implements TileUser {
5
+ readonly viewport: Viewport;
6
+ readonly treeRef: GeometryTileTreeReference;
7
+ readonly sideAngle: Angle;
8
+ readonly maxDistanceZ = 100000;
9
+ readonly tileUserId: number;
10
+ constructor(viewport: Viewport, treeRef: GeometryTileTreeReference);
11
+ dispose(): void;
12
+ get iModel(): import("@itwin/core-frontend").IModelConnection;
13
+ onRequestStateChanged(): void;
14
+ discloseTileTrees(trees: DisclosedTileTreeSet): void;
15
+ getMeshTopFacets(mesh: IndexedPolyface): IndexedPolyfaceSubsetVisitor;
16
+ drapeLineString(outStrings: CurvePrimitive[], inPoints: GrowableXYZArray, tolerance: number, range: Range3d): "loading" | "complete";
17
+ drapeLoop(outMeshes: Polyface[], loop: Loop, tolerance: number, range: Range3d): "loading" | "complete";
18
+ drapePoint(outPoint: Point3d, point: Point3d, chordTolerance: number, range: Range3d): "loading" | "complete";
19
+ }
20
+ //# sourceMappingURL=GeometryTerrainDraper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GeometryTerrainDraper.d.ts","sourceRoot":"","sources":["../../../src/Tools/GeometryTerrainDraper.ts"],"names":[],"mappings":"AAIA,OAAO,EACc,oBAAoB,EACvC,yBAAyB,EACI,QAAQ,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChF,OAAO,EAAE,KAAK,EAAsB,cAAc,EAAE,gBAAgB,EAAE,eAAe,EAAE,4BAA4B,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAA2C,OAAO,EAA8D,MAAM,sBAAsB,CAAC;AA6CzR,gBAAgB;AAChB,qBAAa,qBAAsB,YAAW,QAAQ;aASjB,QAAQ,EAAE,QAAQ;aAAkB,OAAO,EAAE,yBAAyB;IALzG,SAAgB,SAAS,QAA6B;IAEtD,SAAgB,YAAY,UAAS;IACrC,SAAgB,UAAU,EAAE,MAAM,CAAC;gBAEA,QAAQ,EAAE,QAAQ,EAAkB,OAAO,EAAE,yBAAyB;IAKlG,OAAO,IAAI,IAAI;IAItB,IAAW,MAAM,oDAAmC;IAE7C,qBAAqB;IAIrB,iBAAiB,CAAC,KAAK,EAAE,oBAAoB;IAM7C,gBAAgB,CAAC,IAAI,EAAE,eAAe;IAqBtC,eAAe,CAAC,UAAU,EAAE,cAAc,EAAE,EAAE,QAAQ,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,SAAS,GAAG,UAAU;IA8BpI,SAAS,CAAC,SAAS,EAAE,QAAQ,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,SAAS,GAAG,UAAU;IA4BvG,UAAU,CAAC,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,SAAS,GAAG,UAAU;CAyBrH"}
@@ -0,0 +1,153 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GeometryTerrainDraper = void 0;
4
+ /*---------------------------------------------------------------------------------------------
5
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
6
+ * See LICENSE.md in the project root for license terms and full copyright notice.
7
+ *--------------------------------------------------------------------------------------------*/
8
+ const core_frontend_1 = require("@itwin/core-frontend");
9
+ const core_geometry_1 = require("@itwin/core-geometry");
10
+ const core_bentley_1 = require("@itwin/core-bentley");
11
+ const loggerCategory = "MapLayersFormats.GeometryTerrainDraper";
12
+ /** A TileGeometryCollector that restricts collection to tiles that overlap a line string.
13
+ /* @internal
14
+ */
15
+ class LineSegmentCollector extends core_frontend_1.TileGeometryCollector {
16
+ constructor(user, chordTolerance, range, transform, points) {
17
+ super({ user, chordTolerance, range, transform });
18
+ this._points = points;
19
+ }
20
+ addMissingTile(tile) {
21
+ core_bentley_1.Logger.logTrace(loggerCategory, `CollectorAdd missing tile: ${tile.contentId}`);
22
+ super.addMissingTile(tile);
23
+ }
24
+ collectTile(tile) {
25
+ let status = super.collectTile(tile);
26
+ if ("reject" !== status && !this.rangeOverlapsLineString(tile.range)) {
27
+ status = "reject";
28
+ }
29
+ core_bentley_1.Logger.logTrace(loggerCategory, `collectTile - tile: ${tile.contentId} status: ${status} isReady: ${tile.isReady} status:${tile.loadStatus}`);
30
+ return status;
31
+ }
32
+ rangeOverlapsLineString(range) {
33
+ let inside = false;
34
+ const clipper = core_geometry_1.ConvexClipPlaneSet.createRange3dPlanes(range, true, true, true, true, false, false);
35
+ if (this._options.transform)
36
+ clipper.transformInPlace(this._options.transform);
37
+ for (let i = 0; i < this._points.length - 1 && !inside; i++)
38
+ inside = clipper.announceClippedSegmentIntervals(0, 1, this._points.getPoint3dAtUncheckedPointIndex(i), this._points.getPoint3dAtUncheckedPointIndex(i + 1));
39
+ return inside;
40
+ }
41
+ }
42
+ /** @internal */
43
+ class GeometryTerrainDraper {
44
+ constructor(viewport, treeRef) {
45
+ this.viewport = viewport;
46
+ this.treeRef = treeRef;
47
+ // The side angle measures how close the sweep vector is from being parallel to a side face.
48
+ // The larger the angle, the more nearly vertical facets are ignored.
49
+ // This is an "empirical" value that was determined by looking at "problematic" polyfaces
50
+ this.sideAngle = core_geometry_1.Angle.createDegrees(0.06);
51
+ this.maxDistanceZ = 1.0E5; // Expand the Z Range, but not so much that we get opposite side of globe.
52
+ this.tileUserId = core_frontend_1.TileUser.generateId();
53
+ core_frontend_1.IModelApp.tileAdmin.registerUser(this);
54
+ }
55
+ dispose() {
56
+ core_frontend_1.IModelApp.tileAdmin.forgetUser(this);
57
+ }
58
+ get iModel() { return this.viewport.iModel; }
59
+ onRequestStateChanged() {
60
+ this.viewport.invalidateDecorations();
61
+ }
62
+ discloseTileTrees(trees) {
63
+ trees.disclose(this.treeRef);
64
+ }
65
+ // Filter out non-top facets:
66
+ // For unknown reasons, there are "perpendicular" facets appearing in the terrain meshes.
67
+ getMeshTopFacets(mesh) {
68
+ // constant inputs
69
+ const sweepVector = core_geometry_1.Vector3d.unitZ();
70
+ // i.e., region is horizontal
71
+ // create subset visitor from the top facets
72
+ const topFacets = [];
73
+ const facetNormal = core_geometry_1.Vector3d.createZero();
74
+ for (const visitor = mesh.createVisitor(0); visitor.moveToNextFacet();) {
75
+ if (core_geometry_1.PolygonOps.unitNormal(visitor.point, facetNormal)) {
76
+ const theta = facetNormal.angleFromPerpendicular(sweepVector);
77
+ if (!theta.isMagnitudeLessThanOrEqual(this.sideAngle)) { // skip side facet
78
+ if (facetNormal.dotProduct(sweepVector) > 0) // this is a top facet
79
+ topFacets.push(visitor.currentReadIndex());
80
+ }
81
+ }
82
+ }
83
+ return core_geometry_1.IndexedPolyfaceSubsetVisitor.createSubsetVisitor(mesh, topFacets, 0);
84
+ }
85
+ drapeLineString(outStrings, inPoints, tolerance, range) {
86
+ const tree = this.treeRef.treeOwner.load();
87
+ if (!tree)
88
+ return "loading";
89
+ const expandedRange = core_geometry_1.Range3d.createFrom(range);
90
+ expandedRange.extendZOnly(-this.maxDistanceZ);
91
+ expandedRange.extendZOnly(this.maxDistanceZ);
92
+ const collector = new LineSegmentCollector(this, tolerance, expandedRange, tree.iModelTransform, inPoints);
93
+ this.treeRef.collectTileGeometry(collector);
94
+ collector.requestMissingTiles();
95
+ if (collector.isAllGeometryLoaded && collector.polyfaces.length > 0) {
96
+ for (const polyface of collector.polyfaces) {
97
+ // Use this to serialize (problematic) polyface
98
+ // console.log (`const polyface = ${JSON.stringify(IModelJson.Writer.toIModelJson(polyface))}`);
99
+ outStrings.push(...core_geometry_1.PolyfaceQuery.sweepLineStringToFacets(inPoints, polyface, core_geometry_1.SweepLineStringToFacetsOptions.create(core_geometry_1.Vector3d.unitZ(), this.sideAngle, true, true, false, false)));
100
+ }
101
+ return "complete";
102
+ }
103
+ return "loading";
104
+ }
105
+ drapeLoop(outMeshes, loop, tolerance, range) {
106
+ const tree = this.treeRef.treeOwner.load();
107
+ if (!tree)
108
+ return "loading";
109
+ const expandedRange = core_geometry_1.Range3d.createFrom(range);
110
+ expandedRange.extendZOnly(-this.maxDistanceZ);
111
+ expandedRange.extendZOnly(this.maxDistanceZ);
112
+ const strokes = loop.getPackedStrokes();
113
+ if (!strokes)
114
+ return "complete";
115
+ const collector = new LineSegmentCollector(this, tolerance, expandedRange, tree.iModelTransform, strokes);
116
+ this.treeRef.collectTileGeometry(collector);
117
+ collector.requestMissingTiles();
118
+ if (collector.isAllGeometryLoaded && collector.polyfaces.length > 0) {
119
+ for (const polyface of collector.polyfaces) {
120
+ const topFacets = this.getMeshTopFacets(polyface);
121
+ const mesh = core_geometry_1.PolyfaceClip.drapeRegion(topFacets, loop);
122
+ if (mesh)
123
+ outMeshes.push(mesh);
124
+ }
125
+ return "complete";
126
+ }
127
+ return "loading";
128
+ }
129
+ drapePoint(outPoint, point, chordTolerance, range) {
130
+ const tree = this.treeRef.treeOwner.load();
131
+ if (!tree)
132
+ return "loading";
133
+ const expandedRange = core_geometry_1.Range3d.createFrom(range);
134
+ expandedRange.extendZOnly(-this.maxDistanceZ);
135
+ expandedRange.extendZOnly(this.maxDistanceZ);
136
+ const collector = new core_frontend_1.TileGeometryCollector({ chordTolerance, range: expandedRange, user: this });
137
+ this.treeRef.collectTileGeometry(collector);
138
+ collector.requestMissingTiles();
139
+ if (collector.isAllGeometryLoaded && collector.polyfaces.length > 0) {
140
+ for (const polyface of collector.polyfaces) {
141
+ // Im assuming a single polyface here since we are draping a single point
142
+ const facetLocation = core_geometry_1.PolyfaceQuery.intersectRay3d(polyface, core_geometry_1.Ray3d.create(point, core_geometry_1.Vector3d.unitZ()));
143
+ if (!facetLocation)
144
+ continue;
145
+ outPoint.setFromPoint3d(facetLocation.point);
146
+ }
147
+ return "complete";
148
+ }
149
+ return "loading";
150
+ }
151
+ }
152
+ exports.GeometryTerrainDraper = GeometryTerrainDraper;
153
+ //# sourceMappingURL=GeometryTerrainDraper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GeometryTerrainDraper.js","sourceRoot":"","sources":["../../../src/Tools/GeometryTerrainDraper.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F,wDAGgF;AAChF,wDAAyR;AACzR,sDAA6C;AAE7C,MAAM,cAAc,GAAG,wCAAwC,CAAC;AAEhE;;EAEE;AACF,MAAM,oBAAqB,SAAQ,qCAAqB;IAGtD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AAE,CAAC;YACpE,KAAK,MAAM,QAAQ,IAAI,SAAS,CAAC,SAAS,EAAE,CAAC;gBAC3C,yEAAyE;gBACzE,MAAM,aAAa,GAAG,6BAAa,CAAC,cAAc,CAAC,QAAQ,EAAE,qBAAK,CAAC,MAAM,CAAC,KAAK,EAAE,wBAAQ,CAAC,KAAK,EAAE,CAAE,CAAC,CAAC;gBACrG,IAAI,CAAC,aAAa;oBAChB,SAAS;gBACX,QAAQ,CAAC,cAAc,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;YAC/C,CAAC;YACD,OAAO,UAAU,CAAC;QACpB,CAAC;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;CACF;AAtID,sDAsIC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\nimport {\r\n CollectTileStatus, DisclosedTileTreeSet,\r\n GeometryTileTreeReference, IModelApp,\r\n Tile, TileGeometryCollector, TileUser, Viewport } from \"@itwin/core-frontend\";\r\nimport { Angle, ConvexClipPlaneSet, CurvePrimitive, GrowableXYZArray, IndexedPolyface, IndexedPolyfaceSubsetVisitor, Loop, Point3d, Polyface, PolyfaceClip, PolyfaceQuery, PolygonOps, Range3d, Ray3d, SweepLineStringToFacetsOptions, Transform, Vector3d } from \"@itwin/core-geometry\";\r\nimport { Logger } from \"@itwin/core-bentley\";\r\n\r\nconst loggerCategory = \"MapLayersFormats.GeometryTerrainDraper\";\r\n\r\n/** A TileGeometryCollector that restricts collection to tiles that overlap a line string.\r\n/* @internal\r\n*/\r\nclass LineSegmentCollector extends TileGeometryCollector {\r\n private _points: GrowableXYZArray;\r\n\r\n constructor(user: TileUser, chordTolerance: number, range: Range3d, transform: Transform, points: GrowableXYZArray) {\r\n super({ user, chordTolerance, range, transform });\r\n this._points = points;\r\n }\r\n\r\n public override addMissingTile(tile: Tile): void {\r\n Logger.logTrace(loggerCategory, `CollectorAdd missing tile: ${tile.contentId}`);\r\n super.addMissingTile(tile);\r\n }\r\n\r\n public override collectTile(tile: Tile): CollectTileStatus {\r\n let status = super.collectTile(tile);\r\n\r\n if (\"reject\" !== status && !this.rangeOverlapsLineString(tile.range)) {\r\n status = \"reject\";\r\n }\r\n\r\n Logger.logTrace(loggerCategory, `collectTile - tile: ${tile.contentId} status: ${status } isReady: ${tile.isReady} status:${tile.loadStatus}`);\r\n return status;\r\n }\r\n\r\n private rangeOverlapsLineString(range: Range3d) {\r\n let inside = false;\r\n const clipper = ConvexClipPlaneSet.createRange3dPlanes(range, true, true, true, true, false, false);\r\n if (this._options.transform)\r\n clipper.transformInPlace(this._options.transform);\r\n\r\n for (let i = 0; i < this._points.length - 1 && !inside; i++)\r\n inside = clipper.announceClippedSegmentIntervals(0, 1, this._points.getPoint3dAtUncheckedPointIndex(i), this._points.getPoint3dAtUncheckedPointIndex(i + 1));\r\n\r\n return inside;\r\n }\r\n}\r\n\r\n/** @internal */\r\nexport class GeometryTerrainDraper implements TileUser {\r\n // The side angle measures how close the sweep vector is from being parallel to a side face.\r\n // The larger the angle, the more nearly vertical facets are ignored.\r\n // This is an \"empirical\" value that was determined by looking at \"problematic\" polyfaces\r\n public readonly sideAngle = Angle.createDegrees(0.06);\r\n\r\n public readonly maxDistanceZ = 1.0E5; // Expand the Z Range, but not so much that we get opposite side of globe.\r\n public readonly tileUserId: number;\r\n\r\n public constructor(public readonly viewport: Viewport, public readonly treeRef: GeometryTileTreeReference) {\r\n this.tileUserId = TileUser.generateId();\r\n IModelApp.tileAdmin.registerUser(this);\r\n }\r\n\r\n public dispose(): void {\r\n IModelApp.tileAdmin.forgetUser(this);\r\n }\r\n\r\n public get iModel() { return this.viewport.iModel; }\r\n\r\n public onRequestStateChanged() {\r\n this.viewport.invalidateDecorations();\r\n }\r\n\r\n public discloseTileTrees(trees: DisclosedTileTreeSet) {\r\n trees.disclose(this.treeRef);\r\n }\r\n\r\n // Filter out non-top facets:\r\n // For unknown reasons, there are \"perpendicular\" facets appearing in the terrain meshes.\r\n public getMeshTopFacets(mesh: IndexedPolyface) {\r\n // constant inputs\r\n const sweepVector = Vector3d.unitZ();\r\n // i.e., region is horizontal\r\n // create subset visitor from the top facets\r\n const topFacets: number[] = [];\r\n const facetNormal = Vector3d.createZero();\r\n\r\n for (const visitor = mesh.createVisitor(0); visitor.moveToNextFacet(); ) {\r\n if (PolygonOps.unitNormal(visitor.point, facetNormal)) {\r\n const theta = facetNormal.angleFromPerpendicular(sweepVector);\r\n if (!theta.isMagnitudeLessThanOrEqual(this.sideAngle)) { // skip side facet\r\n if (facetNormal.dotProduct(sweepVector) > 0) // this is a top facet\r\n topFacets.push(visitor.currentReadIndex());\r\n }\r\n }\r\n }\r\n\r\n return IndexedPolyfaceSubsetVisitor.createSubsetVisitor(mesh, topFacets, 0);\r\n }\r\n\r\n public drapeLineString(outStrings: CurvePrimitive[], inPoints: GrowableXYZArray, tolerance: number, range: Range3d): \"loading\" | \"complete\" {\r\n const tree = this.treeRef.treeOwner.load();\r\n if (!tree)\r\n return \"loading\";\r\n\r\n const expandedRange = Range3d.createFrom(range);\r\n expandedRange.extendZOnly(-this.maxDistanceZ);\r\n expandedRange.extendZOnly(this.maxDistanceZ);\r\n\r\n const collector = new LineSegmentCollector(this, tolerance, expandedRange, tree.iModelTransform, inPoints);\r\n this.treeRef.collectTileGeometry(collector);\r\n collector.requestMissingTiles();\r\n\r\n if (collector.isAllGeometryLoaded && collector.polyfaces.length > 0) {\r\n\r\n for (const polyface of collector.polyfaces) {\r\n // Use this to serialize (problematic) polyface\r\n // console.log (`const polyface = ${JSON.stringify(IModelJson.Writer.toIModelJson(polyface))}`);\r\n outStrings.push(...PolyfaceQuery.sweepLineStringToFacets(\r\n inPoints,\r\n polyface,\r\n SweepLineStringToFacetsOptions.create(Vector3d.unitZ(), this.sideAngle, true, true, false, false)));\r\n }\r\n\r\n return \"complete\";\r\n }\r\n\r\n return \"loading\";\r\n }\r\n\r\n public drapeLoop(outMeshes: Polyface[], loop: Loop, tolerance: number, range: Range3d): \"loading\" | \"complete\" {\r\n const tree = this.treeRef.treeOwner.load();\r\n if (!tree)\r\n return \"loading\";\r\n\r\n const expandedRange = Range3d.createFrom(range);\r\n expandedRange.extendZOnly(-this.maxDistanceZ);\r\n expandedRange.extendZOnly(this.maxDistanceZ);\r\n\r\n const strokes = loop.getPackedStrokes();\r\n if (!strokes)\r\n return \"complete\";\r\n\r\n const collector = new LineSegmentCollector(this, tolerance, expandedRange, tree.iModelTransform, strokes);\r\n this.treeRef.collectTileGeometry(collector);\r\n collector.requestMissingTiles();\r\n\r\n if (collector.isAllGeometryLoaded && collector.polyfaces.length > 0) {\r\n for (const polyface of collector.polyfaces) {\r\n const topFacets = this.getMeshTopFacets(polyface);\r\n const mesh = PolyfaceClip.drapeRegion(topFacets, loop);\r\n if (mesh)\r\n outMeshes.push(mesh);\r\n }\r\n return \"complete\";\r\n }\r\n return \"loading\";\r\n }\r\n public drapePoint(outPoint: Point3d, point: Point3d, chordTolerance: number, range: Range3d): \"loading\" | \"complete\" {\r\n const tree = this.treeRef.treeOwner.load();\r\n if (!tree)\r\n return \"loading\";\r\n\r\n const expandedRange = Range3d.createFrom(range);\r\n expandedRange.extendZOnly(-this.maxDistanceZ);\r\n expandedRange.extendZOnly(this.maxDistanceZ);\r\n\r\n const collector = new TileGeometryCollector({chordTolerance, range: expandedRange, user: this });\r\n this.treeRef.collectTileGeometry(collector);\r\n collector.requestMissingTiles();\r\n\r\n if (collector.isAllGeometryLoaded && collector.polyfaces.length > 0) {\r\n for (const polyface of collector.polyfaces) {\r\n // Im assuming a single polyface here since we are draping a single point\r\n const facetLocation = PolyfaceQuery.intersectRay3d(polyface, Ray3d.create(point, Vector3d.unitZ() ));\r\n if (!facetLocation)\r\n continue;\r\n outPoint.setFromPoint3d(facetLocation.point);\r\n }\r\n return \"complete\";\r\n }\r\n return \"loading\";\r\n }\r\n}\r\n"]}
@@ -1,37 +1,42 @@
1
1
  import { ColorDef } from "@itwin/core-common";
2
2
  import { DecorateContext, Decorator } from "@itwin/core-frontend";
3
- import { LineString3d, Point2d, Point3d } from "@itwin/core-geometry";
3
+ import { Point2d, Point3d } from "@itwin/core-geometry";
4
4
  import { MapFeatureInfoToolData } from "./MapFeatureInfoTool";
5
5
  /** @internal */
6
6
  export declare class MapFeatureInfoDecorator implements Decorator {
7
7
  hidden: boolean;
8
8
  readonly useCachedDecorations = true;
9
- readonly disableTerrainDraper = true;
9
+ readonly disableTerrainDraper = false;
10
10
  markerSize: Point2d;
11
11
  lineWidth: number;
12
+ maxDrapeSizePixels: number;
13
+ chordTolerancePixels: number;
12
14
  private _highlightColor;
13
15
  get highlightColor(): ColorDef;
14
16
  set highlightColor(color: ColorDef);
15
17
  get defaultMarkerIconSvgXml(): string;
16
- private _drapePoints;
17
18
  private _scratchPoints;
18
- private _drapePointsStates;
19
- private _drapedStrings?;
19
+ private _drapeGraphicsStates;
20
+ private _drapedPrimitives;
20
21
  private _allGeomDraped;
21
22
  private _draper?;
22
23
  private _markerImage;
23
24
  private _markerSet;
24
25
  extraMarkers: Point3d[] | undefined;
25
- private _state;
26
+ private _data;
26
27
  private readonly _graphicType;
27
28
  constructor();
28
29
  private updateMarkerImage;
29
- private _computeChordTolerance;
30
- clearState: () => void;
31
- setState: (state: MapFeatureInfoToolData) => void;
30
+ private computePixelSize;
31
+ private computeChordTolerance;
32
+ clearData: () => void;
33
+ setData: (data: MapFeatureInfoToolData) => void;
32
34
  private getGeometryTreeRef;
33
35
  protected renderGraphics(context: DecorateContext): import("@itwin/core-frontend").RenderGraphic | undefined;
34
- addDrapedStrings(drapedStrings: LineString3d[]): void;
36
+ private initializeDrapeState;
37
+ private drapeGeometries;
38
+ private appendDrapedGeometries;
39
+ private appendGeometries;
35
40
  decorate(context: DecorateContext): void;
36
41
  }
37
42
  //# sourceMappingURL=MapFeatureInfoDecorator.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"M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