using UnityEngine;

/// <summary>
/// Component attached to tile prefab roots to store geo metadata.
/// Useful for positioning prefabs in scene or querying tile info at runtime.
/// </summary>
public class GeoTileMetadata : MonoBehaviour
{
    public string tileId;
    public double xmin;
    public double ymin;
    public double globalMin;
    public double globalMax;
    public double tileMin;
    public double tileMax;
    public bool hasTileMinMax;

    /// <summary>
    /// Returns the world position this tile should be placed at, given a global origin.
    /// </summary>
    public Vector3 GetWorldPosition(double originX, double originY)
    {
        double baseMin = hasTileMinMax ? tileMin : globalMin;
        return new Vector3(
            (float)(xmin - originX),
            (float)baseMin,
            (float)(ymin - originY)
        );
    }
}
