void updatePointPosition() { /// Top left point position of the tile in the world. GCS tile = HeightLoader.WorldToTilePos(lon, lat, zoom); /// Get the decimals in the interval [0 - 1) tile.lon = tile.lon - System.Math.Truncate(tile.lon); tile.lat = tile.lat - System.Math.Truncate(tile.lat); /// Terrain coordinates in Unity starts in bottom left, BUT! /// terrain coordinates in Height map starts in top left GCSImagePos.x = (float)(tile.lon * 256); GCSImagePos.z = 256 - (float)(tile.lat * 256); /// so we need to subtract that /// Coordinates in height map int xx = (int)(tile.lon * 256); int zz = 256 - (int)(tile.lat * 256); /// Update position GCSImagePos.y = GetComponent <Terrain>().terrainData.GetHeight(xx, zz) + GetComponent <Transform>().position.y; }
public static USlippyTile GCS2Slippy(GCS p, int _zoom) { p = HeightLoader.WorldToTilePos(p.lon, p.lat, _zoom); return(new USlippyTile((int)System.Math.Floor(p.lon), (int)System.Math.Floor(p.lat), _zoom)); }