Merge branch 'develop' into Gerardo/AñadirPinvoke

ConfiguracionSimplificada
Gerardo 2022-02-06 12:26:35 +01:00
commit 56473824df
7 changed files with 256 additions and 102 deletions

View File

@ -263,18 +263,19 @@ namespace OliviaAddInPro.Helper
} }
//Abre una feature class cuando es un shapefile //Abre una feature class cuando es un shapefile
public static Task<FeatureClass> GetFtClassFromShp(string pathShp) public static async Task<FeatureClass> GetFtClassFromShp(string pathShp)
{ {
FeatureClass ftclss = null; FeatureClass ftclss = null;
ReiniciaOutStr(); ReiniciaOutStr();
return ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run((Func<FeatureClass>)(() => return await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run((Func<FeatureClass>)(() =>
{ {
if (pathShp.Contains(SHP_EXT)) if (pathShp.Contains(SHP_EXT))
{ {
try try
{ {
string shpname = System.IO.Path.GetFileNameWithoutExtension(pathShp); string shpname = System.IO.Path.GetFileNameWithoutExtension(pathShp);
var shapeFileConnPath = new FileSystemConnectionPath(new Uri(pathShp), FileSystemDatastoreType.Shapefile); var shapeFileConnPath = new FileSystemConnectionPath(new Uri(System.IO.Path.GetDirectoryName(pathShp)),
FileSystemDatastoreType.Shapefile);
var shapefile = new FileSystemDatastore(shapeFileConnPath); var shapefile = new FileSystemDatastore(shapeFileConnPath);
ftclss = shapefile.OpenDataset<FeatureClass>(shpname); ftclss = shapefile.OpenDataset<FeatureClass>(shpname);
} }
@ -311,9 +312,9 @@ namespace OliviaAddInPro.Helper
} }
//Crea un filtro espacial a partir de una consulta y en todo caso, una geometría //Crea un filtro espacial a partir de una consulta y en todo caso, una geometría
public static ArcGIS.Core.Data.QueryFilter CreateFiler(string consulta, ArcGIS.Core.Geometry.Geometry geom, SpatialRelationship rel= SpatialRelationship.Intersects) public static ArcGIS.Core.Data.SpatialQueryFilter CreateFiler(string consulta, ArcGIS.Core.Geometry.Geometry geom, SpatialRelationship rel= SpatialRelationship.Intersects)
{ {
ArcGIS.Core.Data.QueryFilter filt=null; ArcGIS.Core.Data.SpatialQueryFilter filt =null;
if (geom != null) if (geom != null)
{ {
SpatialQueryFilter filtSpat = new SpatialQueryFilter SpatialQueryFilter filtSpat = new SpatialQueryFilter
@ -322,12 +323,12 @@ namespace OliviaAddInPro.Helper
FilterGeometry = geom, FilterGeometry = geom,
SpatialRelationship = rel, SpatialRelationship = rel,
}; };
filt = (ArcGIS.Core.Data.QueryFilter)filtSpat; filt = filtSpat;
} }
else else
{ {
filt = new ArcGIS.Core.Data.QueryFilter(); filt = new ArcGIS.Core.Data.SpatialQueryFilter();
filt.WhereClause = consulta; filt.WhereClause = consulta;
} }
return filt; return filt;
@ -547,13 +548,13 @@ namespace OliviaAddInPro.Helper
* Forma la envolvente convexa, el mínimo polígono, * 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 * que contiene los ámbitos para exportar, a partir de ahí la red navegable ampliando a un buffer
*/ */
public static Task<ArcGIS.Core.Geometry.Geometry> GetGeomConvexHull(FeatureClass fclss, ArcGIS.Core.Data.QueryFilter filter, CancelableProgressorSource cps) public static Task<ArcGIS.Core.Geometry.Geometry> GetGeomConvexHull(FeatureClass fclss, ArcGIS.Core.Data.QueryFilter filter, CancelableProgressorSource cps=null)
{ {
ArcGIS.Core.Geometry.Geometry geomIni = null; ArcGIS.Core.Geometry.Geometry geomIni = null;
return ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run((Func<ArcGIS.Core.Geometry.Geometry>)(() => return ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run((Func<ArcGIS.Core.Geometry.Geometry>)(() =>
{ {
geomIni = GetGeomUnica(fclss, filter, cps); geomIni = GetGeomUnique(fclss, filter, cps);
if (geomIni != null) if (geomIni != null)
{ {
ArcGIS.Core.Geometry.Geometry geomSal = null; ArcGIS.Core.Geometry.Geometry geomSal = null;
@ -575,7 +576,7 @@ namespace OliviaAddInPro.Helper
/* /*
* A partir de una capa recorre todos los elementos que cumplen el filtro y los une en una única geometría * 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, CancelableProgressorSource cps) public static ArcGIS.Core.Geometry.Geometry GetGeomUnique(FeatureClass fclss, ArcGIS.Core.Data.QueryFilter filtro, CancelableProgressorSource cps)
{ {
ArcGIS.Core.Geometry.Geometry geomsal = null; ArcGIS.Core.Geometry.Geometry geomsal = null;
ReiniciaOutStr(); ReiniciaOutStr();
@ -635,7 +636,7 @@ namespace OliviaAddInPro.Helper
{ {
where = $"{fieldName} = {Quote(f)}{selFieldVals[i]}{Quote(f)}"; where = $"{fieldName} = {Quote(f)}{selFieldVals[i]}{Quote(f)}";
filtro = new ArcGIS.Core.Data.QueryFilter { WhereClause = where }; filtro = new ArcGIS.Core.Data.QueryFilter { WhereClause = where };
geomAux = GetGeomUnica(fclss, filtro, null); geomAux = GetGeomUnique(fclss, filtro, null);
if(geomAux == null) if(geomAux == null)
{ {
ok = false; ok = false;
@ -824,7 +825,7 @@ namespace OliviaAddInPro.Helper
//Selection selFeatures = featureClass.Select(filter, SelectionType.ObjectID, SelectionOption.Normal); //Selection selFeatures = featureClass.Select(filter, SelectionType.ObjectID, SelectionOption.Normal);
// make a value array of strings to be passed to ExecuteToolAsync // make a value array of strings to be passed to ExecuteToolAsync
/*
System.Threading.CancellationTokenSource _cts1 = new System.Threading.CancellationTokenSource(); System.Threading.CancellationTokenSource _cts1 = new System.Threading.CancellationTokenSource();
cps.Status = "Guardando geometria a shp"; cps.Status = "Guardando geometria a shp";
@ -862,17 +863,14 @@ namespace OliviaAddInPro.Helper
*/
System.Threading.CancellationTokenSource _cts= new System.Threading.CancellationTokenSource();
cps.Status = "Guardando geometria a shp"; cps.Status = "Guardando geometria a shp";
var progSrc = new CancelableProgressorSource(); //var progSrc = new CancelableProgressorSource();
string[] args = { pathLayerIn, outpath }; string[] args = { pathLayerIn, outpath };
// execute the tool // execute the tool
IGPResult gpResult = Geoprocessing.ExecuteToolAsync("FeatureClassToShapefile_conversion", args, IGPResult gpResult = Geoprocessing.ExecuteToolAsync("FeatureClassToShapefile_conversion", args,
null, _cts.Token, null, cps.CancellationTokenSource.Token,
(event_name, o) => // implement delegate and handle events (event_name, o) => // implement delegate and handle events
{ {
@ -931,6 +929,83 @@ namespace OliviaAddInPro.Helper
return true; return true;
} }
/**
* Comprueba si un punto está contenido en un polígono
*/
public static Respuesta<bool> IsPtoInGeom(Coordinate2D pto, ArcGIS.Core.Geometry.Geometry geom)
{
Respuesta<bool> resp=new Respuesta<bool>();
try
{
ArcGIS.Core.Geometry.Geometry geom_convexhull = GeometryEngine.Instance.ConvexHull(geom);
ArcGIS.Core.Geometry.Polygon poli = (ArcGIS.Core.Geometry.Polygon)geom_convexhull;
bool contains = GeometryEngine.Instance.Contains(poli, pto.ToMapPoint());
resp.Value = contains;
return resp;
}
catch
{
resp.Value = false;
resp.Error.Add("Error al comprobar si punto está contenido en polígono");
return resp;
}
}
/**Amplía la geometría para que incluya el punto
*/
public static Respuesta<ArcGIS.Core.Geometry.Geometry> AddPtoInGeom(Coordinate2D pto, ArcGIS.Core.Geometry.Geometry geom)
{
Respuesta<ArcGIS.Core.Geometry.Geometry> resp = new Respuesta<ArcGIS.Core.Geometry.Geometry>();
double buffer = 100;//m de distancia desde la instalación
try
{
ArcGIS.Core.Geometry.Geometry geom_pto = GeometryEngine.Instance.Buffer(pto.ToMapPoint(), buffer);
if(geom_pto==null || geom_pto.IsEmpty)
{
resp.Value = null;
resp.Error.Add("Error al bufferear punto para incluirlo en polígono");
return resp;
}
ArcGIS.Core.Geometry.Geometry geom_sal = GeometryEngine.Instance.Union(geom_pto, geom);
if (geom_sal == null || geom_sal.IsEmpty)
{
resp.Value = null;
resp.Error.Add("Error al unir punto a polígono");
return resp;
}
resp.Value = geom_sal;
return resp;
}
catch
{
resp.Value = null;
resp.Error.Add("Error al incluir punto en polígono");
return resp;
}
}
/*
* Dada una lista de ids de elemento, crea una consulta en la que se llama a todos esos elementos
*/
public static string GetWhereClauseFromIds(List<long> ids)
{
string consulta, orstr;
consulta = string.Empty;
orstr = string.Empty;
var n = ids.Count;
for (int i = 0; i < n; i++)
{
consulta = consulta + orstr + "(" + RecogidaDef.campos.cons_id + "=" + ids.ElementAt(i) + ")";
if (String.IsNullOrEmpty(orstr))
orstr = " OR ";
}
if (consulta == "()")
consulta = string.Empty;
return consulta;
}
/** /**
* Elimina las filas indicadas del shp * Elimina las filas indicadas del shp
**/ **/
@ -940,6 +1015,11 @@ namespace OliviaAddInPro.Helper
if (fc == null) if (fc == null)
return false; return false;
//Crea la consulta
var consulta = GetWhereClauseFromIds(quita);
if (String.IsNullOrEmpty(consulta))
return false;
string message = String.Empty; string message = String.Empty;
bool deletionResult = false; bool deletionResult = false;
@ -952,7 +1032,7 @@ namespace OliviaAddInPro.Helper
EditOperation editOperation = new EditOperation(); EditOperation editOperation = new EditOperation();
editOperation.Callback(context => editOperation.Callback(context =>
{ {
ArcGIS.Core.Data.QueryFilter openCutFilter = new ArcGIS.Core.Data.QueryFilter { WhereClause = "ACTION = 'Open Cut'" }; ArcGIS.Core.Data.QueryFilter openCutFilter = new ArcGIS.Core.Data.QueryFilter { WhereClause = consulta };
using (RowCursor rowCursor = table.Search(openCutFilter, false)) using (RowCursor rowCursor = table.Search(openCutFilter, false))
{ {

View File

@ -26,6 +26,10 @@ namespace OliviaAddInPro.Model
* Nombre dle shp exportado de datos * Nombre dle shp exportado de datos
*/ */
public string NombreShpExport { get; set; } = string.Empty; public string NombreShpExport { get; set; } = string.Empty;
/**
* Nombre dle shp exportado de datos
*/
public string NombreShpExp_PrefTto { get; set; } = string.Empty;
/** /**
* Nombre dle shp exportado de nw * Nombre dle shp exportado de nw
*/ */

View File

@ -24,7 +24,7 @@ namespace OliviaAddInPro.Services
//Cadenas de nombres internos para la exportación/importación de los archivos //Cadenas de nombres internos para la exportación/importación de los archivos
public string prefNameExport = "data_"; public string prefNameExport = "data_";
public string extShp = ".shp"; public string extShp = ".shp";
public string name_export_nw = "nw_"; public string prefNameExportNw = "nw_";
public string ErrStr = ""; public string ErrStr = "";
SpatialQueryFilter filtroEspacial = null; SpatialQueryFilter filtroEspacial = null;
@ -35,67 +35,80 @@ namespace OliviaAddInPro.Services
* Modo 0, sectorizar * Modo 0, sectorizar
* Modo 1, planificar * Modo 1, planificar
*/ */
public bool ComienzaEjec(ModosEjec modo, CancelableProgressorSource cps, out string ErrStr) public bool LanzaEjec(ModosEjec modo, CancelableProgressorSource cps, out string ErrStr)
{ {
bool fue_mal = false;
ErrStr = string.Empty; ErrStr = string.Empty;
FeatureClass fc = null;
try
{
//Cuenta las filas que cumplen la consulta //Cuenta las filas que cumplen la consulta
int nelems = HelperGdb.GetNumElems(com.CapaElems, com.ConsultaAmbs); int nelems = HelperGdb.GetNumElems(com.CapaElems, com.ConsultaAmbs);
if (nelems <= 0) if (nelems <= 0)
{ {
ErrStr = "No existen ámbitos que cumplan las condiciones introducidas para la exportación " + com.ConsultaAmbs; ErrStr = "No existen ámbitos que cumplan las condiciones introducidas para la exportación " + com.ConsultaAmbs;
fue_mal = true; return false;
} }
cps.Status = "Exportando geometria"; cps.Status = "Exportando geometria";
//Obtiene la geometría que envuelve a los ámbitos //Obtiene la geometría que envuelve a los ámbitos
Geometry geom_export = null; Geometry geom_export = null;
if (!fue_mal)
{
geom_export = GetGeomAmbitsExport(cps); geom_export = GetGeomAmbitsExport(cps);
if (geom_export == null || geom_export.IsEmpty) if (geom_export == null || geom_export.IsEmpty)
{ {
ErrStr = "No se ha podido generar geometría de los ámbitos" + com.ConsultaAmbs + ErrStr; ErrStr = "No se ha podido generar geometría de los ámbitos" + com.ConsultaAmbs + ErrStr;
fue_mal = true; return false;
}
} }
//crea el filtro de exportación //crea el filtro de exportación
if (!fue_mal)
{
//mira spatialreference de los datos de entrada //mira spatialreference de los datos de entrada
spatRef = geom_export.SpatialReference; spatRef = geom_export.SpatialReference;
filtroEspacial = (SpatialQueryFilter) HelperGdb.CreateFiler(com.ConsultaAmbs, geom_export); filtroEspacial = HelperGdb.CreateFiler(com.ConsultaAmbs, geom_export);
fue_mal = filtroEspacial == null; if (filtroEspacial == null)
if (fue_mal)
ErrStr = "Error al crear el filtro de exportacion";
if (!fue_mal)
fue_mal = Exporta(modo, cps, out ErrStr);
if (!fue_mal)
{ {
ErrStr = "Error al crear el filtro de exportacion de los ámbitos";
return false;
}
//Termina de preparar nombre
//Prepara nombre
string fechaHora = string.Empty;
//se consigue el tiempo en este instante para añadirlo a los nombres de los archivos de salida (shapefiles)
fechaHora = DateTime.Now.ToString("yyyyMMdd_Hmmss");
//Pone nombre al shape en función de los ámbitos, el tratamiento, y los polígonos + timestamp
com.NombreShpExport = prefNameExport + com.NombreShpExp_PrefTto +"_" + fechaHora + extShp;
//exporta los datos de entrada
if (!HelperGdb.ExportShp(com.CapaElems, filtroEspacial, com.NombreShpExport, OliviaGlob.Paths.DirData, cps, out ErrStr))
{
ErrStr = ErrStr+"Error al exportar los ámbitos";
return false;
}
//Guarda el nombre //Guarda el nombre
OliviaGlob.Paths.PathData = OliviaGlob.Paths.DirData + com.NombreShpExport; OliviaGlob.Paths.PathData = OliviaGlob.Paths.DirData + com.NombreShpExport;
} if(cps.CancellationTokenSource.IsCancellationRequested)
{
ErrStr = "Se ha cancelado la operación";
return false;
} }
cps.Value = 80; cps.Value = 80;
if (!fue_mal)
{
//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
if (geom_export != null && if (((com.GeomNiv != null) || (com.GeomZon!=null)) &&
(OliviaGlob.IsReco() || (OliviaGlob.IsLimp() && (com.TipoTto < (int)LimpiezaDef.TiposTto.TtoPapeVaci)))) (OliviaGlob.IsReco() || (OliviaGlob.IsLimp() && (com.TipoTto < (int)LimpiezaDef.TiposTto.TtoPapeVaci))))
{ {
if (!HelperGdb.RemoveRowsGeom(OliviaGlob.Paths.PathData, geom_export, 0.4)) if (!HelperGdb.RemoveRowsGeom(OliviaGlob.Paths.PathData, geom_export, 0.4))
{ {
ErrStr = "Error al quitar los ámbitos que sobresalen: "+HelperGdb.OutStr; ErrStr = "Error al quitar los ámbitos que sobresalen: " + HelperGdb.OutStr;
return false; return false;
} }
} }
}
//comprueba que no se haya quedado sin ámbitos //comprueba que no se haya quedado sin ámbitos
using (FeatureClass fc = HelperGdb.GetFtClassFromShp(OliviaGlob.Paths.PathData).Result) fc = HelperGdb.GetFtClassFromShp(OliviaGlob.Paths.PathData).Result;
if (fc==null)
{ {
if (fc.GetCount() <= 0) ErrStr = HelperGdb.OutStr;
return false;
}
if(fc.GetCount() <= 0)
{ {
ErrStr = "No quedan ámbitos que cumplan la geometría seleccionada."; ErrStr = "No quedan ámbitos que cumplan la geometría seleccionada.";
return false; return false;
@ -104,30 +117,94 @@ namespace OliviaAddInPro.Services
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
//amplia la geom para englobar las instalaciones //amplia la geom para englobar las instalaciones
geom_export = HelperGdb.GetGeomConvexHull(fc, null, cps).Result; geom_export = HelperGdb.GetGeomConvexHull(fc, null, cps).Result;
/*if (limp.coords_instala[0] != 0 && limp.coords_instala[1] != 0) if (!com.CoordsInstal.IsEmpty && (com.CoordsInstal.X!=0))
{ {
//hay instalación //hay instalación
if (!FunGDB.is_pto_in_geom(limp.coords_instala[0], limp.coords_instala[1], geom_ambits)) Respuesta<bool> resp;
geom_ambits = FunGDB.amplia_geom_convexhull(geom_ambits, limp.coords_instala[0], limp.coords_instala[1]);
//comprueba, si hay restricciones de circulación, que la instalación no está en ellas //comprueba, si hay restricciones de circulación, que la instalación no está en ellas
if (limp.geom_rest_acces != null) if (com.GeomRestr != null)
{ {
if (FunGDB.is_pto_in_geom(limp.coords_instala[0], limp.coords_instala[1], limp.geom_rest_acces)) resp = HelperGdb.IsPtoInGeom(com.CoordsInstal, com.GeomRestr);
if (!resp.Value)
{ {
err_st = "Error, la instalación sal/lleg está en la zona restringida a la circulación"; if (resp.HasError)
ErrStr = "Error al comprobar si la instalación está contenida en el polígono de restricciones: " + resp.Error.ElementAt(0);
else
ErrStr = "Error, la instalación está en la zona restringida a la circulación ";
return false; return false;
} }
} }
}*/
//comprueba si la geometría de exportación contiene a la instalación
resp = HelperGdb.IsPtoInGeom(com.CoordsInstal, geom_export);
if (!resp.Value)
{
//ha ido mal
if (resp.HasError)
{
ErrStr = "Error al comprobar si la instalación está contenida en el polígono de exportación: " + resp.Error.ElementAt(0);
return false;
}
else
{
//amplía la geom
Respuesta<ArcGIS.Core.Geometry.Geometry> respGeom = HelperGdb.AddPtoInGeom(com.CoordsInstal, geom_export);
if (respGeom.Value == null)
{
//ha ido mal
if (resp.HasError)
ErrStr = resp.Error.ElementAt(0);
else
ErrStr = "Error al incluir punto de instalación en polígono de exportación.";
return false;
}
//actualiza la geometría
geom_export = respGeom.Value;
}
}
}
if (cps.CancellationTokenSource.IsCancellationRequested)
{
ErrStr = "Se ha cancelado la operación";
return false;
} }
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
//exporta la red navegable (buffer, le quita las restr...) //exporta la red navegable (buffer, le quita las restr...)
filtroEspacial = HelperGdb.CreateFiler(String.Empty, geom_export);
if (filtroEspacial == null)
{
ErrStr = "Error al crear el filtro de exportacion de la red navegable";
return false;
}
//Prepara naombre de exportación
com.NombreShpExportNw = prefNameExportNw + fechaHora + extShp;
//exporta los datos de entrada
string capaNw =System.IO.Path.Combine(OliviaGlob.Paths.PathGdbNw, OliviaGlob.Capas.ftclass_ejes);
if (!HelperGdb.ExportShp(capaNw, filtroEspacial, com.NombreShpExportNw, OliviaGlob.Paths.DirData, cps, out ErrStr))
{
ErrStr = ErrStr + "Error al exportar la red navegable";
return false;
}
//guarda los nombres del shape //guarda los nombres del shape
OliviaGlob.Paths.PathNW = OliviaGlob.Paths.DirData + com.NombreShpExportNw; OliviaGlob.Paths.PathNW = OliviaGlob.Paths.DirData + com.NombreShpExportNw;
return fue_mal; if (cps.CancellationTokenSource.IsCancellationRequested)
{
ErrStr = "Se ha cancelado la operación";
return false;
}
}
catch (Exception ex)
{
ErrStr = "Errores al comenzar la ejecución: " + ex.Message;
return false;
}
finally
{
HelperGdb.Free(fc);
}
return true;
} }
/** /**
@ -171,7 +248,7 @@ namespace OliviaAddInPro.Services
cps.Value = 30; cps.Value = 30;
//prepara el filtro con consulta y espacial //prepara el filtro con consulta y espacial
SpatialQueryFilter filtro = (SpatialQueryFilter)HelperGdb.CreateFiler(com.ConsultaAmbs, geomAux); SpatialQueryFilter filtro = HelperGdb.CreateFiler(com.ConsultaAmbs, geomAux);
//Ahora hace la geometría de los ámbitos que cumplen la consulta //Ahora hace la geometría de los ámbitos que cumplen la consulta
geomAmbits = HelperGdb.GetGeomConvexHull(fc, filtro, cps).Result; geomAmbits = HelperGdb.GetGeomConvexHull(fc, filtro, cps).Result;
@ -214,15 +291,6 @@ namespace OliviaAddInPro.Services
return str; return str;
} }
/**
* Exporta y lanza proceso y ventana de proceso
*/
public bool Exporta(ModosEjec modo, CancelableProgressorSource cps, out string msg)
{
msg = "";
//exporta los datos de entrada
return HelperGdb.ExportShp(com.CapaElems, filtroEspacial, com.NombreShpExport, OliviaGlob.Paths.DirData, cps, out msg);
}
/* /*
* Lee la capa que se ha seleccionzdo de recogida y se comprueba que contiene los campos necesarios * Lee la capa que se ha seleccionzdo de recogida y se comprueba que contiene los campos necesarios
* Devuelve 0 si va todo bien, -1 si da error, y num>0 con los campos que no encuentra * Devuelve 0 si va todo bien, -1 si da error, y num>0 con los campos que no encuentra

View File

@ -47,18 +47,14 @@ namespace OliviaAddInPro.Services
res.Errores = true; res.Errores = true;
return res; return res;
} }
cps.Value = 10; cps.Value = 5;
//Prepara nombre //Prepara nombre
string fechaHora = string.Empty; limp.NombreShpExp_PrefTto = "T" + limp.TipoTto.ToString("00") + nombFileAmbs + DameStrPoligs();
//se consigue el tiempo en este instante para añadirlo a los nombres de los archivos de salida (shapefiles)
fechaHora = DateTime.Now.ToString("yyyyMMdd_Hmmss");
//Pone nombre al shape en función de los ámbitos, el tratamiento, y los polígonos + timestamp
limp.NombreShpExport = prefNameExport + "T" + limp.TipoTto.ToString("00") + nombFileAmbs + DameStrPoligs() + "_" + fechaHora + extShp;
string msg = ""; string msg = "";
//comienza ejecucion //comienza ejecucion
if(!ComienzaEjec(ModosEjec.Sectoriza, cps, out msg)) if(!LanzaEjec(ModosEjec.Sectoriza, cps, out msg))
{ {
res.Errores = true; res.Errores = true;
res.msg = msg; res.msg = msg;

View File

@ -84,15 +84,13 @@ namespace OliviaAddInPro.Services
cps.Value = 10; cps.Value = 10;
//Prepara nombre //Prepara nombre
string fechaHora = string.Empty;
//se consigue el tiempo en este instante para añadirlo a los nombres de los archivos de salida (shapefiles)
fechaHora = DateTime.Now.ToString("yyyyMMdd_Hmmss");
//Pone nombre al shape en función de los ámbitos, el tratamiento, y los polígonos + timestamp //Pone nombre al shape en función de los ámbitos, el tratamiento, y los polígonos + timestamp
reco.NombreShpExport = prefNameExport + "T" + reco.TipoTto.ToString("00") + nombFileAmbs + DameStrPoligs() + "_" + fechaHora + extShp; //REVISAR PARA RECO
reco.NombreShpExp_PrefTto = nombFileAmbs + DameStrPoligs();
string msg = ""; string msg = "";
//comienza ejecucion //comienza ejecucion
if (!ComienzaEjec(ModosEjec.Sectoriza, cps, out msg)) if (!LanzaEjec(ModosEjec.Sectoriza, cps, out msg))
{ {
res.Errores = true; res.Errores = true;
res.msg = msg; res.msg = msg;

View File

@ -36,7 +36,7 @@
<ComboBox x:Name="comboBox_ambitos" IsEnabled="{Binding Path=CapaAbierta, Mode = TwoWay}" ItemsSource="{Binding Path=OpsAmbs, Mode = TwoWay}" HorizontalAlignment="Left" Margin="20,0,0,0" <ComboBox x:Name="comboBox_ambitos" IsEnabled="{Binding Path=CapaAbierta, Mode = TwoWay}" ItemsSource="{Binding Path=OpsAmbs, Mode = TwoWay}" HorizontalAlignment="Left" Margin="20,0,0,0"
VerticalAlignment="Top" Width="260" SelectionChanged="comboBox_ambitos_SelectionChanged" VerticalAlignment="Top" Width="260" SelectionChanged="comboBox_ambitos_SelectionChanged"
SelectedIndex="{Binding Path=SelOpAmb, Mode = TwoWay}"/> SelectedIndex="{Binding Path=SelOpAmb, Mode = TwoWay}"/>
<ListBox x:Name="listBox_ambitos" IsEnabled="{Binding Path=EnableListBoxAmb, Mode = TwoWay}" ItemsSource="{Binding Path=Ambitos, Mode = TwoWay}" HorizontalAlignment="Left" Height="100" <ListBox x:Name="listBox_ambitos" IsEnabled="{Binding Path=CapaAbierta, Mode = TwoWay}" ItemsSource="{Binding Path=Ambitos, Mode = TwoWay}" HorizontalAlignment="Left" Height="100"
ItemContainerStyle="{DynamicResource Esri_ListBoxItemHighlightBrush}" Margin="20,10,0,0" VerticalAlignment="Top" Width="260"> ItemContainerStyle="{DynamicResource Esri_ListBoxItemHighlightBrush}" Margin="20,10,0,0" VerticalAlignment="Top" Width="260">
<ListBox.ItemTemplate> <ListBox.ItemTemplate>
<DataTemplate> <DataTemplate>

View File

@ -364,6 +364,7 @@ namespace OliviaAddInPro
private void check_ambitos(int iop, ObservableCollection<AmbitsList> lista) private void check_ambitos(int iop, ObservableCollection<AmbitsList> lista)
{ {
bool check = false; bool check = false;
bool enable = false;
if (lista == null) if (lista == null)
return; return;
for (int i = 0; i < lista.Count; i++) for (int i = 0; i < lista.Count; i++)
@ -373,6 +374,7 @@ namespace OliviaAddInPro
{ {
//para reseteo //para reseteo
check=false; check=false;
enable = true;
} }
else if (iop == 0) else if (iop == 0)
{ {
@ -399,9 +401,12 @@ namespace OliviaAddInPro
} }
else if (iop == 1) else if (iop == 1)
{ {
//opción genérica, ejes de vía
check = true;
enable = true;
//es la opción Genérica que es la opción 2 del TtoCustom, de ahi que el índice sea [iop + 1] //es la opción Genérica que es la opción 2 del TtoCustom, de ahi que el índice sea [iop + 1]
check = LimpiezaDef.ambs_val[(int)LimpiezaDef.TiposTto.TtoCustom].ambs_ops[iop + 1].ambs[(int)((AmbitsList)lista[i]).amb_i] /*LimpiezaDef.ambs_val[(int)LimpiezaDef.TiposTto.TtoCustom].ambs_ops[iop + 1].ambs[(int)((AmbitsList)lista[i]).amb_i]
&& amb_tra_gdb[(int)((AmbitsList)lista[i]).amb_i]; && amb_tra_gdb[(int)((AmbitsList)lista[i]).amb_i]*/
} }
else if ((iop - 2) < (LimpiezaDef.ambs_val[TipoTto].n_ops)) else if ((iop - 2) < (LimpiezaDef.ambs_val[TipoTto].n_ops))
{ {
@ -410,8 +415,11 @@ namespace OliviaAddInPro
check = LimpiezaDef.ambs_val[TipoTto].ambs_ops[iop - 2].ambs[(int)((AmbitsList)lista[i]).amb_i] check = LimpiezaDef.ambs_val[TipoTto].ambs_ops[iop - 2].ambs[(int)((AmbitsList)lista[i]).amb_i]
&& amb_tra_gdb[(int)((AmbitsList)lista[i]).amb_i]; && amb_tra_gdb[(int)((AmbitsList)lista[i]).amb_i];
} }
if (iop != 1)
enable = amb_tra_gdb[(int)((AmbitsList)lista[i]).amb_i];
Ambitos.ElementAt(i).IsChecked = check; Ambitos.ElementAt(i).IsChecked = check;
Ambitos.ElementAt(i).IsEnabled = amb_tra_gdb[(int)((AmbitsList)lista[i]).amb_i]; Ambitos.ElementAt(i).IsEnabled = enable;
} }
} }
/** /**