Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
public async queryViewProps(imodel: IModelConnection, refresh?: boolean): Promise {
if (!this._viewDefCache || refresh) {
const params: ViewQueryParams = {};
params.from = ViewState.classFullName; // use "BisCore.ViewDefinition" as default class name
params.where = "";
const viewProps = await IModelReadRpcInterface.getClient().queryElementProps(imodel.iModelToken.toJSON(), params);
this._viewDefCache = viewProps as ViewDefinitionProps[];
}
return this._viewDefCache;
}
}
}
// if none are missing from the cache, resolve the promise immediately
if (undefined === missing) {
response.fromCache = request.geoCoords.length;
} else {
// keep track of how many came from the cache (mostly for tests).
response.fromCache = request.geoCoords.length - missing.length;
// Avoiding requesting too many points at once, exceeding max request length (this definition of "too many" should be safely conservative)
const maxPointsPerRequest = 200;
const promises: Array> = [];
for (let i = 0; i < missing.length; i += maxPointsPerRequest) {
const remainingRequest = { sourceDatum: this._sourceDatum, geoCoords: missing.slice(i, i + maxPointsPerRequest) };
const promise = IModelReadRpcInterface.getClient().getIModelCoordinatesFromGeoCoordinates(this._iModel.iModelToken.toJSON(), JSON.stringify(remainingRequest)).then((remainingResponse) => {
// put the responses into the cache, and fill in the output response for each
for (let iResponse: number = 0; iResponse < remainingResponse.iModelCoords.length; ++iResponse) {
const thisPoint: PointWithStatus = remainingResponse.iModelCoords[iResponse];
// put the answer in the cache.
const thisGeoCoord: XYZProps = remainingRequest!.geoCoords[iResponse];
const thisCacheKey: string = JSON.stringify(thisGeoCoord);
this._cache[thisCacheKey] = thisPoint;
// transfer the answer stored in remainingResponse to the correct position in the overall response.
const responseIndex = originalPositions[thisCacheKey];
if (Array.isArray(responseIndex)) {
for (const thisIndex of responseIndex) {
response.iModelCoords[thisIndex] = thisPoint;
}
} else {
public async load(viewDefinitionId: Id64String): Promise {
const viewProps = await IModelReadRpcInterface.getClient().getViewStateData(this._iModel.iModelToken.toJSON(), viewDefinitionId);
const className = viewProps.viewDefinitionProps.classFullName;
const ctor = await this._iModel.findClassFor(className, undefined) as typeof ViewState | undefined;
if (undefined === ctor)
return Promise.reject(new IModelError(IModelStatus.WrongClass, "Invalid ViewState class", Logger.logError, loggerCategory, () => viewProps));
const viewState = ctor.createFromProps(viewProps, this._iModel)!;
await viewState.load(); // loads models for ModelSelector
return viewState;
}
private async process(elementIds: Id64String[]) {
const request = {
elementIds,
options: this._options,
};
let messageDetails: NotifyMessageDetails;
try {
const str = await IModelReadRpcInterface.getClient().getGeometrySummary(this.iModel.iModelToken.toJSON(), request);
if (this._doCopy)
copyStringToClipboard(str);
const brief = "Summary " + (this._doCopy ? "copied to clipboard." : "complete.");
messageDetails = new NotifyMessageDetails(OutputMessagePriority.Info, brief, str);
if (this._modal) {
const div = document.createElement("div");
const appendText = (toAppend: string) => {
const txt = document.createElement("div");
txt.innerText = toAppend;
div.append(txt);
};
const lines = str.split("\n");
const maxLines = 30;
private async _getViewProps(imodel: IModelConnection, params: ViewQueryParams): Promise {
try {
const viewProps = await IModelReadRpcInterface.getClient().queryElementProps(imodel.iModelToken, params);
return viewProps as ViewDefinitionProps[];
} catch {
return [] as ViewDefinitionProps[];
}
}
public async queryEntityIds(params: EntityQueryParams): Promise {
return new Set(this.isOpen ? await IModelReadRpcInterface.getClient().queryEntityIds(this.iModelToken.toJSON(), params) : undefined);
}
public async loadFontMap(): Promise {
if (undefined === this.fontMap) {
this.fontMap = new FontMap();
if (this.isOpen) {
const fontProps = JSON.parse(await IModelReadRpcInterface.getClient().readFontJson(this.iModelToken.toJSON())) as FontMapProps;
this.fontMap.addFonts(fontProps.fonts);
}
}
return this.fontMap;
}
public async queryRows(ecsql: string, bindings?: any[] | object, limit?: QueryLimit, quota?: QueryQuota, priority?: QueryPriority): Promise {
return IModelReadRpcInterface.getClient().queryRows(this.iModelToken.toJSON(), ecsql, bindings, limit, quota, priority);
}
private _toolTipRpc = new OneAtATimeAction((id: string) => IModelReadRpcInterface.getClient().getToolTipMessage(this.iModelToken.toJSON(), id));
/** Request a tooltip from the backend.