Zum Hauptinhalt gehen

ExistsInCollection FeatureSet

Kommentare

2 Kommentare

  • Zack Robison
    I would personally use linq for this (such as in this Stackoverflow answer to what is essentially the same question (https://stackoverflow.com/a/11092955) , mind you this is the c# syntax and you'll want the vb).  If you don't feel up to that task there is a .Contains method for .net enumerables that you may find helps you out better (since lambda expressions are not exactly straightforward, noone could blame you).

     

    I think the linq option would be an assignment activity to a boolean variable where the right-hand expression looks like: fs1.features.Any( Function(x) fs.Features.Any(Function(y) y.Attributes("objectid").toString=x.Attributes("objectid").tostring) )  but I am kinda spitballing here so the syntax might need some tweaking... that'll be close anyway.  

     

    The other option that I would consider is to loop like you're already doing.  First I'd get one list of object id's ahead of time so that you don't need to generate it each time you loop.  You'll want to create a new enumerable for this, let's call it Objects.  Again I would choose to use linq for this (.select method this time) but for your purposes, I'd use a foreach over each feat in fs.features insert each feat.Attributes("objectid") into Objects.  Then when that's done, for each feature in that fs.features collection, check if Objects.contains(feature.attributes("objectid").
    0
  • Zack Robison
    *I forgot to mention that nested loops can become severe resource hogs and should be avoided where possible.
    0

Bitte melden Sie sich an, um einen Kommentar zu hinterlassen.