@itwin/map-layers-formats 4.6.0-dev.27 → 4.6.0-dev.28

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.
@@ -2,71 +2,12 @@
2
2
  * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
3
  * See LICENSE.md in the project root for license terms and full copyright notice.
4
4
  *--------------------------------------------------------------------------------------------*/
5
- /* eslint-disable no-console */
6
5
  import { Base64EncodedString, ColorDef } from "@itwin/core-common";
7
- import { GraphicType, IModelApp, MapTileTreeReference, Marker, MarkerSet, TileGeometryCollector, TileUser } from "@itwin/core-frontend";
8
- import { ConvexClipPlaneSet, GrowableXYZArray, Point2d, Point3d, PolyfaceQuery, Range3d, SweepLineStringToFacetsOptions, Transform, Vector3d } from "@itwin/core-geometry";
9
- /** A TileGeometryCollector that restricts collection to tiles that overlap a line string.
10
- /* @internal
11
- */
12
- class DrapeLineStringCollector extends TileGeometryCollector {
13
- constructor(user, chordTolerance, range, transform, _points) {
14
- super({ user, chordTolerance, range, transform });
15
- this._points = _points;
16
- }
17
- collectTile(tile) {
18
- let status = super.collectTile(tile);
19
- if ("reject" !== status && !this.rangeOverlapsLineString(tile.range))
20
- status = "reject";
21
- return status;
22
- }
23
- rangeOverlapsLineString(range) {
24
- let inside = false;
25
- const clipper = ConvexClipPlaneSet.createRange3dPlanes(range, true, true, true, true, false, false);
26
- if (this._options.transform)
27
- clipper.transformInPlace(this._options.transform);
28
- for (let i = 0; i < this._points.length - 1 && !inside; i++)
29
- inside = clipper.announceClippedSegmentIntervals(0, 1, this._points.getPoint3dAtUncheckedPointIndex(i), this._points.getPoint3dAtUncheckedPointIndex(i + 1));
30
- return inside;
31
- }
32
- }
33
- /** @internal */
34
- class TerrainDraper {
35
- constructor(viewport, treeRef) {
36
- this.viewport = viewport;
37
- this.treeRef = treeRef;
38
- this.tileUserId = TileUser.generateId();
39
- IModelApp.tileAdmin.registerUser(this);
40
- }
41
- dispose() {
42
- IModelApp.tileAdmin.forgetUser(this);
43
- }
44
- get iModel() { return this.viewport.iModel; }
45
- onRequestStateChanged() {
46
- this.viewport.invalidateDecorations();
47
- }
48
- discloseTileTrees(trees) {
49
- trees.disclose(this.treeRef);
50
- }
51
- drapeLineString(outStrings, inPoints, tolerance, maxDistance = 1.0E5) {
52
- const tree = this.treeRef.treeOwner.load();
53
- if (!tree)
54
- return "loading";
55
- const range = Range3d.createNull();
56
- range.extendArray(inPoints);
57
- range.extendZOnly(-maxDistance); // Expand - but not so much that we get opposite side of globe.
58
- range.extendZOnly(maxDistance);
59
- const collector = new DrapeLineStringCollector(this, tolerance, range, tree.iModelTransform, inPoints);
60
- this.treeRef.collectTileGeometry(collector);
61
- collector.requestMissingTiles();
62
- if (collector.isAllGeometryLoaded && collector.polyfaces.length > 0) {
63
- for (const polyface of collector.polyfaces)
64
- outStrings.push(...PolyfaceQuery.sweepLineStringToFacets(inPoints, polyface, SweepLineStringToFacetsOptions.create(Vector3d.unitZ(), undefined, true, true, false, false)));
65
- return "complete";
66
- }
67
- return "loading";
68
- }
69
- }
6
+ import { GraphicType, IModelApp, MapTileTreeReference, Marker, MarkerSet } from "@itwin/core-frontend";
7
+ import { GrowableXYZArray, Point2d, Point3d, Range3d, Transform } from "@itwin/core-geometry";
8
+ import { GeometryTerrainDraper } from "./GeometryTerrainDraper";
9
+ import { Logger } from "@itwin/core-bentley";
10
+ const loggerCategory = "MapLayersFormats.MapFeatureInfoDecorator";
70
11
  /** @internal */
