Añadido para abrir capa con valor único. Corregido abrir capa de limpieza puntual

Elena/develop
Elena 2022-05-29 17:17:57 +02:00
parent a0164e6bb4
commit 4694f56861
4 changed files with 94 additions and 35 deletions

View File

@ -1887,7 +1887,7 @@ 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)
public static bool OpenLayer(string ftclasspath, string campValUniq, bool visible=true)
{
var mapView = MapView.Active;
int indexNumber = mapView.Map.Layers.Count;
@ -1895,44 +1895,72 @@ namespace OliviaAddInPro.Helper
if (mapView != null)//Check if there is a map
{
System.Uri ftclass_uri = new System.Uri(ftclasspath); //creating uri for the ftclass
QueuedTask.Run(() =>
//mira el tipo de geometría
GeometryType tipo = GetGeomType(ftclasspath);
var task=QueuedTask.Run(() =>
{
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);
SetSimpleRendererPoint(selectedLayer,campValUniq,tipo);
selectedLayer.SetVisibility(visible);
});
task.Wait();
}
return true;
}
/*
* Crea el renderer para la capa, dado un campo en el que fijarse y una simbología
*/
internal static void SetSimpleRendererPoint(FeatureLayer featureLayer)
{
CIMSimpleRenderer renderer=null;
QueuedTask.Run(() =>
internal static void SetSimpleRendererPoint(FeatureLayer featureLayer, string field, GeometryType tipo)
{
//QueuedTask.Run(() =>
//{
try
{
//Create a circle marker
var pointSymbol = SymbolFactory.Instance.ConstructPointSymbol(ColorFactory.Instance.RedRGB, 8, SimpleMarkerStyle.Circle);
String[] fields = new string[] { field }; //field to be used to retrieve unique values
UniqueValueRendererDefinition uniqueValueRendererDef;
CIMSymbolReference symbolTemplate=new CIMSymbolReference();
if (tipo == GeometryType.Point)//puntual
{
CIMPointSymbol pointSym = SymbolFactory.Instance.ConstructPointSymbol(
ColorFactory.Instance.GreenRGB, 10.0, SimpleMarkerStyle.Circle); //constructing a point symbol as a template symbol
symbolTemplate = pointSym.MakeSymbolReference();
}
else if(tipo== GeometryType.Polyline)//lineal
{
CIMLineSymbol lineSym = SymbolFactory.Instance.ConstructLineSymbol(ColorFactory.Instance.GreenRGB, 3);
symbolTemplate = lineSym.MakeSymbolReference();
}
//constructing renderer definition for unique value renderer
uniqueValueRendererDef = new UniqueValueRendererDefinition(fields, symbolTemplate);
//Get the layer's current renderer
renderer = featureLayer.GetRenderer() as CIMSimpleRenderer;
//creating a unique value renderer
CIMUniqueValueRenderer uniqueValueRenderer = (CIMUniqueValueRenderer)featureLayer.CreateRenderer(uniqueValueRendererDef);
//setting the renderer to the feature layer
featureLayer.SetRenderer(uniqueValueRenderer);
//Update the symbol of the current simple renderer
renderer.Symbol = pointSymbol.MakeSymbolReference();
}
catch (Exception ex)
{
}
//Update the feature layer renderer
featureLayer.SetRenderer(renderer);
//});
}
public static GeometryType GetGeomType(string ftclassName)
{
FeatureClass ftcl = GetFtClass(ftclassName);
GeometryType tipo = GeometryType.Unknown;
if (ftcl == null)
return tipo ;
var task = QueuedTask.Run(() =>
{
tipo = ftcl.GetDefinition().GetShapeType();
});
task.Wait();
Free(ftcl);
return tipo;
}
}
}

View File

@ -61,6 +61,16 @@ namespace OliviaAddInPro.Model
public override Respuesta<TiposEjecucion> Ejecuta(ModosEjec modo)
{
/////////////////////////////
/////
///DEBUG
///
/*Respuesta<TiposEjecucion> res1 = new Respuesta<TiposEjecucion> { Value = TiposEjecucion.FinEjecOk };
HelperGdb.OpenLayer(@"C:\Users\Elena\Documents\ArcGIS\Projects\MyProject3\MyProject3.gdb\Barrido_man\BarMan_AceM_AceNM_20220529_134336", "SECTOR", true);
return res1;*/
/////////////////////////////
Respuesta<bool> res = new Respuesta<bool> { Value=false};
Respuesta<TiposEjecucion> res2 = new Respuesta<TiposEjecucion> (){ Value = TiposEjecucion.FinEjecNOk };
res = Serv.Ejecuta(modo);

View File

@ -147,15 +147,33 @@ namespace OliviaAddInPro.Services
*/
public bool CompruebaCamposLimp(string pathCapa)
{
int NCAMPS = 5;
string[] camps;
GeometryType tipo = HelperGdb.GetGeomType(pathCapa);
if (tipo == GeometryType.Polyline)
{
int NCAMPS = 5;
camps = new string[NCAMPS];
camps[0] = LimpiezaDef.Campos.consulta_entidad;
camps[1] = LimpiezaDef.Campos.consulta_mecan;
camps[2] = LimpiezaDef.Campos.consulta_observ;
camps[3] = LimpiezaDef.Campos.consulta_anch_tip;
camps[4] = LimpiezaDef.Campos.consulta_tipolo;
return HelperGdb.CheckFileds(pathCapa, camps)==0;
}
else if (tipo == GeometryType.Point)//es mobiliario, con el tipo vale
{
int NCAMPS = 1;
camps = new string[NCAMPS];
camps[0] = LimpiezaDef.Campos.consulta_entidad;
}
else
{
ErrStr = "Error al comprobar campos en la capa.";
return false;
}
int res = HelperGdb.CheckFileds(pathCapa, camps);
if (res != 0)
ErrStr = HelperGdb.OutStr;
return res==0;
}
/**
* Lee la gdb y devuelve el array de ámbitos en función de si hay en la gdb o no

View File

@ -114,8 +114,10 @@ namespace OliviaAddInPro
limp.RespCirc = _subPanel1ViewModel.RespCirc;
//lee velo de desplazamiento
int vv = -1;
if((!HelperGlobal.Str2Int(_subPanel1ViewModel.TextVeloDespl, out vv)) && (_subPanel1ViewModel.TextVeloDespl!=Resource1.String_velo_nodef))
int vv = 0;
if (string.Compare(_subPanel1ViewModel.TextVeloDespl, Resource1.String_velo_nodef) != 0)
{
if (!HelperGlobal.Str2Int(_subPanel1ViewModel.TextVeloDespl, out vv))
{
err_str = "Error al leer la velocidad de desplazamiento";
return false;
@ -125,6 +127,7 @@ namespace OliviaAddInPro
err_str = "La velocidad de desplazamiento no está dentro de los límites configurados";
return false;
}
}
limp.VDespl = vv;
//lee tiempo de tto