Avances exportación

ConfiguracionSimplificada
Elena 2022-02-06 17:05:50 +01:00
parent 939e7a50c8
commit 492475fbdd
14 changed files with 400 additions and 98 deletions

View File

@ -25,14 +25,26 @@ namespace OliviaAddInPro
{
protected override void OnClick()
{
/////////////////////////////////////////////////////
OliviaGlob.progrDialog= new ProgressDialog(
"Procesando", "Canceled", 100, false);
if (OliviaGlob.TipoEjec == TiposEjecucion.Ninguno)
{
OliviaGlob.SetFlagTipEjec(TiposEjecucion.Limp);
OliviaGlob.Limp = new Limpieza();
DockpaneLimpiezaViewModel.Reset();
DockpaneLimpiezaViewModel.Show();
///Comprueba que existe la red navegable configurada
if (HelperGdb.GetGdb(OliviaGlob.Paths.PathGdbNw).Result == null)
{
HelperGlobal.ponMsg("No encuentra Gdb de red navegable, cambie Configuración: " + HelperGdb.OutStr,
System.Windows.MessageBoxImage.Warning);
}
else
{
OliviaGlob.SetFlagTipEjec(TiposEjecucion.Limp);
if(OliviaGlob.Limp==null)
OliviaGlob.Limp = new Limpieza();
DockpaneLimpiezaViewModel.Reset();
DockpaneLimpiezaViewModel.Show();
}
}
else
{

View File

@ -29,10 +29,20 @@ namespace OliviaAddInPro
"Procesando", "Canceled", 100, false);
if (OliviaGlob.TipoEjec==TiposEjecucion.Ninguno)
{
OliviaGlob.SetFlagTipEjec(TiposEjecucion.Reco);
OliviaGlob.Reco = new Recogida();
DockpaneRecogidaViewModel.Reset();
DockpaneRecogidaViewModel.Show();
///Comprueba que existe la red navegable configurada
if (HelperGdb.GetGdb(OliviaGlob.Paths.PathGdbNw).Result == null)
{
HelperGlobal.ponMsg("No encuentra Gdb de red navegable, cambie Configuración: " + HelperGdb.OutStr,
System.Windows.MessageBoxImage.Warning);
}
else
{
OliviaGlob.SetFlagTipEjec(TiposEjecucion.Reco);
if(OliviaGlob.Reco==null)
OliviaGlob.Reco = new Recogida();
DockpaneRecogidaViewModel.Reset();
DockpaneRecogidaViewModel.Show();
}
}
else
{

View File

@ -26,6 +26,7 @@ namespace OliviaAddInPro.Helper
{
public static class HelperGdb
{
private static string ObjectId = "OBJECTID";
private static string out_str = string.Empty;
public static string OutStr {
get
@ -312,7 +313,7 @@ namespace OliviaAddInPro.Helper
}
//Crea un filtro espacial a partir de una consulta y en todo caso, una geometría
public static ArcGIS.Core.Data.SpatialQueryFilter 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.Contains)
{
ArcGIS.Core.Data.SpatialQueryFilter filt =null;
if (geom != null)
@ -555,7 +556,8 @@ namespace OliviaAddInPro.Helper
return ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run((Func<ArcGIS.Core.Geometry.Geometry>)(() =>
{
geomIni = GetGeomUnique(fclss, filter, cps);
if (geomIni != null)
return geomIni;
/*if (geomIni != null)
{
ArcGIS.Core.Geometry.Geometry geomSal = null;
try
@ -569,7 +571,7 @@ namespace OliviaAddInPro.Helper
}
}
else
return null;
return null;*/
}));
}
@ -795,13 +797,109 @@ namespace OliviaAddInPro.Helper
return res;
}
public static bool ExportShp(string pathLayerIn, SpatialQueryFilter filter, string nameShp, string outpath, CancelableProgressorSource cps, out string msgOut, ProgressorSource progrDialog = null)
public static bool ExportShp2(string pathLayerIn, SpatialQueryFilter filter, string nameShp, string outpath, CancelableProgressorSource cps)
{
if (!System.IO.Directory.Exists(outpath))
System.IO.Directory.CreateDirectory(outpath);
FeatureClass fc = null;
/////////////////////////////////////////////////////////
//Prepara una where_clause con las entidades que cumplen el filtro
//Abre la featureclass
try
{
fc = GetFtClass(pathLayerIn);
if (fc == null)
{
OutStr = "Error al abrir Feature Class en exportación";
return false;
}
List<long> ids = new List<long>();
cps.Status = "Aplicando filtro espacial a exportación";
//Añade a la lista los ids que cumplen el filtro espacial
using (RowCursor cursor = fc.Search(filter))
{
while (cursor.MoveNext())
{
using (Feature feature = (Feature)cursor.Current)
{
ids.Add(feature.GetObjectID());
}
}
}
if (ids.Count <= 0)
{
OutStr = "Error al aplicar filtro espacial en exportación";
return false;
}
//convierte la lista de ids a string para la clause de la forma
//(id1, id2, id3..)
string whereClause = GetWhereClauseFromIds(ids);
///////////////////////////////////////////////////////////
///Exporta
cps.Status = "Exportando datos";
string[] args = { pathLayerIn, outpath, nameShp, whereClause };
// execute the tool
IGPResult gpResult = Geoprocessing.ExecuteToolAsync("FeatureClassToFeatureClass_conversion", args,
null, cps.CancellationTokenSource.Token,
(event_name, o) => // implement delegate and handle events
{
switch (event_name)
{
case "OnValidate": // stop execute if any warnings
//if ((o as IGPMessage[]).Any(it => it.Type == GPMessageType.Warning))
//_cts.Cancel();
break;
case "OnProgressMessage":
{
string msg = string.Format("{0}: {1}", new object[] { event_name, (string)o });
Debug.WriteLine(msg);
;
//System.Windows.MessageBox.Show(msg);
//_cts.Cancel();
}
break;
case "OnProgressPos":
{
string msg2 = string.Format("{0}: {1} %", new object[] { event_name, (int)o });
Debug.WriteLine(msg2);
var av = (int)0;
if (av > 0)
{
cps.Value = (uint)(80 * av * 0.2);
}
// if ((int)o < 0)
//System.Windows.MessageBox.Show(msg2);
//_cts.Cancel();
break;
}
}
}).Result;
cps.Status = "Finalizando exportacion";
return true;
}
catch (Exception ex)
{
OutStr = "Error: " + ex.Message;
return false;
}
finally
{
Free(fc);
}
}
public static bool ExportShp(string pathLayerIn, SpatialQueryFilter filter, string nameShp, string outpath, CancelableProgressorSource cps, out string msgOut, ProgressorSource progrDialog = null)
{
msgOut = "";
if (!System.IO.Directory.Exists(outpath))
System.IO.Directory.CreateDirectory(outpath);
//FeatureClass fc = HelperGdb.GetFtClass(pathLayerIn);
//fc.
/*
@ -950,6 +1048,24 @@ namespace OliviaAddInPro.Helper
return resp;
}
}
/**
* Amplía la geometría para añadirele buffer
*/
public static Respuesta<ArcGIS.Core.Geometry.Geometry> BufferGeom(ArcGIS.Core.Geometry.Geometry geom, double buffer)
{
Respuesta<ArcGIS.Core.Geometry.Geometry> resp = new Respuesta<ArcGIS.Core.Geometry.Geometry>();
ArcGIS.Core.Geometry.Geometry geomBuff = null;
try
{
geomBuff = GeometryEngine.Instance.Buffer(geom, buffer);
}
catch
{
}
resp.Value = geomBuff;
return resp;
}
/**Amplía la geometría para que incluya el punto
*/
@ -973,6 +1089,22 @@ namespace OliviaAddInPro.Helper
resp.Error.Add("Error al unir punto a polígono");
return resp;
}
//hace la convez hull, por si no fueran conexas las zonas
ArcGIS.Core.Geometry.Geometry geom_aux= GeometryEngine.Instance.Intersection(geom_pto, geom);
if (geom_aux == null || geom_aux.IsEmpty)
{
ArcGIS.Core.Geometry.Envelope env1 = geom_sal.Extent;
ArcGIS.Core.Geometry.Envelope env2 = geom_pto.Extent;
ArcGIS.Core.Geometry.Envelope env3 = env1.Union(env2);
geom_sal = (ArcGIS.Core.Geometry.Geometry) env3;
//geom_sal = GeometryEngine.Instance.Envelope(geom_sal);
if (geom_sal == null || geom_sal.IsEmpty)
{
resp.Value = null;
resp.Error.Add("Error al hacer envolvente en unir punto al polígono");
return resp;
}
}
resp.Value = geom_sal;
return resp;
}
@ -985,10 +1117,30 @@ namespace OliviaAddInPro.Helper
}
/*
* Dada una lista de ids de elemento, crea una consulta en la que se llama a todos esos elementos
* campo IN (id1, id2, id3..)
*/
public static string GetWhereClauseFromIds(List<long> ids)
{
string consulta, orstr;
if (ids.Count <= 0)
return string.Empty;
string ids_str = "(";
bool first = true;
foreach (long i in ids)
{
if (first)
{
ids_str += i.ToString();
first = false;
}
else
ids_str += "," + i.ToString();
}
//el último
ids_str += ")";
string whereClause = ObjectId + " IN " + ids_str; //Cambiar id a otro sitio
return whereClause;
/*string consulta, orstr;
consulta = string.Empty;
orstr = string.Empty;
@ -1003,15 +1155,68 @@ namespace OliviaAddInPro.Helper
if (consulta == "()")
consulta = string.Empty;
return consulta;
return consulta;*/
}
/**
* Elimina las filas indicadas del shp
**/
public static bool RemoveRowsFromShp(string shp_path, List<long> quita)
public static bool RemoveRowsFromShp(FeatureClass fc, List<long> quita)
{
FeatureClass fc = HelperGdb.GetFtClassFromShp(shp_path).Result;
//Crea la consulta
var consulta = GetWhereClauseFromIds(quita);
if (String.IsNullOrEmpty(consulta))
return false;
string message = String.Empty;
bool deletionResult = false;
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => {
EditOperation editOperation = new EditOperation();
editOperation.Callback(context =>
{
ArcGIS.Core.Data.QueryFilter openCutFilter = new ArcGIS.Core.Data.QueryFilter { WhereClause = consulta };
using (RowCursor rowCursor = fc.Search(openCutFilter, false))
{
while (rowCursor.MoveNext())
{
using (Row row = rowCursor.Current)
{
// In order to update the Map and/or the attribute table. Has to be called before the delete.
context.Invalidate(row);
row.Delete();
}
}
}
}, fc);
try
{
deletionResult = editOperation.Execute();
if (!deletionResult)
{
message = editOperation.ErrorMessage;
}
}
catch (GeodatabaseException exObj)
{
message = exObj.Message;
}
});
if (!string.IsNullOrEmpty(message))
{
OutStr = message;
return false;
}
else
return true;
/*FeatureClass fc = HelperGdb.GetFtClassFromShp(shp_path).Result;
if (fc == null)
return false;
@ -1025,7 +1230,8 @@ namespace OliviaAddInPro.Helper
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => {
string shpname = System.IO.Path.GetFileNameWithoutExtension(shp_path);
var shapeFileConnPath = new FileSystemConnectionPath(new Uri(shp_path), FileSystemDatastoreType.Shapefile);
var shapeFileConnPath = new FileSystemConnectionPath(new Uri(System.IO.Path.GetDirectoryName(shp_path)),
FileSystemDatastoreType.Shapefile);
var shapefile = new FileSystemDatastore(shapeFileConnPath);
using (Table table = shapefile.OpenDataset<Table>(shp_path))
{
@ -1071,6 +1277,7 @@ namespace OliviaAddInPro.Helper
}
else
return true;
*/
}
/**
@ -1114,16 +1321,22 @@ namespace OliviaAddInPro.Helper
Free(f);
}
Free(f);
Free(fc);
Free(cursor);
//comprueba que no se haya quedado sin ámbitos
if (quita.Count>=fc.GetCount())
{
OutStr = "No quedan ámbitos que cumplan la geometría seleccionada.";
return false;
}
//Quita los ámbitos del shp
if (quita.Count > 0)
{
//borra las líneas que se han indicado
if (!RemoveRowsFromShp(shp_path, quita))
if (!RemoveRowsFromShp(fc, quita))
return false;
}
Free(fc);
return true;
}

View File

@ -9,6 +9,7 @@ namespace OliviaAddInPro.Model
{
//*************************************************************************************
//Enums y structs generales
public static int BuffExport = 1000;
/**
* Nombre de los campos de la cartografía de la red navegable que se consultan para la exportación
*/

View File

@ -6,6 +6,8 @@ using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using Xceed.Wpf.Toolkit.PropertyGrid;
using Xceed.Wpf.Toolkit.PropertyGrid.Editors;
namespace OliviaAddInPro.Model
{
@ -190,6 +192,7 @@ namespace OliviaAddInPro.Model
[Category("General")]
[DisplayName("Red de carreteras")]
[Description("Red de carreteras que se usara para la navegación")]
//[Editor(typeof(EditorFilePickerDefinition), typeof(EditorFilePickerDefinition))]
public string red_carreteras { get; set; }
[Category("General")]

View File

@ -209,8 +209,6 @@ namespace OliviaAddInPro.Model
Conexion.Ip = c.Ip;
Conexion.TiempoOutSocket = c.TiempoOutSocket;
//buff_export = c.buffer_export;
///////////////////////////////////////
//Capas, consultas y filtros GENERALES
Capas.ftclass_ejes = c.eje_via;
@ -398,7 +396,7 @@ namespace OliviaAddInPro.Model
RecogidaDef.tipos_lateralidad[(int)RecogidaDef.Lateralidad.Dcha] = c.derecha;
RecogidaDef.tipos_lateralidad[(int)RecogidaDef.Lateralidad.Izqda] = c.izquierda;
ComunDef.BuffExport = c.buffer_export;
//Campos de la red navegable que se leen
ComunDef.CamposNW.cons_onew = c.cons_onew;
ComunDef.CamposNW.cons_kph = c.cons_kph;

View File

@ -10,7 +10,7 @@ namespace OliviaAddInPro.Model
{
public T Value { get; set; }
public List<string> Error { get; set; }
public List<string> Error { get; set; } = new List<string>();
public bool HasError
{

View File

@ -38,7 +38,6 @@ namespace OliviaAddInPro.Services
public bool LanzaEjec(ModosEjec modo, CancelableProgressorSource cps, out string ErrStr)
{
ErrStr = string.Empty;
FeatureClass fc = null;
try
{
//Cuenta las filas que cumplen la consulta
@ -67,7 +66,6 @@ namespace OliviaAddInPro.Services
{
ErrStr = "Error al crear el filtro de exportacion de los ámbitos";
return false;
}
//Termina de preparar nombre
//Prepara nombre
@ -78,9 +76,10 @@ namespace OliviaAddInPro.Services
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))
if (!HelperGdb.ExportShp2(com.CapaElems, filtroEspacial, com.NombreShpExport, OliviaGlob.Paths.DirData, cps))
//if (!HelperGdb.ExportShp(com.CapaElems, filtroEspacial, com.NombreShpExport, OliviaGlob.Paths.DirData, cps, out ErrStr))
{
ErrStr = ErrStr+"Error al exportar los ámbitos";
ErrStr = "Error al exportar los ámbitos: "+ HelperGdb.OutStr;
return false;
}
//Guarda el nombre
@ -92,7 +91,8 @@ namespace OliviaAddInPro.Services
}
cps.Value = 80;
//hace intersecciones espaciales en caso de ámbitos lineales para quitar los que tienen más parte fuera de la zona que dentro
if (((com.GeomNiv != null) || (com.GeomZon!=null)) &&
//REVISAR
/*if (((com.GeomNiv != null) || (com.GeomZon != null)) &&
(OliviaGlob.IsReco() || (OliviaGlob.IsLimp() && (com.TipoTto < (int)LimpiezaDef.TiposTto.TtoPapeVaci))))
{
if (!HelperGdb.RemoveRowsGeom(OliviaGlob.Paths.PathData, geom_export, 0.4))
@ -100,44 +100,55 @@ namespace OliviaAddInPro.Services
ErrStr = "Error al quitar los ámbitos que sobresalen: " + HelperGdb.OutStr;
return false;
}
}
//comprueba que no se haya quedado sin ámbitos
fc = HelperGdb.GetFtClassFromShp(OliviaGlob.Paths.PathData).Result;
if (fc==null)
{
ErrStr = HelperGdb.OutStr;
return false;
}
if(fc.GetCount() <= 0)
{
ErrStr = "No quedan ámbitos que cumplan la geometría seleccionada.";
return false;
}
}*/
///////////////////////////////////////////////////////////////////////////
//amplia la geom para englobar las instalaciones
geom_export = HelperGdb.GetGeomConvexHull(fc, null, cps).Result;
if (!com.CoordsInstal.IsEmpty && (com.CoordsInstal.X!=0))
//comprueba, si hay restricciones de circulación y hay instalación, que la instalación no está en ellas
if (!com.CoordsInstal.IsEmpty && (com.CoordsInstal.X!=0) && (com.GeomRestr != null))
{
//hay instalación
Respuesta<bool> resp;
//comprueba, si hay restricciones de circulación, que la instalación no está en ellas
if (com.GeomRestr != null)
Respuesta<bool> resp = HelperGdb.IsPtoInGeom(com.CoordsInstal, com.GeomRestr);
if (!resp.Value && resp.HasError)
{
resp = HelperGdb.IsPtoInGeom(com.CoordsInstal, com.GeomRestr);
if (!resp.Value)
{
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;
}
ErrStr = "Error al comprobar si la instalación está contenida en el polígono de restricciones: " + resp.Error.ElementAt(0);
return false;
}
else if(resp.Value) //sí está contenido en las restricciones
{
ErrStr = "Error, la instalación está en la zona restringida a la circulación ";
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)
}
if (cps.CancellationTokenSource.IsCancellationRequested)
{
ErrStr = "Se ha cancelado la operación";
return false;
}
///////////////////////////////////////////////////////////////////////////
//exporta la red navegable (buffer, le quita las restr...)
//se obtiene la geometría a intersecar con la red, que será la que contiene
//a todos los ámbitos y la instalación, ampliada un buffer, mayor si hay
//restricciones de circulación
Geometry geom_aux = HelperGdb.BufferGeom(geom_export, com.BuffExport).Value;
if(geom_aux==null)
{
ErrStr = "Error al añadir buffer a la geometría";
return false;
}
//quita las restricciones
geom_aux = HelperGdb.QuitaGeom(geom_aux, com.GeomRestr);
if (geom_aux == null)
{
ErrStr = "Error al intersecar con las restricciones.";
return false;
}
geom_export = geom_aux;
//////////////////////////////////////////////////////////////
//comprueba si la geometría de exportación contiene a la instalación
if (!com.CoordsInstal.IsEmpty && (com.CoordsInstal.X != 0))
{
Respuesta<bool> resp = HelperGdb.IsPtoInGeom(com.CoordsInstal, geom_export);
if (!resp.Value) //si no lo contiene
{
//ha ido mal
if (resp.HasError)
@ -163,13 +174,7 @@ namespace OliviaAddInPro.Services
}
}
}
if (cps.CancellationTokenSource.IsCancellationRequested)
{
ErrStr = "Se ha cancelado la operación";
return false;
}
///////////////////////////////////////////////////////////////////////////
//exporta la red navegable (buffer, le quita las restr...)
//Hace el filtro con la geometría final
filtroEspacial = HelperGdb.CreateFiler(String.Empty, geom_export);
if (filtroEspacial == null)
{
@ -181,9 +186,10 @@ namespace OliviaAddInPro.Services
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))
//if (!HelperGdb.ExportShp(capaNw, filtroEspacial, com.NombreShpExportNw, OliviaGlob.Paths.DirData, cps, out ErrStr))
if (!HelperGdb.ExportShp2(capaNw, filtroEspacial, com.NombreShpExportNw, OliviaGlob.Paths.DirData, cps))
{
ErrStr = ErrStr + "Error al exportar la red navegable";
ErrStr = "Error al exportar la red navegable: " + HelperGdb.OutStr;
return false;
}
//guarda los nombres del shape
@ -200,10 +206,6 @@ namespace OliviaAddInPro.Services
ErrStr = "Errores al comenzar la ejecución: " + ex.Message;
return false;
}
finally
{
HelperGdb.Free(fc);
}
return true;
}
@ -249,15 +251,17 @@ namespace OliviaAddInPro.Services
//prepara el filtro con consulta y espacial
SpatialQueryFilter filtro = HelperGdb.CreateFiler(com.ConsultaAmbs, geomAux);
//Ahora hace la geometría de los ámbitos que cumplen la consulta
geomAmbits = HelperGdb.GetGeomConvexHull(fc, filtro, cps).Result;
if (geomAmbits == null || geomAmbits.IsEmpty)
if (geomAux == null)
{
ErrStr = "No se ha podido generar geometría de los ámbitos" + com.ConsultaAmbs + HelperGdb.OutStr;
return null;
//Ahora hace la geometría de los ámbitos que cumplen la consulta, si no hay ya geometría
geomAmbits = HelperGdb.GetGeomConvexHull(fc, filtro, cps).Result;
if (geomAmbits == null || geomAmbits.IsEmpty)
{
ErrStr = "No se ha podido generar geometría de los ámbitos" + com.ConsultaAmbs + HelperGdb.OutStr;
return null;
}
geomAux = geomAmbits;
}
geomAux = geomAmbits;
cps.Value = 60;
//le quita las restricciones
if (com.GeomRestr != null)
@ -328,5 +332,45 @@ namespace OliviaAddInPro.Services
camps[1] = LimpiezaDef.Campos.consulta_secuen;
return CompruebaCampos(pathCapa, camps) == 0;
}
/**
* Borra los archivos exportados para el proceso
*/
public static void BorraFiles()
{
string[] list = null;
string capa_principal = System.IO.Path.GetFileNameWithoutExtension(OliviaGlob.Paths.PathData);
string capa_principal_nw = System.IO.Path.GetFileNameWithoutExtension(OliviaGlob.Paths.PathNW);
try
{
if (capa_principal == null)
return;
list = System.IO.Directory.GetFiles(OliviaGlob.Paths.DirData, capa_principal + "*");
if (list.Length > 0)
{
foreach (string f in list)
{
if (System.IO.Path.GetExtension(f) == ".lock")
continue;
System.IO.File.Delete(f);
}
}
if (capa_principal_nw == null)
return;
list = System.IO.Directory.GetFiles(OliviaGlob.Paths.DirData, capa_principal_nw + "*");
if (list.Length > 0)
{
foreach (string f in list)
{
System.IO.File.Delete(f);
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
}
}

View File

@ -13,6 +13,7 @@ using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using OliviaAddInPro.Model;
namespace OliviaAddInPro
{
@ -29,8 +30,11 @@ namespace OliviaAddInPro
private void OnGuardar(object sender, RoutedEventArgs e)
{
if (DataContext is PaneConfigViewModel mod)
mod.OnGuardar();
if (DataContext is PaneConfigViewModel mod)
{
mod.OnGuardar();
OliviaGlob.IniDefault();
}
}
private void OnRefres(object sender, RoutedEventArgs e)

View File

@ -87,9 +87,16 @@ namespace OliviaAddInPro
ArcGIS.Core.Geometry.Geometry geomsal = HelperGdb.OpenGeom(HelperGdb.TiposOpenFileDlg.OpenFtrClassPoint, out texto);
if ((DataContext is PaneLimpiezaSub2ViewModel mod) && geomsal != null && geomsal is MapPoint mp)
if ((DataContext is PaneLimpiezaSub2ViewModel mod) && (geomsal != null))
{
mod.CoordsInstal = mp.Coordinate2D;
if (geomsal is MapPoint map)
mod.CoordsInstal = map.Coordinate2D;
else if (geomsal is Multipoint multip)
{
if(multip.Copy2DCoordinatesToList().Count>0)
mod.CoordsInstal = multip.Copy2DCoordinatesToList().First();
}
}
if (geomsal != null)
label_capainst.Content = texto;

View File

@ -157,7 +157,13 @@ namespace OliviaAddInPro
if ((DataContext is PaneRecogidaSub1ViewModel mod) && geomsal != null && geomsal is MapPoint mp)
{
mod.CoordsPlanta = mp.Coordinate2D;
if (geomsal is MapPoint map)
mod.CoordsPlanta = map.Coordinate2D;
else if (geomsal is Multipoint multip)
{
if (multip.Copy2DCoordinatesToList().Count > 0)
mod.CoordsPlanta = multip.Copy2DCoordinatesToList().First();
}
}
if (geomsal != null)
label_capaplant.Content = texto;

View File

@ -57,6 +57,7 @@ namespace OliviaAddInPro
internal static void Reset()
{
//HAY QUE HACER QUE SE LIMPIE TODO
}
//The parameter passed to this method will be true if the Dockpane is being opened and it is false when you close the dockpane

View File

@ -14,6 +14,7 @@ using ArcGIS.Desktop.Framework.Contracts;
using ArcGIS.Desktop.Framework.Dialogs;
using ArcGIS.Desktop.Framework.Threading.Tasks;
using ArcGIS.Desktop.Mapping;
using OliviaAddInPro.Model;
namespace OliviaAddInPro
{
@ -22,7 +23,7 @@ namespace OliviaAddInPro
public PaneLimpiezaSub2ViewModel()
{
lblCapaRestr= lblCapaNiv= lblCapaZon= lblCapaInst = Resource1.String_selec_capa;
txtBuffExport = 1000;
txtBuffExport = ComunDef.BuffExport;
}

View File

@ -7,6 +7,7 @@ using System.Threading.Tasks;
using System.Text.RegularExpressions;
using System.Runtime.InteropServices.WindowsRuntime;
using OliviaAddInPro.Model;
using OliviaAddInPro.Helper;
namespace OliviaAddInPro
{
@ -122,6 +123,7 @@ namespace OliviaAddInPro
return false;
}
return true;
}
}