71
12
  class PinMarker extends Marker {
72
13
  constructor(worldLocation, size, image) {
@@ -107,6 +48,37 @@ class PinMarkerSet extends MarkerSet {
107
48
  return new PinMarkerCluster(cluster.getClusterLocation(), cluster.markers[0].size, cluster, undefined);
108
49
  }
109
50
  }
51
+ class DrapedPrimitives {
52
+ constructor() {
53
+ this._points = new GrowableXYZArray();
54
+ }
55
+ get strings() {
56
+ return this._strings;
57
+ }
58
+ get meshes() {
59
+ return this._meshes;
60
+ }
61
+ get points() {
62
+ return this._points;
63
+ }
64
+ clear() {
65
+ this._strings = undefined;
66
+ this._meshes = undefined;
67
+ this._points.clear();
68
+ }
69
+ addStrings(drapedStrings) {
70
+ if (!this._strings) {
71
+ this._strings = [];
72
+ }
73
+ for (const ds of drapedStrings)
74
+ this._strings.push(ds);
75
+ }
76
+ addMeshes(drapedMeshes) {
77
+ if (!this._meshes)
78
+ this._meshes = [];
79
+ drapedMeshes.forEach((ds) => this._meshes.push(ds));
80
+ }
81
+ }
110
82
  /** @internal */
111
83
  export class MapFeatureInfoDecorator {
112
84
  get highlightColor() { return this._highlightColor; }
@@ -118,32 +90,37 @@ export class MapFeatureInfoDecorator {
118
90
  constructor() {
119
91
  this.hidden = false;
120
92
  this.useCachedDecorations = true;
121
- this.disableTerrainDraper = true;
93
+ this.disableTerrainDraper = false;
122
94
  this.markerSize = new Point2d(32, 32);
123
95
  this.lineWidth = 3;
96
+ // This is the maximum allowed size of a geometry, in pixels, to be draped.
97
+ // If the value is too large, we will end up downloading tons of terrain tiles, and possibly hang for too long.
98
+ this.maxDrapeSizePixels = 50000;
99
+ // This value controls the chord tolerance used to collect terrain tiles
100
+ // at the "right" resolution. Higher values, will give coarser terrain tiles.
101
+ this.chordTolerancePixels = 20;
124
102
  this._highlightColor = ColorDef.from(0, 255, 255, 127);
125
- this._drapePoints = new GrowableXYZArray();
126
103
  this._scratchPoints = new GrowableXYZArray();
127
- this._drapePointsStates = [];
104
+ this._drapeGraphicsStates = [];
105
+ this._drapedPrimitives = new DrapedPrimitives();
128
106
  this._allGeomDraped = false;
129
107
  this._markerSet = new PinMarkerSet();
130
108
  this._graphicType = GraphicType.WorldOverlay;
131
- this.clearState = () => {
132
- this._state = undefined;
109
+ this.clearData = () => {
110
+ this._data = undefined;
133
111
  };
134
- this.setState = (state) => {
135
- this._drapedStrings = undefined;
112
+ this.setData = (data) => {
113
+ this._drapedPrimitives.clear();
136
114
  this._allGeomDraped = false;
137
115
  this.hidden = false;
138
- this._state = state;
116
+ this._data = data;
139
117
  IModelApp.viewManager.invalidateCachedDecorationsAllViews(this);
140
- this._drapePoints.clear();
141
- this._drapePointsStates = [];
142
- if (!this.disableTerrainDraper && this._state.mapInfo?.layerInfos && state.hit.viewport.displayStyle.displayTerrain) {
143
- if (state.hit?.modelId) {
144
- const drapeTreeRef = this.getGeometryTreeRef(state.hit.viewport);
118
+ this._drapeGraphicsStates = [];
119
+ if (!this.disableTerrainDraper && this._data.mapInfo?.layerInfos && data.hit.viewport.displayStyle.displayTerrain) {
120
+ if (data.hit?.modelId) {
121
+ const drapeTreeRef = this.getGeometryTreeRef(data.hit.viewport);
145
122
  if (drapeTreeRef) {
146
- this._draper = new TerrainDraper(state.hit.viewport, drapeTreeRef);
123
+ this._draper = new GeometryTerrainDraper(data.hit.viewport, drapeTreeRef);
147
124
  return;
148
125
  }
149
126
  }
@@ -161,10 +138,10 @@ export class MapFeatureInfoDecorator {
161
138
  const base64 = Base64EncodedString.encode(this.defaultMarkerIconSvgXml);
162
139
  this._markerImage.src = `data:image/svg+xml;base64,${base64}`;
163
140
  }
164
- _computeChordTolerance(viewport, applyAspectRatioSkew, computeRange) {
141
+ computePixelSize(viewport, applyAspectRatioSkew, pointWorld) {
165
142
  let pixelSize = 1;
166
143
  // Compute the horizontal distance in meters between two adjacent pixels at the center of the geometry.
167
- pixelSize = viewport.getPixelSizeAtPoint(computeRange().center);
144
+ pixelSize = viewport.getPixelSizeAtPoint(pointWorld);
168
145
  pixelSize = viewport.target.adjustPixelSizeForLOD(pixelSize);
169
146
  // Aspect ratio skew > 1.0 stretches the view in Y. In that case use the smaller vertical pixel distance for our stroke tolerance.
170
147
  const skew = applyAspectRatioSkew ? viewport.view.getAspectRatioSkew() : 0;
@@ -172,6 +149,17 @@ export class MapFeatureInfoDecorator {
172
149
  pixelSize /= skew;
173
150
  return pixelSize * 0.25;
174
151
  }
152
+ computeChordTolerance(viewport, drapeRange) {
153
+ const drapeSizeWorld = Math.max(drapeRange.xLength(), drapeRange.yLength());
154
+ const pixelSize = this.computePixelSize(viewport, true, drapeRange.center);
155
+ const maxDrapeRangeSizeRatio = this.maxDrapeSizePixels / (drapeSizeWorld / pixelSize);
156
+ if (maxDrapeRangeSizeRatio < 1) {
157
+ Logger.logWarning(loggerCategory, "Element too large; chord tolerance was adjusted");
158
+ return (pixelSize / maxDrapeRangeSizeRatio) * this.chordTolerancePixels;
159
+ }
160
+ return pixelSize * this.chordTolerancePixels;
161
+ }
162
+ ;
175
163
  getGeometryTreeRef(vp) {
176
164
  let treeRef;
177
165
  if (vp.backgroundMapSettings.applyTerrain) {
@@ -185,7 +173,7 @@ export class MapFeatureInfoDecorator {
185
173
  }
186
174
  renderGraphics(context) {
187
175
  this._markerSet.markers.clear();
188
- if (this._state?.mapInfo?.layerInfos === undefined || this.hidden) {
176
+ if (this._data?.mapInfo?.layerInfos === undefined || this.hidden) {
189
177
  return undefined;
190
178
  }
191
179
  let transform;
@@ -195,71 +183,137 @@ export class MapFeatureInfoDecorator {
195
183
  }
196
184
  const builder = context.createGraphicBuilder(this._graphicType, transform);
197
185
  if (this._draper) {
198
- if (this._drapePoints.length === 0 && this._state.mapInfo.layerInfos) {
199
- for (const layerInfo of this._state.mapInfo.layerInfos) {
200
- if (layerInfo.subLayerInfos) {
201
- for (const subLayerInfo of layerInfo.subLayerInfos) {
202
- for (const feature of subLayerInfo.features) {
203
- if (feature.geometries) {
204
- for (const geom of feature.geometries) {
205
- if (geom.graphic.type === "linestring") {
206
- this._drapePointsStates.push({ count: geom.graphic.points.length, collectorState: "loading" });
207
- this._drapePoints.pushAll(geom.graphic.points);
208
- }
209
- }
210
- }
211
- }
212
- }
186
+ this.initializeDrapeState(context.viewport);
187
+ // We need to call drapeGeometries() until it returns true (i.e. fully complete)
188
+ if (!this._allGeomDraped) {
189
+ if (!this.drapeGeometries(context.viewport))
190
+ return undefined;
191
+ }
192
+ this.appendDrapedGeometries(builder);
193
+ }
194
+ else {
195
+ // Append geometries straight from the state to the builder
196
+ this.appendGeometries(builder);
197
+ }
198
+ // Add extra markers if any specified
199
+ if (this.extraMarkers !== undefined) {
200
+ this.extraMarkers.forEach((markerPoint) => {
201
+ builder.setSymbology(this.highlightColor, this.highlightColor, this.lineWidth);
202
+ this._markerSet.markers.add(new PinMarker(markerPoint, this.markerSize, this._markerImage));
203
+ });
204
+ }
205
+ return builder.finish();
206
+ }
207
+ // Iterates the mapfeatureinfo data and create a draping state for each entry
208
+ initializeDrapeState(viewport) {
209
+ if (this._drapeGraphicsStates.length === 0) {
210
+ const getGraphicRange = (graphic) => {
211
+ if (graphic.type === "linestring")
212
+ return Range3d.createArray(graphic.points);
213
+ else if (graphic.type === "loop")
214
+ return graphic.loop.range();
215
+ else if (graphic.type === "pointstring")
216
+ return Range3d.createArray(graphic.points);
217
+ else
218
+ return Range3d.createNull();
219
+ };
220
+ for (const layerInfo of this._data?.mapInfo?.layerInfos ?? []) {
221
+ for (const subLayerInfo of layerInfo?.subLayerInfos ?? []) {
222
+ for (const feature of subLayerInfo.features) {
223
+ feature.geometries?.forEach(((geom) => {
224
+ const range = getGraphicRange(geom.graphic);
225
+ this._drapeGraphicsStates.push({
226
+ graphic: geom.graphic,
227
+ collectorState: "loading",
228
+ chordTolerance: this.computeChordTolerance(viewport, range),
229
+ range,
230
+ });
231
+ }));
213
232
  }
214
233
  }
215
234
  }
216
- if (!this._allGeomDraped) {
217
- let hasMissingLineStrings = false;
218
- let drapePointsOffset = 0;
219
- for (const state of this._drapePointsStates) {
220
- if (state.collectorState === "loading") {
221
- this._scratchPoints.clear();
222
- this._scratchPoints.resize(state.count);
223
- let dstIdx = 0;
224
- for (let srcIdx = drapePointsOffset; srcIdx < drapePointsOffset + state.count; srcIdx++) {
225
- this._scratchPoints.transferFromGrowableXYZArray(dstIdx++, this._drapePoints, srcIdx);
226
- }
227
- const drapeRange = Range3d.createNull();
228
- drapeRange.extendArray(this._scratchPoints);
229
- const drapedStrings = [];
230
- const tolerance = this._computeChordTolerance(context.viewport, true, () => drapeRange) * 10; // 10 pixels
231
- if ("loading" === this._draper.drapeLineString(drapedStrings, this._scratchPoints, tolerance)) {
232
- hasMissingLineStrings = true;
235
+ }
236
+ }
237
+ // returns true when all geometries are fully draped; otherwise false
238
+ drapeGeometries(_viewport) {
239
+ if (!this._draper)
240
+ return false;
241
+ let hasMissingDrapeGeoms = false;
242
+ for (const state of this._drapeGraphicsStates) {
243
+ if (state.collectorState === "loading") {
244
+ this._scratchPoints.clear();
245
+ if (state.graphic.type === "linestring") {
246
+ this._scratchPoints.pushAll(state.graphic.points);
247
+ const drapedStrings = [];
248
+ if ("loading" === this._draper.drapeLineString(drapedStrings, this._scratchPoints, state.chordTolerance, state.range)) {
249
+ hasMissingDrapeGeoms = true;
250
+ break;
251
+ }
252
+ else {
253
+ this._drapedPrimitives.addStrings(drapedStrings);
254
+ state.collectorState = "complete";
255
+ }
256
+ }
257
+ else if (state.graphic.type === "loop") {
258
+ const loop = state.graphic.loop;
259
+ const outMeshes = [];
260
+ if ("loading" === this._draper.drapeLoop(outMeshes, loop, state.chordTolerance, state.range)) {
261
+ hasMissingDrapeGeoms = true;
262
+ break; // We drape each graphic sequentially, otherwise collector get messed up.
263
+ }
264
+ else {
265
+ this._drapedPrimitives.addMeshes(outMeshes);
266
+ state.collectorState = "complete";
267
+ }
268
+ }
269
+ else if (state.graphic.type === "pointstring") {
270
+ const outPoint = Point3d.createZero();
271
+ for (const point of state.graphic.points) {
272
+ if ("loading" === this._draper.drapePoint(outPoint, point, state.chordTolerance, state.range)) {
273
+ this._allGeomDraped = false;
274
+ return false;
233
275
  }
234
- else {
235
- this.addDrapedStrings(drapedStrings);
236
- state.collectorState = "complete";
276
+ else if (!outPoint.isZero) {
277
+ this._drapedPrimitives.points.push(outPoint);
237
278
  }
238
279
  }
239
- drapePointsOffset += state.count;
240
280
  }
241
- this._allGeomDraped = !hasMissingLineStrings;
242
- }
243
- if (this._drapedStrings) {
244
- builder.setSymbology(this.highlightColor, this.highlightColor, this.lineWidth);
245
- this._drapedStrings.forEach((line) => builder.addLineString(line.points));
246
281
  }
247
282
  }
248
- else {
283
+ this._allGeomDraped = !hasMissingDrapeGeoms;
284
+ return this._allGeomDraped;
285
+ }
286
+ appendDrapedGeometries(builder) {
287
+ if (this._drapedPrimitives.strings) {
249
288
  builder.setSymbology(this.highlightColor, this.highlightColor, this.lineWidth);
250
- for (const layerInfo of this._state.mapInfo.layerInfos) {
251
- if (layerInfo.subLayerInfos && !(layerInfo.subLayerInfos instanceof HTMLElement)) {
252
- for (const subLayerInfo of layerInfo.subLayerInfos) {
253
- for (const feature of subLayerInfo.features) {
254
- if (feature.geometries) {
255
- for (const geom of feature.geometries) {
256
- if (geom.graphic.type === "pointstring") {
257
- for (const point of geom.graphic.points)
258
- this._markerSet.markers.add(new PinMarker(point, this.markerSize, this._markerImage));
259
- }
260
- else {
261
- builder.addPrimitive(geom.graphic);
262
- }
289
+ this._drapedPrimitives.strings.forEach((line) => builder.addLineString(line.points));
290
+ }
291
+ if (this._drapedPrimitives.meshes) {
292
+ builder.setSymbology(this.highlightColor, this.highlightColor, this.lineWidth);
293
+ this._drapedPrimitives.meshes.forEach((polyface) => builder.addPolyface(polyface, true));
294
+ }
295
+ if (this._drapedPrimitives.points.length > 0) {
296
+ for (let i = 0; i < this._drapedPrimitives.points.length; i++) {
297
+ this._markerSet.markers.add(new PinMarker(this._drapedPrimitives.points.getPoint3dAtUncheckedPointIndex(i), this.markerSize, this._markerImage));
298
+ }
299
+ }
300
+ }
301
+ appendGeometries(builder) {
302
+ if (!this._data?.mapInfo?.layerInfos)
303
+ return;
304
+ builder.setSymbology(this.highlightColor, this.highlightColor, this.lineWidth);
305
+ for (const layerInfo of this._data.mapInfo.layerInfos) {
306
+ if (layerInfo.subLayerInfos && !(layerInfo.subLayerInfos instanceof HTMLElement)) {
307
+ for (const subLayerInfo of layerInfo.subLayerInfos) {
308
+ for (const feature of subLayerInfo.features) {
309
+ if (feature.geometries) {
310
+ for (const geom of feature.geometries) {
311
+ if (geom.graphic.type === "pointstring") {
312
+ for (const point of geom.graphic.points)
313
+ this._markerSet.markers.add(new PinMarker(point, this.markerSize, this._markerImage));
314
+ }
315
+ else {
316
+ builder.addPrimitive(geom.graphic);
263
317
  }
264
318
  }
265
319
  }
@@ -267,26 +321,13 @@ export class MapFeatureInfoDecorator {
267
321
  }
268
322
  }
269
323
  }
270
- // Add extra markers if any specified
271
- if (this.extraMarkers !== undefined) {
272
- this.extraMarkers.forEach((markerPoint) => {
273
- builder.setSymbology(this.highlightColor, this.highlightColor, this.lineWidth);
274
- this._markerSet.markers.add(new PinMarker(markerPoint, this.markerSize, this._markerImage));
275
- });
276
- }
277
- return builder.finish();
278
- }
279
- addDrapedStrings(drapedStrings) {
280
- if (!this._drapedStrings) {
281
- this._drapedStrings = [];
282
- }
283
- for (const ds of drapedStrings)
284
- this._drapedStrings.push(ds);
285
324
  }
286
325
  decorate(context) {
287
326
  const graphics = this.renderGraphics(context);
288
- if (graphics)
327
+ if (graphics) {
289
328
  context.addDecoration(this._graphicType, graphics);
329
+ IModelApp.toolAdmin.setCursor(undefined);
330
+ }
290
331
  this._markerSet.addDecoration(context);
291
332
  return;
292
333
  }
@@ -1 +1 @@
1
- {"version":3,"file":"MapFeatureInfoDecorator.js","sourceRoot":"","sources":["../../../src/Tools/MapFeatureInfoDecorator.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,+BAA+B;AAC/B,OAAO,EAAE,mBAAmB,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AACnE,OAAO,EAEsB,WAAW,EAAE,SAAS,EAAE,oBAAoB,EAAE,MAAM,EAAe,SAAS,EACjG,qBAAqB,EAAqB,QAAQ,EAAY,MAAM,sBAAsB,CAAC;AACnG,OAAO,EAAE,kBAAkB,EAAkB,gBAAgB,EAAgB,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,8BAA8B,EAAE,SAAS,EAAE,QAAQ,EAAiB,MAAM,sBAAsB,CAAC;AAGxN;;EA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OAAO,CAAC,GAAG,CAAC,IAAI,SAAS,CAAC,WAAW,EAAE,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC;YAC9F,CAAC,CAAC,CAAC;QACL,CAAC;QAED,OAAO,OAAO,CAAC,MAAM,EAAE,CAAC;IAC1B,CAAC;IAEM,gBAAgB,CAAC,aAA6B;QACnD,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,CAAC;YACzB,IAAI,CAAC,cAAc,GAAG,EAAE,CAAC;QAC3B,CAAC;QACD,KAAK,MAAM,EAAE,IAAI,aAAa;YAC5B,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACjC,CAAC;IAEM,QAAQ,CAAC,OAAwB;QACtC,MAAM,QAAQ,GAAG,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;QAC9C,IAAI,QAAQ;YACV,OAAO,CAAC,aAAa,CAAC,IAAI,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC;QAErD,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;QACvC,OAAO;IACT,CAAC;CACF","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/* eslint-disable no-console */\nimport { Base64EncodedString, ColorDef } from \"@itwin/core-common\";\nimport {\n BeButtonEvent, Cluster, CollectTileStatus, DecorateContext, Decorator, DisclosedTileTreeSet,\n GeometryTileTreeReference, GraphicType, IModelApp, MapTileTreeReference, Marker, MarkerImage, MarkerSet,\n Tile, TileGeometryCollector, TileTreeReference, TileUser, Viewport } from \"@itwin/core-frontend\";\nimport { ConvexClipPlaneSet, CurvePrimitive, GrowableXYZArray, LineString3d, Point2d, Point3d, PolyfaceQuery, Range3d, SweepLineStringToFacetsOptions, Transform, Vector3d, XAndY, XYAndZ } from \"@itwin/core-geometry\";\nimport { MapFeatureInfoToolData } from \"./MapFeatureInfoTool\";\n\n/** A TileGeometryCollector that restricts collection to tiles that overlap a line string.\n/* @internal\n*/\nclass DrapeLineStringCollector extends TileGeometryCollector {\n constructor(user: TileUser, chordTolerance: number, range: Range3d, transform: Transform, private _points: GrowableXYZArray) {\n super({ user, chordTolerance, range, transform });\n }\n\n public override collectTile(tile: Tile): CollectTileStatus {\n let status = super.collectTile(tile);\n if (\"reject\" !== status && !this.rangeOverlapsLineString(tile.range))\n status = \"reject\";\n\n return status;\n }\n\n private rangeOverlapsLineString(range: Range3d) {\n let inside = false;\n const clipper = ConvexClipPlaneSet.createRange3dPlanes(range, true, true, true, true, false, false);\n if (this._options.transform)\n clipper.transformInPlace(this._options.transform);\n\n for (let i = 0; i < this._points.length - 1 && !inside; i++)\n inside = clipper.announceClippedSegmentIntervals(0, 1, this._points.getPoint3dAtUncheckedPointIndex(i), this._points.getPoint3dAtUncheckedPointIndex(i + 1));\n\n return inside;\n }\n}\n\n/** @internal */\nclass TerrainDraper implements TileUser {\n public readonly tileUserId: number;\n\n public constructor(public readonly viewport: Viewport, public readonly treeRef: GeometryTileTreeReference) {\n this.tileUserId = TileUser.generateId();\n IModelApp.tileAdmin.registerUser(this);\n }\n\n public dispose(): void {\n IModelApp.tileAdmin.forgetUser(this);\n }\n\n public get iModel() { return this.viewport.iModel; }\n\n public onRequestStateChanged() {\n this.viewport.invalidateDecorations();\n }\n\n public discloseTileTrees(trees: DisclosedTileTreeSet) {\n trees.disclose(this.treeRef);\n }\n\n public drapeLineString(outStrings: CurvePrimitive[], inPoints: GrowableXYZArray, tolerance: number, maxDistance = 1.0E5): \"loading\" | \"complete\" {\n const tree = this.treeRef.treeOwner.load();\n if (!tree)\n return \"loading\";\n\n const range = Range3d.createNull();\n range.extendArray(inPoints);\n range.extendZOnly(-maxDistance); // Expand - but not so much that we get opposite side of globe.\n range.extendZOnly(maxDistance);\n\n const collector = new DrapeLineStringCollector(this, tolerance, range, tree.iModelTransform, inPoints);\n this.treeRef.collectTileGeometry(collector);\n collector.requestMissingTiles();\n\n if (collector.isAllGeometryLoaded && collector.polyfaces.length > 0) {\n for (const polyface of collector.polyfaces)\n outStrings.push(...PolyfaceQuery.sweepLineStringToFacets(inPoints, polyface,\n SweepLineStringToFacetsOptions.create(Vector3d.unitZ(), undefined, true, true, false, false)));\n return \"complete\";\n }\n\n return \"loading\";\n }\n}\n\n/** @internal */\nclass PinMarker extends Marker {\n public constructor(worldLocation: XYAndZ, size: XAndY, image: MarkerImage) {\n super(worldLocation, size);\n this.image = image;\n this.imageOffset = new Point3d(0, Math.floor(size.y * .5));\n }\n}\n\n/** @internal */\nclass PinMarkerCluster extends Marker {\n /** Create a new cluster marker */\n constructor(location: XYAndZ, size: XAndY, cluster: Cluster<PinMarker>, image: MarkerImage | Promise<MarkerImage> | undefined) {\n super(location, size);\n\n this.title = IModelApp.localization.getLocalizedString(\"mapLayersFormats:Messages.MapFeatureInfoDecorator.clusterZoomIn\", { nbInstances: cluster.markers.length});\n\n this.imageOffset = new Point3d(0, size.y * 0.5);\n this.label = cluster.markers.length.toLocaleString();\n this.labelColor = \"black\";\n this.labelFont = \"bold 14px sans-serif\";\n\n if (image)\n this.setImage(image);\n }\n\n /** Show the cluster as a white circle with an outline */\n public override drawFunc(ctx: CanvasRenderingContext2D): void {\n ctx.beginPath();\n ctx.strokeStyle = \"#372528\";\n ctx.fillStyle = \"white\";\n ctx.lineWidth = 5;\n ctx.arc(0, 0, this.size.x * 0.5, 0, Math.PI * 2);\n ctx.fill();\n ctx.stroke();\n }\n\n public override onMouseButton(_ev: BeButtonEvent): boolean { return true; } // Don't allow clicks to be sent to active tool...\n}\n\n/** @internal */\nclass PinMarkerSet extends MarkerSet<PinMarker> {\n protected getClusterMarker(cluster: Cluster<PinMarker>): Marker {\n // No image passed to the cluster, we prefer to have the circle only\n return new PinMarkerCluster(cluster.getClusterLocation(), cluster.markers[0].size, cluster, undefined);\n }\n}\n\n/** @internal */\ninterface DrapePointState {\n count: number;\n collectorState: string;\n}\n\n/** @internal */\nexport class MapFeatureInfoDecorator implements Decorator {\n public hidden = false;\n public readonly useCachedDecorations = true;\n public readonly disableTerrainDraper = true;\n public markerSize = new Point2d(32, 32);\n public lineWidth = 3;\n private _highlightColor = ColorDef.from(0, 255, 255, 127);\n\n public get highlightColor() { return this._highlightColor;}\n public set highlightColor(color: ColorDef) {\n this.updateMarkerImage();\n this._highlightColor = color;\n }\n\n public get defaultMarkerIconSvgXml() { return `<svg class=\"indicator\" viewBox=\"0 0 22 22\" width=\"22\" height=\"22\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"m11 0a7.44506 7.44506 0 0 0 -7.5 7.2875c0 1.65 1.132 4.2625 3.25477 8.1125 1.55652 2.75 4.24523 6.6 4.24523 6.6s2.68865-3.9875 4.24528-6.7375c2.12272-3.85 3.25472-6.4625 3.25472-8.1125a7.4215 7.4215 0 0 0 -7.5-7.15z\" fill=\"black\"/><path d=\"m11 1.01715a6.46476 6.46476 0 0 0 -6.48285 6.27033c0 1.72619 1.67181 4.97973 3.12836 7.62139.97564 1.7237 2.42828 3.92176 3.34118 5.27161.91413-1.39148 2.385-3.673 3.37336-5.41907 1.451-2.63171 3.1228-5.88525 3.1228-7.61139a6.39982 6.39982 0 0 0 -6.48285-6.13287zm.00183 8.98285a3 3 0 1 1 3-3 3 3 0 0 1 -3 3z\" fill=\"${this.highlightColor.toRgbString()}\"/></svg>`; }\n\n private _drapePoints = new GrowableXYZArray();\n private _scratchPoints = new GrowableXYZArray();\n\n private _drapePointsStates: DrapePointState[] = [];\n private _drapedStrings?: LineString3d[];\n private _allGeomDraped = false;\n private _draper?: TerrainDraper;\n private _markerImage: HTMLImageElement;\n private _markerSet = new PinMarkerSet();\n\n // Extra markers can be added outside the normal state\n public extraMarkers: Point3d[]|undefined;\n\n private _state: MapFeatureInfoToolData | undefined;\n\n private readonly _graphicType = GraphicType.WorldOverlay;\n\n public constructor() {\n this._markerImage = new Image();\n this.updateMarkerImage();\n }\n\n private updateMarkerImage() {\n const base64 = Base64EncodedString.encode(this.defaultMarkerIconSvgXml);\n this._markerImage.src = `data:image/svg+xml;base64,${base64}`;\n }\n\n private _computeChordTolerance(viewport: Viewport, applyAspectRatioSkew: boolean, computeRange: () => Range3d) {\n let pixelSize = 1;\n // Compute the horizontal distance in meters between two adjacent pixels at the center of the geometry.\n pixelSize = viewport.getPixelSizeAtPoint(computeRange().center);\n pixelSize = viewport.target.adjustPixelSizeForLOD(pixelSize);\n\n // Aspect ratio skew > 1.0 stretches the view in Y. In that case use the smaller vertical pixel distance for our stroke tolerance.\n const skew = applyAspectRatioSkew ? viewport.view.getAspectRatioSkew() : 0;\n if (skew > 1)\n pixelSize /= skew;\n return pixelSize * 0.25;\n }\n\n public clearState = () => {\n this._state = undefined;\n };\n\n public setState = (state: MapFeatureInfoToolData) => {\n\n this._drapedStrings = undefined;\n this._allGeomDraped = false;\n this.hidden = false;\n\n this._state = state;\n IModelApp.viewManager.invalidateCachedDecorationsAllViews(this);\n\n this._drapePoints.clear();\n this._drapePointsStates = [];\n\n if (!this.disableTerrainDraper && this._state.mapInfo?.layerInfos && state.hit.viewport.displayStyle.displayTerrain) {\n\n if (state.hit?.modelId) {\n const drapeTreeRef = this.getGeometryTreeRef(state.hit.viewport);\n if (drapeTreeRef) {\n this._draper = new TerrainDraper(state.hit.viewport, drapeTreeRef);\n return;\n }\n }\n }\n\n if (this._draper) {\n // Dispose draper every time?\n this._draper.dispose();\n this._draper = undefined;\n }\n };\n\n private getGeometryTreeRef(vp: Viewport): GeometryTileTreeReference | undefined {\n let treeRef: GeometryTileTreeReference | undefined;\n if (vp.backgroundMapSettings.applyTerrain) {\n vp.forEachMapTreeRef((ref: TileTreeReference) => {\n if (!treeRef && ref instanceof MapTileTreeReference) {\n treeRef = ref.createGeometryTreeReference();\n }\n });\n }\n\n return treeRef;\n }\n\n protected renderGraphics(context: DecorateContext) {\n this._markerSet.markers.clear();\n\n if (this._state?.mapInfo?.layerInfos === undefined || this.hidden) {\n return undefined;\n }\n\n let transform: Transform|undefined;\n const groundBias = context.viewport.displayStyle.backgroundMapSettings.groundBias;\n if (groundBias !== 0) {\n transform = Transform.createTranslationXYZ(0, 0 , groundBias);\n }\n const builder = context.createGraphicBuilder(this._graphicType, transform);\n\n if (this._draper) {\n if (this._drapePoints.length === 0 && this._state.mapInfo.layerInfos) {\n\n for (const layerInfo of this._state.mapInfo.layerInfos) {\n if (layerInfo.subLayerInfos) {\n for (const subLayerInfo of layerInfo.subLayerInfos) {\n for (const feature of subLayerInfo.features) {\n if (feature.geometries) {\n for (const geom of feature.geometries) {\n if (geom.graphic.type === \"linestring\") {\n this._drapePointsStates.push({ count: geom.graphic.points.length, collectorState: \"loading\" });\n this._drapePoints.pushAll(geom.graphic.points);\n }\n }\n }\n }\n }\n\n }\n }\n }\n\n if (!this._allGeomDraped) {\n\n let hasMissingLineStrings = false;\n let drapePointsOffset = 0;\n for (const state of this._drapePointsStates) {\n\n if (state.collectorState === \"loading\") {\n this._scratchPoints.clear();\n this._scratchPoints.resize(state.count);\n\n let dstIdx = 0;\n for (let srcIdx = drapePointsOffset; srcIdx < drapePointsOffset + state.count; srcIdx++) {\n this._scratchPoints.transferFromGrowableXYZArray(dstIdx++, this._drapePoints, srcIdx);\n }\n\n const drapeRange = Range3d.createNull();\n drapeRange.extendArray(this._scratchPoints);\n const drapedStrings: LineString3d[] = [];\n const tolerance = this._computeChordTolerance(context.viewport, true, () => drapeRange) * 10; // 10 pixels\n if (\"loading\" === this._draper.drapeLineString(drapedStrings, this._scratchPoints, tolerance)) {\n hasMissingLineStrings = true;\n } else {\n this.addDrapedStrings(drapedStrings);\n state.collectorState = \"complete\";\n }\n }\n drapePointsOffset += state.count;\n }\n this._allGeomDraped = !hasMissingLineStrings;\n }\n\n if (this._drapedStrings) {\n builder.setSymbology(this.highlightColor, this.highlightColor, this.lineWidth);\n this._drapedStrings.forEach((line) => builder.addLineString(line.points));\n }\n\n } else {\n builder.setSymbology(this.highlightColor, this.highlightColor, this.lineWidth);\n for (const layerInfo of this._state.mapInfo.layerInfos) {\n if (layerInfo.subLayerInfos && !(layerInfo.subLayerInfos instanceof HTMLElement)) {\n for (const subLayerInfo of layerInfo.subLayerInfos) {\n for (const feature of subLayerInfo.features) {\n if (feature.geometries) {\n for (const geom of feature.geometries) {\n if (geom.graphic.type === \"pointstring\") {\n for (const point of geom.graphic.points)\n this._markerSet.markers.add(new PinMarker(point, this.markerSize, this._markerImage));\n } else {\n builder.addPrimitive(geom.graphic);\n }\n\n }\n }\n }\n }\n\n }\n\n }\n }\n\n // Add extra markers if any specified\n if ( this.extraMarkers !== undefined) {\n this.extraMarkers.forEach((markerPoint)=> {\n builder.setSymbology(this.highlightColor, this.highlightColor, this.lineWidth);\n this._markerSet.markers.add(new PinMarker(markerPoint, this.markerSize, this._markerImage));\n });\n }\n\n return builder.finish();\n }\n\n public addDrapedStrings(drapedStrings: LineString3d[]) {\n if (!this._drapedStrings) {\n this._drapedStrings = [];\n }\n for (const ds of drapedStrings)\n this._drapedStrings.push(ds);\n }\n\n public decorate(context: DecorateContext): void {\n const graphics = this.renderGraphics(context);\n if (graphics)\n context.addDecoration(this._graphicType, graphics);\n\n this._markerSet.addDecoration(context);\n return;\n }\n}\n"]}
1
+ {"version":3,"file":"MapFeatureInfoDecorator.js","sourceRoot":"","sources":["../../../src/Tools/MapFeatureInfoDecorator.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,OAAO,EAAE,mBAAmB,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AACnE,OAAO,EAEwD,WAAW,EAAE,SAAS,EAAE,oBAAoB,EAAE,MAAM,EAAe,SAAS,EAE5G,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAgB,OAAO,EAAE,OAAO,EAAY,OAAO,EAAE,SAAS,EAAiB,MAAM,sBAAsB,CAAC;AAErI,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,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N,OAAO,CAAC,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;gCACrC,CAAC;4BAEH,CAAC;wBACH,CAAC;oBACH,CAAC;gBACH,CAAC;YAEH,CAAC;QAEH,CAAC;IACH,CAAC;IAEM,QAAQ,CAAC,OAAwB;QACtC,MAAM,QAAQ,GAAG,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;QAC9C,IAAI,QAAQ,EAAE,CAAC;YACb,OAAO,CAAC,aAAa,CAAC,IAAI,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC;YACnD,SAAS,CAAC,SAAS,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;QAC3C,CAAC;QAED,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;QACvC,OAAO;IACT,CAAC;CACF","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*--------------------------------------------------------------------------------------------*/\nimport { Base64EncodedString, ColorDef } from \"@itwin/core-common\";\nimport {\n BeButtonEvent, Cluster, DecorateContext, Decorator,\n GeometryTileTreeReference, GraphicBuilder, GraphicPrimitive, GraphicType, IModelApp, MapTileTreeReference, Marker, MarkerImage, MarkerSet,\n ScreenViewport,\n TileTreeReference, Viewport } from \"@itwin/core-frontend\";\nimport { GrowableXYZArray, LineString3d, Point2d, Point3d, Polyface, Range3d, Transform, XAndY, XYAndZ } from \"@itwin/core-geometry\";\nimport { MapFeatureInfoToolData } from \"./MapFeatureInfoTool\";\nimport { GeometryTerrainDraper } from \"./GeometryTerrainDraper\";\nimport { Logger } from \"@itwin/core-bentley\";\nconst loggerCategory = \"MapLayersFormats.MapFeatureInfoDecorator\";\n\n/** @internal */\nclass PinMarker extends Marker {\n public constructor(worldLocation: XYAndZ, size: XAndY, image: MarkerImage) {\n super(worldLocation, size);\n this.image = image;\n this.imageOffset = new Point3d(0, Math.floor(size.y * .5));\n }\n}\n\n/** @internal */\nclass PinMarkerCluster extends Marker {\n /** Create a new cluster marker */\n constructor(location: XYAndZ, size: XAndY, cluster: Cluster<PinMarker>, image: MarkerImage | Promise<MarkerImage> | undefined) {\n super(location, size);\n\n this.title = IModelApp.localization.getLocalizedString(\"mapLayersFormats:Messages.MapFeatureInfoDecorator.clusterZoomIn\", { nbInstances: cluster.markers.length});\n\n this.imageOffset = new Point3d(0, size.y * 0.5);\n this.label = cluster.markers.length.toLocaleString();\n this.labelColor = \"black\";\n this.labelFont = \"bold 14px sans-serif\";\n\n if (image)\n this.setImage(image);\n }\n\n /** Show the cluster as a white circle with an outline */\n public override drawFunc(ctx: CanvasRenderingContext2D): void {\n ctx.beginPath();\n ctx.strokeStyle = \"#372528\";\n ctx.fillStyle = \"white\";\n ctx.lineWidth = 5;\n ctx.arc(0, 0, this.size.x * 0.5, 0, Math.PI * 2);\n ctx.fill();\n ctx.stroke();\n }\n\n public override onMouseButton(_ev: BeButtonEvent): boolean { return true; } // Don't allow clicks to be sent to active tool...\n}\n\n/** @internal */\nclass PinMarkerSet extends MarkerSet<PinMarker> {\n protected getClusterMarker(cluster: Cluster<PinMarker>): Marker {\n // No image passed to the cluster, we prefer to have the circle only\n return new PinMarkerCluster(cluster.getClusterLocation(), cluster.markers[0].size, cluster, undefined);\n }\n}\n\ninterface DrapeGraphicState {\n graphic: GraphicPrimitive;\n collectorState: string;\n chordTolerance: number;\n range: Range3d;\n}\n\nclass DrapedPrimitives {\n private _strings?: LineString3d[];\n private _meshes?: Polyface[];\n private _points = new GrowableXYZArray();\n\n public get strings() {\n return this._strings;\n }\n\n public get meshes() {\n return this._meshes;\n }\n\n public get points() {\n return this._points;\n }\n\n public clear() {\n this._strings = undefined;\n this._meshes = undefined;\n this._points.clear();\n }\n\n public addStrings(drapedStrings: LineString3d[]) {\n if (!this._strings) {\n this._strings = [];\n }\n for (const ds of drapedStrings)\n this._strings.push(ds);\n }\n\n public addMeshes(drapedMeshes: Polyface[]) {\n if (!this._meshes)\n this._meshes = [];\n drapedMeshes.forEach((ds) => this._meshes!.push(ds));\n }\n}\n\n/** @internal */\nexport class MapFeatureInfoDecorator implements Decorator {\n public hidden = false;\n public readonly useCachedDecorations = true;\n public readonly disableTerrainDraper = false;\n public markerSize = new Point2d(32, 32);\n public lineWidth = 3;\n\n // This is the maximum allowed size of a geometry, in pixels, to be draped.\n // If the value is too large, we will end up downloading tons of terrain tiles, and possibly hang for too long.\n public maxDrapeSizePixels = 50000;\n\n // This value controls the chord tolerance used to collect terrain tiles\n // at the \"right\" resolution. Higher values, will give coarser terrain tiles.\n public chordTolerancePixels = 20;\n\n private _highlightColor = ColorDef.from(0, 255, 255, 127);\n public get highlightColor() { return this._highlightColor;}\n public set highlightColor(color: ColorDef) {\n this.updateMarkerImage();\n this._highlightColor = color;\n }\n\n public get defaultMarkerIconSvgXml() { return `<svg class=\"indicator\" viewBox=\"0 0 22 22\" width=\"22\" height=\"22\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"m11 0a7.44506 7.44506 0 0 0 -7.5 7.2875c0 1.65 1.132 4.2625 3.25477 8.1125 1.55652 2.75 4.24523 6.6 4.24523 6.6s2.68865-3.9875 4.24528-6.7375c2.12272-3.85 3.25472-6.4625 3.25472-8.1125a7.4215 7.4215 0 0 0 -7.5-7.15z\" fill=\"black\"/><path d=\"m11 1.01715a6.46476 6.46476 0 0 0 -6.48285 6.27033c0 1.72619 1.67181 4.97973 3.12836 7.62139.97564 1.7237 2.42828 3.92176 3.34118 5.27161.91413-1.39148 2.385-3.673 3.37336-5.41907 1.451-2.63171 3.1228-5.88525 3.1228-7.61139a6.39982 6.39982 0 0 0 -6.48285-6.13287zm.00183 8.98285a3 3 0 1 1 3-3 3 3 0 0 1 -3 3z\" fill=\"${this.highlightColor.toRgbString()}\"/></svg>`; }\n\n private _scratchPoints = new GrowableXYZArray();\n\n private _drapeGraphicsStates: DrapeGraphicState[] = [];\n private _drapedPrimitives = new DrapedPrimitives();\n private _allGeomDraped = false;\n private _draper?: GeometryTerrainDraper;\n private _markerImage: HTMLImageElement;\n private _markerSet = new PinMarkerSet();\n\n // Extra markers can be added outside the normal state\n public extraMarkers: Point3d[]|undefined;\n\n private _data: MapFeatureInfoToolData | undefined;\n\n private readonly _graphicType = GraphicType.WorldOverlay;\n\n public constructor() {\n this._markerImage = new Image();\n this.updateMarkerImage();\n }\n\n private updateMarkerImage() {\n const base64 = Base64EncodedString.encode(this.defaultMarkerIconSvgXml);\n this._markerImage.src = `data:image/svg+xml;base64,${base64}`;\n }\n\n private computePixelSize(viewport: Viewport, applyAspectRatioSkew: boolean, pointWorld: Point3d) {\n let pixelSize = 1;\n // Compute the horizontal distance in meters between two adjacent pixels at the center of the geometry.\n pixelSize = viewport.getPixelSizeAtPoint(pointWorld);\n pixelSize = viewport.target.adjustPixelSizeForLOD(pixelSize);\n\n // Aspect ratio skew > 1.0 stretches the view in Y. In that case use the smaller vertical pixel distance for our stroke tolerance.\n const skew = applyAspectRatioSkew ? viewport.view.getAspectRatioSkew() : 0;\n if (skew > 1)\n pixelSize /= skew;\n return pixelSize * 0.25;\n }\n\n private computeChordTolerance(viewport: Viewport, drapeRange: Range3d) {\n const drapeSizeWorld = Math.max(drapeRange.xLength(), drapeRange.yLength());\n const pixelSize = this.computePixelSize(viewport, true, drapeRange.center);\n const maxDrapeRangeSizeRatio = this.maxDrapeSizePixels / (drapeSizeWorld / pixelSize);\n if (maxDrapeRangeSizeRatio < 1) {\n Logger.logWarning(loggerCategory, \"Element too large; chord tolerance was adjusted\");\n return (pixelSize / maxDrapeRangeSizeRatio)*this.chordTolerancePixels;\n }\n return pixelSize*this.chordTolerancePixels;\n };\n\n public clearData = () => {\n this._data = undefined;\n };\n\n public setData = (data: MapFeatureInfoToolData) => {\n\n this._drapedPrimitives.clear();\n this._allGeomDraped = false;\n this.hidden = false;\n\n this._data = data;\n IModelApp.viewManager.invalidateCachedDecorationsAllViews(this);\n\n this._drapeGraphicsStates = [];\n\n if (!this.disableTerrainDraper && this._data.mapInfo?.layerInfos && data.hit.viewport.displayStyle.displayTerrain) {\n\n if (data.hit?.modelId) {\n const drapeTreeRef = this.getGeometryTreeRef(data.hit.viewport);\n if (drapeTreeRef) {\n this._draper = new GeometryTerrainDraper(data.hit.viewport, drapeTreeRef);\n return;\n }\n }\n }\n\n if (this._draper) {\n // Dispose draper every time?\n this._draper.dispose();\n this._draper = undefined;\n }\n };\n\n private getGeometryTreeRef(vp: Viewport): GeometryTileTreeReference | undefined {\n let treeRef: GeometryTileTreeReference | undefined;\n if (vp.backgroundMapSettings.applyTerrain) {\n vp.forEachMapTreeRef((ref: TileTreeReference) => {\n if (!treeRef && ref instanceof MapTileTreeReference) {\n treeRef = ref.createGeometryTreeReference();\n }\n });\n }\n\n return treeRef;\n }\n\n protected renderGraphics(context: DecorateContext) {\n this._markerSet.markers.clear();\n\n if (this._data?.mapInfo?.layerInfos === undefined || this.hidden) {\n return undefined;\n }\n\n let transform: Transform|undefined;\n const groundBias = context.viewport.displayStyle.backgroundMapSettings.groundBias;\n if (groundBias !== 0) {\n transform = Transform.createTranslationXYZ(0, 0 , groundBias);\n }\n const builder = context.createGraphicBuilder(this._graphicType, transform);\n\n if (this._draper) {\n this.initializeDrapeState(context.viewport);\n\n // We need to call drapeGeometries() until it returns true (i.e. fully complete)\n if (!this._allGeomDraped) {\n if (!this.drapeGeometries(context.viewport))\n return undefined;\n }\n\n this.appendDrapedGeometries(builder);\n } else {\n // Append geometries straight from the state to the builder\n this.appendGeometries(builder);\n }\n\n // Add extra markers if any specified\n if ( this.extraMarkers !== undefined) {\n this.extraMarkers.forEach((markerPoint)=> {\n builder.setSymbology(this.highlightColor, this.highlightColor, this.lineWidth);\n this._markerSet.markers.add(new PinMarker(markerPoint, this.markerSize, this._markerImage));\n });\n }\n\n return builder.finish();\n }\n\n // Iterates the mapfeatureinfo data and create a draping state for each entry\n private initializeDrapeState(viewport: ScreenViewport) {\n if (this._drapeGraphicsStates.length === 0) {\n const getGraphicRange = (graphic: GraphicPrimitive) => {\n if (graphic.type === \"linestring\")\n return Range3d.createArray(graphic.points);\n else if (graphic.type === \"loop\")\n return graphic.loop.range();\n else if (graphic.type === \"pointstring\")\n return Range3d.createArray(graphic.points);\n else\n return Range3d.createNull();\n };\n\n for (const layerInfo of this._data?.mapInfo?.layerInfos??[]) {\n for (const subLayerInfo of layerInfo?.subLayerInfos??[]) {\n for (const feature of subLayerInfo.features) {\n\n feature.geometries?.forEach(((geom)=> {\n const range = getGraphicRange(geom.graphic);\n this._drapeGraphicsStates.push({\n graphic: geom.graphic,\n collectorState: \"loading\",\n chordTolerance: this.computeChordTolerance(viewport, range),\n range,\n });\n } ));\n }\n }\n }\n }\n }\n\n // returns true when all geometries are fully draped; otherwise false\n private drapeGeometries(_viewport: ScreenViewport): boolean {\n if (!this._draper)\n return false;\n\n let hasMissingDrapeGeoms = false;\n for (const state of this._drapeGraphicsStates) {\n if (state.collectorState === \"loading\") {\n this._scratchPoints.clear();\n\n if (state.graphic.type === \"linestring\") {\n this._scratchPoints.pushAll(state.graphic.points);\n const drapedStrings: LineString3d[] = [];\n if (\"loading\" === this._draper.drapeLineString(drapedStrings, this._scratchPoints, state.chordTolerance, state.range)) {\n hasMissingDrapeGeoms = true;\n break;\n } else {\n this._drapedPrimitives.addStrings(drapedStrings);\n state.collectorState = \"complete\";\n }\n } else if (state.graphic.type === \"loop\") {\n const loop = state.graphic.loop;\n const outMeshes: Polyface[] = [];\n if (\"loading\" === this._draper.drapeLoop(outMeshes, loop, state.chordTolerance, state.range)) {\n hasMissingDrapeGeoms = true;\n break; // We drape each graphic sequentially, otherwise collector get messed up.\n } else {\n this._drapedPrimitives.addMeshes(outMeshes);\n state.collectorState = \"complete\";\n }\n } else if (state.graphic.type === \"pointstring\") {\n const outPoint = Point3d.createZero();\n for (const point of state.graphic.points) {\n if (\"loading\" === this._draper.drapePoint(outPoint, point, state.chordTolerance, state.range)) {\n this._allGeomDraped = false;\n return false;\n } else if (!outPoint.isZero) {\n this._drapedPrimitives.points.push(outPoint);\n }\n }\n }\n }\n }\n\n this._allGeomDraped = !hasMissingDrapeGeoms;\n return this._allGeomDraped;\n }\n\n private appendDrapedGeometries(builder: GraphicBuilder) {\n if (this._drapedPrimitives.strings) {\n builder.setSymbology(this.highlightColor, this.highlightColor, this.lineWidth);\n this._drapedPrimitives.strings.forEach((line) => builder.addLineString(line.points));\n }\n\n if (this._drapedPrimitives.meshes) {\n builder.setSymbology(this.highlightColor, this.highlightColor, this.lineWidth);\n this._drapedPrimitives.meshes.forEach((polyface) => builder.addPolyface(polyface, true));\n }\n\n if (this._drapedPrimitives.points.length > 0) {\n for (let i = 0; i < this._drapedPrimitives.points.length; i++) {\n this._markerSet.markers.add(new PinMarker(this._drapedPrimitives.points.getPoint3dAtUncheckedPointIndex(i), this.markerSize, this._markerImage));\n }\n }\n }\n\n private appendGeometries(builder: GraphicBuilder) {\n if (!this._data?.mapInfo?.layerInfos)\n return;\n\n builder.setSymbology(this.highlightColor, this.highlightColor, this.lineWidth);\n for (const layerInfo of this._data.mapInfo.layerInfos) {\n if (layerInfo.subLayerInfos && !(layerInfo.subLayerInfos instanceof HTMLElement)) {\n for (const subLayerInfo of layerInfo.subLayerInfos) {\n for (const feature of subLayerInfo.features) {\n if (feature.geometries) {\n for (const geom of feature.geometries) {\n if (geom.graphic.type === \"pointstring\") {\n for (const point of geom.graphic.points)\n this._markerSet.markers.add(new PinMarker(point, this.markerSize, this._markerImage));\n } else {\n builder.addPrimitive(geom.graphic);\n }\n\n }\n }\n }\n }\n\n }\n\n }\n }\n\n public decorate(context: DecorateContext): void {\n const graphics = this.renderGraphics(context);\n if (graphics) {\n context.addDecoration(this._graphicType, graphics);\n IModelApp.toolAdmin.setCursor(undefined);\n }\n\n this._markerSet.addDecoration(context);\n return;\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"MapFeatureInfoTool.d.ts","sourceRoot":"","sources":["../../../src/Tools/MapFeatureInfoTool.ts"],"names":[],"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jB,OAAO,CAAC,YAAY,CAAC;IAOF,aAAa;IAMnC,gBAAgB;IAChB,SAAS,CAAC,UAAU,IAAI,IAAI;CAmB7B"}
@@ -101,7 +101,7 @@ export class MapFeatureInfoTool extends PrimitiveTool {
101
101
  else {
102
102
  // Flush existing decorations until a new selection is made
103
103
  this.onInfoCleared.raiseEvent();
104
- this._decorator.clearState();
104
+ this._decorator.clearData();
105
105
  }
106
106
  vp.invalidateDecorations();
107
107
  }
@@ -202,10 +202,13 @@ export class MapFeatureInfoTool extends PrimitiveTool {
202
202
  const pixelRadius = Math.floor(aperture + 0.5);
203
203
  mapInfo = await hit.viewport.getMapFeatureInfo(hit, { tolerance: pixelRadius });
204
204
  if (mapInfo) {
205
- this._decorator.setState({ hit, mapInfo });
205
+ this._decorator.setData({ hit, mapInfo });
206
+ }
207
+ else {
208
+ IModelApp.toolAdmin.setCursor(undefined);
206
209
  }
207
210
  }
208
- finally {
211
+ catch {
209
212
  IModelApp.toolAdmin.setCursor(undefined);
210
213
  }
211
214
  }