Image footprint coverage - #850
Conversation
drone_type.py: add FC9313 -> DJI_MINI_5_PRO. image_footprints.py: new helper functions to calculate one image’s rectangle on the ground, build footprint GeoJSON, and compute its union coverage percentage. image_classification.py: call image_footprints.py instead of circle ST_Buffer logic, then return coverage_percentage and image_footprints. classification.ts: add image_footprints to the frontend response type. TaskVerificationModal.tsx: draw image_footprints as thin rectangle outlines on the map. check if the overlap is too much/hard to see test_flight_gap_detection.py: test FC9313 works test_image_footprints: test the footprint code
Changed absolute altitude to relative altitude Highlight the rectangles based on image selected
Contributor Signature RequiredThank you for your contribution! Before we can accept your pull request, you need to sign our Contribution Policy. Why do I need to do this?
How to signTo sign the agreement, please comment on this PR with: I have read the CONTRIBUTING.md document and I hereby sign and agree with the guidelines You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot. |
for more information, see https://pre-commit.ci
|
I have read the CONTRIBUTING.md document and I hereby sign and agree with the guidelines |
spwoodcock
left a comment
There was a problem hiding this comment.
Really nice work!! This is looking great 😄
Left some small comments. The main one is about the mercator project towards the poles, which will distort the footprint calcs a lot
| # Build in meters first, then convert back to lon/lat only for display. | ||
| width_m, height_m = footprint_size | ||
| # Convert image GPS point into meter coordinates | ||
| center = transform(projector.transform, shape(image["location"])) |
There was a problem hiding this comment.
This will be an EPSG:3857 (web mercator) coordination, but the footprint calculated below is true ground meters, so the calculations as we get closer to the equator will be increasingly incorrect.
I would propose a simple solution is to correct by the 1/cos(latitude) adjustment that web mercator uses:
center = transform(projector.transform, shape(image["location"]))
x, y = center.x, center.y
# EPSG:3857 stretches ground distance by 1/cos(lat). Scale the rectangle
# so its footprint is stretched to match the mercator projection.
lat_deg = image["location"]["coordinates"][1]
mercator_scale = 1 / math.cos(math.radians(lat_deg))
half_width = (width_m / 2) * mercator_scale
half_height = (height_m / 2) * mercator_scale| # A tiny fake image where GSD makes the footprint exactly 10m x 10m. | ||
| image = { | ||
| "id": "image-1", | ||
| "location": {"type": "Point", "coordinates": [0, 0]}, |
There was a problem hiding this comment.
Both these tests uses a 0,0 coord, so won't be affected by the web meracator stretching that I mentioned.
It would be good to add an additional test at say 45 latitude, to ensure our fix handles it well.
(perhaps add the tests first, run the test and see it fail, apply the fix, run again and see it pass 😄 )
| return {"type": "FeatureCollection", "features": features} | ||
|
|
||
|
|
||
| def coverage_percentage_from_footprints( |
There was a problem hiding this comment.
This is great 👍
We calculate coverage in this endpoint, but also for the entire project in get_project_coverage.
It would be great to refactor the usage there to also use this updated code, so the project level coverage is calculated correctly (merging this as-is would cause two different values between the two implementations. The old implementation can be removed / cleaned up)
| # Frontend map layers need GeoJSON in lon/lat. | ||
| features = [] | ||
| for image in images: | ||
| footprint = image_footprint_polygon(image) |
There was a problem hiding this comment.
**any way we could consolidate these two footprint calcs, so we only have to do it once per image?
What type of PR is this? (check all applicable)
Related Issue
Fixes #819
Describe this PR
What changed
Notes
Tested
AI Tool Usage
If AI-assisted:
Screenshots
If applicable.
Alternative Approaches Considered
Did you consider other approaches? Why this one?
Review Guide
Notes for the reviewer. How to test this change?
Main things to look at:
Things I’d especially like feedback on:
Checklist
[optional] What gif best describes this PR or how it makes you feel?
https://giphy.com/gifs/square-triangle-shape-slap-V6kvt4UVqfHha3Eb19 (cuz the rectangles/squares are the superior shapes in image coverage)