Termina ciclo sectorización en limpieza. Pendiente planificación y recogida.

Elena/develop
Elena 2022-06-11 14:00:56 +02:00
parent b4bdeed856
commit 828eff60c1
5 changed files with 105 additions and 146 deletions

View File

@ -2281,8 +2281,9 @@ namespace OliviaAddInPro.Helper
/** /**
* Abre en el mapa la capa seleccionada, con los parámetros seleccionados * Abre en el mapa la capa seleccionada, con los parámetros seleccionados
*/ */
public static bool OpenLayerUniqueValue(string ftclasspath, string campValUniq, bool visible=true) public static Respuesta<bool> OpenLayerUniqueValue(string ftclasspath, string campValUniq, bool visible = true)
{ {
var res = new Respuesta<bool> { Value = false };
var mapView = MapView.Active; var mapView = MapView.Active;
int indexNumber = mapView.Map.Layers.Count; int indexNumber = mapView.Map.Layers.Count;
string ftclassname = System.IO.Path.GetFileNameWithoutExtension(ftclasspath); string ftclassname = System.IO.Path.GetFileNameWithoutExtension(ftclasspath);
@ -2294,15 +2295,17 @@ namespace OliviaAddInPro.Helper
//mira el tipo de geometría //mira el tipo de geometría
GeometryType tipo = GetGeomType(ftclasspath); GeometryType tipo = GetGeomType(ftclasspath);
if (tipo == GeometryType.Unknown) if (tipo == GeometryType.Unknown)
return false; {
res.Error.Add("Tipo de geometría desconocido en la capa a importar");
return res;
}
var task = QueuedTask.Run(() => var task = QueuedTask.Run(() =>
{ {
Layer layer = null; Layer layer = null;
FeatureLayer selectedLayer = null; FeatureLayer selectedLayer = null;
try try
{ {
layer = mapView.Map.FindLayer(ftclass_uri.ToString()); layer = mapView.Map.FindLayers(ftclassname).FirstOrDefault();
selectedLayer = layer as FeatureLayer;
} }
catch catch
{ {
@ -2310,9 +2313,10 @@ namespace OliviaAddInPro.Helper
} }
if (layer == null) if (layer == null)
{ {
layer = LayerFactory.Instance.CreateLayer(ftclass_uri, mapView.Map, indexNumber, ftclassname); layer = LayerFactory.Instance.CreateLayer(ftclass_uri, mapView.Map, indexNumber, ftclassname);
selectedLayer = mapView.GetSelectedLayers()[0] as FeatureLayer; //selectedLayer = mapView.GetSelectedLayers()[0] as FeatureLayer;
} }
selectedLayer = layer as FeatureLayer;
//Do something with selected layer //Do something with selected layer
SetSimpleRendererPoint(selectedLayer, campValUniq, tipo); SetSimpleRendererPoint(selectedLayer, campValUniq, tipo);
selectedLayer.SetVisibility(visible); selectedLayer.SetVisibility(visible);
@ -2321,10 +2325,12 @@ namespace OliviaAddInPro.Helper
} }
catch catch
{ {
return false; res.Error.Add("Errores en creación de renderer para valor único");
return res;
} }
} }
return true; res.Value = true;
return res;
} }
/* /*
* Crea el renderer para la capa, dado un campo en el que fijarse y una simbología * Crea el renderer para la capa, dado un campo en el que fijarse y una simbología

View File

@ -26,6 +26,10 @@ namespace OliviaAddInPro.Model
* Capa de ámbitos * Capa de ámbitos
*/ */
public string CapaElems { get; set; } = string.Empty; public string CapaElems { get; set; } = string.Empty;
/**
* Capa de ámbitos después de haber planificado
*/
public string CapaPlanif { get; set; } = string.Empty;
/** /**
* Nombre dle shp exportado de datos * Nombre dle shp exportado de datos
*/ */

View File

