Shapefile.GetRelatedShapes(2) has side-effect of clearing 'selection' set

Description

GetRelatedShapeCore is called internally by GetRelatedShapes and GetRelatedShapes2.

This method uses GEOS geometries to perform the specified operation, and in the past, the entire Shapefile would be converted to GEOS geometries, which could be thousands of shapes, after which a QTree operation may determine that only 1 or a few Shapes actually needed to be converted.

As an optimization (implemented last year) this method was modified to only convert those geometries that were returned by the QTree operation, and it used the 'selected' flag of each shape to tag those that required conversion. When the operation was complete, all 'selected' flags would be cleared. The problem is that if you are using the 'selected' flag for an actual 'selection' operation (the cmSelection tool), then your 'selected' set would be cleared whenever this method was called.

I have changed this method so that it does not use or modify the 'selected' set, but instead uses a local std::set to hold the ID's of those shapes identified by the QTree operation. And a new private helper function was created ReadGeosGeometries(std::set<int> list) to convert just those shapes to GEOS geometries.

Environment

None

Assignee

Jerry Faust

Reporter

Jerry Faust

Labels

None

Fix versions

Priority

Medium
Configure