Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions sdkproject/Assets/Mapbox/Unity/Utilities/Conversions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -200,13 +200,13 @@ public static RectD TileBounds(UnwrappedTileId unwrappedTileId)
/// <param name="longitude"> The longitude. </param>
/// <param name="zoom"> Zoom level. </param>
/// <returns> A <see cref="T:UnityEngine.Vector2d"/> xy tile ID. </returns>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't forget to edit the code comments too.
Are there no other changes needed?
That would mean LatitudeLongitudeToTileId is not referenced anywhere in our code -> this is bad.
We definitely need tests for Conversions.cs.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@BergWerkGIS Sorry for being an idiot, will edit code comments now. The return type was Vector2d and in most cases we would only use the x,y component of the tileId. We found this issue when writing an API for queryingHeight at a certain LatLong for which we needed the entire tileid.

public static Vector2d LatitudeLongitudeToTileId(double latitude, double longitude, int zoom)
public static UnwrappedTileId LatitudeLongitudeToTileId(double latitude, double longitude, int zoom)
{
var x = (int)Math.Floor((longitude + 180.0) / 360.0 * Math.Pow(2.0, zoom));
var y = (int)Math.Floor((1.0 - Math.Log(Math.Tan(latitude * Math.PI / 180.0)
+ 1.0 / Math.Cos(latitude * Math.PI / 180.0)) / Math.PI) / 2.0 * Math.Pow(2.0, zoom));

return new Vector2d(x, y);
return new UnwrappedTileId(x, y, zoom);
}

/// <summary>
Expand Down