Topic: Losing precision

Hey Devs,
So I'm having an issue with precision that you might be able to help with.

I'm trying to place 3d markers as in the examples...

double lng, lat;
OnlineMapsControlBase3D.instance.GetCoords(out lng, out lat);
// Create 3D marker
OnlineMapsMarker3D marker3D = OnlineMapsMarker3DManager.CreateItem(lng, lat, currentPlaceableObject);

I then save the lat/lng to my database, but when I load the 3dmarker using the same data, it's not in the same spot.

Attached is a screenshot of my initial placement, showing the model placed by the mouse, and the 3d marker placed by the lat/long recieveded from mouse clicking the map.

As you can see, there is a small, but significant difference between the 2.

I'm currently going to simply store the Cartesian coords of the model placed on mouse click, and use that to place the 3d marker ( I hope)

But maybe there is something simple I'm missing?

Here is how I create the 3d marker on load

// Create 3D marker
OnlineMapsMarker3D marker3D = OnlineMapsMarker3DManager.CreateItem(actor.actorLongitude, actor.actorLatitude, actor);

and just the sake of data precision, here is what I'm storing for the lat/lng

lat -17.0355420413186
lng -53.7589743348561

Post's attachments

Attachment icon Capture.PNG 1.18 mb, 54 downloads since 2020-08-27 

Re: Losing precision

Hello.

I see in your screenshot the distance between markers is 100+ meters, which is a lot and cannot happen simply due to the loss of precision between float and double.
I think you have a problem with saving / loading coordinates.
Please attach the code that saves the coordinates and the code that loads the coordinates.
I will check it.

Kind Regards,
Infinity Code Team.

Boost your productivity a lot and immediately using Ultimate Editor Enhancer. Trial and non-commerce versions available.

3 (edited by mcb 2020-08-27 20:31:23)

Re: Losing precision

This is how I create the 3d marker

if (Input.GetMouseButtonDown(0))
{
    double lng, lat;
    OnlineMapsControlBase3D.instance.GetCoords(out lng, out lat);
    // Create 3D marker
    OnlineMapsMarker3D marker3D = OnlineMapsMarker3DManager.CreateItem(lng, lat, currentPlaceableObject);
    // push the data out to be saved
    SetPosition(lat, lng);
}

Here is SetPosition, called when the user places the model, in a separate script.

public void SetPosition(double lat, double lng)
    {
        this.actorLatitude = lat;
        this.actorLongitude = lng;
}

I then serialize that data and push it to my DB. 

And this is how I load it:

private void LoadMission(SceneActor actor){
    // Create 3D marker
    OnlineMapsMarker3D marker3D = OnlineMapsMarker3DManager.CreateItem(actor.actorLongitude, actor.actorLatitude, actor);
    
}

Note, I was able to keep making progress and skirt this issue by just storing the Transform values and instantiating a game object instead of using the 3d marker.

Re: Losing precision

What type are actorLatitude and actorLongitude?
Do you have the same values when serializing and deserializing?
What values do you have in Map / Width and Height (pixels)?

Kind Regards,
Infinity Code Team.

Boost your productivity a lot and immediately using Ultimate Editor Enhancer. Trial and non-commerce versions available.

5 (edited by mcb 2020-08-28 15:17:49)

Re: Losing precision

they are doubles.

Database shows:
lat =  33.4089173493387
long = -105.44465691910773

Loaded:
lat = 33.4089173493387
long = -105.444656919108

pixels are 1024x1024

Is it possible this is hitting some kind of Unity limit? 

The lat has 13 decimals stored and the long has 14, but when loaded, I'm losing 2 whole decimals on the long due to rounding. I'm certainly not rounding the long.

Re: Losing precision

Loss of precision from double to float conversion, up to 1 meter.
In your screenshot in post 1, I see a distance of about 100 meters (visually) and this is definitely not a loss of precision.

Somewhere you have a bug, but where it is difficult to say.
The code you showed looks good and does not contain a bug that could cause this behavior.
Try to track the coordinates of the marker in all phases, when you interact with it (create under the cursor, save, load).
There is a bug somewhere, and it might be a typo.

If you can't find the problem, in theory we can schedule a call using AnyDesk next week. I will connect to you and check on your side why this is happening.

Kind Regards,
Infinity Code Team.

Boost your productivity a lot and immediately using Ultimate Editor Enhancer. Trial and non-commerce versions available.

Re: Losing precision

Thanks I will continue to trace through and see where it might be happening