1 (edited by danielesuppo 2019-04-27 11:37:29)

Topic: Elevation is wrong

Hello,
I should put some Gameobjects at real positions, longitude, latitude and altitude (in meters).

To do this, I'm using your suggested code:

public static Vector3 GetWorldPositionWithAltitude(double longitude, double latitude, float elevation)
    {
        double tlx, tly, brx, bry;
        OnlineMaps.instance.GetCorners(out tlx, out tly, out brx, out bry);

        Vector3 p = OnlineMapsTileSetControl.instance.GetWorldPositionWithElevation(longitude, latitude, tlx, tly, brx, bry);
        float el = OnlineMapsElevationManagerBase.GetUnscaledElevation(longitude, latitude, tlx, tly, brx, bry);

        float yOff = elevation - el;
        yOff *= OnlineMapsElevationManagerBase.GetBestElevationYScale(tlx, tly, brx, bry);
        yOff *= OnlineMaps.instance.transform.localScale.x;
        p.y += yOff;

        return p;
    }

Unfortunately the Gameobjects seem to be placed at a wrong height: someone is more or less right (on the surface), but most of them are a lot under or over the surface.
I've tried with Mapbox, ArcGis and Bing elevation, but with all of them I get the same result.

I'd be glad for your help!
Thanks!

Re: Elevation is wrong

Hello.

GetUnscaledElevation requires a point in the scene relative to the top left corner of the map.
The right way:

float el = OnlineMapsElevationManagerBase.GetUnscaledElevation(p.x, p.z, tlx, tly, brx, bry);
Kind Regards,
Infinity Code Team.

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

Re: Elevation is wrong

I'm a bit confused.
Actually I think to use "GetUnscaledElevation" in the right way, because the code is:

...
OnlineMaps.instance.GetCorners(out tlx, out tly, out brx, out bry);
...
float el = OnlineMapsElevationManagerBase.GetUnscaledElevation(longitude, latitude, tlx, tly, brx, bry);
...

I've read your post here
http://forum.infinity-code.com/viewtopic.php?id=1056
and the above code should work.

I should place my Gameobjects on top of the terrain, just like 3dMarker, based on their Longitude / Latitude.
I gave a look to the 3dMarker function to do this, but I could'nt understand the right way...

Re: Elevation is wrong

This is not my code. This is Thibault code.
As I wrote in that post, I modified this method without an IDE, so I did not test it.
I missed that wrong parameters are used.
Sometimes it happens.

In your case, I tested it because you wrote that elevations is not working correctly, and found that the wrong parameters are used.
You only need to replace one line in this method to make it work.

Kind Regards,
Infinity Code Team.

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

Re: Elevation is wrong

Many thanks!
Simply using OnlineMapsTileSetControl.instance.GetWorldPositionWithElevation did the job