Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (undefined === this._noGcsDefined && !this.isGeoLocated)
this._noGcsDefined = true;
if (this._noGcsDefined)
throw new IModelError(IModelStatus.NoGeoLocation, "iModel is not GeoLocated");
const geoConverter = this.geoServices.getConverter()!;
const coordResponse = await geoConverter.getGeoCoordinatesFromIModelCoordinates([spatial]);
if (this._noGcsDefined = (1 !== coordResponse.geoCoords.length || GeoCoordStatus.NoGCSDefined === coordResponse.geoCoords[0].s))
throw new IModelError(IModelStatus.NoGeoLocation, "iModel is not GeoLocated");
if (GeoCoordStatus.Success !== coordResponse.geoCoords[0].s)
throw new IModelError(IModelStatus.BadRequest, "Error converting spatial to cartographic");
const longLatHeight = Point3d.fromJSON(coordResponse.geoCoords[0].p); // x is longitude in degrees, y is latitude in degrees, z is height in meters...
return Cartographic.fromDegrees(longLatHeight.x, longLatHeight.y, longLatHeight.z, result);
}
iModel.withPreparedStatement("SELECT ECInstanceId,Category.Id,Origin,Yaw,Pitch,Roll,BBoxLow,BBoxHigh FROM bis.GeometricElement3d", (stmt: ECSqlStatement) => {
while (DbResult.BE_SQLITE_ROW === stmt.step()) {
const row = stmt.getRow();
if (undefined !== row.bBoxLow && undefined !== row.bBoxHigh && undefined !== row.origin) {
const box = Range3d.create(row.bBoxLow, row.bBoxHigh) as ElementAlignedBox3d;
const placement = new Placement3d(Point3d.fromJSON(row.origin), YawPitchRollAngles.createDegrees(row.yaw, row.pitch, row.roll), box);
const range = placement.calculateRange();
totalRange.extendRange(range);
}
}
});
if (totalRange.isNull)
public async insertBarrier(tokenProps: IModelTokenProps, modelId: Id64String, location: XYZProps, angle: AngleProps, length: number): Promise {
return RobotWorldEngine.insertBarrier(IModelDb.find(IModelToken.fromJSON(tokenProps)), modelId, Point3d.fromJSON(location), Angle.fromJSON(angle), length);
}
public getAnimationClip(time: number, interval: Interval): RenderClipVolume | undefined {
if (this.currentClip) {
this.currentClip.dispose();
this.currentClip = undefined;
}
if (!ElementTimeline.findTimelineInterval(interval, time, this.cuttingPlaneTimeline) || this.cuttingPlaneTimeline![interval.index0].value === null)
return undefined;
const timeline = this.cuttingPlaneTimeline!;
const value = timeline[interval.index0].value;
if (!value)
return undefined;
const position = Point3d.fromJSON(value.position);
const direction = Vector3d.fromJSON(value.direction);
if (interval.fraction > 0.0) {
const value1 = timeline[interval.index1].value;
position.interpolate(interval.fraction, Point3d.fromJSON(value1.position), position);
direction.interpolate(interval.fraction, Vector3d.fromJSON(value1.direction), direction);
} else {
if (value.hidden || value.visible)
return undefined;
}
direction.negate(direction);
direction.normalizeInPlace();
const plane = Plane3dByOriginAndUnitNormal.create(position, direction);
const clipPlane = ClipPlane.createPlane(plane!);
const clipPlaneSet = UnionOfConvexClipPlaneSets.createConvexSets([ConvexClipPlaneSet.createPlanes([clipPlane])]);
const clipPrimitive = ClipPrimitive.createCapture(clipPlaneSet);
public static fromJSON(json?: ParamsProps) {
const result = new Params();
if (!json)
return result;
result.origin = json.origin ? Point3d.fromJSON(json.origin) : undefined;
result.rotation = json.rotation ? YawPitchRollAngles.fromJSON(json.rotation) : undefined;
result.space1 = json.space1;
result.space2 = json.space2;
result.angle1 = json.angle1 ? Angle.fromJSON(json.angle1) : undefined;
result.angle2 = json.angle2 ? Angle.fromJSON(json.angle2) : undefined;
result.scale = json.scale;
result.color = json.color ? ColorDef.fromJSON(json.color) : undefined;
result.weight = json.weight;
result.invisibleBoundary = json.invisibleBoundary;
result.snappable = json.snappable;
result.symbolId = json.symbolId ? Id64.fromJSON(json.symbolId) : undefined;
if (!json.defLines)
return result;
const defLines: HatchDefLine[] = [];
json.defLines.forEach((defLine) => defLines.push(new HatchDefLine(defLine)));
result.defLines = defLines;
private readInstances(primitive: any): Point3d | InstancedGraphicParams | undefined {
const viJson = primitive.viewIndependentOrigin;
if (undefined !== viJson)
return Point3d.fromJSON(viJson);
const json = primitive.instances;
if (undefined === json)
return undefined;
const count = JsonUtils.asInt(json.count, 0);
if (count <= 0)
return undefined;
const centerComponents = JsonUtils.asArray(json.transformCenter);
if (undefined === centerComponents || 3 !== centerComponents.length)
return undefined;
const transformCenter = Point3d.create(centerComponents[0], centerComponents[1], centerComponents[2]);
const featureIds = this.findBuffer(JsonUtils.asString(json.featureIds));
public async moveRobot(tokenProps: IModelTokenProps, id: Id64String, location: XYZProps): Promise {
RobotWorldEngine.moveRobot(IModelDb.find(IModelToken.fromJSON(tokenProps)), id, Point3d.fromJSON(location));
}
else if (entry.fill.color)
this.entry.geomParams.fillColor = new ColorDef(entry.fill.color);
} else if (entry.pattern) {
const params = AreaPattern.Params.fromJSON(entry.pattern);
if (this.entry.localToWorld !== undefined)
params.applyTransform(this.entry.localToWorld);
this.entry.geomParams.pattern = params;
} else if (entry.material) {
if (entry.material.materialId)
this.entry.geomParams.materialId = Id64.fromJSON(entry.material.materialId);
} else if (entry.subRange) {
this.entry.localRange = Range3d.fromJSON(entry.subRange);
} else if (entry.geomPart) {
this.entry.partId = Id64.fromJSON(entry.geomPart.part);
if (entry.geomPart.origin !== undefined || entry.geomPart.rotation !== undefined || entry.geomPart.scale !== undefined) {
const origin = entry.geomPart.origin ? Point3d.fromJSON(entry.geomPart.origin) : Point3d.createZero();
const rotation = entry.geomPart.rotation ? YawPitchRollAngles.fromJSON(entry.geomPart.rotation).toMatrix3d() : Matrix3d.createIdentity();
this.entry.partToLocal = Transform.createRefs(origin, rotation);
if (entry.geomPart.scale)
this.entry.partToLocal.multiplyTransformTransform(Transform.createRefs(Point3d.createZero(), Matrix3d.createUniformScale(entry.geomPart.scale)), this.entry.partToLocal);
}
return { value: this.entry, done: false };
} else if (entry.textString) {
this.entry.textString = new TextString(entry.textString);
if (this.entry.localToWorld !== undefined)
this.entry.textString.transformInPlace(this.entry.localToWorld);
return { value: this.entry, done: false };
} else if (entry.brep) {
this.entry.brep = entry.brep;
if (this.entry.localToWorld !== undefined) {
const entityTrans = Transform.fromJSON(entry.brep.transform);
this.entry.brep.transform = entityTrans.multiplyTransformTransform(this.entry.localToWorld);
public static fromJSON(json?: Placement3dProps): Placement3d {
const props: any = json ? json : {};
return new Placement3d(Point3d.fromJSON(props.origin), YawPitchRollAngles.fromJSON(props.angles), ElementAlignedBox3d.fromJSON(props.bbox));
}