Hi,
I have an overlaylayer with 6 layers.
When the user clicks on a feature, I add this feature in a Inmemorylayer to consider this feature as selected and ,I want to know to which layer belongs the feature. (ie the code below).
So i do a foreach, and it's slow when i click on a feature.
Is there a way to optimize this code or do it differently ?
Thanks.
Regards.
Steph.
foreach (FeatureLayer rr in ((LayerOverlay)_wpfMap.Overlays[ConstantsMap.NOMOVERLAYDYNAMIC + "_KEY"]).Layers)
{
if (rr.Name != ConstantsMap.NOMINMEMORYLAYERSELECT && rr.IsVisible == true)
{
if (rr.IsOpen == false)
rr.Open();
ftsQuery = rr.QueryTools.GetFeaturesContaining(clickLocation, ReturningColumnsType.AllColumns);
if (ftsQuery.Count > 0)
{
foreach (Feature ftQuery in ftsQuery)
{
//Si colonne attributaire "TypeDetourage" n'existe pas alors ajout
if (ftQuery.ColumnValues.ContainsKey("TypeDetourage") == false)
{
tyDt = _vm.LayersMapConfig.Where(p => p.NomLayer == rr.Name).First().RangModaTypeDt;
ftQuery.ColumnValues.Add("TypeDetourage", tyDt.ToString());
}
ftQuery.ColumnValues.Add("LayerEnCours", rr.Name);
dejaSlc = _inMemFeatureLayerEnCours.InternalFeatures.Where(ii => ii.ColumnValues.SequenceEqual(ftQuery.ColumnValues)).Count() > 0 ? true : false;
//Sélection
if (dejaSlc == false)
{
_inMemFeatureLayerEnCours.InternalFeatures.Add(ftQuery);
}
//Dé-sélection
else
{
_inMemFeatureLayerEnCours.InternalFeatures.Remove(ftQuery);
_vm.LstSourceAsso = null;
}
ftFind = true;
if (ftFind == true)
{
_wpfMap.Overlays[ConstantsMap.NOMOVERLAYDYNAMIC + "_KEY"].Refresh();
}
}