@@ -226,6 +226,7 @@ const FlightDetails = () => {
226226 const [ flightPathParams , setFlightPathParams ] = useState ( {
227227 heading : '' ,
228228 medianSpeed : '' ,
229+ circularRadius : '' ,
229230 boundaryNorth : '' ,
230231 boundaryEast : '' ,
231232 boundarySouth : '' ,
@@ -379,24 +380,28 @@ const FlightDetails = () => {
379380 return ;
380381 }
381382
382- // Parse boundary values (optional)
383+ // Parse circular boundary (optional)
384+ const circularRadius = parseFloat ( flightPathParams . circularRadius ) ;
385+ const circularBoundary = ! isNaN ( circularRadius ) && circularRadius > 0 ? { radius : circularRadius } : null ;
386+
387+ // Parse rectangular boundaries (optional)
383388 const boundaries = {
384389 north : parseFloat ( flightPathParams . boundaryNorth ) || 0 ,
385390 east : parseFloat ( flightPathParams . boundaryEast ) || 0 ,
386391 south : parseFloat ( flightPathParams . boundarySouth ) || 0 ,
387392 west : parseFloat ( flightPathParams . boundaryWest ) || 0
388393 } ;
389394
390- // Check if any boundary is set
391- const hasBoundaries = boundaries . north > 0 || boundaries . east > 0 ||
392- boundaries . south > 0 || boundaries . west > 0 ;
395+ // Check if any rectangular boundary is set
396+ const hasRectangularBoundaries = boundaries . north > 0 || boundaries . east > 0 ||
397+ boundaries . south > 0 || boundaries . west > 0 ;
393398
394399 setShowFlightPathModal ( false ) ;
395- processFlightPathCalculation ( heading , medianSpeed , hasBoundaries ? boundaries : null ) ;
400+ processFlightPathCalculation ( heading , medianSpeed , hasRectangularBoundaries ? boundaries : null , circularBoundary ) ;
396401 } ;
397402
398403 // Process flight path calculation with user parameters
399- const processFlightPathCalculation = ( heading , medianSpeed , boundaries = null ) => {
404+ const processFlightPathCalculation = ( heading , medianSpeed , boundaries = null , circularBoundary = null ) => {
400405 const fileInput = document . createElement ( 'input' ) ;
401406 fileInput . type = 'file' ;
402407 fileInput . accept = '.csv' ;
@@ -442,7 +447,8 @@ const FlightDetails = () => {
442447 heading ,
443448 medianSpeed ,
444449 0.025 , // scalingFactor
445- boundaries
450+ boundaries ,
451+ circularBoundary
446452 ) ;
447453
448454 if ( ! trackPoints . length ) {
@@ -464,7 +470,8 @@ const FlightDetails = () => {
464470 throw new Error ( 'Failed to save calculated flight path to database' ) ;
465471 }
466472
467- const boundaryText = boundaries ? ' with boundary constraints' : '' ;
473+ const boundaryText = circularBoundary ? ` with circular boundary (${ circularBoundary . radius } m radius)` :
474+ boundaries ? ' with rectangular boundary constraints' : '' ;
468475 setAlertMessage ( {
469476 type : 'success' ,
470477 message : `Successfully calculated and saved flight path with ${ trackPoints . length } points based on telemetry data${ boundaryText } .`
@@ -488,6 +495,7 @@ const FlightDetails = () => {
488495 setFlightPathParams ( {
489496 heading : '' ,
490497 medianSpeed : '' ,
498+ circularRadius : '' ,
491499 boundaryNorth : '' ,
492500 boundaryEast : '' ,
493501 boundarySouth : '' ,
@@ -668,13 +676,38 @@ const FlightDetails = () => {
668676 </ div >
669677 </ div >
670678
671- { /* Optional Boundary Parameters */ }
679+ { /* Circular Boundary Parameters */ }
680+ < div className = "border-t pt-4" >
681+ < h4 className = "text-sm font-medium text-gray-700 mb-2" >
682+ Circular Flight Boundary (Optional)
683+ </ h4 >
684+ < p className = "text-xs text-gray-500 mb-3" >
685+ Set a circular boundary around the takeoff point. Drone will turn when approaching this limit.
686+ </ p >
687+ < div className = "w-1/2" >
688+ < label className = "block text-xs font-medium text-gray-600 mb-1" >
689+ Radius from Takeoff Point (meters)
690+ </ label >
691+ < input
692+ type = "number"
693+ min = "0"
694+ step = "10"
695+ className = "w-full px-2 py-1 text-sm border border-gray-300 rounded-md focus:outline-none focus:ring-1 focus:ring-blue-500"
696+ placeholder = "e.g., 500"
697+ value = { flightPathParams . circularRadius }
698+ onChange = { ( e ) => setFlightPathParams ( prev => ( { ...prev , circularRadius : e . target . value } ) ) }
699+ />
700+ </ div >
701+ </ div >
702+
703+ { /* Rectangular Boundary Parameters */ }
672704 < div className = "border-t pt-4" >
673705 < h4 className = "text-sm font-medium text-gray-700 mb-2" >
674- Flight Boundaries (Optional)
706+ Rectangular Flight Boundaries (Optional)
675707 </ h4 >
676708 < p className = "text-xs text-gray-500 mb-3" >
677709 Set maximum distances in meters from takeoff point. Drone will turn when approaching these limits.
710+ Note: Circular boundary takes priority over rectangular boundaries if both are set.
678711 </ p >
679712 < div className = "grid grid-cols-2 gap-4" >
680713 < div >
0 commit comments