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

Allow real GPS position to be used, even after fake GPS has been set #560

Merged
merged 2 commits into from
Aug 28, 2023

Conversation

nickw1
Copy link
Collaborator

@nickw1 nickw1 commented Aug 22, 2023

⚠️ All PRs have to be done versus 'dev' branch, so be aware of that, or we'll close your issue ⚠️

What kind of change does this PR introduce?

Allows real GPS position to be used even after fake GPS has been set (#500)
Can it be referenced to an Issue? If so what is the issue # ?

500

How can we test it?
Set up a fake GPS location in the HTML. Then use the application in a real GPS location. The real GPS location will be recognised.

Summary

Does this PR introduce a breaking change?

Please TEST your PR before proposing it. Specify here what device you have used for tests, version of OS and version of Browser

Tested by @Platform-Group, who contributed this fix (but did not prepare the PR). Verified as sensible code by @nickw1.

@kalwalt do you need to check this, or shall I just merge into dev? It's a very simple fix.

Other information

I think it would be more sensible longer-term to allow the fake GPS to be set multiple times, which this logic prevents (as did the code before this fix). However this might possibly break existing apps so needs more testing. This can be considered a 'quick fix'

@kalwalt
Copy link
Member

kalwalt commented Aug 22, 2023

@nickw1 i will ahve more time at the end of this month, i was very busy lately, hadn't the time to read and answer to any issue. If you think that it can be merged, go straight. 🙂

@nickw1
Copy link
Collaborator Author

nickw1 commented Aug 22, 2023

@kalwalt no worries, I haven't had so much time lately either!
I think, to be honest, the fix is so simple that it can be merged straight away, so thanks.

@kalwalt
Copy link
Member

kalwalt commented Aug 22, 2023

@kalwalt no worries, I haven't had so much time lately either! I think, to be honest, the fix is so simple that it can be merged straight away, so thanks.

Ok no problems then!

@nickw1 nickw1 merged commit 0259764 into master Aug 28, 2023
3 checks passed
@kalwalt kalwalt added enhancement New feature or request location based labels Aug 28, 2023
@Platform-Group
Copy link

Hey @nickw1 there's a minor issue with this PR, because of the flag you're now not able to update the simulateLatitude or simulateLongitude values during runtime. Fixed by moving the flag check from update's if statement to play's if statement. Working code:

update: function (oldData) {
    this.threeLoc.setGpsOptions({
      gpsMinAccuracy: this.data.positionMinAccuracy,
      gpsMinDistance: this.data.gpsMinDistance,
      maximumAge: this.data.gpsTimeInterval,
    });
    if (
      (this.data.simulateLatitude !== 0 || this.data.simulateLongitude !== 0) &&
      (this.data.simulateLatitude != oldData.simulateLatitude ||
        this.data.simulateLongitude != oldData.simulateLongitude)
    ) {
      this.threeLoc.stopGps();
      this.threeLoc.fakeGps(
        this.data.simulateLongitude,
        this.data.simulateLatitude
      );
      this.data.fakeGpsStarted = true
    }
    if (this.data.simulateAltitude > -Number.MAX_VALUE) {
      this.threeLoc.setElevation(this.data.simulateAltitude + 1.6);
    }
  },

  play: function () {
    if (!this.data.fakeGpsStarted && this.data.simulateLatitude === 0 && this.data.simulateLongitude === 0) {
      this.threeLoc.startGps();
    }
  },

I'm using a button to jump the camera to different sides of a building by adjusting simulated latitude and longitude which is how I found this problem. My use case is that the devices running my program are going to be tethered to plinths in various rooms and GPS doesn't work within the building, so I needed a way to change the cameras simulated location.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request location based
3 participants