diff --git a/Config.daml b/Config.daml
index 1e55652..882f6e4 100644
--- a/Config.daml
+++ b/Config.daml
@@ -38,7 +38,7 @@
Add-In de ArcGIS Pro para la herramienta de optimización de la limpieza viaria, OLIVIA
-
+
Add-In de ArcGIS Pro para la herramienta de optimización de la limpieza viaria, OLIVIA
diff --git a/Helper/HelperGdb.cs b/Helper/HelperGdb.cs
index d72e7ea..a4d4453 100644
--- a/Helper/HelperGdb.cs
+++ b/Helper/HelperGdb.cs
@@ -562,7 +562,7 @@ namespace OliviaAddInPro.Helper
return ftclss;
}
//devuelve el campo dado el nombre
- private static ArcGIS.Core.Data.Field GetFieldByNameSinc(FeatureClass ftClss, string fieldName)
+ private static ArcGIS.Core.Data.Field GetFieldByNameSync(FeatureClass ftClss, string fieldName)
{
FeatureClassDefinition ftcldef = ftClss.GetDefinition();
ReiniciaOutStr();
@@ -739,9 +739,10 @@ namespace OliviaAddInPro.Helper
if (!fields.Contains(field))
{
HelperGdb.OutStr = "No se encuentra el campo " + field;
+ Free(fc);
return false;
}
-
+ Free(fc);
return true;
}
/*
@@ -757,13 +758,14 @@ namespace OliviaAddInPro.Helper
}
ObservableCollection fields = GetFieldsSync(fc);
+ bool encuentra = true;
if (!fields.Contains(field))
{
HelperGdb.OutStr = "No se encuentra el campo " + field;
- return false;
+ encuentra= false;
}
-
- return true;
+ Free(fc);
+ return encuentra;
}
/*
* Lee la capa que se ha seleccionzdo de recogida y se comprueba que contiene los campos necesarios
@@ -1946,12 +1948,27 @@ namespace OliviaAddInPro.Helper
if (brwsFilt != null)
dlg.BrowseFilter = brwsFilt;
- bool? ok = dlg.ShowDialog();
+ try
+ {
+ bool? ok = dlg.ShowDialog();
- if ((ok ?? true) && dlg.FilePath.Length > 0)
- return dlg.FilePath;
- else
+ if ((ok ?? true) && dlg.FilePath.Length > 0)
+ return dlg.FilePath;
+ else
+ return string.Empty;
+ }
+ catch(Exception ex)
+ {
return string.Empty;
+ }
+ }
+
+ /**
+ * Saca diálogo para elegir directorio
+ */
+ public static string FolderBrowseDlg(string title_, string initloc_)
+ {
+ return null;
}
/**
@@ -2391,5 +2408,113 @@ namespace OliviaAddInPro.Helper
Free(ftcl);
return tipo;
}
+
+ /*
+ * Renombra un campo de la feature class dada
+ */
+ public static bool RenameFieldSync(string fcname, string oldFieldName, string newFieldName, string newFieldAlias)
+ {
+ bool res = false;
+ string[] args = { fcname, oldFieldName, newFieldName,newFieldAlias };
+ // execute the tool
+ try
+ {
+ var gpres = Geoprocessing.ExecuteToolAsync("management.AlterField", args);
+ if (gpres.Result.IsFailed)
+ {
+ var gpResult = gpres.Result;
+ string msg;
+ if (gpResult.ErrorMessages != null)
+ msg = gpResult.ErrorMessages.First().Text;
+ else
+ msg = "Errores al renombrar campo "+newFieldName;
+ }
+ else
+ res= true; //ha ido bien
+ return res;
+ }
+ catch
+ {
+ }
+
+ return res;
+ }
+ public struct FieldToAdd
+ {
+ public string Name;
+ public string Tipo; //LONG, TEXT, ...
+ public string Alias;
+ public int Length;
+
+ public FieldToAdd(string nomb, string tip, string al, int len)
+ {
+ Name = nomb; //obligatorio
+ Tipo = tip; //obligatorio
+ Alias = al;
+ Length = len;
+ }
+ }
+ /*
+ * Renombra un campo de la feature class dada
+ */
+ public static bool AddFieldsSync(string fcname, FieldToAdd[] fields)
+ {
+ bool res = false;
+
+ // set up the arguments
+ string fields_str = "";
+ int camps = 0;
+ for(int i=0;i res1 = new Respuesta { Value = TiposEjecucion.FinEjecOk };
- HelperGdb.OpenLayer(@"C:\Users\Elena\Documents\ArcGIS\Projects\MyProject3\MyProject3.gdb\Barrido_man\BarMan_AceM_AceNM_20220529_134336", "SECTOR", true);
- return res1;*/
+ //Respuesta res1 = new Respuesta { Value = TiposEjecucion.FinEjecOk };
+ //HelperGdb.OpenLayer(@"C:\Users\Elena\Documents\ArcGIS\Projects\MyProject3\MyProject3.gdb\Barrido_man\BarMan_AceM_AceNM_20220529_134336", "SECTOR", true);
+ //Serv.ActualizaSecto(@"D:\Proyectos\Olivia\Instal2.0\data\data_T00_A0405_20220628_214902.shp", @"C:\\Users\\Elena\\Documents\\ArcGIS\\Projects\\MyProject3\\MyProject3.gdb\\Barrido_man\\BarMan_AceM_AceNM_20220628_214613");
+ //return res1;
+
+ //////////////////
/////////////////////////////
Respuesta res = new Respuesta { Value=false};
@@ -144,5 +147,20 @@ namespace OliviaAddInPro.Model
ambitos = ambitos + shapefile.Substring(aux);
}
+ /**
+ * Restaura el nombre original del campo si se ha truncado a 10 car al exportar a shp
+ */
+ public override string[] GetCamposRestaura()
+ {
+ string[] camps = {
+ LimpiezaDef.Campos.consulta_entidad,
+ LimpiezaDef.Campos.consulta_mecan,
+ LimpiezaDef.Campos.consulta_observ,
+ LimpiezaDef.Campos.consulta_anch_tip,
+ LimpiezaDef.Campos.consulta_tipolo,
+ /*LimpiezaDef.Campos.consulta_sector,
+ LimpiezaDef.Campos.consulta_secuen */};
+ return camps;
+ }
}
}
diff --git a/Model/OliviaGlob.cs b/Model/OliviaGlob.cs
index a78aa57..8e491f3 100644
--- a/Model/OliviaGlob.cs
+++ b/Model/OliviaGlob.cs
@@ -212,7 +212,7 @@ namespace OliviaAddInPro.Model
if (sh)
{
DockpaneLimpiezaViewModel.Show();
- SetFlagTipEjec(TiposEjecucion.Limp);
+ //SetFlagTipEjec(TiposEjecucion.Limp);
ViewSetFlagTipEjec(TiposEjecucion.Limp);
}
else
@@ -226,7 +226,7 @@ namespace OliviaAddInPro.Model
if (sh)
{
DockpaneRecogidaViewModel.Show();
- SetFlagTipEjec(TiposEjecucion.Reco);
+ //SetFlagTipEjec(TiposEjecucion.Reco);
ViewSetFlagTipEjec(TiposEjecucion.Reco);
diff --git a/Model/Recogida.cs b/Model/Recogida.cs
index d9c3d75..bfee6f4 100644
--- a/Model/Recogida.cs
+++ b/Model/Recogida.cs
@@ -155,5 +155,42 @@ namespace OliviaAddInPro.Model
//concatena el timestamp
carga = carga + shapefile.Substring(aux);
}
+
+ /**
+ * Restaura el nombre original del campo si se ha truncado a 10 car al exportar a shp
+ */
+ public override string[] GetCamposRestaura()
+ {
+ string[] camps = {
+ RecogidaDef.campos_def.cons_id,
+ RecogidaDef.campos_def.cons_nomrec,
+ RecogidaDef.campos_def.cons_lateral ,
+ RecogidaDef.campos_def.cons_fracc,
+ RecogidaDef.campos_def.cons_capac,
+ RecogidaDef.campos_def.cons_uds,
+ RecogidaDef.campos_def.cons_kgrec };
+ return camps;
+ }
+
+ /**
+ * Rellena el array de filtros en base a la config
+ */
+ public void RellenaFiltrosReco()
+ {
+ //se rellena el array de filtros
+ RecogidaDef.filtro_str = new string[RecogidaDef.tipos_fracc_str.Length + RecogidaDef.tipos_carg_str.Length];
+ for (int i = 0; i < RecogidaDef.tipos_fracc_str.Length; i++)
+ {
+ //se comprueba que tipo de fracción se ha seleccionado. Si se ha seleccionado una fracción sin nombre (el campo en la capa es NULL, y en el comboBox de fracciiones aparece como "-") hay que modificar el filtro
+ if (RecogidaDef.tipos_fracc_str[i] == "-")
+ RecogidaDef.filtro_str[i] = RecogidaDef.campos_def.cons_fracc + " IS NULL";
+ else
+ RecogidaDef.filtro_str[i] = RecogidaDef.campos_def.cons_fracc + "= '" + RecogidaDef.tipos_fracc_str[i] + "'";
+ }
+ for (int i = RecogidaDef.tipos_fracc_str.Length; i < RecogidaDef.filtro_str.Length; i++)
+ {
+ RecogidaDef.filtro_str[i] = RecogidaDef.campos_def.cons_nomrec + "= '" + RecogidaDef.tipos_carg_str[i - RecogidaDef.tipos_fracc_str.Length] + "'";
+ }
+ }
}
}
diff --git a/Model/TratamientoComun.cs b/Model/TratamientoComun.cs
index c902b02..f9d8308 100644
--- a/Model/TratamientoComun.cs
+++ b/Model/TratamientoComun.cs
@@ -9,6 +9,9 @@ using OliviaAddInPro.Helper;
using OliviaAddInPro.Model.contract;
using OliviaAddInPro.Services;
using static OliviaAddInPro.Model.ComunDef;
+using ArcGIS.Core.CIM;
+using ArcGIS.Core.Data;
+using System.Collections.ObjectModel;
namespace OliviaAddInPro.Model
{
@@ -191,5 +194,62 @@ namespace OliviaAddInPro.Model
tratamiento = string.Empty;
ambitos = string.Empty;
}
+ /**
+ * Restaura el nombre original del campo si se ha truncado a 10 car al exportar a shp
+ */
+ public virtual string[] GetCamposRestaura()
+ {
+ return null;
+ }
+
+ /**
+ * Restaura el nombre original del campo si se ha truncado a 10 car al exportar a shp
+ */
+ public Respuesta RestauraNomCampos(string nombFtClass)
+ {
+ int LENGTHCAMPSHP = 10;
+ Respuesta resp = new Respuesta { Value = false };
+ FeatureClass fc = HelperGdb.GetFtClassSync(nombFtClass);
+ if (fc == null)
+ return resp;
+ ////////////////////////////////////////////////////////
+ string[] camps = GetCamposRestaura();
+
+ ObservableCollection fields = HelperGdb.GetFieldsSync(fc);
+ HelperGdb.Free(fc);
+ if (fields == null)
+ return resp;
+ try
+ {
+ int i = 0;
+ int indx;
+ string campTrunc = string.Empty;
+ for (i = 0; i < camps.Length; i++)
+ {
+ if (camps[i].Length <= LENGTHCAMPSHP)
+ continue;
+ campTrunc = camps[i].Substring(0, LENGTHCAMPSHP);
+ //si tiene más de 10 caracteres, lo ha truncado al exportar
+ //busca el nombre actual del campo en la fc
+ indx = fields.IndexOf(campTrunc);
+ if (indx < 0)
+ break;
+ if (!HelperGdb.RenameFieldSync(nombFtClass, campTrunc, camps[i],camps[i]))
+ break;
+ }
+ if (i < camps.Length)
+ {
+ resp.Error.Add("Error en el campo " + camps[i]);
+ }
+ else
+ resp.Value = true;
+ }
+ catch
+ {
+
+ }
+
+ return resp;
+ }
}
}
diff --git a/OliviaAddInPro.csproj b/OliviaAddInPro.csproj
index afe5a47..e8f1d77 100644
--- a/OliviaAddInPro.csproj
+++ b/OliviaAddInPro.csproj
@@ -25,7 +25,7 @@
bin\Debug\
DEBUG;TRACE
prompt
- 4
+ 0
Program
$(ArcGISFolder)\bin\ArcGISPro.exe
x64
@@ -357,6 +357,9 @@
+
+
+