Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pass pullMerge to getIModelProps which causes extents to be loaded from the database instead of the cached value #7187

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

nick4598
Copy link
Contributor

@nick4598 nick4598 commented Sep 23, 2024

@@ -305,6 +305,13 @@ export abstract class IModelDb extends IModel {
GeoCoordConfig.loadForImodel(this.workspace.settings); // load gcs data specified by iModel's settings dictionaries, must be done before calling initializeIModelDb

this.initializeIModelDb();
this.onChangesetApplied.addListener(() => {
const extents = this.queryFilePropertyString({ name: "Extents", namespace: "dgn_Db" });
// TODO: What if extents is undefined? And was previously defined? Is this a possibility?
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any thoughts on this? My guess is that it is unlikely for an imodel to go from having project extents to no project extents so it is not worth handling, but not sure.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dont think its possible to from defined extents to undefined, the other way around yes

@@ -305,6 +305,13 @@ export abstract class IModelDb extends IModel {
GeoCoordConfig.loadForImodel(this.workspace.settings); // load gcs data specified by iModel's settings dictionaries, must be done before calling initializeIModelDb

this.initializeIModelDb();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

initializeIModelDb() is called after pullMerge() after applying all change set. It internally calls following. If I understand correctly, you want to notify native side of any change to project extent or ecf location. If this is the case, you should not listen to apply change set event, rather just do that in initializeIModelDb(). You may want to add parameter to initializeIModelDb(when: "pullMerge" | undefined)

  protected initialize(name: string, props: IModelProps) {
    this.name = name;
    this.rootSubject = props.rootSubject;
    this.projectExtents = Range3d.fromJSON(props.projectExtents);
    this.globalOrigin = Point3d.fromJSON(props.globalOrigin);

    const ecefLocation = props.ecefLocation ? new EcefLocation(props.ecefLocation) : undefined;
    this.ecefLocation = ecefLocation?.isValid ? ecefLocation : undefined;

    this.geographicCoordinateSystem = props.geographicCoordinateSystem ? new GeographicCRS(props.geographicCoordinateSystem) : undefined;
  }

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Switched to passing pullMerge into intializeIModelDb

@nick4598 nick4598 changed the title updateProjectExtents on changesetapplied event and add test pass pullMerge to getIModelProps which causes extents to be loaded from the database instead of the cached value Sep 24, 2024
@@ -3116,7 +3116,7 @@ export abstract class IModelDb extends IModel {
// @alpha
importSchemaStrings(serializedXmlSchemas: string[]): Promise<void>;
// @internal (undocumented)
protected initializeIModelDb(): void;
protected initializeIModelDb(when?: "pullMerge"): void;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are we really just going to use a string literal?
what other possible option is there for this in the future?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also personally wanted to do a boolean "afterPullMerge" or something along those lines that defaults to false because it seems unlikely we'd need to special case anything else. But, affan mentioned that he was working on a Pr to support table conflict handlers which are called before applying changests, after applying changesets, and eventually after calling pullMerge. That was where his suggestion came from. Im not tied to either approach.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@toddsouthenbentley
Copy link
Contributor

@nick4598 Any updates on this?

@nick4598
Copy link
Contributor Author

nick4598 commented Oct 10, 2024

@nick4598 Any updates on this?

This PR is ready for another round of review (especially the native one)

@aruniverse
Copy link
Member

@khanaffan can you review?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants