diff --git a/Button/ButtonConfig.cs b/Button/ButtonConfig.cs index b4ec672..8d500ad 100644 --- a/Button/ButtonConfig.cs +++ b/Button/ButtonConfig.cs @@ -16,6 +16,8 @@ using ArcGIS.Desktop.Internal.Framework.Controls; using ArcGIS.Desktop.Framework.Dialogs; using ArcGIS.Desktop.Framework.Threading.Tasks; using ArcGIS.Desktop.Mapping; +using OliviaAddInPro.Helper; +using OliviaAddInPro.Model; namespace OliviaAddInPro { @@ -23,13 +25,13 @@ namespace OliviaAddInPro { protected override void OnClick() { - if (OliviaGlob.tipEjec == TiposEjecucion.Ninguno) + if (OliviaGlob.TipoEjec == TiposEjecucion.Ninguno) { //OliviaGlob.tipEjec = TiposEjecucion.Config; } else { - OliviaGlob.ponMsg(Resource1.String_existe_ejec, MessageType.Warning); + HelperGlobal.ponMsg(Resource1.String_existe_ejec, MessageType.Warning); } } } diff --git a/Button/ButtonLimp.cs b/Button/ButtonLimp.cs index 0be0c66..3875446 100644 --- a/Button/ButtonLimp.cs +++ b/Button/ButtonLimp.cs @@ -16,6 +16,8 @@ using ArcGIS.Desktop.Internal.Framework.Controls; using ArcGIS.Desktop.Framework.Dialogs; using ArcGIS.Desktop.Framework.Threading.Tasks; using ArcGIS.Desktop.Mapping; +using OliviaAddInPro.Helper; +using OliviaAddInPro.Model; namespace OliviaAddInPro { @@ -23,14 +25,14 @@ namespace OliviaAddInPro { protected override void OnClick() { - if (OliviaGlob.tipEjec == TiposEjecucion.Ninguno) + if (OliviaGlob.TipoEjec == TiposEjecucion.Ninguno) { - OliviaGlob.tipEjec = TiposEjecucion.LimpiezaConfig; + OliviaGlob.TipoEjec = TiposEjecucion.LimpiezaConfig; DockpaneLimpiezaViewModel.Show(); } else { - OliviaGlob.ponMsg(Resource1.String_existe_ejec, MessageType.Warning); + HelperGlobal.ponMsg(Resource1.String_existe_ejec, MessageType.Warning); } } } diff --git a/Button/ButtonMaq.cs b/Button/ButtonMaq.cs index f48e281..bc8935b 100644 --- a/Button/ButtonMaq.cs +++ b/Button/ButtonMaq.cs @@ -16,6 +16,8 @@ using ArcGIS.Desktop.Internal.Framework.Controls; using ArcGIS.Desktop.Framework.Dialogs; using ArcGIS.Desktop.Framework.Threading.Tasks; using ArcGIS.Desktop.Mapping; +using OliviaAddInPro.Helper; +using OliviaAddInPro.Model; namespace OliviaAddInPro { @@ -23,13 +25,13 @@ namespace OliviaAddInPro { protected override void OnClick() { - if (OliviaGlob.tipEjec == TiposEjecucion.Ninguno) + if (OliviaGlob.TipoEjec == TiposEjecucion.Ninguno) { //OliviaGlob.tipEjec = TiposEjecucion.Maqueta; } else { - OliviaGlob.ponMsg(Resource1.String_existe_ejec, MessageType.Warning); + HelperGlobal.ponMsg(Resource1.String_existe_ejec, MessageType.Warning); } } } diff --git a/Button/ButtonRec.cs b/Button/ButtonRec.cs index 5df8c3d..7929e28 100644 --- a/Button/ButtonRec.cs +++ b/Button/ButtonRec.cs @@ -16,6 +16,8 @@ using ArcGIS.Desktop.Framework.Dialogs; using ArcGIS.Desktop.Framework.Threading.Tasks; using ArcGIS.Desktop.Internal.Framework.Controls; using ArcGIS.Desktop.Mapping; +using OliviaAddInPro.Helper; +using OliviaAddInPro.Model; namespace OliviaAddInPro { @@ -23,14 +25,14 @@ namespace OliviaAddInPro { protected override void OnClick() { - if(OliviaGlob.tipEjec==TiposEjecucion.Ninguno) + if(OliviaGlob.TipoEjec==TiposEjecucion.Ninguno) { - OliviaGlob.tipEjec = TiposEjecucion.RecoConfig; + OliviaGlob.TipoEjec = TiposEjecucion.RecoConfig; DockpaneRecogidaViewModel.Show(); } else { - OliviaGlob.ponMsg(Resource1.String_existe_ejec, MessageType.Warning); + HelperGlobal.ponMsg(Resource1.String_existe_ejec, MessageType.Warning); } } } diff --git a/Helper/CheckedListItem.cs b/Helper/CheckedListItem.cs new file mode 100644 index 0000000..e1a91d2 --- /dev/null +++ b/Helper/CheckedListItem.cs @@ -0,0 +1,58 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace OliviaAddInPro.Helper +{ + class CheckedListItem : INotifyPropertyChanged + { + public event PropertyChangedEventHandler PropertyChanged; + + private bool isChecked; + private bool isEnabled; + private T item; + + public CheckedListItem() + { } + + public CheckedListItem(T item, bool isChecked = false, bool isEnabled = true) + { + this.item = item; + this.isChecked = isChecked; + this.isEnabled = isEnabled; + } + + public T Item + { + get { return item; } + set + { + item = value; + if (PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs("Item")); + } + } + + + public bool IsChecked + { + get { return isChecked; } + set + { + isChecked = value; + if (PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs("IsChecked")); + } + } + public bool IsEnabled + { + get { return isEnabled; } + set + { + isEnabled = value; + if (PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs("IsEnabled")); + } + } + } +} diff --git a/Helper/HelperGdb.cs b/Helper/HelperGdb.cs index f7e6e93..734fe61 100644 --- a/Helper/HelperGdb.cs +++ b/Helper/HelperGdb.cs @@ -17,7 +17,25 @@ namespace OliviaAddInPro.Helper { public static class HelperGdb { - public static string out_st = string.Empty; + private static string out_str = string.Empty; + public static string OutStr { + get + { + string val = out_str; + out_str = string.Empty; //lo borra cada vez que se consulta + return val; + } + set { out_str = value; } + } + private static string texto_sal = string.Empty; + public static string TextoSal + { + get { + string val = texto_sal; + texto_sal = string.Empty; //lo borra cada vez que se consulta + return val; } + set { texto_sal = value; } + } [Flags] public enum TiposOpenFileDlg @@ -28,12 +46,18 @@ namespace OliviaAddInPro.Helper OpenGdb=8, } + private static void ReiniciaOutStr() + { + out_str = string.Empty; + } + //Dado el tipo de FtClass y una posición inicial abre un diálogo de búsqueda de ftclass //si se cancela o no es una feature class lo que se ha abierto devuelve null //si no, devuelve la featureclass directamente abierta public static FeatureClass OpenFtClassDialog(TiposOpenFileDlg tipo, string initialLoc = "") { FeatureClass fc = null; + ReiniciaOutStr(); string path = OpenFileDialog( tipo, initialLoc); if(!string.IsNullOrEmpty(path)) { @@ -45,13 +69,15 @@ namespace OliviaAddInPro.Helper //Libera el objeto public static void Free(IDisposable obj) { - obj.Dispose(); + if(obj!=null) + obj.Dispose(); } //Devuelve el Path del archivo seleccionado o un string vacío si se ha cancelado public static string OpenFileDialog(TiposOpenFileDlg tipo, string initialLoc="") { string titulo; + ReiniciaOutStr(); titulo = "Abrir Archivo"; //Create a browse filter that uses Pro's "esri_browseDialogFilters_geodatabases" filter. //The browse filter is used in an OpenItemDialog. @@ -98,15 +124,6 @@ namespace OliviaAddInPro.Helper return string.Empty; } - /*public static bool SelecPolig(string title, int wnd_handle, out string text_sal, out IGeometry geom_sal) - { - - } - public static bool SelecInstal(string title, int wnd_handle, out string text_sal, out double x, out double y) - { - - }*/ - //Dado un path comprueba que sea de una gdb, termina en .gdb, o si tiene .gdb en medio lo corta ahí //y si no tiene devuelve vacío public static string GetPathGdb(string path) @@ -128,7 +145,8 @@ namespace OliviaAddInPro.Helper public static Task GetGdb(string pathGdb) { Geodatabase fileGeodatabase = null; - return ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => + ReiniciaOutStr(); + return ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run((Func)(() => { string path = GetPathGdb(pathGdb); if (!string.IsNullOrEmpty(path)) @@ -139,12 +157,12 @@ namespace OliviaAddInPro.Helper } catch (Exception ex) { - out_st = "Error al abrir Geodatabase " + path + ": " + ex.Message; + HelperGdb.out_str = "Error al abrir Geodatabase " + path + ": " + ex.Message; return null; } } return fileGeodatabase; - }); + })); //return fileGeodatabase; } @@ -154,6 +172,7 @@ namespace OliviaAddInPro.Helper { FeatureClass ftclss = null; Geodatabase gdb = GetGdb(pathFtClss).Result; + ReiniciaOutStr(); if (gdb != null) { ftclss = GetFtClass(System.IO.Path.GetFileNameWithoutExtension(pathFtClss), gdb).Result; @@ -171,7 +190,8 @@ namespace OliviaAddInPro.Helper public static Task GetFtClass(string nameFtclss, Geodatabase gdb) { FeatureClass ftclss = null; - return ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => + ReiniciaOutStr(); + return ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run((Func)(() => { try { @@ -179,18 +199,19 @@ namespace OliviaAddInPro.Helper } catch (Exception ex) { - out_st = "Error al abrir Feature Class " + nameFtclss + ": " + ex.Message; + HelperGdb.out_str = "Error al abrir Feature Class " + nameFtclss + ": " + ex.Message; return null; } return ftclss; - }); + })); } //Abre una feature class cuando es un shapefile public static Task GetFtClassFromShp(string pathShp) { FeatureClass ftclss = null; - return ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => + ReiniciaOutStr(); + return ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run((Func)(() => { if (pathShp.Contains(".shp")) { @@ -203,20 +224,21 @@ namespace OliviaAddInPro.Helper } catch (Exception ex) { - out_st = "Error al abrir Shapefile " + pathShp + ": " + ex.Message; + HelperGdb.out_str = "Error al abrir Shapefile " + pathShp + ": " + ex.Message; return null; } } return ftclss; - }); + })); } //devuelve el campo dado el nombre private static Task GetFieldByName(FeatureClass ftClss, string fieldName) { FeatureClassDefinition ftcldef = ftClss.GetDefinition(); + ReiniciaOutStr(); ArcGIS.Core.Data.Field field=null; - return ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => + return ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run((Func)(() => { try { @@ -224,11 +246,11 @@ namespace OliviaAddInPro.Helper } catch (Exception ex) { - out_st = "No se encuentra el campo " + fieldName + ": " + ex.Message; + HelperGdb.out_str = "No se encuentra el campo " + fieldName + ": " + ex.Message; return null; } return field; - }); + })); } @@ -237,8 +259,9 @@ namespace OliviaAddInPro.Helper { FeatureClassDefinition ftcldef=null; IReadOnlyList fields = null; + ReiniciaOutStr(); ObservableCollection fields_st = new ObservableCollection(); - return ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => + return ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run((Func>)(() => { try { @@ -251,11 +274,11 @@ namespace OliviaAddInPro.Helper } catch (Exception ex) { - out_st = "Error al leer los campos " + fc.GetName() + ": " + ex.Message; + HelperGdb.out_str = "Error al leer los campos " + fc.GetName() + ": " + ex.Message; return fields_st; } return fields_st; - }); + })); } //Devuelve comilla simple si el campo es de texto, o nada si es númerico @@ -265,74 +288,219 @@ namespace OliviaAddInPro.Helper return f.FieldType == FieldType.String ? "'" : ""; } - //Dado un nombre de campo, devuelve los atributos que aparecen distintos - public static Task> GetAttributes(FeatureClass fc, string fieldName) + //Dado un nombre de campo, devuelve los valores que encuentra para ese nombre de campo + public static Task> GetFieldVals(FeatureClass fc, string fieldName, bool uniquevals) { ObservableCollection attribs_st = new ObservableCollection(); - return ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => + ReiniciaOutStr(); + return ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run((Func>)(() => { try { - FeatureClassDefinition ftcldef = fc.GetDefinition(); - ArcGIS.Core.Data.Field field = ftcldef.GetFields().First(x => x.Name.Equals(fieldName)); - string whereClause = $""; - ArcGIS.Core.Data.QueryFilter queryFilter = new ArcGIS.Core.Data.QueryFilter { WhereClause = whereClause }; - using (RowCursor rowCursor = fc.Search(queryFilter)) + using (FeatureClassDefinition ftcldef = fc.GetDefinition()) { - while (rowCursor.MoveNext()) + ArcGIS.Core.Data.Field field = ftcldef.GetFields().First(x => x.Name.Equals(fieldName)); + using (RowCursor rowCursor = fc.Search()) { - using (Row row = rowCursor.Current) + string str; + while (rowCursor.MoveNext()) { - attribs_st.Add(Convert.ToString(row[fieldName])); + using (Row row = rowCursor.Current) + { + str = Convert.ToString(row[fieldName]); + if (uniquevals) + { + if (attribs_st.Contains(str)) + continue; + } + attribs_st.Add(str); + } } } } } catch (Exception ex) { - out_st = "Error al leer los campos " + fc.GetName() + ": " + ex.Message; + HelperGdb.out_str = "Error al leer los campos " + fc.GetName() + ": " + ex.Message; return attribs_st; } return attribs_st; - }); + })); } - /*public static Geometry GetGeomSel(string pathLyr, string selField, ObservableCollection selAttributes, out string textoSal) + /** + * Devuelve una geometría que es la suma de la inicial y la que se añade Add + */ + public static ArcGIS.Core.Geometry.Geometry UneGeom(ArcGIS.Core.Geometry.Geometry geomIni, ArcGIS.Core.Geometry.Geometry geomUne) { - string _textosal = ""; - Geometry geomsal = null; + if (geomIni == null) + return geomUne; + return GeometryEngine.Instance.Union(geomIni, geomUne); + } - /*is_str = FunGDB.is_str_field(clase_path, selField); - nval = list.selec_valores_campo(selField, out val_ids, out val_st);//valores únicos - if (nval > 0) + /** + * Devuelve una geometría a la que dada una geometría inicial se le quita Excl + */ + public static ArcGIS.Core.Geometry.Geometry QuitaGeom(ArcGIS.Core.Geometry.Geometry geomIni, ArcGIS.Core.Geometry.Geometry geomQuita) + { + return GeometryEngine.Instance.Union(geomIni, geomQuita); + } + + /** + * Forma la envolvente convexa, el mínimo polígono, + * que contiene los ámbitos para exportar, a partir de ahí la red navegable ampliando a un buffer + */ + public static ArcGIS.Core.Geometry.Geometry GetGeomConvexHull(FeatureClass fclss, ArcGIS.Core.Data.QueryFilter filter) + { + ArcGIS.Core.Geometry.Geometry geomIni = null; + geomIni = GetGeomUnica(fclss, filter); + if (geomIni != null) + return GeometryEngine.Instance.ConvexHull(geomIni); + else + return null; + } + + /* + * A partir de una capa recorre todos los elementos que cumplen el filtro y los une en una única geometría + */ + public static ArcGIS.Core.Geometry.Geometry GetGeomUnica(FeatureClass fclss, ArcGIS.Core.Data.QueryFilter filtro) + { + ArcGIS.Core.Geometry.Geometry geomsal = null; + ReiniciaOutStr(); + + try { - //se embucla para unir las geoms - for (int i = 0; i < nval; i++) + using (RowCursor rowCursor = fclss.Search(filtro)) { - if (is_str) - consulta = selField + " = '" + val_st[i] + "'"; - else - consulta = selField + " = " + val_st[i]; - ids = FunGDB.dame_ids_consulta(clase_path, consulta); - fc = FunGDB.abre_ftclass(clase_path); - if ((ids != null) && (fc != null)) + while (rowCursor.MoveNext()) { - for (j = 0; j < ids.Length; j++) + using (Row row = rowCursor.Current) { - f = fc.GetFeature(ids[j]); - geom = f.Shape; - geom_sal = FunGDB.une_geoms(geom_sal, geom); - FunGDB.libera(f); + if(row is Feature ft) + geomsal = UneGeom(geomsal, ft.GetShape()); } } - FunGDB.libera(fc); - //Actualiza el texto de salida - _textosal = _textosal + HelperGlobal.RevisaText(val_st[i]); } } - textoSal = _textosal; + catch (Exception ex) + { + out_str = "Error al leer generar geometría única " + out_str + ex.Message; + return geomsal; + } + return geomsal; - }*/ + } + /** + * Dado un campo de una feature class y el valor que se quiere para el campo + * devuelve las geometrías que cumplen dicho criterio + */ + public static Task GetGeomSel(FeatureClass fclss, string fieldName, ObservableCollection selFieldVals) + { + ArcGIS.Core.Geometry.Geometry geomsal = null; + ArcGIS.Core.Geometry.Geometry geomAux = null; + string where = ""; + ArcGIS.Core.Data.Field f; + ArcGIS.Core.Data.QueryFilter filtro; + bool ok = true; + ReiniciaOutStr(); + TextoSal = string.Empty; + + return ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run((Func)(() => + { + try + { + using (FeatureClassDefinition ftcldef = fclss.GetDefinition()) + { + f = ftcldef.GetFields().First(x => x.Name.Equals(fieldName)); + //se embucla para unir las geoms + for (int i = 0; i < selFieldVals.Count && ok; i++) + { + where = $"{fieldName} = {Quote(f)}{selFieldVals[i]}{Quote(f)}"; + filtro = new ArcGIS.Core.Data.QueryFilter { WhereClause = where }; + geomAux = GetGeomUnica(fclss, filtro); + if(geomAux == null) + { + ok = false; + continue; + } + geomsal = UneGeom(geomsal, geomAux); + TextoSal = TextoSal + HelperGlobal.RevisaText(selFieldVals[i]); + } + } + } + catch (Exception ex) + { + HelperGdb.out_str = "Error al generar geometría en " + fclss.GetName() + " Con filtro " + where +": " + ex.Message; + return geomsal; + + } + if (!ok) + HelperGdb.out_str = "Error al generar geometría en " + fclss.GetName() + " Con filtro " + where + HelperGdb.out_str; + return geomsal; + })); + } + /** + * Devuelve el número de entidades de una FeatureClass que cumplen la consulta, o todos si la consulta es empty + */ + public static int GetNumElems(string pathGdb, string ftclssName, string consulta = "") + { + Geodatabase gdb = GetGdb(pathGdb).Result; + FeatureClass fc = null; + int n = -1; + if (gdb != null) + { + fc = GetFtClass(ftclssName, gdb).Result; + if(fc!=null) + n= GetNumElems(fc, consulta).Result; + } + Free(fc); + Free(gdb); + return n; + + } + /** + * Devuelve el número de entidades de una FeatureClass que cumplen la consulta, o todos si la consulta es empty + */ + public static Task GetNumElems(FeatureClass fc, string consulta = "") + { + int n = -1; + return ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run((Func)(() => + { + try + { + if (fc != null) + { + if (string.IsNullOrEmpty(consulta)) + n = fc.GetCount(); + else + { + //realiza consulta + n = 0; + using (Selection sel = fc.Select(new ArcGIS.Core.Data.QueryFilter { WhereClause = consulta }, SelectionType.ObjectID, SelectionOption.Normal)) + n = sel.GetCount(); + } + } + return n; + } + catch (Exception ex) + { + HelperGdb.out_str = "Error al contar filas en " + fc.GetName() + ": " + ex.Message; + return n; + + } + })); + } + + /** + * Devuelve el número de entidades de una FeatureClass que cumplen la consulta, o todos si la consulta es empty + */ + public static int GetNumElems(string pathFtClss, string consulta = "") + { + FeatureClass fc = GetFtClass(pathFtClss); + int n=GetNumElems(fc,consulta).Result; + Free(fc); + return n; + } } } diff --git a/Helper/HelperGlobal.cs b/Helper/HelperGlobal.cs index 108fba5..1af1daf 100644 --- a/Helper/HelperGlobal.cs +++ b/Helper/HelperGlobal.cs @@ -1,13 +1,22 @@ using System; using System.Collections.Generic; +using System.Collections.ObjectModel; using System.Linq; using System.Text; using System.Threading.Tasks; +using ArcGIS.Desktop.Internal.Framework.Controls; namespace OliviaAddInPro.Helper { public static class HelperGlobal { + public static ErrorMessageDialog msg; + + public static void ponMsg(String mensaje, MessageType tipo, String titulo = "OLIVIA") + { + msg = new ErrorMessageDialog(titulo, mensaje, tipo); + msg.ShowDialog(); + } public static string RevisaText(string text) { StringBuilder sb = new StringBuilder(); diff --git a/Model/Comun.cs b/Model/Comun.cs new file mode 100644 index 0000000..8c71e60 --- /dev/null +++ b/Model/Comun.cs @@ -0,0 +1,77 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using ArcGIS.Core.Geometry; + +namespace OliviaAddInPro.Model +{ + class Comun + { + /** + * Capa de ámbitos + */ + public string CapaElems = string.Empty; + /** + * Velocidad de desplazamiento, en km/h. Si es 0, es determinada por la vía + */ + public double VDespl = 0; + /** + * Tiempo de tratamiento, en minutos + */ + public double Ttto = 5; + /** + * Geometría para el filtro de ámbitos, incluye zonas, se añaden los ámbitos que pertenecen a esa geom + */ + public Geometry GeomZon = null; + /** + * Geometría para el filtro de ámbitos, incluye zonas, se añaden los ámbitos que pertenecen a esa geom + */ + public Geometry GeomNiv = null; + /** + * Geometría para el filtro de ámbitos, incluye restricciones, se quitan los ámbitos que pertenecen a esa geom + */ + public Geometry GeomRestr = null; + /** + * Coordenadas de la instalación + */ + public Coordinate2D CoordsInstal = new Coordinate2D(0, 0); + /** + * Buffer para la exportación, en metros + */ + public int BuffExport = 1000; + /** + * Tiempo de trabajo al día por convenio, en minutos + */ + public double TConv = LimpiezaDef.Parametros.t_conv; + /** + * Tiempo de descanso del personal, en minutos + */ + public double TDescan = LimpiezaDef.Parametros.t_descanso; + /** + * Tiempo de carga y descarga, en minutos + */ + public double TDescarg = LimpiezaDef.Parametros.t_cardesc; + /** + * Tiempo de desplazamiento inicio/fin a las instalaciones, en minutos + */ + public double TDesplIniFin = LimpiezaDef.Parametros.t_desp; + /** + * hora de inicio de la jornada de trabajo, en minutos + */ + public double HIni = LimpiezaDef.Parametros.h_inicio; + /** + * Porcentaje de tráfico que se estima, ya que si no los vehículos irían siempre a la velocida máxima permitida por la vía + */ + public int Trafico = 80; + /** + * Número de puntos de control + */ + public int NPtosCtrl = 3; + /** + * Número de sectores, si es 0, se calcula automáticamente, si es negativo, se ajusta a jornada + */ + public int NSect = 3; + } +} diff --git a/Model/Limpieza.cs b/Model/Limpieza.cs new file mode 100644 index 0000000..8a109a8 --- /dev/null +++ b/Model/Limpieza.cs @@ -0,0 +1,65 @@ +using ArcGIS.Core.Geometry; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using OliviaAddInPro.Helper; + +namespace OliviaAddInPro.Model +{ + class Limpieza : Comun + { + //********************************************** + //Se recogen en PaneLimpiezaSub1 + /** + * Tipo de tratamiento elegidos + */ + public int TipoTto = -1; + /** + * Ámbitos de trabajo elegidos + */ + public bool[] AmbitosSel = new bool[(int)LimpiezaDef.AmbitsTra.AmbN]; + /** + * Indica si respeta el sentido de circulación o no + */ + public bool RespCirc = false; + /** + * Tipo de unidades del tiempo de tto + */ + public int UdsTTto = (int)GeneralDef.OlvTiposTto.OlvTipTtoNoDef; + + /** + * Lee la gdb y devuelve el array de ámbitos en función de si hay en la gdb o no + */ + public bool[] BuscAmbGdb() + { + string consulta; + int numero_lin; + bool[] amb_gdb = new bool[(int)LimpiezaDef.AmbitsTra.AmbN];//se inician a false + string ftclass; + + //mira a ver si hay ejes de calle + ftclass = LimpiezaDef.ftclass[(int)LimpiezaDef.AmbitsTra.AmbEjeCalle]; + consulta = LimpiezaDef.filtro_str[(int)LimpiezaDef.AmbitsTra.AmbEjeCalle]; + numero_lin = HelperGdb.GetNumElems(OliviaGlob.Paths.PathGdbNw, ftclass, consulta); + if (numero_lin > 0) + { + amb_gdb[(int)LimpiezaDef.AmbitsTra.AmbEjeCalle] = true; + } + //mira a ver si hay el resto de capas y tienen entidades + for (int i = (int)LimpiezaDef.AmbitsTra.AmbBordLibreMec; i < (int)LimpiezaDef.AmbitsTra.AmbN; i++) + { + consulta = LimpiezaDef.filtro_str[i]; + numero_lin = HelperGdb.GetNumElems(CapaElems, consulta); + + if (numero_lin > 0) + { + amb_gdb[i] = true; + } + } + + return amb_gdb; + } + } +} diff --git a/Model/LimpiezaDef.cs b/Model/LimpiezaDef.cs new file mode 100644 index 0000000..e1d9298 --- /dev/null +++ b/Model/LimpiezaDef.cs @@ -0,0 +1,792 @@ +using System; + +/** +* @file LimpiezaDef.cs +* Clase con definiciones de limpieza comunes al proyecto Olivia y a OliviaTask. +*/ +/** +* Clase con definiciones de limpieza comunes al proyecto Olivia y a OliviaTask. +*/ +namespace OliviaAddInPro.Model +{ + public static class LimpiezaDef + { + public const int NMaxZon = 9; + public const int NMaxNiv = 12; + + //************************************************************************************* + //Enums y structs generales + /** + * Nombre de las capas que se van a necesitar para la exportación de datos para la limpieza + */ + public struct Capas + { + public static string ftclass_niveles; //512 {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - + $([MSBuild]::GetRegistryValueFromView('HKEY_LOCAL_MACHINE\SOFTWARE\ESRI\ArcGISPro', 'InstallDir', null, RegistryView.Registry64)) $(registry:HKEY_CURRENT_USER\SOFTWARE\ESRI\ArcGISPro@InstallDir) - true full @@ -42,7 +41,6 @@ $(ArcGISFolder)\bin\ArcGISPro.exe AnyCPU - @@ -132,9 +130,14 @@ + - + + + + + @@ -165,7 +168,7 @@ - + True diff --git a/OliviaGlob.cs b/OliviaGlob.cs deleted file mode 100644 index e826aa2..0000000 --- a/OliviaGlob.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using ArcGIS.Desktop.Internal.Framework.Controls; - -namespace OliviaAddInPro -{ - enum TiposEjecucion - { - Ninguno, - LimpiezaConfig, - LimpiezaEjec, - RecoConfig, - RecoEjec, - Maqueta, - Config - } - static class OliviaGlob - { - public static TiposEjecucion tipEjec { get; set; } = TiposEjecucion.Ninguno; - public static ErrorMessageDialog msg; - - public static void ponMsg(String mensaje, MessageType tipo, String titulo="OLIVIA") - { - msg = new ErrorMessageDialog(titulo, mensaje, tipo); - msg.ShowDialog(); - } - } -} diff --git a/Resource1.Designer.cs b/Resource1.Designer.cs index a30f454..bef0ba3 100644 --- a/Resource1.Designer.cs +++ b/Resource1.Designer.cs @@ -69,6 +69,15 @@ namespace OliviaAddInPro { } } + /// + /// Busca una cadena traducida similar a No se ha encontrado ningún elemento en la tabla que cumpla con los criterios seleccionados.. + /// + internal static string String_error_elems_tabla { + get { + return ResourceManager.GetString("String_error_elems_tabla", resourceCulture); + } + } + /// /// Busca una cadena traducida similar a Ya existe una ejecución en marcha. /// diff --git a/Resource1.resx b/Resource1.resx index 65f8492..614dd04 100644 --- a/Resource1.resx +++ b/Resource1.resx @@ -120,6 +120,9 @@ Control + + No se ha encontrado ningún elemento en la tabla que cumpla con los criterios seleccionados. + Ya existe una ejecución en marcha diff --git a/View/PaneLimpiezaSub1.xaml b/View/PaneLimpiezaSub1.xaml index 97c74ff..046ead0 100644 --- a/View/PaneLimpiezaSub1.xaml +++ b/View/PaneLimpiezaSub1.xaml @@ -29,11 +29,19 @@