Skip to content

Commit

Permalink
Production Release (#423)
Browse files Browse the repository at this point in the history
* feat: add function to convert exifData to GeoJson data

* feat: add function to extract exif data from image file

* feat: add function to sort array of objects using dateTime property

* hotfix: orthophoto zoom to geotiff

* refactor: handle cases of no selection

* refactor: handle cases of undefined/ null data

* refactor: rename item to exifData at map function

* refactor: remove destructuring of state and use single var

* refactor: update type for handle change event

* feat: post drone registered certificate and drone pilot certificate on profile complete

* refactor: update import of redux state

* refactor: destructure url instead of accessing whole object and accessing url

* feat: show default image on profile in case of failure

* refactor: update message mutation for if the task is not flyable

* refactor: reset exifData at redux state at initial render

* feat(update-profile): post only the binary file on certificate

* feat: add `@cyntler/react-doc-viewer` package

* feat: add document preview modal

* feat(dashboard): implement drone certificate preview on task lock request

* fix(individual-project): task requested for lock although the project owner lockes the task

* feat: set certificate & registration url in my-info endpoint

* fix: document viewer details style

* fix: UploadArea component

* feat: show uploaded certificates on edit profile page

* feat: clear selectedDocumentDetails on document preview component unmount

* docs: update user roadmap with latest requirements

* feat(document-preview): download certificate using blob and additional UI  if the file is image

* docs: tweak user roadmap based on feedback

* feat: set the certificate & registration url in task request page

* feat(dashboard): show drone certificate and pilot certificate on task request log

* feat: ommit password section if the existing user is trying to login as another role

* fix: remove comment code from task schemas

* feat(regulators-approval-page): clear local storage on main page unmount

* feat: implemented user certificate upload functionality, storing user certificates on S3. (#331)

* feat: Implement S3 path structure & file upload for user-specific drone operator certificate uploads

* refac: refactor user profile update: Add validation for empty data, handle certificate URL and role updates

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* feat: update certificate URL in database for user profile

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* feat: update registration registration of drone operator

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* fix(profile-update): UI Issue

* feat: add method parameter on `callApiSimultaneously` function

* feat(update-profile): post add files `certificate` and `drone registration` file along with the other details

* feat: post drone registered certificate and drone pilot certificate on profile complete

* feat: show default image on profile in case of failure

* feat(update-profile): post only the binary file on certificate

* feat: add `@cyntler/react-doc-viewer` package

* feat: add document preview modal

* feat(dashboard): implement drone certificate preview on task lock request

* fix(individual-project): task requested for lock although the project owner lockes the task

* feat: set certificate & registration url in my-info endpoint

* fix: document viewer details style

* fix: UploadArea component

* feat: show uploaded certificates on edit profile page

* feat: clear selectedDocumentDetails on document preview component unmount

* feat(document-preview): download certificate using blob and additional UI  if the file is image

* feat: set the certificate & registration url in task request page

* feat(dashboard): show drone certificate and pilot certificate on task request log

* feat: ommit password section if the existing user is trying to login as another role

* fix: remove comment code from task schemas

* feat(regulators-approval-page): clear local storage on main page unmount

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Sujit <[email protected]>

* fix: set iscertifiedDroneUser initial value once

* feat(user-profile): support pdf to upload certificates

* feat: add zoom to extent function

* refactor: remove unecessary states and handle session end of modal

* refactor: rename title for imageMapBox modal

* feat(project-approval-page): clear comment on approval comment success

* feat: update type for coordinates

* feat: make project `DescriptionSection` dynamic to render on both project description and project approval page

* feat: add about section on project description page

* feat: make regulator approval status optional to view on description section

* feat(project-description): make map popup disabled if the regulator approval status is `REJECTED`

* feat(project-description): disable popup open on table row click if requlator approval status is `REJECTED`

* Adjust project description as per regulator's approval status  (#361)

* feat: Implement S3 path structure & file upload for user-specific drone operator certificate uploads

* refac: refactor user profile update: Add validation for empty data, handle certificate URL and role updates

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* feat: update certificate URL in database for user profile

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* feat: update registration registration of drone operator

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* fix(profile-update): UI Issue

* feat: add method parameter on `callApiSimultaneously` function

* feat(update-profile): post add files `certificate` and `drone registration` file along with the other details

* feat: post drone registered certificate and drone pilot certificate on profile complete

* feat: show default image on profile in case of failure

* feat(update-profile): post only the binary file on certificate

* feat: add `@cyntler/react-doc-viewer` package

* feat: add document preview modal

* feat(dashboard): implement drone certificate preview on task lock request

* fix(individual-project): task requested for lock although the project owner lockes the task

* feat: set certificate & registration url in my-info endpoint

* fix: document viewer details style

* fix: UploadArea component

* feat: show uploaded certificates on edit profile page

* feat: clear selectedDocumentDetails on document preview component unmount

* feat(document-preview): download certificate using blob and additional UI  if the file is image

* feat: set the certificate & registration url in task request page

* feat(dashboard): show drone certificate and pilot certificate on task request log

* feat: ommit password section if the existing user is trying to login as another role

* fix: remove comment code from task schemas

* feat(regulators-approval-page): clear local storage on main page unmount

* fix: set iscertifiedDroneUser initial value once

* feat(user-profile): support pdf to upload certificates

* feat(project-approval-page): clear comment on approval comment success

* feat: make project `DescriptionSection` dynamic to render on both project description and project approval page

* feat: add about section on project description page

* feat: make regulator approval status optional to view on description section

* feat(project-description): make map popup disabled if the regulator approval status is `REJECTED`

* feat(project-description): disable popup open on table row click if requlator approval status is `REJECTED`

---------

Co-authored-by: Pradip-p <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Sujit <[email protected]>

* fix: hide approval section if the approval status has value

* add trailing slash(/) in the regulator approval endpoint

* style: about project

* feat(project-description): show different popup message and hide task lock button if the `regulator_approval_status` is `PENDING` or `REJECTED`

* fix: about typo and set default selected project tab to about

* fix: capitalize tab options label

* fix: update roles in existing user when auto local regulator creation

* feat(regulators-approval-section): hide approval section on approval status updates

* fix: remove commented code

* fix: show popup on task click although the project is rejected

* fix: update roles in existing user when auto local regulator creation (#362)

* fix: upadate the regulator

* Fix/regulator profile creation (#366)

* fix: update roles in existing user when auto local regulator creation

* fix: upadate the regulator

* fix: reslove user roles access issues with regulator

* feat: add drone altitude regulations model

* feat: Add 'get all' and 'get one' endpoints for drone altitudes

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* reac: Rename DbDroneAltitude class to DbDroneFlightHeight and update table name

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* feat: Implemented endpoint to retrieve all drone altitude regulations of country (#368)

* feat: add drone altitude regulations model

* feat: Add 'get all' and 'get one' endpoints for drone altitudes

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* reac: Rename DbDroneAltitude class to DbDroneFlightHeight and update table name

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

* feat: add `OSM_NOMINATIM_URL` on viteconfig and env.example

* feat(project-creation): get project country by project centroid using `OSM Nominatim API`

find centroid with the help of `truf`

Integrated Nominatim API to fetch the country based on the centroid coordinates

* Replace `pdm` to `uv` for faster dependency management (#347)

* feat: migrate from pdm to uv

* build: replace pdm with uv, add pre-commit hook to lock deps

* build: replace all usage of pdm with uv

* build:  replace pdm with uv for faster dependency managementreplace all usage of pdm with uv

* feat: update entry point to run with uv

* update: users deps login_required

---------

Co-authored-by: Niraj Adhikari <[email protected]>

* feat: add className optional prop to InfoMessage component for dynamic styling

* feat: add orthoPhoto task component

* feat: add symbol type prop for icon at tooltip

* refactor: remove delay

* feat: add functions to handle visiblity of vector layers and orthophoto layers

* refactor: remove button of show orthophoto from description section

* refactor: update onSuccess function to navigate user from task page to project page

* feat(create-project): Show warning if altitude exceeds country’s max limit

* feat(individual-project): disable popup only if the user role regulator and has no other roles

* feat(create-project): update fields description

* feat: add validations for input feild

* refactor: update onSuccess Function to navigate user to dashboard after password change

* style: add z-index to user profile

* feat: remove nominatim api from .env and vite config and save as a constant variable since it is constant on all environment

* feat: update .env.example

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* feat: Show warning if altitude exceeds country's max limit (#370)

* feat: add drone altitude regulations model

* feat: Add 'get all' and 'get one' endpoints for drone altitudes

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* reac: Rename DbDroneAltitude class to DbDroneFlightHeight and update table name

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* feat: add `OSM_NOMINATIM_URL` on viteconfig and env.example

* feat(project-creation): get project country by project centroid using `OSM Nominatim API`

find centroid with the help of `truf`

Integrated Nominatim API to fetch the country based on the centroid coordinates

* feat: add className optional prop to InfoMessage component for dynamic styling

* feat(create-project): Show warning if altitude exceeds country’s max limit

* feat(individual-project): disable popup only if the user role regulator and has no other roles

* feat(create-project): update fields description

* feat: remove nominatim api from .env and vite config and save as a constant variable since it is constant on all environment

* feat: update .env.example

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: Pradip-p <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Sujit <[email protected]>

* feat: overwrite props className using `cn` the utils function to merge class names using `clsc` and `twMerge`

* fix: typo

* feat: add validation to check if old and new password are same

* refactor: update placeholder for file upload

* feat: updated count waypoints within AOI

* fix: added auth in endpoint

* feat: update handleDrawEnd function to prevent duplicate draw

* feat: add conditional rendering for orthophoto button at map

* refactor: remove character length restriction from comment submission

* refactor: update naming of filterDuplicateFeature parameters

* fix: update waypoints count of aoi

* feat: add service to get project waypoints

* feat: implementation of project avg taskway points count api

* feat: add logic to count number of waypoints in task split (#373)

* feat: updated count waypoints within AOI

* fix: added auth in endpoint

* fix: update waypoints count of aoi

* feat: add service to get project waypoints

* feat: implementation of project avg taskway points count api

---------

Co-authored-by: Bijay Rauniyar <[email protected]>

* fix: disable popup trigger if user signin as `ReGULATOR`

* fix: added slash in waypoints count endpoint

* [pre-commit.ci] pre-commit autoupdate (#376)

updates:
- [github.com/astral-sh/uv-pre-commit: 0.5.2 → 0.5.5](astral-sh/uv-pre-commit@0.5.2...0.5.5)
- [github.com/commitizen-tools/commitizen: v3.31.0 → v4.0.0](commitizen-tools/commitizen@v3.31.0...v4.0.0)
- [github.com/astral-sh/ruff-pre-commit: v0.8.0 → v0.8.1](astral-sh/ruff-pre-commit@v0.8.0...v0.8.1)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

* refctor: update params and add a loading state for avg way points

* fix: ensure small areas merge with the nearest one in task splitting (#378)

* fix: task locking and validation error in project creator (#382)

* add images.json file into s3

* feat: add turf/transform-rotate package

* feat: add onDrag event listner and corresponding props

* feat: add type for functions to be call at on drag event

* feat: add feature to rotate filght plan

* feat: add function to calculate angle, centeroid

* feat: add funciton to rotate geojson

* refactor: update type for function params

* Feat/flightplan rotation (#383)

* feat: add turf/transform-rotate package

* feat: add onDrag event listner and corresponding props

* feat: add type for functions to be call at on drag event

* feat: add feature to rotate filght plan

* feat: add function to calculate angle, centeroid

* feat: add funciton to rotate geojson

* refactor: update type for function params

* feat: gcp app with router setup

* feat: function to calculate image footprints

* fix: regulator tags updated in routes

* functions to find images within a point

* feat: endpoint to find all the images that contains the specific point

* gcp router added in main.py

* typing used for params

* refactor: update type for calculate angle fn

* hot-fix: ignore ts on modal component

* feat: add needDragEvent Prop

* refactor: update taskDataPolygon and pass needDragEvent at vector layer

* bump drone_flightplan version

* bump drone_flightplan version (#387)

* bump drone_flightplan version to 0.3.3

* [pre-commit.ci] pre-commit autoupdate

updates:
- [github.com/astral-sh/uv-pre-commit: 0.5.5 → 0.5.7](astral-sh/uv-pre-commit@0.5.5...0.5.7)
- [github.com/commitizen-tools/commitizen: v4.0.0 → v4.1.0](commitizen-tools/commitizen@v4.0.0...v4.1.0)
- [github.com/astral-sh/ruff-pre-commit: v0.8.1 → v0.8.2](astral-sh/ruff-pre-commit@v0.8.1...v0.8.2)
- [github.com/pycontribs/mirrors-prettier: v3.3.3 → v3.4.2](pycontribs/mirrors-prettier@v3.3.3...v3.4.2)

* feat: update rotation funcitons

* feat: optimization of  flightplan rotation

* style: add dropshadow style

* feat: add newAsync Popup for taskpage

* feat: add rotattionCue component

* feat: optimize flightplan rotation

* feat: add layer ids constants

* refactor: remove unused vars

* feat: add function to swap first and last coordinate and fucntion to get last coordinate

* style: add responsive attributes to rotation cue

* refactor: update swapFirstAndLastCoordinate

* refactor: remove swapFirstAndLast coordinate function

* fix: update the flight plan time & updated waypoints conuts if user terrian follow (#390)

* feat: update api for taskDataPolygon

* refactor: update popup close fn

* refactor: update type for mouse Events

* fix: calculate bbox for the drone image (#393)

* refactor: update taskWayPointsData data

* feat: add est flight time

* refactor: update type for coordinates

* feat: generate and download KMZ files with placemarks (#392)

* Added API to generate and download KMZ files

* feat: added centroids on task details

* fix: update authentication read task

* feat: update rotation cue to handle touch events

* feat: add button to save rotated taskpoints

* Gcp calculation (#394)

* fix: calculate bbox for the drone image

* fix: calculate image footprints

* refactor: extract centroid from api

* feat: remove conditional color of points vector layer

* refactor: update get exif data function to check N and S and provide negative or positive coordinates

* style: decrease height of save rotated plan button

* feat: add rotation degree inside rotation cue

* docs: add quick summary page about GCP workflow

* style: add bgcolor for toggled buttons

* feat: update events for rotation handle

* Get a list of images that contains a GCP Point from a whole Project (#396)

* fix: calculate bbox for the drone image

* fix: calculate image footprints

* feat: get a list of images that contains a point

* Style/responsive (#397)

* refactor: remove useEffect and items to show state

* style: add css to hide spinner on input:number

* style: decrease width of select and input feilds

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

* Fix/image procssing status (#386)

* fix: add state image processing started to already image uploaded state

* fix: change updated time to be same as created at

* fix: add state for image processing to already present url

* refactor: add funcitonality to start image processing manually

* refactor: remove upload button

* style: add bg color for IMAGE_UPLOADED state

* fix: resolved image processing issues, state management for color, and dashboard listing

---------

Co-authored-by: Bijay Rauniyar <[email protected]>
Co-authored-by: Pradip-p <[email protected]>

* feat: Download dem file from JAXA if not provided by the user (#380)

* feat: auto add dem file if not provided by the user

for more information, see https://pre-commit.ci

* fix: scrapy signals issue with signals

for more information, see https://pre-commit.ci

* feat: add constants for dem radio data

* feat: add reducer and action ro set demTYpe

* feat: add dem type

* feat: auto add dem file if not provided by the user

for more information, see https://pre-commit.ci

* fix: scrapy signals issue with signals

for more information, see https://pre-commit.ci

* refactor: remove title from dem type switch

* fix: pre commit  fix

---------

Co-authored-by: Bijay Rauniyar <[email protected]>

* Update README.md

* update: label for dem file download from jaxa

* Feat/flightplan rotation (#400)

* feat: implement api to save rotated flight plan

* refactor: remove type from flightPlan mutation

* refactor: update condition to show update image button

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

* [pre-commit.ci] pre-commit autoupdate (#403)

updates:
- [github.com/astral-sh/uv-pre-commit: 0.5.7 → 0.5.9](astral-sh/uv-pre-commit@0.5.7...0.5.9)
- [github.com/astral-sh/ruff-pre-commit: v0.8.2 → v0.8.3](astral-sh/ruff-pre-commit@v0.8.2...v0.8.3)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

* feat: update drone image processor to handle single and multiple tasks (#399)

* feat: add endpoints to process all task images of AOI

* reac: refactor process_assets_from_odm function to reduce redundancy

* fix: remove double s3_path from process_assets_from_odm

* fix: added all tasks images in odm processing

* fix: remove local setup of config & docker-compose

* fix: remove multple class for drone images processing & now handle from single class

* fix: refine drone image processing

* added tags in the odm webhook router endpoint

---------

Co-authored-by: Niraj Adhikari <[email protected]>

* Update faq section to add basic frequently asked questions.md (#402)

* Update faq.md

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

* feat: initial py-test setup & update Dockerfile (#404)

* feat: setup the pytest

* feat: initial pytest setup for drone create

* feat: updated dependency overrides for login required

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* feat: updated test case for read drone

* feat: update user test routes & make dummy project data as fixtures

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

* fix: update response for flight plan

* [pre-commit.ci] pre-commit autoupdate (#412)

updates:
- [github.com/astral-sh/uv-pre-commit: 0.5.9 → 0.5.11](astral-sh/uv-pre-commit@0.5.9...0.5.11)
- [github.com/astral-sh/ruff-pre-commit: v0.8.3 → v0.8.4](astral-sh/ruff-pre-commit@v0.8.3...v0.8.4)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

* Implement Waylines flight mode in flights with terrain following enabled. (#411)

* flight mode enums

* updated drone_flightplan package

* implement waylines in terrain following as well

* upgrade drone_flightplan package

* remove: generate each points in waypoints generation

* feat: update waypint service to accept waypoint mode

* feat: add reducer state and action for waypoint mode value update

* feat: add constant waypoint options

* feat: fetch waypoint data as per selected waypoint mode

* style: download waypoints/waylines as per waypoint mode

---------

Co-authored-by: Sujit <[email protected]>
Co-authored-by: Sujit <[email protected]>

* heading angle added in popup

* fix: waypoints count

* remove unwanted params in waypoint generation

* change buffer distance for take off point

* fix: waypoints count in project creation

* fix: kmz download in android chrome

* [pre-commit.ci] pre-commit autoupdate (#418)

updates:
- [github.com/astral-sh/uv-pre-commit: 0.5.11 → 0.5.13](astral-sh/uv-pre-commit@0.5.11...0.5.13)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

* fix: Show re-upload section if image upload is failed (#417)

* feat: show re-upload section if the image count is >0 and task status is still `LOCKED_FOR_MAPPING`

if image count is >0 and status is same it indicates that all images upload is failed so it couldnt trigger the status update api

so display re-upload section if image count is >0 and status is `LOCKED_FOR_MAPPING`

* fix: download menu hidden on mobile view

 reduce waypoint mode switcher z-index

* Implement all image processing with gcp files & updated task table to maintain task areas and so on. (#416)

* feat: update the gcp files for all project images

* feat: update the new fields in tasks tables

* feat: update task areas from  db to instead  of postgis

* feat: update task flight time, flight distance & task areas

* fix: import errors in project routes

* fix: waypoints & waylines counts

* fix: only get unique task id based on task events when all image processing..

* fix: issues resolved in user task out lists in dashboard

* fixup! fix: issues resolved in user task out lists in dashboard

* feat: update assests_url in task tables instead of searching in s3

* fix: run pre-commit for format migartions file

* fix: process assests from odm, download issues

* feat: update the gcp files for all project images

* feat: update the new fields in tasks tables

* feat: update task areas from  db to instead  of postgis

* feat: update task flight time, flight distance & task areas

* fix: import errors in project routes

* fix: waypoints & waylines counts

* fix: only get unique task id based on task events when all image processing..

* fix: issues resolved in user task out lists in dashboard

* fixup! fix: issues resolved in user task out lists in dashboard

* feat: update assests_url in task tables instead of searching in s3

* fix: run pre-commit for format migartions file

* fix: process assests from odm, download issues

* feat: add dem file on task split api payload

* fix: dem data upload section is on view althoiugh the terrian follow option is false

* fix: projection creation fail if no fly is []

remove no flyzone key if np fly zone data is not available

* feat: remove unused api service `getAllAssetsUrl`

* feat: add remove project assets api fetch and display data from project description api

* feat: add action and slice for storing assets information of task

* feat(task-description-map-section): remove extra call for task information and use data from redux state

* feat: remove task-assets-information api and display data from task description api

store asests info on redux state on api call success and remove on component unmount

update keys as per data information

* refactor: comment task assets information services

* refactor: remove comment

* feat: implement dummy api for upload the task table

* fix: remove flight data from waypoints routes

---------

Co-authored-by: Sujit <[email protected]>

* fix: update all image processing without gcp files

issues solve on task table update

* hotfix: fixes on flight plan time & distance

* fix:Ensure password is saved during user creation if provided (#421)

- Updated logic to handle cases where a password is provided during profile creation.

Improved user creation flow to avoid incomplete records.

Added checks to hash and save the password if it's present.

* feat: invalidate task description storing to refetch the updated data on image upload and start processing (#422)

---------

Co-authored-by: Bijay Rauniyar <[email protected]>
Co-authored-by: Niraj Adhikari <[email protected]>
Co-authored-by: Sujit <[email protected]>
Co-authored-by: Sovas Tiwari <[email protected]>
Co-authored-by: spwoodcock <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Sujit <[email protected]>
Co-authored-by: Bijay Rauniyar <[email protected]>
Co-authored-by: Niraj Adhikari <[email protected]>
Co-authored-by: Saurav Aryal <[email protected]>
Co-authored-by: Manjita Pandey <[email protected]>
Co-authored-by: Sujit <[email protected]>
  • Loading branch information
13 people authored Jan 1, 2025
1 parent 4e371f1 commit b6b2f35
Show file tree
Hide file tree
Showing 36 changed files with 1,083 additions and 373 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ repos:

# Deps: ensure Python uv lockfile is up to date
- repo: https://github.com/astral-sh/uv-pre-commit
rev: 0.5.9
rev: 0.5.13
hooks:
- id: uv-lock
files: src/backend/pyproject.toml
Expand All @@ -95,7 +95,7 @@ repos:
# Lint / autoformat: Python code
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: "v0.8.3"
rev: "v0.8.4"
hooks:
# Run the linter
- id: ruff
Expand Down
4 changes: 2 additions & 2 deletions src/backend/app/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from pydantic_settings import BaseSettings
from typing import Annotated, Optional, Union, Any
from pydantic.networks import HttpUrl, PostgresDsn

from loguru import logger as log

HttpUrlStr = Annotated[
str,
Expand Down Expand Up @@ -122,7 +122,7 @@ def get_settings():
"""Cache settings when accessed throughout app."""
_settings = Settings()
if _settings.DEBUG:
print(f"Loaded settings: {_settings.model_dump()}")
log.info(f"Loaded settings: {_settings.model_dump()}")
return _settings


Expand Down
7 changes: 7 additions & 0 deletions src/backend/app/db/db_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,13 @@ class DbTask(Base):
take_off_point = cast(
WKBElement, Column(Geometry("POINT", srid=4326), nullable=True)
)
total_area_sqkm = cast(float, Column(Float, nullable=True))
flight_time_minutes = cast(int, Column(Float, nullable=True))
flight_distance_km = cast(float, Column(Float, nullable=True))
total_image_uploaded = cast(int, Column(SmallInteger, nullable=True))
assets_url = cast(
str, Column(String, nullable=True)
) # download link for assets of images(orthophoto)


class DbProject(Base):
Expand Down
12 changes: 6 additions & 6 deletions src/backend/app/gcp/gcp_routes.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import uuid
from app.config import settings
from app.projects import project_schemas
from fastapi import APIRouter, Depends
from app.waypoints import waypoint_schemas
from app.gcp import gcp_crud
Expand All @@ -21,15 +22,15 @@
async def find_images(
project_id: uuid.UUID,
task_id: uuid.UUID,
db: Annotated[Connection, Depends(database.get_db)],
point: waypoint_schemas.PointField = None,
) -> List[str]:
"""Find images that contain a specified point."""

fov_degree = 82.1 # For DJI Mini 4 Pro
altitude = 100 # TODO: Get this from db

result = await project_schemas.DbProject.one(db, project_id)
return await gcp_crud.find_images_in_a_task_for_point(
project_id, task_id, point, fov_degree, altitude
project_id, task_id, point, fov_degree, result.altitude
)


Expand All @@ -42,11 +43,10 @@ async def find_images_for_a_project(
"""Find images that contain a specified point in a project."""

fov_degree = 82.1 # For DJI Mini 4 Pro
altitude = 100 # TODO: Get this from db

result = await project_schemas.DbProject.one(db, project_id)
# Get all task IDs for the project from database
task_id_list = await list_task_id_for_project(db, project_id)

return await gcp_crud.find_images_in_a_project_for_point(
project_id, task_id_list, point, fov_degree, altitude
project_id, task_id_list, point, fov_degree, result.altitude
)
79 changes: 79 additions & 0 deletions src/backend/app/migrations/versions/b18103ac4ab7_.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
"""
Revision ID: b18103ac4ab7
Revises: e23c05f21542
Create Date: 2024-12-30 11:36:29.762485
"""

from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql

# revision identifiers, used by Alembic.
revision: str = "b18103ac4ab7"
down_revision: Union[str, None] = "e23c05f21542"
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.alter_column(
"task_events",
"state",
existing_type=postgresql.ENUM(
"REQUEST_FOR_MAPPING",
"UNLOCKED_TO_MAP",
"LOCKED_FOR_MAPPING",
"UNLOCKED_TO_VALIDATE",
"LOCKED_FOR_VALIDATION",
"UNLOCKED_DONE",
"UNFLYABLE_TASK",
"IMAGE_UPLOADED",
"IMAGE_PROCESSING_FAILED",
"IMAGE_PROCESSING_STARTED",
"IMAGE_PROCESSING_FINISHED",
name="state",
),
nullable=False,
)
op.add_column("tasks", sa.Column("total_area_sqkm", sa.Float(), nullable=True))
op.add_column("tasks", sa.Column("flight_time_minutes", sa.Float(), nullable=True))
op.add_column("tasks", sa.Column("flight_distance_km", sa.Float(), nullable=True))
op.add_column(
"tasks", sa.Column("total_image_uploaded", sa.SmallInteger(), nullable=True)
)
op.add_column("tasks", sa.Column("assets_url", sa.String(), nullable=True))
# ### end Alembic commands ###


def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column("tasks", "assets_url")
op.drop_column("tasks", "total_image_uploaded")
op.drop_column("tasks", "flight_distance_km")
op.drop_column("tasks", "flight_time_minutes")
op.drop_column("tasks", "total_area_sqkm")
op.alter_column(
"task_events",
"state",
existing_type=postgresql.ENUM(
"REQUEST_FOR_MAPPING",
"UNLOCKED_TO_MAP",
"LOCKED_FOR_MAPPING",
"UNLOCKED_TO_VALIDATE",
"LOCKED_FOR_VALIDATION",
"UNLOCKED_DONE",
"UNFLYABLE_TASK",
"IMAGE_UPLOADED",
"IMAGE_PROCESSING_FAILED",
"IMAGE_PROCESSING_STARTED",
"IMAGE_PROCESSING_FINISHED",
name="state",
),
nullable=True,
)
# ### end Alembic commands ###
14 changes: 13 additions & 1 deletion src/backend/app/models/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ class DroneType(IntEnum):
DJI_MINI_4_PRO = 1


class UserRole(IntEnum, Enum):
class UserRole(int, Enum):
PROJECT_CREATOR = 1
DRONE_PILOT = 2
REGULATOR = 3
Expand Down Expand Up @@ -197,3 +197,15 @@ class EventType(str, Enum):
UNLOCK = "unlock"
IMAGE_UPLOAD = "image_upload"
IMAGE_PROCESSING_START = "image_processing_start"


class FlightMode(str, Enum):
"""The flight mode of the drone.
The flight mode can be:
- ``waylines``
- ``waypoints``
"""

waylines = "waylines"
waypoints = "waypoints"
59 changes: 42 additions & 17 deletions src/backend/app/projects/image_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from app.models.enums import State
from app.utils import timestamp
from app.db import database
from app.projects import project_logic
from pyodm import Node
from app.s3 import get_file_from_bucket, list_objects_from_bucket, add_file_to_bucket
from loguru import logger as log
Expand Down Expand Up @@ -165,6 +166,17 @@ async def _process_images(
self.download_images_from_s3(bucket_name, temp_dir, self.task_id)
images_list = self.list_images(temp_dir)
else:
gcp_list_file = f"dtm-data/projects/{self.project_id}/gcp/gcp_list.txt"
gcp_file_path = os.path.join(temp_dir, "gcp_list.txt")

# Check and add the GCP file to the images list if it exists
if get_file_from_bucket(bucket_name, gcp_list_file, gcp_file_path):
images_list.append(gcp_file_path)
else:
log.info(
f"GCP file not available for project ID {self.project_id}."
)

for task_id in self.task_ids:
self.download_images_from_s3(bucket_name, temp_dir, task_id)
images_list.extend(self.list_images(temp_dir))
Expand Down Expand Up @@ -355,16 +367,22 @@ async def process_assets_from_odm(
"""
log.info(f"Starting processing for project {dtm_project_id}")
node = Node.from_url(node_odm_url)
output_file_path = f"/tmp/{dtm_project_id}"
output_file_path = f"/tmp/{uuid.uuid4()}"

try:
os.makedirs(output_file_path, exist_ok=True)
task = node.get_task(odm_task_id)
log.info(f"Downloading results for task {dtm_project_id} to {output_file_path}")
log.info(f"Downloading results for task {odm_task_id} to {output_file_path}")

assets_path = task.download_zip(output_file_path)
s3_path = f"dtm-data/projects/{dtm_project_id}/{dtm_task_id if dtm_task_id else ''}/assets.zip".strip(
"/"
)
if not os.path.exists(assets_path):
log.error(f"Downloaded file not found: {assets_path}")
raise
log.info(f"Successfully downloaded ZIP to {assets_path}")

# Construct the S3 path dynamically to avoid empty segments
task_segment = f"{dtm_task_id}/" if dtm_task_id else ""
s3_path = f"dtm-data/projects/{dtm_project_id}/{task_segment}assets.zip"
log.info(f"Uploading {assets_path} to S3 path: {s3_path}")
add_file_to_bucket(settings.S3_BUCKET_NAME, assets_path, s3_path)

Expand All @@ -379,22 +397,21 @@ async def process_assets_from_odm(
raise FileNotFoundError("Orthophoto file is missing")

reproject_to_web_mercator(orthophoto_path, orthophoto_path)
s3_ortho_path = f"dtm-data/projects/{dtm_project_id}/{dtm_task_id if dtm_task_id else ''}/orthophoto/odm_orthophoto.tif".strip(
"/"
)

s3_ortho_path = f"dtm-data/projects/{dtm_project_id}/{task_segment}orthophoto/odm_orthophoto.tif"
log.info(f"Uploading reprojected orthophoto to S3 path: {s3_ortho_path}")
add_file_to_bucket(settings.S3_BUCKET_NAME, orthophoto_path, s3_ortho_path)

images_json_path = os.path.join(output_file_path, "images.json")
s3_images_json_path = f"dtm-data/projects/{dtm_project_id}/{dtm_task_id if dtm_task_id else ''}/images.json".strip(
"/"
)

log.info(f"Uploading images.json to S3 path: {s3_images_json_path}")
add_file_to_bucket(
settings.S3_BUCKET_NAME, images_json_path, s3_images_json_path
)
if os.path.exists(images_json_path):
s3_images_json_path = (
f"dtm-data/projects/{dtm_project_id}/{task_segment}images.json"
)
log.info(f"Uploading images.json to S3 path: {s3_images_json_path}")
add_file_to_bucket(
settings.S3_BUCKET_NAME, images_json_path, s3_images_json_path
)
else:
log.warning(f"images.json not found in {output_file_path}")

log.info(f"Processing complete for project {dtm_project_id}")

Expand All @@ -418,6 +435,14 @@ async def process_assets_from_odm(
f"Task {dtm_task_id} state updated to IMAGE_PROCESSING_FINISHED in the database."
)

s3_path_url = (
f"dtm-data/projects/{dtm_project_id}/{dtm_task_id}/assets.zip"
)
# update the task table
await project_logic.update_task_field(
conn, dtm_project_id, dtm_task_id, "assets_url", s3_path_url
)

except Exception as e:
log.error(f"Error during processing for project {dtm_project_id}: {e}")

Expand Down
Loading

0 comments on commit b6b2f35

Please sign in to comment.