381 helmert#385
Conversation
|
This is fully functional, so it is ready to merge to get more feedback. After that, documentation and an update to the modal can follow. For now, the new feature is behind a permissions wall (this served as a good excuse to set the foundation of a better permissions system anyway). For users with permissions:
Further note about the permissions system: Django has "Permissions" objects, "Groups", and "Users". Permission objects can be assigned to Groups, or directly to individual Users, while a User can be added to one or more Groups. So a User's full Permissions list is an aggregation of Permissions assigned to any Groups they are members of, plus any individual Permissions that have been directly assigned to them. For the highest level of granularity, I think it is good practice for the code base to test against specific permissions rather to test against group membership. With that in mind, this helmert transformation option tests against the |
| difference = pt_degrees - px_degrees | ||
| return difference | ||
|
|
||
| def _calculate_helmert_offsets(self, scale: float, rotation: float) -> Tuple[float, float]: |
There was a problem hiding this comment.
Do you have any unit tests for this code? It should be pretty amenable to it, and this would encourage me to try and clean up some of the if statements here :)
There was a problem hiding this comment.
Unfortunately no unit tests. It was a lot of trial and error within the interface to figure the math out, and those if clauses just ended up working. I'd have to take some time to actually figure out what the proper test cases would be, and yeah, I bet that section could be consolidated.
Initial work to support 4-parameter helmert transformation, i.e. georeferencing with only two GCPs, as requested by @danvk in #381.
I've wired up the front-end to show a preview after two GCPs have been added. Helmert is automatically used as the transformation at that point.
If you click the checkmark to submit at this point, a modal appears with a warning:
On the backend, the transformation is run just the same as before, but different arguments are passed to GDAL's warp operation. A proj pipeline is used to pass the 4 parameters and define the transformation. These parameters are:
To do:
The x and y offset does not work properly when the GCPs are in specific quadrants / at specific angles. In these instances the result also differs based on which of the two GCPs is used for the calculations (though neither works properly):