mapbox-unity-sdk icon indicating copy to clipboard operation
mapbox-unity-sdk copied to clipboard

TileSize vs real world distance not matching

Open Markovicho opened this issue 2 years ago • 3 comments

useful informations / sdk version

  • Mapbox SDK version: latest commit on performance branch (using 2D only)

Settings in AbstractMap image

Scenario

  • Let's take a place in real world where we exactly know the size. In this case i took a hockeyfield which measures 90 meters in length. This can be confirmed by google maps measure tool (center to field border --> ~45m):

image

Test setup

  • Placing an object in mapbox at the center point of the field while visualizing a circle with 45m radius
  • Conversion to match unity-units vs. mapbox tilescale has been applied to the circle localscale
  • Calculating the the distance in meters between player position and center of the hockeyfield based on LON/LAT

Expectation

  • A:standing at the border of the field with player should result in ~90m distance to the circle center
  • B:standing at the border of the circle should result in ~45m distance to the circle center
  • C:the circle should match the field size exactly encapsulating the borders of the fields long side

Whats the result?

image image

  • A --> correct
  • B --> correct
  • C --> the underlying tiletexture is larget than the distance informations from A and B.

I don't really get the issue here. Is there something fundamentally wrong in my assumptions or is this an bug in the framework? @brnkhy @Entryist

by the way setting the Scaling-Option to WorldScale results in gaps between the tiles: image

best regards and thanks in advance for any help

Markovicho avatar May 12 '22 07:05 Markovicho

@Markovicho I should look into distance calculations properly some time but on top of my head, I think the difference here might be mercator meters vs real world meters. or in other words, impact of latitude on the distance calculations. a quick test for this might be trying it somewhere close to equator and then somewhere at extreme latitude.

Is that circle 90 units wide in unity space? maybe you can try to scale it by; Mathf.Cos(Mathf.Deg2Rad * (float)map.CenterLatitudeLongitude.x) If I'm not wrong, this was the latitude compensation formula 🤔

brnkhy avatar May 17 '22 10:05 brnkhy

@Markovicho can you contact me via email; [email protected] or twitter brnkhy?

brnkhy avatar May 26 '22 18:05 brnkhy

@Markovicho I should look into distance calculations properly some time but on top of my head, I think the difference here might be mercator meters vs real world meters. or in other words, impact of latitude on the distance calculations. a quick test for this might be trying it somewhere close to equator and then somewhere at extreme latitude.

Is that circle 90 units wide in unity space? maybe you can try to scale it by; Mathf.Cos(Mathf.Deg2Rad * (float)map.CenterLatitudeLongitude.x) If I'm not wrong, this was the latitude compensation formula 🤔

this did the trick. Fits now perfectly :-) thx @brnkhy

Markovicho avatar Jun 21 '22 06:06 Markovicho