@itwin/linear-referencing-backend 5.9.0-dev.3 → 5.9.0-dev.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/LinearReferencingElementAspects.d.ts +15 -1
- package/lib/cjs/LinearReferencingElementAspects.d.ts.map +1 -1
- package/lib/cjs/LinearReferencingElementAspects.js +7 -4
- package/lib/cjs/LinearReferencingElementAspects.js.map +1 -1
- package/lib/cjs/LinearReferencingElements.d.ts +67 -1
- package/lib/cjs/LinearReferencingElements.d.ts.map +1 -1
- package/lib/cjs/LinearReferencingElements.js +51 -62
- package/lib/cjs/LinearReferencingElements.js.map +1 -1
- package/lib/esm/LinearReferencingElementAspects.d.ts +15 -1
- package/lib/esm/LinearReferencingElementAspects.d.ts.map +1 -1
- package/lib/esm/LinearReferencingElementAspects.js +8 -5
- package/lib/esm/LinearReferencingElementAspects.js.map +1 -1
- package/lib/esm/LinearReferencingElements.d.ts +67 -1
- package/lib/esm/LinearReferencingElements.d.ts.map +1 -1
- package/lib/esm/LinearReferencingElements.js +52 -63
- package/lib/esm/LinearReferencingElements.js.map +1 -1
- package/package.json +10 -10
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
* @module LinearReferencing
|
|
7
7
|
*/
|
|
8
8
|
import { assert, DbResult } from "@itwin/core-bentley";
|
|
9
|
-
import { PhysicalElement, SpatialLocationElement } from "@itwin/core-backend";
|
|
9
|
+
import { EditTxn, PhysicalElement, SpatialLocationElement } from "@itwin/core-backend";
|
|
10
|
+
import { _implicitTxn } from "@itwin/core-backend/lib/cjs/internal/Symbols";
|
|
10
11
|
import { Code, IModelError, RelatedElement } from "@itwin/core-common";
|
|
11
12
|
import { ComparisonOption, LinearlyReferencedLocationType, } from "@itwin/linear-referencing-common";
|
|
12
13
|
import { LinearlyReferencedAtLocation, LinearlyReferencedFromToLocation } from "./LinearReferencingElementAspects";
|
|
@@ -60,24 +61,28 @@ export class LinearLocation extends LinearLocationElement {
|
|
|
60
61
|
static create(iModel, modelId, categoryId) {
|
|
61
62
|
return new LinearLocation(this.toProps(modelId, categoryId), iModel);
|
|
62
63
|
}
|
|
63
|
-
static insertFromTo(
|
|
64
|
-
const
|
|
65
|
-
|
|
64
|
+
static insertFromTo(txnOrIModel, modelId, categoryId, linearElementId, fromToPosition, locatedElementId) {
|
|
65
|
+
const txn = txnOrIModel instanceof EditTxn ? txnOrIModel : txnOrIModel[_implicitTxn];
|
|
66
|
+
const newId = LinearlyLocated.insertFromTo(txn, this.toProps(modelId, categoryId), linearElementId, fromToPosition);
|
|
67
|
+
ILinearLocationLocatesElement.insert(txn, newId, locatedElementId);
|
|
66
68
|
return newId;
|
|
67
69
|
}
|
|
68
|
-
insertFromTo(
|
|
69
|
-
const
|
|
70
|
-
|
|
70
|
+
insertFromTo(txnOrIModel, linearElementId, fromToPosition, locatedElementId) {
|
|
71
|
+
const txn = txnOrIModel instanceof EditTxn ? txnOrIModel : txnOrIModel[_implicitTxn];
|
|
72
|
+
const newId = LinearlyLocated.insertFromTo(txn, this.toJSON(), linearElementId, fromToPosition);
|
|
73
|
+
ILinearLocationLocatesElement.insert(txn, newId, locatedElementId);
|
|
71
74
|
return newId;
|
|
72
75
|
}
|
|
73
|
-
static insertAt(
|
|
74
|
-
const
|
|
75
|
-
|
|
76
|
+
static insertAt(txnOrIModel, modelId, categoryId, linearElementId, atPosition, locatedElementId) {
|
|
77
|
+
const txn = txnOrIModel instanceof EditTxn ? txnOrIModel : txnOrIModel[_implicitTxn];
|
|
78
|
+
const newId = LinearlyLocated.insertAt(txn, this.toProps(modelId, categoryId), linearElementId, atPosition);
|
|
79
|
+
ILinearLocationLocatesElement.insert(txn, newId, locatedElementId);
|
|
76
80
|
return newId;
|
|
77
81
|
}
|
|
78
|
-
insertAt(
|
|
79
|
-
const
|
|
80
|
-
|
|
82
|
+
insertAt(txnOrIModel, linearElementId, atPosition, locatedElementId) {
|
|
83
|
+
const txn = txnOrIModel instanceof EditTxn ? txnOrIModel : txnOrIModel[_implicitTxn];
|
|
84
|
+
const newId = LinearlyLocated.insertAt(txn, this.toJSON(), linearElementId, atPosition);
|
|
85
|
+
ILinearLocationLocatesElement.insert(txn, newId, locatedElementId);
|
|
81
86
|
return newId;
|
|
82
87
|
}
|
|
83
88
|
}
|
|
@@ -128,11 +133,13 @@ export class Referent extends ReferentElement {
|
|
|
128
133
|
static create(iModel, modelId, categoryId, referencedElementId) {
|
|
129
134
|
return new Referent(this.toProps(modelId, categoryId, referencedElementId), iModel);
|
|
130
135
|
}
|
|
131
|
-
static insertAt(
|
|
132
|
-
|
|
136
|
+
static insertAt(txnOrIModel, modelId, categoryId, linearElementId, atPosition, referencedElementId) {
|
|
137
|
+
const txn = txnOrIModel instanceof EditTxn ? txnOrIModel : txnOrIModel[_implicitTxn];
|
|
138
|
+
return LinearlyLocated.insertAt(txn, this.toProps(modelId, categoryId, referencedElementId), linearElementId, atPosition);
|
|
133
139
|
}
|
|
134
|
-
insertAt(
|
|
135
|
-
|
|
140
|
+
insertAt(txnOrIModel, linearElementId, atPosition) {
|
|
141
|
+
const txn = txnOrIModel instanceof EditTxn ? txnOrIModel : txnOrIModel[_implicitTxn];
|
|
142
|
+
return LinearlyLocated.insertAt(txn, this.toJSON(), linearElementId, atPosition);
|
|
136
143
|
}
|
|
137
144
|
}
|
|
138
145
|
class ECSQLGenImpl {
|
|
@@ -407,36 +414,22 @@ class QueryLinearLocationsECSQLGen {
|
|
|
407
414
|
* @beta
|
|
408
415
|
*/
|
|
409
416
|
export class LinearlyLocated {
|
|
410
|
-
static insertBasic(
|
|
411
|
-
const newId =
|
|
412
|
-
const linearlyLocatedAlongLinearElement = ILinearlyLocatedAlongILinearElement.create(iModel, newId, linearElementId);
|
|
413
|
-
linearlyLocatedAlongLinearElement.insert();
|
|
417
|
+
static insertBasic(txn, elProps, linearElementId) {
|
|
418
|
+
const newId = txn.insertElement(elProps);
|
|
419
|
+
const linearlyLocatedAlongLinearElement = ILinearlyLocatedAlongILinearElement.create(txn.iModel, newId, linearElementId);
|
|
420
|
+
linearlyLocatedAlongLinearElement.insert(txn);
|
|
414
421
|
return newId;
|
|
415
422
|
}
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
* @param atPosition Linear position.
|
|
421
|
-
* @returns The newly inserted element's Id.
|
|
422
|
-
* @throws [[IModelError]] if unable to insert the element.
|
|
423
|
-
*/
|
|
424
|
-
static insertAt(iModel, elProps, linearElementId, atPosition) {
|
|
425
|
-
const newId = this.insertBasic(iModel, elProps, linearElementId);
|
|
426
|
-
LinearlyReferencedAtLocation.insert(iModel, newId, atPosition.atPosition, (atPosition.fromReferent === undefined) ? undefined : atPosition.fromReferent.id);
|
|
423
|
+
static insertAt(txnOrIModel, elProps, linearElementId, atPosition) {
|
|
424
|
+
const txn = txnOrIModel instanceof EditTxn ? txnOrIModel : txnOrIModel[_implicitTxn];
|
|
425
|
+
const newId = this.insertBasic(txn, elProps, linearElementId);
|
|
426
|
+
LinearlyReferencedAtLocation.insert(txn, newId, atPosition.atPosition, atPosition.fromReferent === undefined ? undefined : atPosition.fromReferent.id);
|
|
427
427
|
return newId;
|
|
428
428
|
}
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
* @param fromToPosition Linear position.
|
|
434
|
-
* @returns The newly inserted element's Id.
|
|
435
|
-
* @throws [[IModelError]] if unable to insert the element.
|
|
436
|
-
*/
|
|
437
|
-
static insertFromTo(iModel, elProps, linearElementId, fromToPosition) {
|
|
438
|
-
const newId = this.insertBasic(iModel, elProps, linearElementId);
|
|
439
|
-
LinearlyReferencedFromToLocation.insert(iModel, newId, fromToPosition.fromPosition, fromToPosition.toPosition, (fromToPosition.fromPositionFromReferent === undefined) ? undefined : fromToPosition.fromPositionFromReferent.id, (fromToPosition.toPositionFromReferent === undefined) ? undefined : fromToPosition.toPositionFromReferent.id);
|
|
429
|
+
static insertFromTo(txnOrIModel, elProps, linearElementId, fromToPosition) {
|
|
430
|
+
const txn = txnOrIModel instanceof EditTxn ? txnOrIModel : txnOrIModel[_implicitTxn];
|
|
431
|
+
const newId = this.insertBasic(txn, elProps, linearElementId);
|
|
432
|
+
LinearlyReferencedFromToLocation.insert(txn, newId, fromToPosition.fromPosition, fromToPosition.toPosition, fromToPosition.fromPositionFromReferent === undefined ? undefined : fromToPosition.fromPositionFromReferent.id, fromToPosition.toPositionFromReferent === undefined ? undefined : fromToPosition.toPositionFromReferent.id);
|
|
440
433
|
return newId;
|
|
441
434
|
}
|
|
442
435
|
static getLinearLocations(iModel, linearlyLocatedElementId, fullClassName) {
|
|
@@ -484,19 +477,17 @@ export class LinearlyLocated {
|
|
|
484
477
|
return linearLocations[0];
|
|
485
478
|
}
|
|
486
479
|
}
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
* @param linearLocationProps The properties to use to update the LinearlyReferencedAtLocation aspect.
|
|
491
|
-
* @param aspectId The Id of the aspect to update. If not known, the first aspectId will be looked-up.
|
|
492
|
-
* @throws [[IModelError]]
|
|
493
|
-
*/
|
|
494
|
-
static updateAtLocation(iModel, linearlyLocatedElementId, linearLocationProps, aspectId) {
|
|
480
|
+
static updateAtLocation(txnOrIModel, linearlyLocatedElementId, linearLocationProps, aspectId) {
|
|
481
|
+
const txn = txnOrIModel instanceof EditTxn ? txnOrIModel : txnOrIModel[_implicitTxn];
|
|
482
|
+
const iModel = txn.iModel;
|
|
495
483
|
let linearLocAspectId;
|
|
496
484
|
if (aspectId !== undefined)
|
|
497
485
|
linearLocAspectId = aspectId;
|
|
498
486
|
else {
|
|
499
|
-
|
|
487
|
+
const queriedAspectId = this.queryFirstLinearLocationAspectId(iModel, linearlyLocatedElementId, "LinearlyReferencedAtLocation");
|
|
488
|
+
if (queriedAspectId === undefined)
|
|
489
|
+
throw new Error("LinearlyReferencedAtLocation aspect not found");
|
|
490
|
+
linearLocAspectId = queriedAspectId;
|
|
500
491
|
}
|
|
501
492
|
const linearLocationAspectProps = {
|
|
502
493
|
id: linearLocAspectId,
|
|
@@ -505,21 +496,19 @@ export class LinearlyLocated {
|
|
|
505
496
|
atPosition: linearLocationProps.atPosition,
|
|
506
497
|
fromReferent: linearLocationProps.fromReferent,
|
|
507
498
|
};
|
|
508
|
-
|
|
499
|
+
txn.updateAspect(linearLocationAspectProps);
|
|
509
500
|
}
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
* @param linearLocationProps The properties to use to update the LinearlyReferencedFromToLocation aspect.
|
|
514
|
-
* @param aspectId The Id of the aspect to update. If not known, the first aspectId will be looked-up.
|
|
515
|
-
* @throws [[IModelError]]
|
|
516
|
-
*/
|
|
517
|
-
static updateFromToLocation(iModel, linearlyLocatedElementId, linearLocationProps, aspectId) {
|
|
501
|
+
static updateFromToLocation(txnOrIModel, linearlyLocatedElementId, linearLocationProps, aspectId) {
|
|
502
|
+
const txn = txnOrIModel instanceof EditTxn ? txnOrIModel : txnOrIModel[_implicitTxn];
|
|
503
|
+
const iModel = txn.iModel;
|
|
518
504
|
let linearLocAspectId;
|
|
519
505
|
if (aspectId !== undefined)
|
|
520
506
|
linearLocAspectId = aspectId;
|
|
521
507
|
else {
|
|
522
|
-
|
|
508
|
+
const queriedAspectId = this.queryFirstLinearLocationAspectId(iModel, linearlyLocatedElementId, "LinearlyReferencedFromToLocation");
|
|
509
|
+
if (queriedAspectId === undefined)
|
|
510
|
+
throw new Error("LinearlyReferencedFromToLocation aspect not found");
|
|
511
|
+
linearLocAspectId = queriedAspectId;
|
|
523
512
|
}
|
|
524
513
|
const linearLocationAspectProps = {
|
|
525
514
|
id: linearLocAspectId,
|
|
@@ -530,7 +519,7 @@ export class LinearlyLocated {
|
|
|
530
519
|
toPosition: linearLocationProps.toPosition,
|
|
531
520
|
toPositionFromReferent: linearLocationProps.toPositionFromReferent,
|
|
532
521
|
};
|
|
533
|
-
|
|
522
|
+
txn.updateAspect(linearLocationAspectProps);
|
|
534
523
|
}
|
|
535
524
|
/** Query for the Id of the Linear-Element along which the specified LinearlyLocated Element is located.
|
|
536
525
|
* @param iModel The iModel to query from.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LinearReferencingElements.js","sourceRoot":"","sources":["../../src/LinearReferencingElements.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAc,MAAM,qBAAqB,CAAC;AACnE,OAAO,EAA2C,eAAe,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AACvH,OAAO,EAAE,IAAI,EAAyC,WAAW,EAAwB,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpI,OAAO,EACL,gBAAgB,EAEhB,8BAA8B,GAC/B,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,4BAA4B,EAAE,gCAAgC,EAAE,MAAM,mCAAmC,CAAC;AACnH,OAAO,EACL,6BAA6B,EAAE,mCAAmC,EAAqC,0BAA0B,GAClI,MAAM,kCAAkC,CAAC;AAE1C;;GAEG;AACH,MAAM,OAAgB,0BAA2B,SAAQ,sBAAsB;IAC7E,gBAAgB;IACT,MAAM,KAAc,SAAS,KAAa,OAAO,4BAA4B,CAAC,CAAC,CAAC;IAEhF,iBAAiB,CAAqC;IAE7D,YAAmB,KAAsC,EAAE,MAAgB;QACzE,KAAK,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QACrB,IAAI,CAAC,iBAAiB,GAAG,cAAc,CAAC,QAAQ,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC;IAC5E,CAAC;IAEM,kBAAkB;QACvB,OAAO,eAAe,CAAC,kBAAkB,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC;IAClE,CAAC;CACF;AAED;;GAEG;AACH,MAAM,OAAgB,qBAAsB,SAAQ,sBAAsB;IACxE,gBAAgB;IACT,MAAM,KAAc,SAAS,KAAa,OAAO,uBAAuB,CAAC,CAAC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AiB,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,SAAS,EAAE;oBAC/C,gBAAgB,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE;iBAC3C,CAAC;gBAEF,kBAAkB,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;YAC7C,CAAC;QACH,CAAC,CAAC,CAAC;QAEH,OAAO,kBAAkB,CAAC;IAC5B,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/** @packageDocumentation\n * @module LinearReferencing\n */\n\nimport { assert, DbResult, Id64String } from \"@itwin/core-bentley\";\nimport { ECSqlStatement, ElementAspect, IModelDb, PhysicalElement, SpatialLocationElement } from \"@itwin/core-backend\";\nimport { Code, ElementProps, GeometricElement3dProps, IModelError, PhysicalElementProps, RelatedElement } from \"@itwin/core-common\";\nimport {\n ComparisonOption, LinearLocationReference, LinearlyLocatedAttributionProps, LinearlyReferencedAtLocationAspectProps,\n LinearlyReferencedAtLocationProps, LinearlyReferencedFromToLocationAspectProps, LinearlyReferencedFromToLocationProps,\n LinearlyReferencedLocationType, QueryParams, ReferentElementProps,\n} from \"@itwin/linear-referencing-common\";\nimport { LinearlyReferencedAtLocation, LinearlyReferencedFromToLocation } from \"./LinearReferencingElementAspects\";\nimport {\n ILinearLocationLocatesElement, ILinearlyLocatedAlongILinearElement, ILinearlyLocatedAttributesElement, IReferentReferencesElement,\n} from \"./LinearReferencingRelationships\";\n\n/** Base class for Spatial Location Element subclasses representing properties whose value is located along a Linear-Element and only applies to a portion of an Element.\n * @beta\n */\nexport abstract class LinearlyLocatedAttribution extends SpatialLocationElement {\n /** @internal */\n public static override get className(): string { return \"LinearlyLocatedAttribution\"; }\n\n public attributedElement?: ILinearlyLocatedAttributesElement;\n\n public constructor(props: LinearlyLocatedAttributionProps, iModel: IModelDb) {\n super(props, iModel);\n this.attributedElement = RelatedElement.fromJSON(props.attributedElement);\n }\n\n public getLinearElementId(): Id64String | undefined {\n return LinearlyLocated.getLinearElementId(this.iModel, this.id);\n }\n}\n\n/** Base class for Spatial Location Element implementations that are linearly located along a Linear-Element.\n * @beta\n */\nexport abstract class LinearLocationElement extends SpatialLocationElement implements LinearlyLocatedBase {\n /** @internal */\n public static override get className(): string { return \"LinearLocationElement\"; }\n\n public constructor(props: GeometricElement3dProps, iModel: IModelDb) {\n super(props, iModel);\n }\n\n public getLinearElementId(): Id64String | undefined {\n return LinearlyLocated.getLinearElementId(this.iModel, this.id);\n }\n}\n\n/** Linear Referencing Location attached to an Element not inherently Linearly Referenced.\n * @beta\n */\nexport class LinearLocation extends LinearLocationElement implements LinearlyLocatedBase {\n /** @internal */\n public static override get className(): string { return \"LinearLocation\"; }\n public constructor(props: GeometricElement3dProps, iModel: IModelDb) {\n super(props, iModel);\n }\n\n private static toProps(modelId: Id64String, categoryId: Id64String): GeometricElement3dProps {\n const props: GeometricElement3dProps = {\n classFullName: LinearLocation.classFullName,\n category: categoryId,\n model: modelId,\n code: Code.createEmpty(),\n };\n\n return props;\n }\n\n public static create(iModel: IModelDb, modelId: Id64String, categoryId: Id64String): LinearLocation {\n return new LinearLocation(this.toProps(modelId, categoryId), iModel);\n }\n\n public static insertFromTo(iModel: IModelDb, modelId: Id64String, categoryId: Id64String, linearElementId: Id64String,\n fromToPosition: LinearlyReferencedFromToLocationProps, locatedElementId: Id64String): Id64String {\n const newId = LinearlyLocated.insertFromTo(iModel, this.toProps(modelId, categoryId), linearElementId, fromToPosition);\n\n ILinearLocationLocatesElement.insert(iModel, newId, locatedElementId);\n\n return newId;\n }\n\n public insertFromTo(iModel: IModelDb, linearElementId: Id64String, fromToPosition: LinearlyReferencedFromToLocationProps, locatedElementId: Id64String): Id64String {\n const newId = LinearlyLocated.insertFromTo(iModel, this.toJSON(), linearElementId, fromToPosition);\n\n ILinearLocationLocatesElement.insert(iModel, newId, locatedElementId);\n\n return newId;\n }\n\n public static insertAt(iModel: IModelDb, modelId: Id64String, categoryId: Id64String, linearElementId: Id64String,\n atPosition: LinearlyReferencedAtLocationProps, locatedElementId: Id64String): Id64String {\n const newId = LinearlyLocated.insertAt(iModel, this.toProps(modelId, categoryId), linearElementId, atPosition);\n\n ILinearLocationLocatesElement.insert(iModel, newId, locatedElementId);\n\n return newId;\n }\n\n public insertAt(iModel: IModelDb, linearElementId: Id64String, atPosition: LinearlyReferencedAtLocationProps, locatedElementId: Id64String): Id64String {\n const newId = LinearlyLocated.insertAt(iModel, this.toJSON(), linearElementId, atPosition);\n\n ILinearLocationLocatesElement.insert(iModel, newId, locatedElementId);\n\n return newId;\n }\n}\n\n/** Base class for Physical Elements that are inherently linearly located along a Linear-Element.\n * @beta\n */\nexport abstract class LinearPhysicalElement extends PhysicalElement {\n /** @internal */\n public static override get className(): string { return \"LinearPhysicalElement\"; }\n\n public constructor(props: PhysicalElementProps, iModel: IModelDb) {\n super(props, iModel);\n }\n}\n\n/** Spatial Location Element that can play the role of a Referent (known location along a Linear-Element).\n * @beta\n */\nexport abstract class ReferentElement extends SpatialLocationElement implements LinearlyLocatedBase {\n /** @internal */\n public static override get className(): string { return \"ReferentElement\"; }\n\n public referencedElement?: IReferentReferencesElement;\n\n public constructor(props: ReferentElementProps, iModel: IModelDb) {\n super(props, iModel);\n this.referencedElement = RelatedElement.fromJSON(props.referencedElement);\n }\n\n public getLinearElementId(): Id64String | undefined {\n return LinearlyLocated.getLinearElementId(this.iModel, this.id);\n }\n}\n\n/** Referent-implementation turning any bis:SpatialElement not inherently Linearly-Referenced into a Referent for Linear-Referencing purposes.\n * @beta\n */\nexport class Referent extends ReferentElement {\n /** @internal */\n public static override get className(): string { return \"Referent\"; }\n public constructor(props: ReferentElementProps, iModel: IModelDb) {\n super(props, iModel);\n }\n\n private static toProps(modelId: Id64String, categoryId: Id64String, referencedElementId: Id64String): ReferentElementProps {\n const props: ReferentElementProps = {\n classFullName: LinearLocation.classFullName,\n category: categoryId,\n model: modelId,\n code: Code.createEmpty(),\n referencedElement: new IReferentReferencesElement(referencedElementId),\n };\n\n return props;\n }\n\n public static create(iModel: IModelDb, modelId: Id64String, categoryId: Id64String, referencedElementId: Id64String): Referent {\n return new Referent(this.toProps(modelId, categoryId, referencedElementId), iModel);\n }\n\n public static insertAt(iModel: IModelDb, modelId: Id64String, categoryId: Id64String, linearElementId: Id64String,\n atPosition: LinearlyReferencedAtLocationProps, referencedElementId: Id64String): Id64String {\n return LinearlyLocated.insertAt(iModel, this.toProps(modelId, categoryId, referencedElementId), linearElementId, atPosition);\n }\n\n public insertAt(iModel: IModelDb, linearElementId: Id64String, atPosition: LinearlyReferencedAtLocationProps): Id64String {\n return LinearlyLocated.insertAt(iModel, this.toJSON(), linearElementId, atPosition);\n }\n}\n\nabstract class ECSQLGenImpl {\n public abstract genSelect(): string;\n public selectDistinct(): boolean {\n return false;\n }\n public abstract genFromJoin(): string;\n public abstract genWhere(bindVals?: any[], from?: number, inclusiveFrom?: boolean, to?: number, inclusiveTo?: boolean): string;\n public abstract genOrderBy(): string;\n}\n\nclass AtAndFromToECSQLGenImpl extends ECSQLGenImpl {\n public genSelect(): string {\n return \"coalesce(AtLocation.AtPosition.DistanceAlongFromStart, FromToLocation.FromPosition.DistanceAlongFromStart) StartDistanceAlong, \" +\n \"coalesce(AtLocation.AtPosition.DistanceAlongFromStart, FromToLocation.ToPosition.DistanceAlongFromStart) StopDistanceAlong, \" +\n \"coalesce(AtLocation.ECInstanceId, FromToLocation.ECInstanceId) LocationAspectId \";\n }\n public override selectDistinct(): boolean {\n return true;\n }\n public genFromJoin(): string {\n return \"LEFT JOIN LinearReferencing.LinearlyReferencedAtLocation AtLocation ON LinearlyLocated.InstanceId = AtLocation.Element.Id \" +\n \"LEFT JOIN LinearReferencing.LinearlyReferencedFromToLocation FromToLocation ON LinearlyLocated.InstanceId = FromToLocation.Element.Id \";\n }\n public genWhere(bindVals: any[], from?: number, inclusiveFrom?: boolean, to?: number, inclusiveTo?: boolean): string {\n const fromCompOp: string = (inclusiveFrom === undefined || inclusiveFrom) ? \">=\" : \">\";\n const toCompOp: string = (inclusiveTo === undefined || inclusiveTo) ? \"<=\" : \"<\";\n\n let ecSql = \"\";\n if (from !== undefined && to !== undefined) {\n ecSql += \"(AtLocation.AtPosition.DistanceAlongFromStart \";\n ecSql += fromCompOp;\n ecSql += \" ? AND AtLocation.AtPosition.DistanceAlongFromStart \";\n ecSql += toCompOp;\n ecSql += \" ?) OR (FromToLocation.FromPosition.DistanceAlongFromStart \";\n ecSql += fromCompOp;\n ecSql += \" ? AND FromToLocation.FromPosition.DistanceAlongFromStart \";\n ecSql += toCompOp;\n ecSql += \" ?) \" + \"OR (FromToLocation.ToPosition.DistanceAlongFromStart \";\n ecSql += fromCompOp;\n ecSql += \" ? AND FromToLocation.ToPosition.DistanceAlongFromStart \";\n ecSql += toCompOp;\n ecSql += \" ?) OR (FromToLocation.FromPosition.DistanceAlongFromStart <= ? AND FromToLocation.ToPosition.DistanceAlongFromStart >= ?) \";\n\n bindVals.push(from);\n bindVals.push(to);\n bindVals.push(from);\n bindVals.push(to);\n bindVals.push(from);\n bindVals.push(to);\n bindVals.push(from);\n bindVals.push(to);\n } else if (from !== undefined) {\n ecSql += \"AtLocation.AtPosition.DistanceAlongFromStart \";\n ecSql += fromCompOp;\n ecSql += \" ? OR FromToLocation.FromPosition.DistanceAlongFromStart \";\n ecSql += fromCompOp;\n ecSql += \" ? OR FromToLocation.ToPosition.DistanceAlongFromStart \";\n ecSql += fromCompOp;\n ecSql += \" ? \";\n\n bindVals.push(from);\n bindVals.push(from);\n bindVals.push(from);\n } else if (to !== undefined) {\n ecSql += \"AtLocation.AtPosition.DistanceAlongFromStart \";\n ecSql += toCompOp;\n ecSql += \" ? OR FromToLocation.FromPosition.DistanceAlongFromStart \";\n ecSql += toCompOp;\n ecSql += \" ? OR FromToLocation.ToPosition.DistanceAlongFromStart \";\n ecSql += toCompOp;\n ecSql += \" ? \";\n\n bindVals.push(to);\n bindVals.push(to);\n bindVals.push(to);\n } else {\n ecSql += \"(AtLocation.AtPosition.DistanceAlongFromStart IS NOT NULL) OR \";\n ecSql += \"(FromToLocation.FromPosition.DistanceAlongFromStart IS NOT NULL) \";\n }\n\n return ecSql;\n }\n public genOrderBy(): string {\n return \"coalesce(AtLocation.AtPosition.DistanceAlongFromStart, FromToLocation.FromPosition.DistanceAlongFromStart)\";\n }\n}\n\nclass FromToECSQLGenImpl extends ECSQLGenImpl {\n public genSelect(): string {\n return \"FromToLocation.FromPosition.DistanceAlongFromStart StartDistanceAlong, FromToLocation.ToPosition.DistanceAlongFromStart StopDistanceAlong, FromToLocation.ECInstanceId LocationAspectId \";\n }\n public genFromJoin(): string {\n return \"INNER JOIN LinearReferencing.LinearlyReferencedFromToLocation FromToLocation ON LinearlyLocated.InstanceId = FromToLocation.Element.Id \";\n }\n public genWhere(bindVals: any[], from?: number, inclusiveFrom?: boolean, to?: number, inclusiveTo?: boolean): string {\n const fromCompOp: string = (inclusiveFrom === undefined || inclusiveFrom) ? \">=\" : \">\";\n const toCompOp: string = (inclusiveTo === undefined || inclusiveTo) ? \"<=\" : \"<\";\n\n let ecSql = \"\";\n if (from !== undefined && to !== undefined) {\n ecSql += \"AND ((FromToLocation.FromPosition.DistanceAlongFromStart \";\n ecSql += fromCompOp;\n ecSql += \" ? AND FromToLocation.FromPosition.DistanceAlongFromStart \";\n ecSql += toCompOp;\n ecSql += \" ?) OR (FromToLocation.ToPosition.DistanceAlongFromStart \";\n ecSql += fromCompOp;\n ecSql += \" ? AND FromToLocation.ToPosition.DistanceAlongFromStart \";\n ecSql += toCompOp;\n ecSql += \" ?) OR (FromToLocation.FromPosition.DistanceAlongFromStart <= ? AND FromToLocation.ToPosition.DistanceAlongFromStart >= ?)) \";\n\n bindVals.push(from);\n bindVals.push(to);\n bindVals.push(from);\n bindVals.push(to);\n bindVals.push(from);\n bindVals.push(to);\n } else if (from !== undefined) {\n ecSql += \"AND (FromToLocation.FromPosition.DistanceAlongFromStart \";\n ecSql += fromCompOp;\n ecSql += \" ? OR FromToLocation.ToPosition.DistanceAlongFromStart \";\n ecSql += fromCompOp;\n ecSql += \" ?)\";\n\n bindVals.push(from);\n bindVals.push(from);\n } else if (to !== undefined) {\n ecSql += \"AND (FromToLocation.FromPosition.DistanceAlongFromStart \";\n ecSql += toCompOp;\n ecSql += \" ? OR FromToLocation.ToPosition.DistanceAlongFromStart \";\n ecSql += toCompOp;\n ecSql += \" ?) \";\n\n bindVals.push(to);\n bindVals.push(to);\n } else {\n ecSql += \"FromToLocation.FromPosition.DistanceAlongFromStart IS NOT NULL \";\n }\n\n return ecSql;\n }\n public genOrderBy(): string {\n return \"FromToLocation.FromPosition.DistanceAlongFromStart\";\n }\n}\n\nclass AtECSQLGenImpl extends ECSQLGenImpl {\n public genSelect(): string {\n return \"AtLocation.AtPosition.DistanceAlongFromStart StartDistanceAlong, AtLocation.AtPosition.DistanceAlongFromStart StopDistanceAlong, AtLocation.ECInstanceId LocationAspectId \";\n }\n public genFromJoin(): string {\n return \"INNER JOIN LinearReferencing.LinearlyReferencedAtLocation AtLocation ON LinearlyLocated.InstanceId = AtLocation.Element.Id \";\n }\n public genWhere(bindVals: any[], from?: number, inclusiveFrom?: boolean, to?: number, inclusiveTo?: boolean): string {\n const fromCompOp: string = (inclusiveFrom === undefined || inclusiveFrom) ? \">=\" : \">\";\n const toCompOp: string = (inclusiveTo === undefined || inclusiveTo) ? \"<=\" : \"<\";\n\n let ecSql = \"\";\n if (from !== undefined && to !== undefined) {\n ecSql += \"AtLocation.AtPosition.DistanceAlongFromStart \";\n ecSql += fromCompOp;\n ecSql += \" ? AND AtLocation.AtPosition.DistanceAlongFromStart \";\n ecSql += toCompOp;\n ecSql += \" ? \";\n\n bindVals.push(from);\n bindVals.push(to);\n } else if (from !== undefined) {\n ecSql += \"AtLocation.AtPosition.DistanceAlongFromStart \";\n ecSql += fromCompOp;\n ecSql += \" ? \";\n\n bindVals.push(from);\n } else if (to !== undefined) {\n ecSql += \"AtLocation.AtPosition.DistanceAlongFromStart \";\n ecSql += toCompOp;\n ecSql += \" ? \";\n\n bindVals.push(to);\n } else\n ecSql += \"AtLocation.AtPosition.DistanceAlongFromStart IS NOT NULL \";\n\n return ecSql;\n }\n public genOrderBy(): string {\n return \"AtLocation.AtPosition.DistanceAlongFromStart\";\n }\n}\n\nclass QueryLinearLocationsECSQLGen {\n private readonly _params: QueryParams;\n private _ecSql: string;\n\n private _addSelectClause(impl: ECSQLGenImpl): void {\n let select = \"SELECT \";\n\n if (impl.selectDistinct())\n select += \"DISTINCT \";\n\n select += \"LinearlyLocated.InstanceId LinearlyLocatedId, printf('%s:%s', meta.ECSchemaDef.Name, meta.ECClassDef.Name) LinearlyLocatedClassFullName, \";\n select += impl.genSelect();\n\n this._ecSql += select;\n }\n\n private _parseClassFullName(classFullName: string): [string, string] | undefined {\n const parts = classFullName.split(\":\");\n if (parts.length !== 2)\n return undefined;\n\n return [parts[0], parts[1]];\n }\n\n private _genLinearlyLocated(): string {\n return \"meta.ECSchemaDef JOIN meta.ECClassDef USING meta.SchemaOwnsClasses JOIN \" +\n \"(SELECT coalesce(Located.TargetECInstanceId, Along.SourceECInstanceId) InstanceId, \" +\n \"coalesce(Located.TargetECClassId, Along.SourceECClassId) ClassId \" +\n \"FROM LinearReferencing.ILinearlyLocatedAlongILinearElement Along LEFT JOIN \" +\n \"LinearReferencing.ILinearLocationLocatesElement Located ON Along.SourceECInstanceId = Located.SourceECInstanceId \" +\n \"WHERE Along.TargetECInstanceId = ?) LinearlyLocated ON meta.ECClassDef.ECInstanceId = LinearlyLocated.ClassId \";\n }\n\n private _addFromClause(impl: ECSQLGenImpl/* bvector<double>& bindVals */): void {\n let from = \"FROM \";\n from += this._genLinearlyLocated();\n from += impl.genFromJoin();\n\n this._ecSql += from;\n }\n\n private _addWhereClause(impl: ECSQLGenImpl, bindVals: any[]) {\n let where = \"WHERE \";\n\n where += impl.genWhere(\n bindVals,\n this._params.fromDistanceAlong,\n (this._params.fromComparisonOption === undefined ||\n this._params.fromComparisonOption === ComparisonOption.Inclusive),\n this._params.toDistanceAlong,\n (this._params.toComparisonOption === undefined ||\n this._params.toComparisonOption === ComparisonOption.Inclusive));\n\n if (this._params.linearlyLocatedClassFullNames !== undefined) {\n if (where.length > 6)\n where += \"AND \";\n\n if (1 === this._params.linearlyLocatedClassFullNames.length) {\n const classFullName = this._params.linearlyLocatedClassFullNames[0];\n const schemaNameClassName = this._parseClassFullName(classFullName);\n if (schemaNameClassName === undefined)\n throw new IModelError(0, \"Invalid full class name\");\n\n where += `meta.ECSchemaDef.Name='${schemaNameClassName[0]}' AND meta.ECClassDef.Name='${schemaNameClassName[1]}' `;\n } else if (1 < this._params.linearlyLocatedClassFullNames.length) {\n where += \"(\";\n for (const classFullName of this._params.linearlyLocatedClassFullNames) {\n if (classFullName === undefined)\n continue;\n\n const schemaNameClassName = this._parseClassFullName(classFullName);\n if (schemaNameClassName === undefined)\n continue;\n\n where += `(meta.ECSchemaDef.Name='${schemaNameClassName[0]}' AND meta.ECClassDef.Name='${schemaNameClassName[1]}') OR `;\n }\n\n where = where.substring(0, where.length - 4); // Removing last OR\n where += \") \";\n }\n }\n\n this._ecSql += where;\n }\n\n private _addOrderByClause(impl: ECSQLGenImpl): void {\n let orderBy = \"ORDER BY \";\n orderBy += impl.genOrderBy();\n\n this._ecSql += orderBy;\n }\n\n private _createImpl(): ECSQLGenImpl {\n if (this._params.linearlyReferencedLocationTypeFilter === undefined ||\n this._params.linearlyReferencedLocationTypeFilter === LinearlyReferencedLocationType.Any) {\n return new AtAndFromToECSQLGenImpl();\n } else if (this._params.linearlyReferencedLocationTypeFilter === LinearlyReferencedLocationType.FromTo) {\n return new FromToECSQLGenImpl();\n } else {\n return new AtECSQLGenImpl();\n }\n }\n\n public constructor(params: QueryParams) {\n this._params = params;\n this._ecSql = \"\";\n }\n\n public generate(linearElementId: Id64String): [string, any[]] {\n this._ecSql = \"\";\n const impl = this._createImpl();\n\n const bindVals: any[] = [linearElementId];\n this._addSelectClause(impl);\n this._addFromClause(impl);\n this._addWhereClause(impl, bindVals);\n this._addOrderByClause(impl);\n\n return [this._ecSql, bindVals];\n }\n}\n\n/** A class offering services for LinearlyLocated elements.\n * @beta\n */\nexport class LinearlyLocated {\n private static insertBasic(iModel: IModelDb, elProps: ElementProps, linearElementId: Id64String): Id64String {\n const newId = iModel.elements.insertElement(elProps);\n\n const linearlyLocatedAlongLinearElement =\n ILinearlyLocatedAlongILinearElement.create(iModel, newId, linearElementId);\n linearlyLocatedAlongLinearElement.insert();\n\n return newId;\n }\n\n /** Insert a new LinearlyLocated element into an iModel at a specific location along an existing Linear-Element.\n * @param iModel The iModel to insert the new element into.\n * @param elProps The properties of the new element.\n * @param linearElementId The Id of the Linear-Element along which the new LinearlyLocated will be inserted.\n * @param atPosition Linear position.\n * @returns The newly inserted element's Id.\n * @throws [[IModelError]] if unable to insert the element.\n */\n public static insertAt(iModel: IModelDb, elProps: ElementProps, linearElementId: Id64String,\n atPosition: LinearlyReferencedAtLocationProps): Id64String {\n const newId: Id64String = this.insertBasic(iModel, elProps, linearElementId);\n\n LinearlyReferencedAtLocation.insert(iModel, newId, atPosition.atPosition,\n (atPosition.fromReferent === undefined) ? undefined : atPosition.fromReferent.id);\n\n return newId;\n }\n\n /** Insert a new LinearlyLocated element into an iModel at a specific from-to location along an existing Linear-Element.\n * @param iModel The iModel to insert the new element into.\n * @param elProps The properties of the new element.\n * @param linearElementId The Id of the Linear-Element along which the new LinearlyLocated will be inserted.\n * @param fromToPosition Linear position.\n * @returns The newly inserted element's Id.\n * @throws [[IModelError]] if unable to insert the element.\n */\n public static insertFromTo(iModel: IModelDb, elProps: ElementProps, linearElementId: Id64String,\n fromToPosition: LinearlyReferencedFromToLocationProps): Id64String {\n const newId: Id64String = this.insertBasic(iModel, elProps, linearElementId);\n\n LinearlyReferencedFromToLocation.insert(iModel, newId,\n fromToPosition.fromPosition, fromToPosition.toPosition,\n (fromToPosition.fromPositionFromReferent === undefined) ? undefined : fromToPosition.fromPositionFromReferent.id,\n (fromToPosition.toPositionFromReferent === undefined) ? undefined : fromToPosition.toPositionFromReferent.id);\n\n return newId;\n }\n\n private static getLinearLocations<T>(iModel: IModelDb, linearlyLocatedElementId: Id64String, fullClassName: string): T[] {\n const aspects: ElementAspect[] =\n iModel.elements.getAspects(linearlyLocatedElementId, fullClassName);\n\n if (aspects.length === 0)\n return [];\n\n const retVal: T[] = [];\n for (const aspect of aspects) {\n const linearAspect = (aspect as unknown) as T;\n retVal.push(linearAspect);\n }\n\n return retVal;\n }\n\n private static queryFirstLinearLocationAspectId(iModel: IModelDb, linearlyLocatedElementId: Id64String, className: string): Id64String | undefined {\n let aspectId: Id64String | undefined;\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n iModel.withPreparedStatement(`SELECT ECInstanceId FROM LinearReferencing.${className} WHERE Element.Id=? LIMIT 1`, (stmt: ECSqlStatement) => {\n stmt.bindId(1, linearlyLocatedElementId);\n if (stmt.step() === DbResult.BE_SQLITE_ROW)\n aspectId = stmt.getValue(0).getId();\n });\n\n return aspectId;\n }\n\n /** Query for LinearlyReferenced AtLocation aspects owned by the specified LinearlyLocated Element.\n * @param iModel The iModel to query from.\n * @param linearlyLocatedElementId The id of the LinearlyLocated Element to query aspects about.\n * @returns Returns an array of LinearlyReferencedAtLocation.\n * @throws [[IModelError]]\n */\n public static getAtLocations(iModel: IModelDb, linearlyLocatedElementId: Id64String): LinearlyReferencedAtLocation[] {\n return this.getLinearLocations<LinearlyReferencedAtLocation>(\n iModel, linearlyLocatedElementId, \"LinearReferencing:LinearlyReferencedAtLocation\");\n }\n\n /** Query for the single LinearlyReferenced AtLocation aspect owned by the specified LinearlyLocated Element. If more than one aspect is expected, use [[getAtLocations]] instead.\n * @param iModel The iModel to query from.\n * @param linearlyLocatedElementId The id of the LinearlyLocated Element to query about.\n * @returns Returns an LinearlyReferencedAtLocation or undefined is none is found.\n * @throws [[IModelError]]\n */\n public static getAtLocation(iModel: IModelDb, linearlyLocatedElementId: Id64String): LinearlyReferencedAtLocation | undefined {\n const linearLocations = this.getAtLocations(iModel, linearlyLocatedElementId);\n if (linearLocations.length === 0)\n return undefined;\n else {\n assert(linearLocations.length === 1);\n return linearLocations[0];\n }\n }\n\n /** Update an existing LinearlyReferencedAtLocation aspect within the iModel.\n * @param iModel The iModel to update.\n * @param linearlyLocatedElementId The Id of the owning Linearly Located Element.\n * @param linearLocationProps The properties to use to update the LinearlyReferencedAtLocation aspect.\n * @param aspectId The Id of the aspect to update. If not known, the first aspectId will be looked-up.\n * @throws [[IModelError]]\n */\n public static updateAtLocation(iModel: IModelDb, linearlyLocatedElementId: Id64String, linearLocationProps: LinearlyReferencedAtLocationProps,\n aspectId?: Id64String): void {\n let linearLocAspectId: Id64String;\n if (aspectId !== undefined)\n linearLocAspectId = aspectId;\n else {\n linearLocAspectId = this.queryFirstLinearLocationAspectId(iModel, linearlyLocatedElementId, \"LinearlyReferencedAtLocation\")!;\n }\n\n const linearLocationAspectProps: LinearlyReferencedAtLocationAspectProps = {\n id: linearLocAspectId,\n element: { id: linearlyLocatedElementId },\n classFullName: \"LinearReferencing:LinearlyReferencedAtLocation\",\n atPosition: linearLocationProps.atPosition,\n fromReferent: linearLocationProps.fromReferent,\n };\n\n iModel.elements.updateAspect(linearLocationAspectProps);\n }\n\n /** Update an existing LinearlyReferencedFromToLocation aspect within the iModel.\n * @param iModel The iModel to update.\n * @param linearlyLocatedElementId The Id of the owning Linearly Located Element.\n * @param linearLocationProps The properties to use to update the LinearlyReferencedFromToLocation aspect.\n * @param aspectId The Id of the aspect to update. If not known, the first aspectId will be looked-up.\n * @throws [[IModelError]]\n */\n public static updateFromToLocation(iModel: IModelDb, linearlyLocatedElementId: Id64String, linearLocationProps: LinearlyReferencedFromToLocationProps,\n aspectId?: Id64String): void {\n let linearLocAspectId: Id64String;\n if (aspectId !== undefined)\n linearLocAspectId = aspectId;\n else {\n linearLocAspectId = this.queryFirstLinearLocationAspectId(iModel, linearlyLocatedElementId, \"LinearlyReferencedFromToLocation\")!;\n }\n\n const linearLocationAspectProps: LinearlyReferencedFromToLocationAspectProps = {\n id: linearLocAspectId,\n element: { id: linearlyLocatedElementId, relClassName: \"LinearReferencing:ILinearlyLocatedOwnsFromToLocations\" },\n classFullName: \"LinearReferencing:LinearlyReferencedFromToLocation\",\n fromPosition: linearLocationProps.fromPosition,\n fromPositionFromReferent: linearLocationProps.fromPositionFromReferent,\n toPosition: linearLocationProps.toPosition,\n toPositionFromReferent: linearLocationProps.toPositionFromReferent,\n };\n\n iModel.elements.updateAspect(linearLocationAspectProps);\n }\n\n /** Query for the Id of the Linear-Element along which the specified LinearlyLocated Element is located.\n * @param iModel The iModel to query from.\n * @param linearlyLocatedElementId The id of the LinearlyLocated Element to query a Linear-Element for.\n * @returns Returns the Id of the Linear-Element or undefined is none is assigned.\n */\n public static getLinearElementId(iModel: IModelDb, linearlyLocatedElementId: Id64String): Id64String | undefined {\n let linearElementId: Id64String | undefined;\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n iModel.withPreparedStatement(\"SELECT TargetECInstanceId FROM LinearReferencing.ILinearlyLocatedAlongILinearElement WHERE SourceECInstanceId = ?\", (stmt: ECSqlStatement) => {\n stmt.bindId(1, linearlyLocatedElementId);\n\n if (DbResult.BE_SQLITE_ROW === stmt.step())\n linearElementId = stmt.getValue(0).getId();\n else\n linearElementId = undefined;\n });\n\n return linearElementId;\n }\n\n /** Query for LinearlyReferenced FromToLocation aspects owned by the specified LinearlyLocated Element.\n * @param iModel The iModel to query from.\n * @param linearlyLocatedElementId The id of the LinearlyLocated Element to query aspects about.\n * @returns Returns an array of LinearlyReferencedFromToLocation.\n * @throws [[IModelError]]\n */\n public static getFromToLocations(iModel: IModelDb, linearlyLocatedElementId: Id64String): LinearlyReferencedFromToLocation[] {\n return this.getLinearLocations<LinearlyReferencedFromToLocation>(\n iModel, linearlyLocatedElementId, \"LinearReferencing:LinearlyReferencedFromToLocation\");\n }\n\n /** Query for the single LinearlyReferenced FromToLocation aspect owned by the specified LinearlyLocated Element. If more than one aspect is expected, use [[getFromToLocations]] instead.\n * @param iModel The iModel to query from.\n * @param linearlyLocatedElementId The id of the LinearlyLocated Element to query about.\n * @returns Returns an LinearlyReferencedFromToLocation or undefined is none is found.\n * @throws [[IModelError]]\n */\n public static getFromToLocation(iModel: IModelDb, linearlyLocatedElementId: Id64String): LinearlyReferencedFromToLocation | undefined {\n const linearLocations = this.getFromToLocations(iModel, linearlyLocatedElementId);\n if (linearLocations.length === 0)\n return undefined;\n else {\n assert(linearLocations.length === 1);\n return linearLocations[0];\n }\n }\n}\n\n/** Base interface to optionally be implemented by Elements inherently Linearly-Located. Implementors should choose the\n * appropriate sub-interface rather than implementing LinearlyLocatedBase directly.\n * @beta\n */\nexport interface LinearlyLocatedBase {\n getLinearElementId(): Id64String | undefined;\n}\n\n/** Interface to optionally be implemented by Elements inherently Linearly-Located whose linear-locations are always a single at-position.\n * It also provides convenient APIs for callers to reach Linear-Referencing data stored on aspects. Classes implementing this interface should\n * make use of the services provided by [LinearlyLocated]($linear-referencing-backend).\n * @beta\n */\nexport interface LinearlyLocatedSingleAt extends LinearlyLocatedBase {\n getAtLocation(): LinearlyReferencedAtLocation | undefined;\n updateAtLocation(linearLocation: LinearlyReferencedAtLocationProps, aspectId?: Id64String): void;\n}\n\n/** Interface to optionally be implemented by Elements inherently Linearly-Located whose linear-locations are always at-positions.\n * It also provides convenient APIs for callers to reach Linear-Referencing data stored on aspects. Classes implementing this interface should\n * make use of the services provided by [LinearlyLocated]($linear-referencing-backend).\n * @beta\n */\nexport interface LinearlyLocatedMultipleAt extends LinearlyLocatedBase {\n getAtLocations(): LinearlyReferencedAtLocation[];\n updateAtLocation(linearLocation: LinearlyReferencedAtLocationProps, aspectId: Id64String): void;\n}\n\n/** Interface to optionally be implemented by Elements inherently Linearly-Located whose linear-locations are always a single from-to-position.\n * It also provides convenient APIs for callers to reach Linear-Referencing data stored on aspects. Classes implementing this interface should\n * make use of the services provided by [LinearlyLocated]($linear-referencing-backend).\n * @beta\n */\nexport interface LinearlyLocatedSingleFromTo extends LinearlyLocatedBase {\n getFromToLocation(): LinearlyReferencedFromToLocation | undefined;\n updateFromToLocation(linearLocation: LinearlyReferencedFromToLocationProps, aspectId?: Id64String): void;\n}\n\n/** Interface to optionally be implemented by Elements inherently Linearly-Located whose linear-locations are always from-to-positions.\n * It also provides convenient APIs for callers to reach Linear-Referencing data stored on aspects. Classes implementing this interface should\n * make use of the services provided by [LinearlyLocated]($linear-referencing-backend).\n * @beta\n */\nexport interface LinearlyLocatedMultipleFromTo extends LinearlyLocatedBase {\n getFromToLocations(): LinearlyReferencedFromToLocation[];\n updateFromToLocation(linearLocation: LinearlyReferencedFromToLocationProps, aspectId: Id64String): void;\n}\n\n/** A class offering services for linearly-located data along a Linear-Element.\n * @beta\n */\nexport class LinearElement {\n /** Query for LinearLocationReferences based on specified query parameters.\n * @returns Returns an array of LinearLocationReferences.\n * @throws [[IModelError]]\n */\n public static queryLinearLocations(iModel: IModelDb, linearElementId: Id64String, queryParams: QueryParams): LinearLocationReference[] {\n const ecSqlGen = new QueryLinearLocationsECSQLGen(queryParams);\n const ecsqlAndBindVals = ecSqlGen.generate(linearElementId);\n\n const linearLocationRefs: LinearLocationReference[] = [];\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n iModel.withPreparedStatement(ecsqlAndBindVals[0], (stmt: ECSqlStatement) => {\n stmt.bindValues(ecsqlAndBindVals[1]);\n\n while (DbResult.BE_SQLITE_ROW === stmt.step()) {\n const linearLocationRef: LinearLocationReference = {\n linearlyLocatedId: stmt.getValue(0).getId(),\n linearlyLocatedClassFullName: stmt.getValue(1).getString(),\n startDistanceAlong: stmt.getValue(2).getDouble(),\n stopDistanceAlong: stmt.getValue(3).getDouble(),\n locationAspectId: stmt.getValue(4).getId(),\n };\n\n linearLocationRefs.push(linearLocationRef);\n }\n });\n\n return linearLocationRefs;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"LinearReferencingElements.js","sourceRoot":"","sources":["../../src/LinearReferencingElements.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAc,MAAM,qBAAqB,CAAC;AACnE,OAAO,EAAkB,OAAO,EAA2B,eAAe,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAChI,OAAO,EAAE,YAAY,EAAE,MAAM,8CAA8C,CAAC;AAC5E,OAAO,EAAE,IAAI,EAAyC,WAAW,EAAwB,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpI,OAAO,EACL,gBAAgB,EAEhB,8BAA8B,GAC/B,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,4BAA4B,EAAE,gCAAgC,EAAE,MAAM,mCAAmC,CAAC;AACnH,OAAO,EACL,6BAA6B,EAAE,mCAAmC,EAAqC,0BAA0B,GAClI,MAAM,kCAAkC,CAAC;AAE1C;;GAEG;AACH,MAAM,OAAgB,0BAA2B,SAAQ,sBAAsB;IAC7E,gBAAgB;IACT,MAAM,KAAc,SAAS,KAAa,OAAO,4BAA4B,CAAC,CAAC,CAAC;IAEhF,iBAAiB,CAAqC;IAE7D,YAAmB,KAAsC,EAAE,MAAgB;QACzE,KAAK,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QACrB,IAAI,CAAC,iBAAiB,GAAG,cAAc,CAAC,QAAQ,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC;IAC5E,CAAC;IAEM,kBAAkB;QACvB,OAAO,eAAe,CAAC,kBAAkB,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC;IAClE,CAAC;CACF;AAED;;GAEG;AACH,MAAM,OAAgB,qBAAsB,SAAQ,sBAAsB;IACxE,gBAAgB;IACT,MAAM,KAAc,SAAS,KAAa,OAAO,uBAAuB,CAAC,CAAC,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,CAAC,CAAC,CAAC,SAAS,EAAE;oBAC1D,kBAAkB,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,SAAS,EAAE;oBAChD,iBAAiB,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,SAAS,EAAE;oBAC/C,gBAAgB,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE;iBAC3C,CAAC;gBAEF,kBAAkB,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;YAC7C,CAAC;QACH,CAAC,CAAC,CAAC;QAEH,OAAO,kBAAkB,CAAC;IAC5B,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/** @packageDocumentation\n * @module LinearReferencing\n */\n\nimport { assert, DbResult, Id64String } from \"@itwin/core-bentley\";\nimport { ECSqlStatement, EditTxn, ElementAspect, IModelDb, PhysicalElement, SpatialLocationElement } from \"@itwin/core-backend\";\nimport { _implicitTxn } from \"@itwin/core-backend/lib/cjs/internal/Symbols\";\nimport { Code, ElementProps, GeometricElement3dProps, IModelError, PhysicalElementProps, RelatedElement } from \"@itwin/core-common\";\nimport {\n ComparisonOption, LinearLocationReference, LinearlyLocatedAttributionProps, LinearlyReferencedAtLocationAspectProps,\n LinearlyReferencedAtLocationProps, LinearlyReferencedFromToLocationAspectProps, LinearlyReferencedFromToLocationProps,\n LinearlyReferencedLocationType, QueryParams, ReferentElementProps,\n} from \"@itwin/linear-referencing-common\";\nimport { LinearlyReferencedAtLocation, LinearlyReferencedFromToLocation } from \"./LinearReferencingElementAspects\";\nimport {\n ILinearLocationLocatesElement, ILinearlyLocatedAlongILinearElement, ILinearlyLocatedAttributesElement, IReferentReferencesElement,\n} from \"./LinearReferencingRelationships\";\n\n/** Base class for Spatial Location Element subclasses representing properties whose value is located along a Linear-Element and only applies to a portion of an Element.\n * @beta\n */\nexport abstract class LinearlyLocatedAttribution extends SpatialLocationElement {\n /** @internal */\n public static override get className(): string { return \"LinearlyLocatedAttribution\"; }\n\n public attributedElement?: ILinearlyLocatedAttributesElement;\n\n public constructor(props: LinearlyLocatedAttributionProps, iModel: IModelDb) {\n super(props, iModel);\n this.attributedElement = RelatedElement.fromJSON(props.attributedElement);\n }\n\n public getLinearElementId(): Id64String | undefined {\n return LinearlyLocated.getLinearElementId(this.iModel, this.id);\n }\n}\n\n/** Base class for Spatial Location Element implementations that are linearly located along a Linear-Element.\n * @beta\n */\nexport abstract class LinearLocationElement extends SpatialLocationElement implements LinearlyLocatedBase {\n /** @internal */\n public static override get className(): string { return \"LinearLocationElement\"; }\n\n public constructor(props: GeometricElement3dProps, iModel: IModelDb) {\n super(props, iModel);\n }\n\n public getLinearElementId(): Id64String | undefined {\n return LinearlyLocated.getLinearElementId(this.iModel, this.id);\n }\n}\n\n/** Linear Referencing Location attached to an Element not inherently Linearly Referenced.\n * @beta\n */\nexport class LinearLocation extends LinearLocationElement implements LinearlyLocatedBase {\n /** @internal */\n public static override get className(): string { return \"LinearLocation\"; }\n public constructor(props: GeometricElement3dProps, iModel: IModelDb) {\n super(props, iModel);\n }\n\n private static toProps(modelId: Id64String, categoryId: Id64String): GeometricElement3dProps {\n const props: GeometricElement3dProps = {\n classFullName: LinearLocation.classFullName,\n category: categoryId,\n model: modelId,\n code: Code.createEmpty(),\n };\n\n return props;\n }\n\n public static create(iModel: IModelDb, modelId: Id64String, categoryId: Id64String): LinearLocation {\n return new LinearLocation(this.toProps(modelId, categoryId), iModel);\n }\n\n /** Insert a new `LinearLocation` using an explicit transaction.\n * @beta\n */\n public static insertFromTo(txn: EditTxn, modelId: Id64String, categoryId: Id64String, linearElementId: Id64String,\n fromToPosition: LinearlyReferencedFromToLocationProps, locatedElementId: Id64String): Id64String;\n /** Insert a new `LinearLocation`.\n * @deprecated Use LinearLocation.insertFromTo(txn, ...) instead, within an explicit EditTxn scope (or via withEditTxn). See EditTxn documentation for migration help.\n */\n public static insertFromTo(iModel: IModelDb, modelId: Id64String, categoryId: Id64String, linearElementId: Id64String,\n fromToPosition: LinearlyReferencedFromToLocationProps, locatedElementId: Id64String): Id64String;\n public static insertFromTo(txnOrIModel: EditTxn | IModelDb, modelId: Id64String, categoryId: Id64String, linearElementId: Id64String,\n fromToPosition: LinearlyReferencedFromToLocationProps, locatedElementId: Id64String): Id64String {\n const txn = txnOrIModel instanceof EditTxn ? txnOrIModel : txnOrIModel[_implicitTxn];\n const newId = LinearlyLocated.insertFromTo(txn, this.toProps(modelId, categoryId), linearElementId, fromToPosition);\n ILinearLocationLocatesElement.insert(txn, newId, locatedElementId);\n return newId;\n }\n\n /** Insert this `LinearLocation` using an explicit transaction.\n * @beta\n */\n public insertFromTo(txn: EditTxn, linearElementId: Id64String, fromToPosition: LinearlyReferencedFromToLocationProps, locatedElementId: Id64String): Id64String;\n /** Insert this `LinearLocation`.\n * @deprecated Use LinearLocation.insertFromTo(txn, ...) instead, within an explicit EditTxn scope (or via withEditTxn). See EditTxn documentation for migration help.\n */\n public insertFromTo(iModel: IModelDb, linearElementId: Id64String, fromToPosition: LinearlyReferencedFromToLocationProps, locatedElementId: Id64String): Id64String;\n public insertFromTo(txnOrIModel: EditTxn | IModelDb, linearElementId: Id64String, fromToPosition: LinearlyReferencedFromToLocationProps, locatedElementId: Id64String): Id64String {\n const txn = txnOrIModel instanceof EditTxn ? txnOrIModel : txnOrIModel[_implicitTxn];\n const newId = LinearlyLocated.insertFromTo(txn, this.toJSON(), linearElementId, fromToPosition);\n ILinearLocationLocatesElement.insert(txn, newId, locatedElementId);\n return newId;\n }\n\n /** Insert a new `LinearLocation` using an explicit transaction.\n * @beta\n */\n public static insertAt(txn: EditTxn, modelId: Id64String, categoryId: Id64String, linearElementId: Id64String,\n atPosition: LinearlyReferencedAtLocationProps, locatedElementId: Id64String): Id64String;\n /** Insert a new `LinearLocation`.\n * @deprecated Use LinearLocation.insertAt(txn, ...) instead, within an explicit EditTxn scope (or via withEditTxn). See EditTxn documentation for migration help.\n */\n public static insertAt(iModel: IModelDb, modelId: Id64String, categoryId: Id64String, linearElementId: Id64String,\n atPosition: LinearlyReferencedAtLocationProps, locatedElementId: Id64String): Id64String;\n public static insertAt(txnOrIModel: EditTxn | IModelDb, modelId: Id64String, categoryId: Id64String, linearElementId: Id64String,\n atPosition: LinearlyReferencedAtLocationProps, locatedElementId: Id64String): Id64String {\n const txn = txnOrIModel instanceof EditTxn ? txnOrIModel : txnOrIModel[_implicitTxn];\n const newId = LinearlyLocated.insertAt(txn, this.toProps(modelId, categoryId), linearElementId, atPosition);\n ILinearLocationLocatesElement.insert(txn, newId, locatedElementId);\n return newId;\n }\n\n /** Insert this `LinearLocation` using an explicit transaction.\n * @beta\n */\n public insertAt(txn: EditTxn, linearElementId: Id64String, atPosition: LinearlyReferencedAtLocationProps, locatedElementId: Id64String): Id64String;\n /** Insert this `LinearLocation`.\n * @deprecated Use LinearLocation.insertAt(txn, ...) instead, within an explicit EditTxn scope (or via withEditTxn). See EditTxn documentation for migration help.\n */\n public insertAt(iModel: IModelDb, linearElementId: Id64String, atPosition: LinearlyReferencedAtLocationProps, locatedElementId: Id64String): Id64String;\n public insertAt(txnOrIModel: EditTxn | IModelDb, linearElementId: Id64String, atPosition: LinearlyReferencedAtLocationProps, locatedElementId: Id64String): Id64String {\n const txn = txnOrIModel instanceof EditTxn ? txnOrIModel : txnOrIModel[_implicitTxn];\n const newId = LinearlyLocated.insertAt(txn, this.toJSON(), linearElementId, atPosition);\n ILinearLocationLocatesElement.insert(txn, newId, locatedElementId);\n return newId;\n }\n}\n\n/** Base class for Physical Elements that are inherently linearly located along a Linear-Element.\n * @beta\n */\nexport abstract class LinearPhysicalElement extends PhysicalElement {\n /** @internal */\n public static override get className(): string { return \"LinearPhysicalElement\"; }\n\n public constructor(props: PhysicalElementProps, iModel: IModelDb) {\n super(props, iModel);\n }\n}\n\n/** Spatial Location Element that can play the role of a Referent (known location along a Linear-Element).\n * @beta\n */\nexport abstract class ReferentElement extends SpatialLocationElement implements LinearlyLocatedBase {\n /** @internal */\n public static override get className(): string { return \"ReferentElement\"; }\n\n public referencedElement?: IReferentReferencesElement;\n\n public constructor(props: ReferentElementProps, iModel: IModelDb) {\n super(props, iModel);\n this.referencedElement = RelatedElement.fromJSON(props.referencedElement);\n }\n\n public getLinearElementId(): Id64String | undefined {\n return LinearlyLocated.getLinearElementId(this.iModel, this.id);\n }\n}\n\n/** Referent-implementation turning any bis:SpatialElement not inherently Linearly-Referenced into a Referent for Linear-Referencing purposes.\n * @beta\n */\nexport class Referent extends ReferentElement {\n /** @internal */\n public static override get className(): string { return \"Referent\"; }\n public constructor(props: ReferentElementProps, iModel: IModelDb) {\n super(props, iModel);\n }\n\n private static toProps(modelId: Id64String, categoryId: Id64String, referencedElementId: Id64String): ReferentElementProps {\n const props: ReferentElementProps = {\n classFullName: LinearLocation.classFullName,\n category: categoryId,\n model: modelId,\n code: Code.createEmpty(),\n referencedElement: new IReferentReferencesElement(referencedElementId),\n };\n\n return props;\n }\n\n public static create(iModel: IModelDb, modelId: Id64String, categoryId: Id64String, referencedElementId: Id64String): Referent {\n return new Referent(this.toProps(modelId, categoryId, referencedElementId), iModel);\n }\n\n /** Insert a new `Referent` using an explicit transaction.\n * @beta\n */\n public static insertAt(txn: EditTxn, modelId: Id64String, categoryId: Id64String, linearElementId: Id64String,\n atPosition: LinearlyReferencedAtLocationProps, referencedElementId: Id64String): Id64String;\n /** Insert a new `Referent`.\n * @deprecated Use Referent.insertAt(txn, ...) instead, within an explicit EditTxn scope (or via withEditTxn). See EditTxn documentation for migration help.\n */\n public static insertAt(iModel: IModelDb, modelId: Id64String, categoryId: Id64String, linearElementId: Id64String,\n atPosition: LinearlyReferencedAtLocationProps, referencedElementId: Id64String): Id64String;\n public static insertAt(txnOrIModel: EditTxn | IModelDb, modelId: Id64String, categoryId: Id64String, linearElementId: Id64String,\n atPosition: LinearlyReferencedAtLocationProps, referencedElementId: Id64String): Id64String {\n const txn = txnOrIModel instanceof EditTxn ? txnOrIModel : txnOrIModel[_implicitTxn];\n return LinearlyLocated.insertAt(txn, this.toProps(modelId, categoryId, referencedElementId), linearElementId, atPosition);\n }\n\n /** Insert this `Referent` using an explicit transaction.\n * @beta\n */\n public insertAt(txn: EditTxn, linearElementId: Id64String, atPosition: LinearlyReferencedAtLocationProps): Id64String;\n /** Insert this `Referent`.\n * @deprecated Use Referent.insertAt(txn, ...) instead, within an explicit EditTxn scope (or via withEditTxn). See EditTxn documentation for migration help.\n */\n public insertAt(iModel: IModelDb, linearElementId: Id64String, atPosition: LinearlyReferencedAtLocationProps): Id64String;\n public insertAt(txnOrIModel: EditTxn | IModelDb, linearElementId: Id64String, atPosition: LinearlyReferencedAtLocationProps): Id64String {\n const txn = txnOrIModel instanceof EditTxn ? txnOrIModel : txnOrIModel[_implicitTxn];\n return LinearlyLocated.insertAt(txn, this.toJSON(), linearElementId, atPosition);\n }\n}\n\nabstract class ECSQLGenImpl {\n public abstract genSelect(): string;\n public selectDistinct(): boolean {\n return false;\n }\n public abstract genFromJoin(): string;\n public abstract genWhere(bindVals?: any[], from?: number, inclusiveFrom?: boolean, to?: number, inclusiveTo?: boolean): string;\n public abstract genOrderBy(): string;\n}\n\nclass AtAndFromToECSQLGenImpl extends ECSQLGenImpl {\n public genSelect(): string {\n return \"coalesce(AtLocation.AtPosition.DistanceAlongFromStart, FromToLocation.FromPosition.DistanceAlongFromStart) StartDistanceAlong, \" +\n \"coalesce(AtLocation.AtPosition.DistanceAlongFromStart, FromToLocation.ToPosition.DistanceAlongFromStart) StopDistanceAlong, \" +\n \"coalesce(AtLocation.ECInstanceId, FromToLocation.ECInstanceId) LocationAspectId \";\n }\n public override selectDistinct(): boolean {\n return true;\n }\n public genFromJoin(): string {\n return \"LEFT JOIN LinearReferencing.LinearlyReferencedAtLocation AtLocation ON LinearlyLocated.InstanceId = AtLocation.Element.Id \" +\n \"LEFT JOIN LinearReferencing.LinearlyReferencedFromToLocation FromToLocation ON LinearlyLocated.InstanceId = FromToLocation.Element.Id \";\n }\n public genWhere(bindVals: any[], from?: number, inclusiveFrom?: boolean, to?: number, inclusiveTo?: boolean): string {\n const fromCompOp: string = (inclusiveFrom === undefined || inclusiveFrom) ? \">=\" : \">\";\n const toCompOp: string = (inclusiveTo === undefined || inclusiveTo) ? \"<=\" : \"<\";\n\n let ecSql = \"\";\n if (from !== undefined && to !== undefined) {\n ecSql += \"(AtLocation.AtPosition.DistanceAlongFromStart \";\n ecSql += fromCompOp;\n ecSql += \" ? AND AtLocation.AtPosition.DistanceAlongFromStart \";\n ecSql += toCompOp;\n ecSql += \" ?) OR (FromToLocation.FromPosition.DistanceAlongFromStart \";\n ecSql += fromCompOp;\n ecSql += \" ? AND FromToLocation.FromPosition.DistanceAlongFromStart \";\n ecSql += toCompOp;\n ecSql += \" ?) \" + \"OR (FromToLocation.ToPosition.DistanceAlongFromStart \";\n ecSql += fromCompOp;\n ecSql += \" ? AND FromToLocation.ToPosition.DistanceAlongFromStart \";\n ecSql += toCompOp;\n ecSql += \" ?) OR (FromToLocation.FromPosition.DistanceAlongFromStart <= ? AND FromToLocation.ToPosition.DistanceAlongFromStart >= ?) \";\n\n bindVals.push(from);\n bindVals.push(to);\n bindVals.push(from);\n bindVals.push(to);\n bindVals.push(from);\n bindVals.push(to);\n bindVals.push(from);\n bindVals.push(to);\n } else if (from !== undefined) {\n ecSql += \"AtLocation.AtPosition.DistanceAlongFromStart \";\n ecSql += fromCompOp;\n ecSql += \" ? OR FromToLocation.FromPosition.DistanceAlongFromStart \";\n ecSql += fromCompOp;\n ecSql += \" ? OR FromToLocation.ToPosition.DistanceAlongFromStart \";\n ecSql += fromCompOp;\n ecSql += \" ? \";\n\n bindVals.push(from);\n bindVals.push(from);\n bindVals.push(from);\n } else if (to !== undefined) {\n ecSql += \"AtLocation.AtPosition.DistanceAlongFromStart \";\n ecSql += toCompOp;\n ecSql += \" ? OR FromToLocation.FromPosition.DistanceAlongFromStart \";\n ecSql += toCompOp;\n ecSql += \" ? OR FromToLocation.ToPosition.DistanceAlongFromStart \";\n ecSql += toCompOp;\n ecSql += \" ? \";\n\n bindVals.push(to);\n bindVals.push(to);\n bindVals.push(to);\n } else {\n ecSql += \"(AtLocation.AtPosition.DistanceAlongFromStart IS NOT NULL) OR \";\n ecSql += \"(FromToLocation.FromPosition.DistanceAlongFromStart IS NOT NULL) \";\n }\n\n return ecSql;\n }\n public genOrderBy(): string {\n return \"coalesce(AtLocation.AtPosition.DistanceAlongFromStart, FromToLocation.FromPosition.DistanceAlongFromStart)\";\n }\n}\n\nclass FromToECSQLGenImpl extends ECSQLGenImpl {\n public genSelect(): string {\n return \"FromToLocation.FromPosition.DistanceAlongFromStart StartDistanceAlong, FromToLocation.ToPosition.DistanceAlongFromStart StopDistanceAlong, FromToLocation.ECInstanceId LocationAspectId \";\n }\n public genFromJoin(): string {\n return \"INNER JOIN LinearReferencing.LinearlyReferencedFromToLocation FromToLocation ON LinearlyLocated.InstanceId = FromToLocation.Element.Id \";\n }\n public genWhere(bindVals: any[], from?: number, inclusiveFrom?: boolean, to?: number, inclusiveTo?: boolean): string {\n const fromCompOp: string = (inclusiveFrom === undefined || inclusiveFrom) ? \">=\" : \">\";\n const toCompOp: string = (inclusiveTo === undefined || inclusiveTo) ? \"<=\" : \"<\";\n\n let ecSql = \"\";\n if (from !== undefined && to !== undefined) {\n ecSql += \"AND ((FromToLocation.FromPosition.DistanceAlongFromStart \";\n ecSql += fromCompOp;\n ecSql += \" ? AND FromToLocation.FromPosition.DistanceAlongFromStart \";\n ecSql += toCompOp;\n ecSql += \" ?) OR (FromToLocation.ToPosition.DistanceAlongFromStart \";\n ecSql += fromCompOp;\n ecSql += \" ? AND FromToLocation.ToPosition.DistanceAlongFromStart \";\n ecSql += toCompOp;\n ecSql += \" ?) OR (FromToLocation.FromPosition.DistanceAlongFromStart <= ? AND FromToLocation.ToPosition.DistanceAlongFromStart >= ?)) \";\n\n bindVals.push(from);\n bindVals.push(to);\n bindVals.push(from);\n bindVals.push(to);\n bindVals.push(from);\n bindVals.push(to);\n } else if (from !== undefined) {\n ecSql += \"AND (FromToLocation.FromPosition.DistanceAlongFromStart \";\n ecSql += fromCompOp;\n ecSql += \" ? OR FromToLocation.ToPosition.DistanceAlongFromStart \";\n ecSql += fromCompOp;\n ecSql += \" ?)\";\n\n bindVals.push(from);\n bindVals.push(from);\n } else if (to !== undefined) {\n ecSql += \"AND (FromToLocation.FromPosition.DistanceAlongFromStart \";\n ecSql += toCompOp;\n ecSql += \" ? OR FromToLocation.ToPosition.DistanceAlongFromStart \";\n ecSql += toCompOp;\n ecSql += \" ?) \";\n\n bindVals.push(to);\n bindVals.push(to);\n } else {\n ecSql += \"FromToLocation.FromPosition.DistanceAlongFromStart IS NOT NULL \";\n }\n\n return ecSql;\n }\n public genOrderBy(): string {\n return \"FromToLocation.FromPosition.DistanceAlongFromStart\";\n }\n}\n\nclass AtECSQLGenImpl extends ECSQLGenImpl {\n public genSelect(): string {\n return \"AtLocation.AtPosition.DistanceAlongFromStart StartDistanceAlong, AtLocation.AtPosition.DistanceAlongFromStart StopDistanceAlong, AtLocation.ECInstanceId LocationAspectId \";\n }\n public genFromJoin(): string {\n return \"INNER JOIN LinearReferencing.LinearlyReferencedAtLocation AtLocation ON LinearlyLocated.InstanceId = AtLocation.Element.Id \";\n }\n public genWhere(bindVals: any[], from?: number, inclusiveFrom?: boolean, to?: number, inclusiveTo?: boolean): string {\n const fromCompOp: string = (inclusiveFrom === undefined || inclusiveFrom) ? \">=\" : \">\";\n const toCompOp: string = (inclusiveTo === undefined || inclusiveTo) ? \"<=\" : \"<\";\n\n let ecSql = \"\";\n if (from !== undefined && to !== undefined) {\n ecSql += \"AtLocation.AtPosition.DistanceAlongFromStart \";\n ecSql += fromCompOp;\n ecSql += \" ? AND AtLocation.AtPosition.DistanceAlongFromStart \";\n ecSql += toCompOp;\n ecSql += \" ? \";\n\n bindVals.push(from);\n bindVals.push(to);\n } else if (from !== undefined) {\n ecSql += \"AtLocation.AtPosition.DistanceAlongFromStart \";\n ecSql += fromCompOp;\n ecSql += \" ? \";\n\n bindVals.push(from);\n } else if (to !== undefined) {\n ecSql += \"AtLocation.AtPosition.DistanceAlongFromStart \";\n ecSql += toCompOp;\n ecSql += \" ? \";\n\n bindVals.push(to);\n } else\n ecSql += \"AtLocation.AtPosition.DistanceAlongFromStart IS NOT NULL \";\n\n return ecSql;\n }\n public genOrderBy(): string {\n return \"AtLocation.AtPosition.DistanceAlongFromStart\";\n }\n}\n\nclass QueryLinearLocationsECSQLGen {\n private readonly _params: QueryParams;\n private _ecSql: string;\n\n private _addSelectClause(impl: ECSQLGenImpl): void {\n let select = \"SELECT \";\n\n if (impl.selectDistinct())\n select += \"DISTINCT \";\n\n select += \"LinearlyLocated.InstanceId LinearlyLocatedId, printf('%s:%s', meta.ECSchemaDef.Name, meta.ECClassDef.Name) LinearlyLocatedClassFullName, \";\n select += impl.genSelect();\n\n this._ecSql += select;\n }\n\n private _parseClassFullName(classFullName: string): [string, string] | undefined {\n const parts = classFullName.split(\":\");\n if (parts.length !== 2)\n return undefined;\n\n return [parts[0], parts[1]];\n }\n\n private _genLinearlyLocated(): string {\n return \"meta.ECSchemaDef JOIN meta.ECClassDef USING meta.SchemaOwnsClasses JOIN \" +\n \"(SELECT coalesce(Located.TargetECInstanceId, Along.SourceECInstanceId) InstanceId, \" +\n \"coalesce(Located.TargetECClassId, Along.SourceECClassId) ClassId \" +\n \"FROM LinearReferencing.ILinearlyLocatedAlongILinearElement Along LEFT JOIN \" +\n \"LinearReferencing.ILinearLocationLocatesElement Located ON Along.SourceECInstanceId = Located.SourceECInstanceId \" +\n \"WHERE Along.TargetECInstanceId = ?) LinearlyLocated ON meta.ECClassDef.ECInstanceId = LinearlyLocated.ClassId \";\n }\n\n private _addFromClause(impl: ECSQLGenImpl/* bvector<double>& bindVals */): void {\n let from = \"FROM \";\n from += this._genLinearlyLocated();\n from += impl.genFromJoin();\n\n this._ecSql += from;\n }\n\n private _addWhereClause(impl: ECSQLGenImpl, bindVals: any[]) {\n let where = \"WHERE \";\n\n where += impl.genWhere(\n bindVals,\n this._params.fromDistanceAlong,\n (this._params.fromComparisonOption === undefined ||\n this._params.fromComparisonOption === ComparisonOption.Inclusive),\n this._params.toDistanceAlong,\n (this._params.toComparisonOption === undefined ||\n this._params.toComparisonOption === ComparisonOption.Inclusive));\n\n if (this._params.linearlyLocatedClassFullNames !== undefined) {\n if (where.length > 6)\n where += \"AND \";\n\n if (1 === this._params.linearlyLocatedClassFullNames.length) {\n const classFullName = this._params.linearlyLocatedClassFullNames[0];\n const schemaNameClassName = this._parseClassFullName(classFullName);\n if (schemaNameClassName === undefined)\n throw new IModelError(0, \"Invalid full class name\");\n\n where += `meta.ECSchemaDef.Name='${schemaNameClassName[0]}' AND meta.ECClassDef.Name='${schemaNameClassName[1]}' `;\n } else if (1 < this._params.linearlyLocatedClassFullNames.length) {\n where += \"(\";\n for (const classFullName of this._params.linearlyLocatedClassFullNames) {\n if (classFullName === undefined)\n continue;\n\n const schemaNameClassName = this._parseClassFullName(classFullName);\n if (schemaNameClassName === undefined)\n continue;\n\n where += `(meta.ECSchemaDef.Name='${schemaNameClassName[0]}' AND meta.ECClassDef.Name='${schemaNameClassName[1]}') OR `;\n }\n\n where = where.substring(0, where.length - 4); // Removing last OR\n where += \") \";\n }\n }\n\n this._ecSql += where;\n }\n\n private _addOrderByClause(impl: ECSQLGenImpl): void {\n let orderBy = \"ORDER BY \";\n orderBy += impl.genOrderBy();\n\n this._ecSql += orderBy;\n }\n\n private _createImpl(): ECSQLGenImpl {\n if (this._params.linearlyReferencedLocationTypeFilter === undefined ||\n this._params.linearlyReferencedLocationTypeFilter === LinearlyReferencedLocationType.Any) {\n return new AtAndFromToECSQLGenImpl();\n } else if (this._params.linearlyReferencedLocationTypeFilter === LinearlyReferencedLocationType.FromTo) {\n return new FromToECSQLGenImpl();\n } else {\n return new AtECSQLGenImpl();\n }\n }\n\n public constructor(params: QueryParams) {\n this._params = params;\n this._ecSql = \"\";\n }\n\n public generate(linearElementId: Id64String): [string, any[]] {\n this._ecSql = \"\";\n const impl = this._createImpl();\n\n const bindVals: any[] = [linearElementId];\n this._addSelectClause(impl);\n this._addFromClause(impl);\n this._addWhereClause(impl, bindVals);\n this._addOrderByClause(impl);\n\n return [this._ecSql, bindVals];\n }\n}\n\n/** A class offering services for LinearlyLocated elements.\n * @beta\n */\nexport class LinearlyLocated {\n private static insertBasic(txn: EditTxn, elProps: ElementProps, linearElementId: Id64String): Id64String {\n const newId = txn.insertElement(elProps);\n\n const linearlyLocatedAlongLinearElement =\n ILinearlyLocatedAlongILinearElement.create(txn.iModel, newId, linearElementId);\n linearlyLocatedAlongLinearElement.insert(txn);\n\n return newId;\n }\n\n /** Insert a new LinearlyLocated element into an iModel at a specific location along an existing Linear-Element.\n * @param txn The EditTxn used to perform inserts.\n * @param elProps The properties of the new element.\n * @param linearElementId The Id of the Linear-Element along which the new LinearlyLocated will be inserted.\n * @param atPosition Linear position.\n * @returns The newly inserted element's Id.\n * @throws [[IModelError]] if unable to insert the element.\n */\n public static insertAt(txn: EditTxn, elProps: ElementProps, linearElementId: Id64String,\n atPosition: LinearlyReferencedAtLocationProps): Id64String;\n /** Insert a new LinearlyLocated element into an iModel at a specific location along an existing Linear-Element.\n * @param iModel The iModel to insert the new element into.\n * @param elProps The properties of the new element.\n * @param linearElementId The Id of the Linear-Element along which the new LinearlyLocated will be inserted.\n * @param atPosition Linear position.\n * @returns The newly inserted element's Id.\n * @throws [[IModelError]] if unable to insert the element.\n * @deprecated Use LinearlyLocated.insertAt(txn, ...) instead, within an explicit EditTxn scope (or via withEditTxn). See EditTxn documentation for migration help.\n */\n public static insertAt(iModel: IModelDb, elProps: ElementProps, linearElementId: Id64String,\n atPosition: LinearlyReferencedAtLocationProps): Id64String;\n public static insertAt(txnOrIModel: EditTxn | IModelDb, elProps: ElementProps, linearElementId: Id64String,\n atPosition: LinearlyReferencedAtLocationProps): Id64String {\n const txn = txnOrIModel instanceof EditTxn ? txnOrIModel : txnOrIModel[_implicitTxn];\n const newId: Id64String = this.insertBasic(txn, elProps, linearElementId);\n LinearlyReferencedAtLocation.insert(txn, newId, atPosition.atPosition,\n atPosition.fromReferent === undefined ? undefined : atPosition.fromReferent.id);\n return newId;\n }\n\n /** Insert a new LinearlyLocated element into an iModel at a specific from-to location along an existing Linear-Element.\n * @param txn The EditTxn used to perform inserts.\n * @param elProps The properties of the new element.\n * @param linearElementId The Id of the Linear-Element along which the new LinearlyLocated will be inserted.\n * @param fromToPosition Linear position.\n * @returns The newly inserted element's Id.\n * @throws [[IModelError]] if unable to insert the element.\n */\n public static insertFromTo(txn: EditTxn, elProps: ElementProps, linearElementId: Id64String,\n fromToPosition: LinearlyReferencedFromToLocationProps): Id64String;\n /** Insert a new LinearlyLocated element into an iModel at a specific from-to location along an existing Linear-Element.\n * @param iModel The iModel to insert the new element into.\n * @param elProps The properties of the new element.\n * @param linearElementId The Id of the Linear-Element along which the new LinearlyLocated will be inserted.\n * @param fromToPosition Linear position.\n * @returns The newly inserted element's Id.\n * @throws [[IModelError]] if unable to insert the element.\n * @deprecated Use LinearlyLocated.insertFromTo(txn, ...) instead, within an explicit EditTxn scope (or via withEditTxn). See EditTxn documentation for migration help.\n */\n public static insertFromTo(iModel: IModelDb, elProps: ElementProps, linearElementId: Id64String,\n fromToPosition: LinearlyReferencedFromToLocationProps): Id64String;\n public static insertFromTo(txnOrIModel: EditTxn | IModelDb, elProps: ElementProps, linearElementId: Id64String,\n fromToPosition: LinearlyReferencedFromToLocationProps): Id64String {\n const txn = txnOrIModel instanceof EditTxn ? txnOrIModel : txnOrIModel[_implicitTxn];\n const newId: Id64String = this.insertBasic(txn, elProps, linearElementId);\n LinearlyReferencedFromToLocation.insert(txn, newId,\n fromToPosition.fromPosition, fromToPosition.toPosition,\n fromToPosition.fromPositionFromReferent === undefined ? undefined : fromToPosition.fromPositionFromReferent.id,\n fromToPosition.toPositionFromReferent === undefined ? undefined : fromToPosition.toPositionFromReferent.id);\n return newId;\n }\n\n private static getLinearLocations<T>(iModel: IModelDb, linearlyLocatedElementId: Id64String, fullClassName: string): T[] {\n const aspects: ElementAspect[] =\n iModel.elements.getAspects(linearlyLocatedElementId, fullClassName);\n\n if (aspects.length === 0)\n return [];\n\n const retVal: T[] = [];\n for (const aspect of aspects) {\n const linearAspect = (aspect as unknown) as T;\n retVal.push(linearAspect);\n }\n\n return retVal;\n }\n\n private static queryFirstLinearLocationAspectId(iModel: IModelDb, linearlyLocatedElementId: Id64String, className: string): Id64String | undefined {\n let aspectId: Id64String | undefined;\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n iModel.withPreparedStatement(`SELECT ECInstanceId FROM LinearReferencing.${className} WHERE Element.Id=? LIMIT 1`, (stmt: ECSqlStatement) => {\n stmt.bindId(1, linearlyLocatedElementId);\n if (stmt.step() === DbResult.BE_SQLITE_ROW)\n aspectId = stmt.getValue(0).getId();\n });\n\n return aspectId;\n }\n\n /** Query for LinearlyReferenced AtLocation aspects owned by the specified LinearlyLocated Element.\n * @param iModel The iModel to query from.\n * @param linearlyLocatedElementId The id of the LinearlyLocated Element to query aspects about.\n * @returns Returns an array of LinearlyReferencedAtLocation.\n * @throws [[IModelError]]\n */\n public static getAtLocations(iModel: IModelDb, linearlyLocatedElementId: Id64String): LinearlyReferencedAtLocation[] {\n return this.getLinearLocations<LinearlyReferencedAtLocation>(\n iModel, linearlyLocatedElementId, \"LinearReferencing:LinearlyReferencedAtLocation\");\n }\n\n /** Query for the single LinearlyReferenced AtLocation aspect owned by the specified LinearlyLocated Element. If more than one aspect is expected, use [[getAtLocations]] instead.\n * @param iModel The iModel to query from.\n * @param linearlyLocatedElementId The id of the LinearlyLocated Element to query about.\n * @returns Returns an LinearlyReferencedAtLocation or undefined is none is found.\n * @throws [[IModelError]]\n */\n public static getAtLocation(iModel: IModelDb, linearlyLocatedElementId: Id64String): LinearlyReferencedAtLocation | undefined {\n const linearLocations = this.getAtLocations(iModel, linearlyLocatedElementId);\n if (linearLocations.length === 0)\n return undefined;\n else {\n assert(linearLocations.length === 1);\n return linearLocations[0];\n }\n }\n\n /** Update an existing LinearlyReferencedAtLocation aspect within the iModel.\n * @param iModel The iModel to update.\n * @param linearlyLocatedElementId The Id of the owning Linearly Located Element.\n * @param linearLocationProps The properties to use to update the LinearlyReferencedAtLocation aspect.\n * @param aspectId The Id of the aspect to update. If not known, the first aspectId will be looked-up.\n * @throws [[IModelError]]\n * @deprecated Use LinearlyLocated.updateAtLocation(txn, ...) instead, within an explicit EditTxn scope (or via withEditTxn). See EditTxn documentation for migration help.\n */\n public static updateAtLocation(iModel: IModelDb, linearlyLocatedElementId: Id64String, linearLocationProps: LinearlyReferencedAtLocationProps,\n aspectId?: Id64String): void;\n\n public static updateAtLocation(txn: EditTxn, linearlyLocatedElementId: Id64String, linearLocationProps: LinearlyReferencedAtLocationProps,\n aspectId?: Id64String): void;\n public static updateAtLocation(txnOrIModel: EditTxn | IModelDb, linearlyLocatedElementId: Id64String, linearLocationProps: LinearlyReferencedAtLocationProps,\n aspectId?: Id64String): void {\n const txn = txnOrIModel instanceof EditTxn ? txnOrIModel : txnOrIModel[_implicitTxn];\n const iModel = txn.iModel;\n let linearLocAspectId: Id64String;\n if (aspectId !== undefined)\n linearLocAspectId = aspectId;\n else {\n const queriedAspectId = this.queryFirstLinearLocationAspectId(iModel, linearlyLocatedElementId, \"LinearlyReferencedAtLocation\");\n if (queriedAspectId === undefined)\n throw new Error(\"LinearlyReferencedAtLocation aspect not found\");\n\n linearLocAspectId = queriedAspectId;\n }\n\n const linearLocationAspectProps: LinearlyReferencedAtLocationAspectProps = {\n id: linearLocAspectId,\n element: { id: linearlyLocatedElementId },\n classFullName: \"LinearReferencing:LinearlyReferencedAtLocation\",\n atPosition: linearLocationProps.atPosition,\n fromReferent: linearLocationProps.fromReferent,\n };\n\n txn.updateAspect(linearLocationAspectProps);\n }\n\n /** Update an existing LinearlyReferencedFromToLocation aspect within the iModel.\n * @param iModel The iModel to update.\n * @param linearlyLocatedElementId The Id of the owning Linearly Located Element.\n * @param linearLocationProps The properties to use to update the LinearlyReferencedFromToLocation aspect.\n * @param aspectId The Id of the aspect to update. If not known, the first aspectId will be looked-up.\n * @throws [[IModelError]]\n * @deprecated Use LinearlyLocated.updateFromToLocation(txn, ...) instead, within an explicit EditTxn scope (or via withEditTxn). See EditTxn documentation for migration help.\n */\n public static updateFromToLocation(iModel: IModelDb, linearlyLocatedElementId: Id64String, linearLocationProps: LinearlyReferencedFromToLocationProps,\n aspectId?: Id64String): void;\n\n public static updateFromToLocation(txn: EditTxn, linearlyLocatedElementId: Id64String, linearLocationProps: LinearlyReferencedFromToLocationProps,\n aspectId?: Id64String): void;\n public static updateFromToLocation(txnOrIModel: EditTxn | IModelDb, linearlyLocatedElementId: Id64String, linearLocationProps: LinearlyReferencedFromToLocationProps,\n aspectId?: Id64String): void {\n const txn = txnOrIModel instanceof EditTxn ? txnOrIModel : txnOrIModel[_implicitTxn];\n const iModel = txn.iModel;\n let linearLocAspectId: Id64String;\n if (aspectId !== undefined)\n linearLocAspectId = aspectId;\n else {\n const queriedAspectId = this.queryFirstLinearLocationAspectId(iModel, linearlyLocatedElementId, \"LinearlyReferencedFromToLocation\");\n if (queriedAspectId === undefined)\n throw new Error(\"LinearlyReferencedFromToLocation aspect not found\");\n\n linearLocAspectId = queriedAspectId;\n }\n\n const linearLocationAspectProps: LinearlyReferencedFromToLocationAspectProps = {\n id: linearLocAspectId,\n element: { id: linearlyLocatedElementId, relClassName: \"LinearReferencing:ILinearlyLocatedOwnsFromToLocations\" },\n classFullName: \"LinearReferencing:LinearlyReferencedFromToLocation\",\n fromPosition: linearLocationProps.fromPosition,\n fromPositionFromReferent: linearLocationProps.fromPositionFromReferent,\n toPosition: linearLocationProps.toPosition,\n toPositionFromReferent: linearLocationProps.toPositionFromReferent,\n };\n\n txn.updateAspect(linearLocationAspectProps);\n }\n\n /** Query for the Id of the Linear-Element along which the specified LinearlyLocated Element is located.\n * @param iModel The iModel to query from.\n * @param linearlyLocatedElementId The id of the LinearlyLocated Element to query a Linear-Element for.\n * @returns Returns the Id of the Linear-Element or undefined is none is assigned.\n */\n public static getLinearElementId(iModel: IModelDb, linearlyLocatedElementId: Id64String): Id64String | undefined {\n let linearElementId: Id64String | undefined;\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n iModel.withPreparedStatement(\"SELECT TargetECInstanceId FROM LinearReferencing.ILinearlyLocatedAlongILinearElement WHERE SourceECInstanceId = ?\", (stmt: ECSqlStatement) => {\n stmt.bindId(1, linearlyLocatedElementId);\n\n if (DbResult.BE_SQLITE_ROW === stmt.step())\n linearElementId = stmt.getValue(0).getId();\n else\n linearElementId = undefined;\n });\n\n return linearElementId;\n }\n\n /** Query for LinearlyReferenced FromToLocation aspects owned by the specified LinearlyLocated Element.\n * @param iModel The iModel to query from.\n * @param linearlyLocatedElementId The id of the LinearlyLocated Element to query aspects about.\n * @returns Returns an array of LinearlyReferencedFromToLocation.\n * @throws [[IModelError]]\n */\n public static getFromToLocations(iModel: IModelDb, linearlyLocatedElementId: Id64String): LinearlyReferencedFromToLocation[] {\n return this.getLinearLocations<LinearlyReferencedFromToLocation>(\n iModel, linearlyLocatedElementId, \"LinearReferencing:LinearlyReferencedFromToLocation\");\n }\n\n /** Query for the single LinearlyReferenced FromToLocation aspect owned by the specified LinearlyLocated Element. If more than one aspect is expected, use [[getFromToLocations]] instead.\n * @param iModel The iModel to query from.\n * @param linearlyLocatedElementId The id of the LinearlyLocated Element to query about.\n * @returns Returns an LinearlyReferencedFromToLocation or undefined is none is found.\n * @throws [[IModelError]]\n */\n public static getFromToLocation(iModel: IModelDb, linearlyLocatedElementId: Id64String): LinearlyReferencedFromToLocation | undefined {\n const linearLocations = this.getFromToLocations(iModel, linearlyLocatedElementId);\n if (linearLocations.length === 0)\n return undefined;\n else {\n assert(linearLocations.length === 1);\n return linearLocations[0];\n }\n }\n}\n\n/** Base interface to optionally be implemented by Elements inherently Linearly-Located. Implementors should choose the\n * appropriate sub-interface rather than implementing LinearlyLocatedBase directly.\n * @beta\n */\nexport interface LinearlyLocatedBase {\n getLinearElementId(): Id64String | undefined;\n}\n\n/** Interface to optionally be implemented by Elements inherently Linearly-Located whose linear-locations are always a single at-position.\n * It also provides convenient APIs for callers to reach Linear-Referencing data stored on aspects. Classes implementing this interface should\n * make use of the services provided by [LinearlyLocated]($linear-referencing-backend).\n * @beta\n */\nexport interface LinearlyLocatedSingleAt extends LinearlyLocatedBase {\n getAtLocation(): LinearlyReferencedAtLocation | undefined;\n updateAtLocation(linearLocation: LinearlyReferencedAtLocationProps, aspectId?: Id64String): void;\n}\n\n/** Interface to optionally be implemented by Elements inherently Linearly-Located whose linear-locations are always at-positions.\n * It also provides convenient APIs for callers to reach Linear-Referencing data stored on aspects. Classes implementing this interface should\n * make use of the services provided by [LinearlyLocated]($linear-referencing-backend).\n * @beta\n */\nexport interface LinearlyLocatedMultipleAt extends LinearlyLocatedBase {\n getAtLocations(): LinearlyReferencedAtLocation[];\n updateAtLocation(linearLocation: LinearlyReferencedAtLocationProps, aspectId: Id64String): void;\n}\n\n/** Interface to optionally be implemented by Elements inherently Linearly-Located whose linear-locations are always a single from-to-position.\n * It also provides convenient APIs for callers to reach Linear-Referencing data stored on aspects. Classes implementing this interface should\n * make use of the services provided by [LinearlyLocated]($linear-referencing-backend).\n * @beta\n */\nexport interface LinearlyLocatedSingleFromTo extends LinearlyLocatedBase {\n getFromToLocation(): LinearlyReferencedFromToLocation | undefined;\n updateFromToLocation(linearLocation: LinearlyReferencedFromToLocationProps, aspectId?: Id64String): void;\n}\n\n/** Interface to optionally be implemented by Elements inherently Linearly-Located whose linear-locations are always from-to-positions.\n * It also provides convenient APIs for callers to reach Linear-Referencing data stored on aspects. Classes implementing this interface should\n * make use of the services provided by [LinearlyLocated]($linear-referencing-backend).\n * @beta\n */\nexport interface LinearlyLocatedMultipleFromTo extends LinearlyLocatedBase {\n getFromToLocations(): LinearlyReferencedFromToLocation[];\n updateFromToLocation(linearLocation: LinearlyReferencedFromToLocationProps, aspectId: Id64String): void;\n}\n\n/** A class offering services for linearly-located data along a Linear-Element.\n * @beta\n */\nexport class LinearElement {\n /** Query for LinearLocationReferences based on specified query parameters.\n * @returns Returns an array of LinearLocationReferences.\n * @throws [[IModelError]]\n */\n public static queryLinearLocations(iModel: IModelDb, linearElementId: Id64String, queryParams: QueryParams): LinearLocationReference[] {\n const ecSqlGen = new QueryLinearLocationsECSQLGen(queryParams);\n const ecsqlAndBindVals = ecSqlGen.generate(linearElementId);\n\n const linearLocationRefs: LinearLocationReference[] = [];\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n iModel.withPreparedStatement(ecsqlAndBindVals[0], (stmt: ECSqlStatement) => {\n stmt.bindValues(ecsqlAndBindVals[1]);\n\n while (DbResult.BE_SQLITE_ROW === stmt.step()) {\n const linearLocationRef: LinearLocationReference = {\n linearlyLocatedId: stmt.getValue(0).getId(),\n linearlyLocatedClassFullName: stmt.getValue(1).getString(),\n startDistanceAlong: stmt.getValue(2).getDouble(),\n stopDistanceAlong: stmt.getValue(3).getDouble(),\n locationAspectId: stmt.getValue(4).getId(),\n };\n\n linearLocationRefs.push(linearLocationRef);\n }\n });\n\n return linearLocationRefs;\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@itwin/linear-referencing-backend",
|
|
3
|
-
"version": "5.9.0-dev.
|
|
3
|
+
"version": "5.9.0-dev.5",
|
|
4
4
|
"main": "lib/cjs/linear-referencing-backend.js",
|
|
5
5
|
"module": "lib/esm/linear-referencing-backend.js",
|
|
6
6
|
"typings": "lib/cjs/linear-referencing-backend",
|
|
@@ -23,10 +23,10 @@
|
|
|
23
23
|
"url": "http://www.bentley.com"
|
|
24
24
|
},
|
|
25
25
|
"peerDependencies": {
|
|
26
|
-
"@itwin/core-backend": "5.9.0-dev.
|
|
27
|
-
"@itwin/core-bentley": "5.9.0-dev.
|
|
28
|
-
"@itwin/core-common": "5.9.0-dev.
|
|
29
|
-
"@itwin/linear-referencing-common": "5.9.0-dev.
|
|
26
|
+
"@itwin/core-backend": "5.9.0-dev.5",
|
|
27
|
+
"@itwin/core-bentley": "5.9.0-dev.5",
|
|
28
|
+
"@itwin/core-common": "5.9.0-dev.5",
|
|
29
|
+
"@itwin/linear-referencing-common": "5.9.0-dev.5"
|
|
30
30
|
},
|
|
31
31
|
"//devDependencies": [
|
|
32
32
|
"NOTE: All peerDependencies should also be listed as devDependencies since peerDependencies are not considered by npm install",
|
|
@@ -44,11 +44,11 @@
|
|
|
44
44
|
"nyc": "^17.1.0",
|
|
45
45
|
"rimraf": "^6.0.1",
|
|
46
46
|
"typescript": "~5.6.2",
|
|
47
|
-
"@itwin/
|
|
48
|
-
"@itwin/
|
|
49
|
-
"@itwin/core-common": "5.9.0-dev.
|
|
50
|
-
"@itwin/core-
|
|
51
|
-
"@itwin/linear-referencing-common": "5.9.0-dev.
|
|
47
|
+
"@itwin/core-backend": "5.9.0-dev.5",
|
|
48
|
+
"@itwin/build-tools": "5.9.0-dev.5",
|
|
49
|
+
"@itwin/core-common": "5.9.0-dev.5",
|
|
50
|
+
"@itwin/core-bentley": "5.9.0-dev.5",
|
|
51
|
+
"@itwin/linear-referencing-common": "5.9.0-dev.5"
|
|
52
52
|
},
|
|
53
53
|
"nyc": {
|
|
54
54
|
"extends": "./node_modules/@itwin/build-tools/.nycrc"
|