-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Template based referenced geometry class #4720
Conversation
The script wasn't waiting for spaces around the |
30ec81b
to
1cf53ff
Compare
LGTM! |
@m-kuhn @wonder-sk keen for feedback here |
I would probably still reconsider the approach with having QgsReferencedRectangle as a subclass of QgsRectangle:
The only source of trouble I can see (in the scenario without virtual destructor) is when someone would be passing QgsReferencedRectangle by pointer, then it would be cast to QgsRectangle pointer and then deleted using that pointer, but this sounds like unlikely scenario as rectangles are normally meant to be passed by reference or by value. |
What's the plan with?
Hide this in the subclass?
On the other hand, the composition approach in this pull request could be enhanced with a conversion operator, no need to explicitly convert every time (in C++ at least).
|
should be IMHO changed to
(no reason to pass by pointer) and in the referenced rect subclass there could be extra override:
(the extra "ok" output argument to indicate reprojection errors) So if at least one of the rects is not referenced, you get the basic variant thanks to automatic upcasting, when they are both referenced rects, you get the variant with reprojection... |
@wonder-sk hows this approach for you? |
1721577
to
96e6d9e
Compare
See qgis#4720 (comment) for discussion of the rationale
96e6d9e
to
f1313af
Compare
Travis is consistently timing out at the moment, but this passed before I fixed a trival merge conflict. So I'm declaring it safe to merge. |
This PR adds a new template based QgsReferencedGeometryPrimitive class, which consists of a geometry primitive and an associated CRS. The intention here is that primitive specific classes are created - included in this PR is QgsReferencedRectangle, for a QgsRectangle with optional CRS. But other uses could be referenced QgsPointXY, QgsGeometry, QgsCircle, etc....
Use is:
I think this is a better approach then subclassing QgsRectangle, because:
An alternative approach would be adding the crs as a member to QgsRectangle - but again there's a memory cost here and QgsRectangle needs to be kept small and light.
That's why I've gone for this approach. I don't like having to access the underlying rectangle with the .rect() method, but I can't see a good alternative.
Main use case here is: