Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimise storage/calculation of geometry bounding boxes #2824

Merged
merged 2 commits into from
Feb 21, 2016

Conversation

nyalldawson
Copy link
Collaborator

This commit delivers a few optimisations to geometry classes:

  1. Removes the storage of an unnecessary QgsRectangle bounding box from QgsPointV2 (gives significant decrease in size of object: 80->48 bytes). This also has follow one benefits to all other geometry classes which storage nodes as QgsPointV2.
  2. Implements a more efficient calculation method for the bounding box of linestrings.

Additionally, this commit moves the bounding box invalidation to a virtual QgsAbstractGeometryV2::clearCache() method, so that other non-bounding box caches can also be cleared when the geometry is modified. @jef-n #2817 will benefit from this (and also the smaller QgsPointV2 objects)

- removes storage of bounding box from QgsPointV2 (gives significant
decrease in size of object)
- more efficient calculation of bounding box for linestrings

Additionally, this commit moves the bounding box invalidation to a
virtual QgsAbstractGeometryV2::clearCache() method, so that other
non-bounding box caches can also be cleared when the geometry
is modified.
@jef-n
Copy link
Member

jef-n commented Feb 21, 2016

then the local mCS in #2817 should probably disappear from QgsAbstractGeometryV2 to avoid it in QgsPointV2. But what should the reference returned by QgsPointV2::coordinateSequence() point at in that case?

@nyalldawson
Copy link
Collaborator Author

@jef-n maybe don't return a reference. QList is implicitly shared anyway, so returning a copy should be inexpensive. And then QgsPointV2 can just create a new sequence with a copy of the point instead.

jef-n added a commit that referenced this pull request Feb 21, 2016
Optimise storage/calculation of geometry bounding boxes
@jef-n jef-n merged commit 4485d3a into qgis:master Feb 21, 2016
@nyalldawson nyalldawson deleted the geombbox branch February 26, 2016 01:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants