Algunas correcciones en importación

Elena/develop
Elena 2022-05-29 18:39:42 +02:00
parent fe3e58ed2c
commit d5d52a2d78
5 changed files with 114 additions and 30 deletions

View File

@ -1904,25 +1904,48 @@ namespace OliviaAddInPro.Helper
/**
* Abre en el mapa la capa seleccionada, con los parámetros seleccionados
*/
public static bool OpenLayer(string ftclasspath, string campValUniq, bool visible=true)
public static bool OpenLayerUniqueValue(string ftclasspath, string campValUniq, bool visible=true)
{
var mapView = MapView.Active;
int indexNumber = mapView.Map.Layers.Count;
string ftclassname = System.IO.Path.GetFileNameWithoutExtension(ftclasspath);
if (mapView != null)//Check if there is a map
{
System.Uri ftclass_uri = new System.Uri(ftclasspath); //creating uri for the ftclass
//mira el tipo de geometría
GeometryType tipo = GetGeomType(ftclasspath);
var task=QueuedTask.Run(() =>
try
{
Layer layer = LayerFactory.Instance.CreateLayer(ftclass_uri, mapView.Map, indexNumber, ftclassname);
var selectedLayer = mapView.GetSelectedLayers()[0] as FeatureLayer;
//Do something with selected layer
SetSimpleRendererPoint(selectedLayer,campValUniq,tipo);
selectedLayer.SetVisibility(visible);
});
task.Wait();
System.Uri ftclass_uri = new System.Uri(ftclasspath); //creating uri for the ftclass
//mira el tipo de geometría
GeometryType tipo = GetGeomType(ftclasspath);
if (tipo == GeometryType.Unknown)
return false;
var task = QueuedTask.Run(() =>
{
Layer layer = null;
FeatureLayer selectedLayer = null;
try
{
layer = mapView.Map.FindLayer(ftclass_uri.ToString());
selectedLayer = layer as FeatureLayer;
}
catch
{
layer = null;
}
if (layer == null)
{
layer = LayerFactory.Instance.CreateLayer(ftclass_uri, mapView.Map, indexNumber, ftclassname);
selectedLayer = mapView.GetSelectedLayers()[0] as FeatureLayer;
}
//Do something with selected layer
SetSimpleRendererPoint(selectedLayer, campValUniq, tipo);
selectedLayer.SetVisibility(visible);
});
task.Wait();
}
catch
{
return false;
}
}
return true;
}
@ -1931,6 +1954,8 @@ namespace OliviaAddInPro.Helper
*/
internal static void SetSimpleRendererPoint(FeatureLayer featureLayer, string field, GeometryType tipo)
{
if (featureLayer == null)
return;
//QueuedTask.Run(() =>
//{
try

View File

@ -377,14 +377,24 @@ namespace OliviaAddInPro.Services
*/
public Respuesta<string> ImportSecto(string GdbFileName)
{
var res = new Respuesta<string> { Value = string.Empty };
res = Import(GdbFileName, 0);
if (res.HasError)
var res = Import(GdbFileName, 0);
if (res.HasError || string.IsNullOrEmpty(res.Value))
{
return res;
}
//////////////////////////////////////////////////
//abre las capas, pintando los sectores
bool mal = false;
string path_import = res.Value;
string path_lyr = path_import;
if(HelperGdb.OpenLayerUniqueValue(path_lyr, LimpiezaDef.Campos.consulta_sector))
{
res.Error.Add("Error al abrir capa "+ path_lyr + " con Valor único.");
res.Value = string.Empty;
mal = true;
}
if(!mal)
res.Value = path_import;
return res;
}
/**
@ -598,25 +608,72 @@ namespace OliviaAddInPro.Services
*/
public Respuesta<string> ImportPlanif(string GdbFileName)
{
var res = new Respuesta<string> { Value = string.Empty };
res = Import(GdbFileName, 1);
if (res.HasError)
var res = Import(GdbFileName, 1);
if (res.HasError || string.IsNullOrEmpty(res.Value))
{
res.Value = string.Empty;
return res;
//abre las capas, pintando por sectores
}
//////////////////////////////////////////////////
//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;
}

View File

@ -130,6 +130,8 @@ namespace OliviaAddInPro.Services
msg = Resource1.String_exito;
//pone modo config2
OliviaGlob.AddFlagTipEjec(TiposEjecucion.Config2);
//actualiza la capa de la que tiene que leer ahora para planificar
inst.CapaElems = resp.Value;
}
}
}

View File

@ -50,7 +50,7 @@ namespace OliviaAddInPro
DockPane pane = FrameworkApplication.DockPaneManager.Find(_dockPaneID);
if (pane == null)
return;
hideTemp = true; //avisa de que solo esconde temporalmente, no para siempre
hideTemp = true; //avisa de que es manual, no por cierre del botón
pane.Hide();
}
@ -63,11 +63,11 @@ namespace OliviaAddInPro
//The parameter passed to this method will be true if the Dockpane is being opened and it is false when you close the dockpane
protected override void OnShow(bool isVisible)
{
/*if (isVisible == false && !firstTimeShow && !hideTemp)
if (isVisible == false && !firstTimeShow && !hideTemp)
{
//avisa de cerrar la ventana
OliviaGlob.SetFlagTipEjec(TiposEjecucion.Ninguno);
}*/
}
if (firstTimeShow)
firstTimeShow = false;
}

View File

@ -61,11 +61,11 @@ namespace OliviaAddInPro
//also false the first time
protected override void OnShow(bool isVisible)
{
/* if (isVisible == false && !firstTimeShow && !hideTemp)
if (isVisible == false && !firstTimeShow && !hideTemp)
{
//avisa de cerrar la ventana
OliviaGlob.SetFlagTipEjec(TiposEjecucion.Ninguno);
}*/
}
if (firstTimeShow)
firstTimeShow = false;
}