using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Maps.MapControl.Core;
using WebSamples.Entities;
using WebSamples.Entities.Interfaces;

namespace WebSamples.TileRendererEngine.Helpers
{
    public class EngineHelper
    {
        #region Private fields

        TileRenderer renderEngine = null;

        #endregion

        #region Constructors

        public EngineHelper(QuadKey quadKey)
        {
            this.renderEngine = new TileRenderer(quadKey);
        }

        #endregion

        #region Public engine helper methods

        /// <summary>
        /// Shapes should be bounded to the current quadkey
        /// </summary>
        /// <param name="shapes"></param>
        /// <returns></returns>
        public Byte[] GetDefaultTile(List<GeoPoint> shapes)
        {
            Byte[] results = null;

            if (shapes != null)
            {
                if (shapes.Any())
                {
                    this.renderEngine.RenderTileFromData(shapes);
                    results = this.renderEngine.GetPNGByteBuffer();
                }
            }

            return results;
        }

        #endregion
    }
}
