I routinely update the internalfeatures of a point layer.
Each item is aided with a specified key.
I have 2 function which add Or remove features as nexessary.
currently I perform a simple check to determine if this element is already present.
Dim t As Boolean = pointLayer.InternalFeatures(lKey).IsValid
This works great if the element is present however if the element is not present, the an exception is thrown.
What I need is a simple IsThisKeyPresent(Lkey) that does not throw an exception as I have found the exception causes the routine to slow considerably.
Thanks.
Steve
How do I determine if a specified key exisits on a layer
Hi Steve,
I am not sure if I understand it. But here are some codes:
Dim currentFeature As Feature = pointLayer.InternalFeatures(lKey)
If currentFeature IsNot Nothing Then
Dim t As Boolean = currentFeature.IsValid()
End If
If I misunderstand anything, please feel free to correct me.
Thanks,
Johnny
What I found was pointlayer.internalfeatures(Lkey).present
Does not throw an exception
Thanks for the help.
Hi Steve,
Sorry I misunderstand the question at before and good to hear you have sorted it out.
But can you give some explanations here on "present" which I am still confused?
Thanks,
Johnny
To Clarify. "Present" meaning already added to the layer.
Hi Steve,
Would you mind to try the below codes to see if it is what you are looking for?
Private Function IsThisKeyPresent(ByVal Lkey As String) As Boolean
Return inlayer.InternalFeatures.GetKeys().Contains(Lkey)
End Function
Hope it helps.
Thanks,
Troy