@ -118,6 +118,18 @@ namespace OliviaAddInPro.Services
//Guarda el nombre //Guarda el nombre
OliviaGlob.Paths.PathData = OliviaGlob.Paths.DirData + com.NombreShpExport; OliviaGlob.Paths.PathData = OliviaGlob.Paths.DirData + com.NombreShpExport;
///////////////////////////////////////////////////////////////////////
//ahora si está en modo planificación y la capa no tiene esa columna, exporta la sectorización
if (modo==ModosEjec.Planifica && !string.IsNullOrEmpty(com.CapaPlanif))
{
if (!ActualizaSecto(OliviaGlob.Paths.PathData, com.CapaPlanif))
{
ErrStr = "Error al exportar campos de SECTOR y/o SECUENCIA de la capa " + com.CapaPlanif;
return false;
}
}
///////////////////////////////////////////////////////////////////////
///
com.ProgrSrc.IncMessage(10, "Preparando exportación de red navegable");//50% com.ProgrSrc.IncMessage(10, "Preparando exportación de red navegable");//50%
//hace intersecciones espaciales en caso de ámbitos lineales para quitar los que tienen más parte fuera de la zona que dentro //hace intersecciones espaciales en caso de ámbitos lineales para quitar los que tienen más parte fuera de la zona que dentro
@ -263,6 +275,13 @@ namespace OliviaAddInPro.Services
} }
return true; return true;
} }
/**
* Actualiza la capa dada añadiendo una columna de sector y una de secuencia
*/
public bool ActualizaSecto(string path_shp, string path_secto)
{
return false;
}
/** /**
* Prepara la geometría para exportar los ámbitos * Prepara la geometría para exportar los ámbitos
@ -362,12 +381,16 @@ namespace OliviaAddInPro.Services
*/ */
public bool CompruebaPlanif() public bool CompruebaPlanif()
{ {
//si ha importado no hace falta que compruebe, seguro que las tiene //comprueba capa
if (OliviaGlob.IsConfig2())
return true;
//no ha importado, comprueba capa
if (ComprCamposPlanif(com.CapaElems)) if (ComprCamposPlanif(com.CapaElems))
{
com.CapaPlanif = string.Empty;//reinicia para que coja la secto de la capa original
return true; return true;
}
//si ha importado seguro que las tiene
if (OliviaGlob.IsConfig2() && !string.IsNullOrEmpty(com.CapaPlanif))
return true;
return false; return false;
} }
@ -381,15 +404,17 @@ namespace OliviaAddInPro.Services
if (res.HasError || string.IsNullOrEmpty(res.Value)) if (res.HasError || string.IsNullOrEmpty(res.Value))
{ {
return res; return res;
} }
////////////////////////////////////////////////// //////////////////////////////////////////////////
//abre las capas, pintando los sectores //abre las capas, pintando los sectores
bool mal = false; bool mal = false;
string path_import = res.Value; string path_import = res.Value;
//abre con valor único
string path_lyr = path_import; string path_lyr = path_import;
if(HelperGdb.OpenLayerUniqueValue(path_lyr, LimpiezaDef.Campos.consulta_sector)) var resb = HelperGdb.OpenLayerUniqueValue(path_lyr, LimpiezaDef.Campos.consulta_sector);
if (!resb.Value)
{ {
res.Error.Add("Error al abrir capa "+ path_lyr + " con Valor único."); res.Error.Add("Error al abrir capa "+ path_lyr + " con Valor único. " + resb.Error.FirstOrDefault());
res.Value = string.Empty; res.Value = string.Empty;
mal = true; mal = true;
} }
@ -397,6 +422,56 @@ namespace OliviaAddInPro.Services
res.Value = path_import; res.Value = path_import;
return res; return res;
} }
/**
* Realiza las funciones de importación de la planificación
*/
public Respuesta<string> ImportPlanif(string GdbFileName)
{
var res = Import(GdbFileName, 1);
if (res.HasError || string.IsNullOrEmpty(res.Value))
{
res.Value = string.Empty;
return res;
}
//////////////////////////////////////////////////
//abre las capas, pintando los sectores
string path_import = res.Value;
int NOPEN = 6;
string[] path_lyr_arr = new string[NOPEN];
//la primera capa que se añade es la de ruta, se le quita la visualización porque lo que interesa
//de esa capa es poder acceder si fuera necesario a la tabla de atributos. shape + name_ruta_out
path_lyr_arr[0]= path_import + NAME_RUTA_OUT;
//la siguiente es la de ruta2, se le quita la visualización porque lo que interesa
//de esa capa es poder acceder si fuera necesario a la tabla de atributos. shape + name_ruta2_out
path_lyr_arr[1] = path_import + NAME_RUTA2_OUT;
//se añade la capa de ruta_aux y se pinta por sectores - shape + name_ruta_out + name_aux
path_lyr_arr[2] = path_import + NAME_RUTA_OUT + NAME_AUX;
//se añade la capa de ambitos original con la secto, y se pinta por sectores - shape
path_lyr_arr[3] = path_import;
//se añade la capa de la ruta a las instalaciones, comprueba si hay configurada coordenadas de la instalación - shape + name_inst_out
path_lyr_arr[4] = path_import + NAME_INSTAL_OUT;
//se abre la capa de puntos de control y se pintan por el sector al que pertenecen - shape + name_control_out
path_lyr_arr[5] = path_import + NAME_CONTROL_OUT;
bool[] visible_arr = {false,false,true,true,false,false };
int i;
var resb = new Respuesta<bool>();
for(i =0;i<NOPEN;i++)
{
resb = HelperGdb.OpenLayerUniqueValue(path_lyr_arr[i], LimpiezaDef.Campos.consulta_sector, visible_arr[i]);
if (!resb.Value)
break;
}
if(i<NOPEN)
{
res.Value = string.Empty;
res.Error.Add("Error al abrir capa " + path_lyr_arr[i] + " con Valor único. "+resb.Error.FirstOrDefault() );
}
else
{
res.Value = path_import;
}
return res;
}
/** /**
* Realiza las funciones de importación, modo 0 secto, modo 1 planif * Realiza las funciones de importación, modo 0 secto, modo 1 planif
*/ */
@ -453,9 +528,9 @@ namespace OliviaAddInPro.Services
tratamiento = datasetNameOut; tratamiento = datasetNameOut;
} }
string dataset = tratamiento; string dataset = tratamiento;
//NO hace falta preguntar ni comprobar el ftclass porque pone el timestamp y el nombre es único
/* /*
* //YA NO hace falta preguntar ni comprobar el ftclass porque pone el timestamp y el nombre es único
///////////////////////////////////////// /////////////////////////////////////////
//pregunta a ver si se quiere ese nombre u otro //pregunta a ver si se quiere ese nombre u otro
bool replace = false; bool replace = false;
@ -498,7 +573,7 @@ namespace OliviaAddInPro.Services
///////////////////////////////////////// /////////////////////////////////////////
//todo ok, se pone a importar //todo ok, se pone a importar
string err_st=string.Empty; string err_st =string.Empty;
string name = ambitos; string name = ambitos;
string path_import = GdbFileName + "\\" + dataset + "\\" + ambitos; string path_import = GdbFileName + "\\" + dataset + "\\" + ambitos;
int NIMPORT; int NIMPORT;
@ -601,81 +676,7 @@ namespace OliviaAddInPro.Services
} }
res.Value = path_import; res.Value = path_import;
return res; return res;
} }
/**
* Realiza las funciones de importación de la planificación
*/
public Respuesta<string> ImportPlanif(string GdbFileName)
{
var res = Import(GdbFileName, 1);
if (res.HasError || string.IsNullOrEmpty(res.Value))
{
res.Value = string.Empty;
return res;
}
//////////////////////////////////////////////////
//abre las capas, pintando los sectores
string path_import = res.Value;
/////////////////////////////////////////////////////
//la primera capa que se añade es la de ruta, se le quita la visualización porque lo que interesa
//de esa capa es poder acceder si fuera necesario a la tabla de atributos. shape + name_ruta_out
bool mal = false;
string path_lyr = path_import + NAME_RUTA_OUT;
if (!HelperGdb.OpenLayerUniqueValue(path_lyr, LimpiezaDef.Campos.consulta_sector,false))
mal = true;
/////////////////////////////////////////////////////
//la siguiente es la de ruta2, se le quita la visualización porque lo que interesa
//de esa capa es poder acceder si fuera necesario a la tabla de atributos. shape + name_ruta2_out
if (!mal)
{
path_lyr = path_import + NAME_RUTA2_OUT;
if (!HelperGdb.OpenLayerUniqueValue(path_lyr, LimpiezaDef.Campos.consulta_sector, false))
mal = true;
}
/////////////////////////////////////////////////////
//se añade la capa de ruta_aux y se pinta por sectores - shape + name_ruta_out + name_aux
if (!mal)
{
path_lyr = path_import + NAME_RUTA_OUT + NAME_AUX;
if (!HelperGdb.OpenLayerUniqueValue(path_lyr, LimpiezaDef.Campos.consulta_sector, false))
mal = true;
}
/////////////////////////////////////////////////////
//se añade la capa de ambitos original con la secto, y se pinta por sectores - shape
if (!mal)
{
path_lyr = path_import;
if (!HelperGdb.OpenLayerUniqueValue(path_lyr, LimpiezaDef.Campos.consulta_sector, false))
mal = true;
}
/////////////////////////////////////////////////////
//se añade la capa de la ruta a las instalaciones, comprueba si hay configurada coordenadas de la instalación - shape + name_inst_out
if (!mal)
{
path_lyr = path_import + NAME_INSTAL_OUT;
if (!HelperGdb.OpenLayerUniqueValue(path_lyr, LimpiezaDef.Campos.consulta_sector, false))
mal = true;
}
//se abre la capa de puntos de control y se pintan por el sector al que pertenecen - shape + name_control_out
if (!mal)
{
path_lyr = path_import + NAME_CONTROL_OUT;
if (!HelperGdb.OpenLayerUniqueValue(path_lyr, LimpiezaDef.Campos.consulta_sector, false))
mal = true;
}
/////////////////////////////////////////////////////
if (mal)
{
res.Value = string.Empty;
res.Error.Add("Error al abrir capa " + path_lyr + " con Valor único.");
}
else
{
res.Value = path_import;
}
return res;
}
/** /**
* Cierra del mapa las capas de trabajo después de la exportación * Cierra del mapa las capas de trabajo después de la exportación

View File

@ -14,53 +14,6 @@ namespace OliviaAddInPro.Services
{ {
public void finEjecuta(Respuesta<TiposEjecucion> res, TratamientoComun inst) public void finEjecuta(Respuesta<TiposEjecucion> res, TratamientoComun inst)
{ {
//REVISAR CUANDO ACABA, SE CAMBIE EL MARCHANDO PARA QUE SE LE DE A FINALIZAR Y TERMINA OK
/*String msg=string.Empty;
//gestiona los flags, el estado de finok o finnok va en res.Vale
if (res.HasError)
{
msg = res.Error.First();
//actualiza los flags
OliviaGlob.RemoveFlagTipEjec(TiposEjecucion.FinEjecNOk);
}
else
{
//actualiza los flags
OliviaGlob.RemoveFlagTipEjec(TiposEjecucion.FinEjecOk);
//importa resultados
var resp = IniImport();
if (resp.HasError)
msg = resp.Error.First();
else
{
string GdbFileName = resp.Value;
var resp2 = new Respuesta<bool> { Value=false};
if (OliviaGlob.HasFlagTipEjec(TiposEjecucion.EjecSecto)) //Ha terminado bien la sectorización
{
resp2 = inst.ServCom.ImportSecto(GdbFileName);
}
else if (OliviaGlob.HasFlagTipEjec(TiposEjecucion.EjecPlanif)) //Ha terminado bien la planificación
{
GuardaCsv(inst);
resp2 = inst.ServCom.ImportPlanif(GdbFileName);
}
if (!resp2.Value)
{
msg = resp2.Error.First();
}
else
{
msg = Resource1.String_exito;
//pone modo config2
OliviaGlob.AddFlagTipEjec(TiposEjecucion.Config2);
}
}
}
//borra los archivos que le toca borrar
BorraFiles();
HelperGlobal.ponMsg(msg);
//Application.Current.Dispatcher.Invoke(new Action<Respuesta<TiposEjecucion>, TratamientoComun>(((p, v)) => { finEjecuta2(p, v); }));*/
Application.Current.Dispatcher.BeginInvoke(new Action<Respuesta<TiposEjecucion>, TratamientoComun>((p, v) => finEjecuta2(p, v)),res,inst); Application.Current.Dispatcher.BeginInvoke(new Action<Respuesta<TiposEjecucion>, TratamientoComun>((p, v) => finEjecuta2(p, v)),res,inst);
//borra los archivos que le toca borrar //borra los archivos que le toca borrar
@ -172,8 +125,6 @@ namespace OliviaAddInPro.Services
bool mal = false; bool mal = false;
try try
{ {
//gestiona los flags, el estado de finok o finnok va en res.Vale //gestiona los flags, el estado de finok o finnok va en res.Vale
if (res.HasError) if (res.HasError)
{ {
@ -270,7 +221,7 @@ namespace OliviaAddInPro.Services
//pone modo config2 //pone modo config2
OliviaGlob.AddFlagTipEjec(TiposEjecucion.Config2); OliviaGlob.AddFlagTipEjec(TiposEjecucion.Config2);
//actualiza la capa de la que tiene que leer ahora para planificar //actualiza la capa de la que tiene que leer ahora para planificar
inst.CapaElems = resp.Value; inst.CapaPlanif = resp2.Value;
} }
} }
catch (Exception ex) catch (Exception ex)
@ -297,9 +248,6 @@ namespace OliviaAddInPro.Services
//borra los archivos que le toca borrar //borra los archivos que le toca borrar
BorraFiles(); BorraFiles();
}); });
//task.Wait();
//borra los archivos que le toca borrar
//BorraFiles();
} }
/** /**
* Borra los archivos exportados para el proceso * Borra los archivos exportados para el proceso

View File

@ -109,7 +109,7 @@ namespace OliviaAddInPro.Services
{ {
//NO SE USA AQUÍ, ESTÁ EN EJECSERV //NO SE USA AQUÍ, ESTÁ EN EJECSERV
//si ha importado no hace falta que compruebe, seguro que las tiene //si ha importado no hace falta que compruebe, seguro que las tiene
if (OliviaGlob.IsConfig2()) if (OliviaGlob.IsConfig2() && ComprCamposPlanif(limp.CapaPlanif))
return true; return true;
//no ha importado, comprueba capa //no ha importado, comprueba capa
if (ComprCamposPlanif(limp.CapaElems)) if (ComprCamposPlanif(limp.CapaElems))