I am working on my gEDA plug and want to get rid of the existing simple system based on tile 1 in favor of real spatial index 2 .
An algorithm that effectively finds points is not enough: I need to find objects with a nonzero degree. Think in terms of objects with bounding boxes, which largely reflects the level of detail I need in the index. Given the search rectangle, I need to be able to efficiently find all objects whose bounding rectangles are inside or intersect the search rectangle.
The index cannot be read-only: gschem is a schematic capture program, and the whole point is to move elements around the schema. So everything will be all right. Therefore, although I can let you insert a little more expensive than a search, it cannot be too expensive, and removal should also be both possible and inexpensive. But the most important requirement is asymptotic behavior: the search must be O (log n) if it cannot be O (1). The insertion / deletion should preferably be O (log n), but O (n) will be fine. I definitely don't want anything> O (n) (per action, obviously, O (n log n) is expected for operation with objects).
What are my options? I do not feel smart enough to appreciate various parameters . Ideally, there would be some C library that will do all the smart things for me, but I will mechanically implement an algorithm that I may or may not fully understand if necessary. gEDA uses glib by the way, if that helps make a recommendation.
Footnote:
1 Standard gEDA divides the schematic diagram into a fixed number (currently 100) of tiles, which serves to speed up the search for objects in the bounding box. This is obviously good enough to make most circuits fast enough to search, but the way to fix them causes other problems: too many functions require a pointer to a de facto global object. The tile geometry has also been fixed: it would be possible to completely defeat this tile system, simply by panning (and possibly enlarging) to an area covered by only one tile.
2 The acceptable answer was to preserve the elements of the tile system, but to correct its shortcomings: to teach it to cover the entire space and, if necessary, to divide into two parts. But I would like others to add their two cents before I arbitrarily decide that this is the best way.
c glib
Bernd jendrissek
source share