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

TileSize vs real world distance not matching #1868

Closed
Markovicho opened this issue May 12, 2022 · 3 comments
Closed

TileSize vs real world distance not matching #1868

Markovicho opened this issue May 12, 2022 · 3 comments

Comments

@Markovicho
Copy link

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

@brnkhy
Copy link
Contributor

brnkhy commented May 17, 2022

@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
Copy link
Contributor

brnkhy commented May 26, 2022

@Markovicho can you contact me via email; baran.kahyaoglu@mapbox.com or twitter brnkhy?

@Markovicho
Copy link
Author

@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

@brnkhy brnkhy closed this as completed Oct 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants