[gt-users] get feature by ID

Gordon Gremme gremme at gmail.com
Thu Feb 12 12:31:30 CET 2009


>> i do this often enough that i just wrote a FeatureIndexMemory subclass
>> to automatically
>> create a dict with key => value of  ID => gt_pointer. then the
>> FeatureNode object is not
>> created until it's actually requested.
>> i also had some fun abusing the python slicing syntax. usage and
>> implementation here:
>> http://gist.github.com/62359
>>
>> it currently doesn't handle potentially repeated ID's... but i'm
>> usually just dealing with a single file at a time.
>
> Looks very convenient and intuitive (python-like) to use. If this can be
> extended to handle ID clashes as well (e.g. by using the filename as an
> additional key which is optional if there is only one file), it may find
> its way into the official bindings. Any comments?

Another possibility would be to return an array of all Features with
the given ID.

Wouldn't it make more sense to have this functionality on the C-side?
It's not complicated to implement.
This way it would be available for all bindings without reimplementing
it for every binding.

Gordon


More information about the gt-users mailing list