Start a new topic

We are following this tutorial: Point Of Interest but we don't understand the following calculation:

"longitude": (lon + (Math.random() / 5 - 0.1)

Although, we notice that if we remove Math.Random() / 5- 0.1, the POI stays very close among them and the have a little "shaking". And when we are moving to other place, the POI keeps in the same position on the screen instead of remain in its geolocalized position.

PS: We are using xamarin iOS.

Regards!

Hello,

Math.random()

gives you a random number in the interval [0, 1).

Dividing that by 5 gives you a random number in the interval [0, 0.2).

Subtracting 0.1 gives you a random number in the interval [-0.1, 0.1).

The

lat
lon
alt

parameters contain the current position of the device.

Adding the random number in the interval [-0.1, 0.1) to the lon variable gives you a longitude that is within 0.1 degree (about 11km at the equator, 0m at the poles) of the current device position.

So, in summary, this code randomly generates a geo location that is somewhat close to the user.

- Daniel

Sorry for my delay answer.

I understand why you are using the random, but I don't understand my current behavior with and without the random.

The following picture is using this code:

“latitude”: parseFloat(poiData[currentPlaceNr].Latitude+ (Math.random() / 5 - 0.1)),

“longitude”: parseFloat(poiData[currentPlaceNr].Longitude+ (Math.random() / 5 - 0.1)), The following code is using this code:

“latitude”: parseFloat(poiData[currentPlaceNr].Latitude),

“longitude”: parseFloat(poiData[currentPlaceNr].Longitude), Why the difference?

If I use the second one, the drops sometimes is moving from its initial position.

Good morning Darío,

if you do not add any sort of offset to the geo location, but use the device location received in AR.context.onLocationChanged directly for creating your point of interest, you will encounter issues caused by the finite accuracy of the GPS.

The accuracy of the GPS is, loosely speaking, a couple of meters; let's assume ten. If you have created a POI at the exact location of the device, following location updates will be within a five meter radius around this initial position, causing significant "jumps"; it might even be placed straight behind you.

If the device is farther away from the POI position, the updates will still be just as inaccurate (five meter radius). While the absolute change in position will be the the same, the relative change with respect to the distance to the device will be much smaller and the POI will appear stable.

So being directly on top of a POI is something that is inherently unstable.

- Daniel

Hi Daniel,

Using injected location I can avoid lot of "jumps". Could be that compass also update the screen?

Other question, if I have a POI 25 meters far from me, and I walk towards it, is it possible to increase the POI size without refresh the view?

Hi Dario,

POIs automatically adjust there size to mimic a real world object. Do you want them to artificially increase there size the closer you come? If so, you can calculate the distance from the POI to the current position using the `distanceToUser` function of our JS API. Based on the distance you could update the drawables scale accordingly. If you put these calculations in a repeating loop using `setInterval`, you should be good to go.

Best regards,

Andreas

Hi Andreas,

It's exactly what I want.

Hi Andreas, could you please explain me how the setUseInjectedLocation method (and related) from WTArchitectView class works?

I am assuming than setting this parameter to 'true' disables default location provider changing it by the injected location, but it seems that this only applies once. If we put a timer to check isUsingInjectedLocation value, we get always false after the first time. So it seems that wikitude it is ignoring that we want to force the position by an injected one all the time.

- Is it possible to force injected location always?

- If not, which is the refresh rate on updating the default location provider? Can it be changed?

Thanks and regards

Good morning Darío,

I believe the following thread should shed some light on the issue: thread.

- Daniel 