using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ESRI.ArcGIS.Geodatabase;
using ESRI.ArcGIS.Geometry;
using System.Windows.Forms;

namespace OliviaAddIn
{
    public class Parquimetros
    {

        //*************************************************************************************
        //Enums     
        //Variables   
        /**
        * Cadena general para indicar los errores
        */
        public String err_str = "";

         
        //*************************************************************************************
        //Métodos
        public Parquimetros()
        {

            
        }

        public void genera_plazas_aparcar(string capa)
        {
           /* double distancia;
            int campo, nplazas, ind, uno = 1;
            string nueva_capa;
            IFeatureClass fclass, fc_shape;
            IFeatureCursor cursor;
            IFeature feat, nueva;
            IFeatureWorkspace featws_shp;
            IWorkspaceEdit ws_shape;
            IFields campos;
            //IField nplazas;
            IPoint plaza;
            IGeometry geom;
            ISpatialReference coor = null;
            IPolyline linea_aparca;
            ITopologicalOperator divide;

            fclass = feat_ws_lin.OpenFeatureClass(capa);
            cursor = fclass.Search(null, false);
            campo = fclass.FindField("Numero");
            campos = fclass.Fields;
            feat = cursor.NextFeature();
            nplazas = (int)feat.get_Value(campo);
            geom = feat.Shape;
            coor = geom.SpatialReference;
            featws_shp = (IFeatureWorkspace)gdb_ws;

            linea_aparca = (IPolyline)geom;
            distancia = linea_aparca.Length;

            try
            {
                ws_shape = (IWorkspaceEdit)featws_shp;
                ws_shape.StartEditing(true);
                ws_shape.StartEditOperation();
                nueva_capa = fclass.AliasName + "_pto";
                //se genera la nueva capa la primera vez que pasa porla función
                //if (!File.Exists(ws.PathName + "\\" + nueva_capa + ".shp"))
                fc_shape = featws_shp.CreateFeatureClass(nueva_capa, campos, null, null, esriFeatureType.esriFTSimple, "FeatureClass", "");
                //else
                //    fc_shape = featws_shp.OpenFeatureClass(nueva_capa);
                //se crea una nuevo campo al que se le añade la geometría de la coleccion de puntos y el campo con elvalor extraido del filtro
                nueva = fc_shape.CreateFeature();
                puntos = (IMultipoint)colec_ptos;
                puntos.SpatialReference = coor;
                nueva.Shape = puntos;
                ind = fc_shape.FindField("Numero");
                nueva.set_Value(ind, uno);
                nueva.Store();

                ws_shape.StopEditOperation();
                ws_shape.StopEditing(true);
            }
            catch (Exception cexp2)
            {
                MessageBox.Show(cexp2.Message);
            }
            finally
            {
                //libera variables
                if (cursor != null)
                    System.Runtime.InteropServices.Marshal.FinalReleaseComObject(cursor);
                //if (camp != null)
                 //   System.Runtime.InteropServices.Marshal.FinalReleaseComObject(camp);
                if (campos != null)
                    System.Runtime.InteropServices.Marshal.FinalReleaseComObject(campos);
                if (nueva != null)
                    System.Runtime.InteropServices.Marshal.FinalReleaseComObject(nueva);
                if (fc_shape != null)
                    System.Runtime.InteropServices.Marshal.FinalReleaseComObject(fc_shape);
            }*/
        }

    }
}
