Algunas correcciones en importación
parent
fe3e58ed2c
commit
d5d52a2d78
|
|
@ -1904,26 +1904,49 @@ 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 OpenLayer(string ftclasspath, string campValUniq, bool visible=true)
|
public static bool OpenLayerUniqueValue(string ftclasspath, string campValUniq, bool visible=true)
|
||||||
{
|
{
|
||||||
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);
|
||||||
if (mapView != null)//Check if there is a map
|
if (mapView != null)//Check if there is a map
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
System.Uri ftclass_uri = new System.Uri(ftclasspath); //creating uri for the ftclass
|
System.Uri ftclass_uri = new System.Uri(ftclasspath); //creating uri for the ftclass
|
||||||
//mira el tipo de geometría
|
//mira el tipo de geometría
|
||||||
GeometryType tipo = GetGeomType(ftclasspath);
|
GeometryType tipo = GetGeomType(ftclasspath);
|
||||||
|
if (tipo == GeometryType.Unknown)
|
||||||
|
return false;
|
||||||
var task = QueuedTask.Run(() =>
|
var task = QueuedTask.Run(() =>
|
||||||
{
|
{
|
||||||
Layer layer = LayerFactory.Instance.CreateLayer(ftclass_uri, mapView.Map, indexNumber, ftclassname);
|
Layer layer = null;
|
||||||
var selectedLayer = mapView.GetSelectedLayers()[0] as FeatureLayer;
|
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
|
//Do something with selected layer
|
||||||
SetSimpleRendererPoint(selectedLayer, campValUniq, tipo);
|
SetSimpleRendererPoint(selectedLayer, campValUniq, tipo);
|
||||||
selectedLayer.SetVisibility(visible);
|
selectedLayer.SetVisibility(visible);
|
||||||
});
|
});
|
||||||
task.Wait();
|
task.Wait();
|
||||||
}
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
|
|
@ -1931,6 +1954,8 @@ namespace OliviaAddInPro.Helper
|
||||||
*/
|
*/
|
||||||
internal static void SetSimpleRendererPoint(FeatureLayer featureLayer, string field, GeometryType tipo)
|
internal static void SetSimpleRendererPoint(FeatureLayer featureLayer, string field, GeometryType tipo)
|
||||||
{
|
{
|
||||||
|
if (featureLayer == null)
|
||||||
|
return;
|
||||||
//QueuedTask.Run(() =>
|
//QueuedTask.Run(() =>
|
||||||
//{
|
//{
|
||||||
try
|
try
|
||||||
|
|
|
||||||
|
|
@ -377,14 +377,24 @@ namespace OliviaAddInPro.Services
|
||||||
*/
|
*/
|
||||||
public Respuesta<string> ImportSecto(string GdbFileName)
|
public Respuesta<string> ImportSecto(string GdbFileName)
|
||||||
{
|
{
|
||||||
var res = new Respuesta<string> { Value = string.Empty };
|
var res = Import(GdbFileName, 0);
|
||||||
res = Import(GdbFileName, 0);
|
if (res.HasError || string.IsNullOrEmpty(res.Value))
|
||||||
if (res.HasError)
|
{
|
||||||
return res;
|
return res;
|
||||||
|
}
|
||||||
//////////////////////////////////////////////////
|
//////////////////////////////////////////////////
|
||||||
//abre las capas, pintando los sectores
|
//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;
|
return res;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
|
@ -598,25 +608,72 @@ namespace OliviaAddInPro.Services
|
||||||
*/
|
*/
|
||||||
public Respuesta<string> ImportPlanif(string GdbFileName)
|
public Respuesta<string> ImportPlanif(string GdbFileName)
|
||||||
{
|
{
|
||||||
var res = new Respuesta<string> { Value = string.Empty };
|
var res = Import(GdbFileName, 1);
|
||||||
res = Import(GdbFileName, 1);
|
if (res.HasError || string.IsNullOrEmpty(res.Value))
|
||||||
if (res.HasError)
|
{
|
||||||
|
res.Value = string.Empty;
|
||||||
return res;
|
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
|
//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
|
//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
|
//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
|
//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
|
//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
|
//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
|
//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
|
//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;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -130,6 +130,8 @@ namespace OliviaAddInPro.Services
|
||||||
msg = Resource1.String_exito;
|
msg = Resource1.String_exito;
|
||||||
//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
|
||||||
|
inst.CapaElems = resp.Value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,7 @@ namespace OliviaAddInPro
|
||||||
DockPane pane = FrameworkApplication.DockPaneManager.Find(_dockPaneID);
|
DockPane pane = FrameworkApplication.DockPaneManager.Find(_dockPaneID);
|
||||||
if (pane == null)
|
if (pane == null)
|
||||||
return;
|
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();
|
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
|
//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)
|
protected override void OnShow(bool isVisible)
|
||||||
{
|
{
|
||||||
/*if (isVisible == false && !firstTimeShow && !hideTemp)
|
if (isVisible == false && !firstTimeShow && !hideTemp)
|
||||||
{
|
{
|
||||||
//avisa de cerrar la ventana
|
//avisa de cerrar la ventana
|
||||||
OliviaGlob.SetFlagTipEjec(TiposEjecucion.Ninguno);
|
OliviaGlob.SetFlagTipEjec(TiposEjecucion.Ninguno);
|
||||||
}*/
|
}
|
||||||
if (firstTimeShow)
|
if (firstTimeShow)
|
||||||
firstTimeShow = false;
|
firstTimeShow = false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -61,11 +61,11 @@ namespace OliviaAddInPro
|
||||||
//also false the first time
|
//also false the first time
|
||||||
protected override void OnShow(bool isVisible)
|
protected override void OnShow(bool isVisible)
|
||||||
{
|
{
|
||||||
/* if (isVisible == false && !firstTimeShow && !hideTemp)
|
if (isVisible == false && !firstTimeShow && !hideTemp)
|
||||||
{
|
{
|
||||||
//avisa de cerrar la ventana
|
//avisa de cerrar la ventana
|
||||||
OliviaGlob.SetFlagTipEjec(TiposEjecucion.Ninguno);
|
OliviaGlob.SetFlagTipEjec(TiposEjecucion.Ninguno);
|
||||||
}*/
|
}
|
||||||
if (firstTimeShow)
|
if (firstTimeShow)
|
||||||
firstTimeShow = false;
|
firstTimeShow = false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue