forked from imodeljs/simple-viewer-app
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fa2d178
commit 8401151
Showing
12 changed files
with
210 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
YES,AT_HRZF7AQ5_1FC | ||
YES,AT_HRZF7AQ5_1FJ | ||
NO,AT_HRZF7AQ5_4IO | ||
NO,AT_HRZF7AQ5_3RO | ||
YES,AT_HRZF7AQ5_3RQ | ||
NO,AT_HRZF7AQ5_40X | ||
NO,AT_HRZF7AQ5_4GO | ||
OPEN ENDED,AT_HRZF7AQ5_4GU | ||
NO,AT_HRZF7AQ5_4HX | ||
YES,AT_HRZF7AQ5_4I2 | ||
NO,AT_HRZF7AQ5_4I8 | ||
YES,AT_HRZF7AQ5_5F9 | ||
OPEN ENDED,AT_HRZF7AQ5_4II | ||
NO,AT_HRZF7AQ5_51E | ||
OPEN ENDED,AT_HRZF7AQ5_549 | ||
OPEN ENDED,AT_HRZF7AQ5_4HU | ||
YES,AT_HRZF7AQ5_4I5 | ||
NO,AT_HRZF7AQ5_4IM | ||
YES,AT_HRZF7AQ5_51B | ||
OPEN ENDED,AT_HRZF7AQ5_51E | ||
OPEN ENDED,AT_HRZF7AQ5_549 | ||
OPEN ENDED,AT_HRZF7AQ5_5F8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { RpcManager, IModelToken } from "@bentley/imodeljs-common"; | ||
import { FileReaderRpcInterface } from "../common/FileReaderRpcInterface"; | ||
import { IModelDb } from "@bentley/imodeljs-backend"; | ||
import * as fs from "fs"; | ||
import * as parse from "csv-parse/lib/sync"; | ||
|
||
export class FileReaderRpcImpl extends FileReaderRpcInterface { | ||
public static register() { RpcManager.registerImpl(FileReaderRpcInterface, FileReaderRpcImpl); } | ||
private _filePath = "assets/testdata.csv"; | ||
|
||
public async fetchInfo(_token: IModelToken): Promise<any[]> { | ||
const data: string = fs.readFileSync(this._filePath, "utf8"); | ||
let info = parse(data, {delimiter: ",", columns: ["status", "component_id"]}); | ||
info = await this.fetchPositions(info, _token); | ||
return info; | ||
} | ||
|
||
private async fetchPositions(info: any[], token: IModelToken) { | ||
let componentList = "("; | ||
const count = info.length; | ||
// prepare list of component ids | ||
info.forEach((value: any, index: number) => { | ||
componentList += "'" + value.component_id + "'"; | ||
componentList += (++index !== count) ? ", " : ")"; | ||
}); | ||
|
||
const query = `SELECT piping.Component_id, physical.Origin | ||
FROM AutoPlantPDWPersistenceStrategySchema.PipingComponent piping | ||
JOIN Bis.ElementOwnsChildElements link ON piping.ECInstanceId = link.SourceECInstanceId | ||
JOIN Bis.PhysicalElement physical ON link.TargetECInstanceId = physical.ECInstanceId | ||
WHERE piping.Component_id IN ${componentList}`; | ||
|
||
const imodel = IModelDb.find(token); | ||
const rows = []; | ||
for await (const row of imodel.query(query)) rows.push(row); | ||
|
||
rows.forEach((row) => { | ||
const index = info.findIndex((x) => x.component_id === row.cOMPONENT_ID); | ||
if (index > 0) info[index].position = row.origin; | ||
}); | ||
|
||
return info; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
| $Copyright: (c) 2017 Bentley Systems, Incorporated. All rights reserved. $ | ||
*--------------------------------------------------------------------------------------------*/ | ||
import { RpcInterface, RpcManager, IModelToken } from "@bentley/imodeljs-common"; | ||
|
||
export abstract class FileReaderRpcInterface extends RpcInterface { | ||
|
||
public static interfaceVersion = "1.0.0"; | ||
public static interfaceName = "FileReaderRpcInterface"; | ||
public static types = () => [IModelToken]; | ||
|
||
public static getClient(): FileReaderRpcInterface { return RpcManager.getClientForInterface(this); } | ||
public async fetchInfo (_token: IModelToken): Promise<any[]> { return this.forward.apply(this, arguments as any) as any; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { DecorateContext, Marker, Decorator } from "@bentley/imodeljs-frontend"; | ||
import { GasketMarker } from "./GasketMarker"; | ||
|
||
export class GasketDecorator implements Decorator { | ||
protected _markers: Marker[] = []; | ||
|
||
constructor(info: any[]) { | ||
info.forEach( (component) => { | ||
if (component.position && component.status) this.addMarker(component); | ||
}); | ||
} | ||
|
||
private addMarker(component: any) { | ||
const marker = new GasketMarker( | ||
{ x: component.position.x, y: component.position.y, z: component.position.z }, | ||
{ x: 50, y: 50 }, | ||
component.status, | ||
); | ||
this._markers.push(marker); | ||
} | ||
|
||
public decorate(context: DecorateContext): void { | ||
this._markers.forEach((marker) => { | ||
marker.addDecoration(context); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { Marker, imageElementFromUrl } from "@bentley/imodeljs-frontend"; | ||
import { XYAndZ, XAndY } from "@bentley/geometry-core"; | ||
|
||
const statusToUrl = new Map<string, string>([ | ||
["YES", "map_pin_green.svg"], | ||
["NO", "map_pin_red.svg"], | ||
["OPEN ENDED", "map_pin_yellow.svg"], | ||
]); | ||
|
||
export class GasketMarker extends Marker { | ||
constructor(worldLocation: XYAndZ, size: XAndY, status: string) { | ||
super(worldLocation, size); | ||
const imageUrl = statusToUrl.get(status); | ||
if (imageUrl) this.setImage(imageElementFromUrl(imageUrl)); | ||
} | ||
} |