using System;
using System.Web;
using System.Collections;
using System.Web.Services;
using System.Web.Services.Protocols;

using Spherical;
using Spherical.IO;
using STC;


/// <summary>
/// Summary description for Service
/// </summary>
[WebService(Namespace = "http://voservices.net/region",
    Description = "This is the VO service for the SDSS DR4 footprint. It illustrates the IVOA interface that returns STC compliant region descriptions.<br>Written by Tamas Budavari, 2005-2006<br><br><i>Conforms to WS-I Basic Profile 1.1</i>")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class SdssFootprint : System.Web.Services.WebService
{
    Region footprint;
    public SdssFootprint()
    {
        footprint = Samples.SdssDr4();
        footprint.Simplify(false, Const.Tolerance, Const.MaximumIteration, false);
    }

    #region Test methods ...

    [WebMethod(Description =
        "Testing... Method supports HTTP-GET")]
    public STCRegion test_intersection()
    {
        Region r = new Region(180, 0, 60);
        STCRegion s = Adapter.StcFromRegion(r);
        return this.Intersection(s);
    }

    #endregion

    [WebMethod(Description=
        "Return the survey footprint in STC format<br><b>Output:</b> region")]
    public STCRegion Footprint()
    {
        return Adapter.StcFromRegion(footprint, 0.99f);
    }

    [WebMethod(Description =
        "Derive the intersection of this footprint with a given region<br><b>Input:</b> region<br><b>Output:</b> region")]
    public STCRegion Intersection(STCRegion rt)
    {
        Region r = Adapter.ToRegion(rt);
        r.Simplify();
        Region i = this.footprint.Intersect(r);
        i.Simplify();
        return Adapter.StcFromRegion(i);
    }

#if false
    [WebMethod(Description =
        "Derive the intersection of this footprint with a given region (optional)<br><b>Input:</b> region<br><b>Output:</b> area")]
    public regionAreaType IntersectionArea(STCRegion rt)
    {
        STCRegion i = this.Intersection(rt);
        return i.Item.Area;
    }
#endif

}

