Skip to content

Commit 6b7bc6b

Browse files
authored
add QueryTerrainHeight function to AbstractMap (#571)
Looks good.
1 parent 47b13d6 commit 6b7bc6b

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

sdkproject/Assets/Mapbox/Unity/Map/AbstractMap.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,15 @@ public virtual Vector3 GeoToWorldPosition(Vector2d latitudeLongitude)
250250
return _root.TransformPoint(Conversions.GeoToWorldPosition(latitudeLongitude, CenterMercator, WorldRelativeScale).ToVector3xz());
251251
}
252252

253+
public virtual float QueryHeightData(Vector2d latlong)
254+
{
255+
var _meters = Conversions.LatLonToMeters(latlong.x, latlong.y);
256+
var tile = MapVisualizer.ActiveTiles[Conversions.LatitudeLongitudeToTileId(latlong.x, latlong.y, (int)Zoom)];
257+
var _rect = tile.Rect;
258+
var _worldPos = GeoToWorldPosition(new Vector2d(latlong.x, latlong.y));
259+
return tile.QueryHeightData((float)((_meters - _rect.Min).x / _rect.Size.x), (float)((_meters.y - _rect.Max.y) / _rect.Size.y));
260+
}
261+
253262
public abstract void Initialize(Vector2d latLon, int zoom);
254263

255264
public void Reset()

0 commit comments

Comments
 (0)