@@ -111,6 +111,7 @@ extern Int32 prevnumtskter;
111
111
extern Int32 numtskter ;
112
112
extern Boolean tskoffterrain ;
113
113
extern Boolean tskcrash ;
114
+ extern Boolean terrainvalid ;
114
115
extern Int32 rxrecs ;
115
116
extern char rxtype [15 ];
116
117
extern DateTimeType curtime ;
@@ -310,59 +311,8 @@ void refresh_task_details(Int16 action)
310
311
StrCopy (data .activetask .declaredtg , SecondsToDateOrTimeString (TimGetSeconds (), tempchar , 4 , data .config .timezone * -1 ));
311
312
}
312
313
313
- // clear terrain array
314
- if ((prevnumtskter > 0 ) && (tskterheights != NULL )) {
315
- // free previous array
316
- FreeMem ((void * )& tskterheights );
317
- tskterheights = NULL ;
318
- }
319
-
320
314
// load terrain on task
321
- if (data .config .usefgterrain ) {
322
-
323
- // calculate array size
324
- numtskter = 0 ;
325
- for (x = 0 ; x < tsk -> numwaypts ; x ++ ) {
326
- // HostTraceOutputTL(appErrorClass, "Task Terrain Index %s", DblToStr(numtskter,0));
327
- if ((tsk -> waypttypes [x ] & CONTROL ) == 0 ) numtskter += (Int32 )(tsk -> distances [x ] * TERGRID )+ 1 ;
328
- // HostTraceOutputTL(appErrorClass, "Task Terrain Points %s", DblToStr(numtskter,0));
329
- tsk -> terrainidx [x ] = numtskter ;
330
- }
331
- tsk -> terrainidx [x ] = numtskter ;
332
-
333
- // allocate new size array
334
- if (AllocMem ((void * )& tskterheights , (numtskter + 1 )* sizeof (double ))) {
335
- MemSet (tskterheights , (numtskter + 1 )* sizeof (double ), 0 );
336
- prevnumtskter = numtskter ;
337
-
338
- // load terrain array for each leg
339
- // HostTraceOutputTL(appErrorClass, "Loading Task Terrain.....");
340
- tskoffterrain = false;
341
- for (x = 0 ; x < tsk -> numwaypts - 1 ; x ++ ) {
342
- while (tsk -> waypttypes [x ] & CONTROL ) x ++ ;
343
- z = x + 1 ;
344
- while (tsk -> waypttypes [z ] & CONTROL ) z ++ ;
345
- // HostTraceOutputTL(appErrorClass, "Load Terrain From %s", tsk->wayptnames[x]);
346
- // HostTraceOutputTL(appErrorClass, "Load Terrain To %s", tsk->wayptnames[z]);
347
- // HostTraceOutputTL(appErrorClass, "start Terrain Points %s", DblToStr((tsk->terrainidx[x]),0));
348
- // HostTraceOutputTL(appErrorClass, "Task Terrain Points %s", DblToStr((tsk->terrainidx[z]-tsk->terrainidx[x]),0));
349
- tskoffterrain = tskoffterrain | !loadterrain (& tskterheights [tsk -> terrainidx [x ]], (tsk -> terrainidx [z ]- tsk -> terrainidx [x ]), tsk -> wayptlats [x ], tsk -> wayptlons [x ], tsk -> elevations [x ], tsk -> wayptlats [z ], tsk -> wayptlons [z ], tsk -> elevations [z ]);
350
- }
351
-
352
- // HostTraceOutputTL(appErrorClass, "Terrain Heights.....");
353
- //for (x = 0; x < numtskter; x++) {
354
- // HostTraceOutputTL(appErrorClass, "Task Terrain Height %s", DblToStr(tskterheights[x],0));
355
- //}
356
-
357
- // check full task for terrain crash
358
- tskcrash = false;
359
- } else {
360
- // AllocMeme failed
361
- tskoffterrain = true;
362
- }
363
- } else {
364
- tskcrash = false;
365
- }
315
+ tskoffterrain = !loadtskterrain (tsk );
366
316
367
317
// copy task
368
318
// HostTraceOutputTL(appErrorClass, "Copy to data.task");
@@ -2995,6 +2945,7 @@ void HandleTask(Int16 action)
2995
2945
2996
2946
//************* TSKNONE
2997
2947
x = activetskway ;
2948
+ glidingtoheight = ELEVATION ;
2998
2949
if (tasknotfinished && !taskonhold && (activetskway >= 0 )) {
2999
2950
if (data .config .AATmode == AAT_MTURN_ON ) {
3000
2951
// update range / bearing to target in current area
@@ -3023,9 +2974,13 @@ void HandleTask(Int16 action)
3023
2974
// check if gliging to min finish height
3024
2975
glidingtoheight = FINISHHEIGHT ;
3025
2976
data .inuseWaypoint .elevation = data .activetask .finishheight ;
2977
+ } else if ((data .task .waypttypes [x ] & AREA )
2978
+ && (LatLonToRange2 (data .task .targetlats [x ],data .task .targetlons [x ],data .task .wayptlats [x ],data .task .wayptlons [x ]) > 0.25 )) {
2979
+ // gliding to area target elevation
2980
+ data .inuseWaypoint .elevation = GetTerrainElev (data .inuseWaypoint .lat , data .inuseWaypoint .lon );
2981
+ if (!terrainvalid ) data .inuseWaypoint .elevation = data .task .elevations [x ];
3026
2982
} else {
3027
- // gliding to normal elevation
3028
- glidingtoheight = ELEVATION ;
2983
+ // gliding to normal waypoint elevation
3029
2984
data .inuseWaypoint .elevation = data .task .elevations [x ];
3030
2985
}
3031
2986
data .input .destination_elev = data .inuseWaypoint .elevation ;
@@ -3040,8 +2995,6 @@ void HandleTask(Int16 action)
3040
2995
data .inuseWaypoint .arearadius = data .task .arearadii [x ];
3041
2996
data .inuseWaypoint .arearadius2 = data .task .arearadii2 [x ];
3042
2997
data .input .destination_valid = true;
3043
- } else {
3044
- glidingtoheight = ELEVATION ;
3045
2998
}
3046
2999
InuseWaypointCalcEvent ();
3047
3000
@@ -3136,30 +3089,18 @@ Boolean InSectorTest(double leftbrg, double rightbrg, double inrng, double outrn
3136
3089
return (true);
3137
3090
}
3138
3091
3092
+ // Determine if currently within the defined range limits
3093
+ if (currng >= inrng && currng <= outrng ) {
3094
+ withinrng = true;
3095
+ // HostTraceOutputTL(appErrorClass, "IST:withinrng =|%hd|", (Int16)withinrng);
3096
+ } else {
3097
+ return (false);
3098
+ }
3099
+
3139
3100
if (leftbrg != rightbrg ) {
3140
3101
recipbrg = RecipCse (curbrg );
3141
3102
// HostTraceOutputTL(appErrorClass, "IST:recipbrg =|%s|", DblToStr(recipbrg, 1));
3142
3103
3143
- // OLD METHOD
3144
- /* // Determine if currently within the defined bearing limits
3145
- if (leftbrg < 180.0) {
3146
- if (recipbrg >= leftbrg && recipbrg <= rightbrg) {
3147
- withinbrg = true;
3148
- // HostTraceOutputTL(appErrorClass, "IST:withinbrg1 =|%hd|", (Int16)withinbrg);
3149
- }
3150
- } else if (rightbrg < 360.0 && rightbrg > leftbrg) {
3151
- if (recipbrg >= leftbrg && recipbrg <= rightbrg) {
3152
- withinbrg = true;
3153
- // HostTraceOutputTL(appErrorClass, "IST:withinbrg2 =|%hd|", (Int16)withinbrg);
3154
- }
3155
- } else {
3156
- if (recipbrg >= leftbrg || recipbrg <= rightbrg) {
3157
- withinbrg = true;
3158
- // HostTraceOutputTL(appErrorClass, "IST:withinbrg3 =|%hd|", (Int16)withinbrg);
3159
- }
3160
- }
3161
- */
3162
- // NEW METHOD
3163
3104
if (leftbrg > rightbrg ) {
3164
3105
rightbrg += 360.0 ;
3165
3106
}
@@ -3174,20 +3115,7 @@ Boolean InSectorTest(double leftbrg, double rightbrg, double inrng, double outrn
3174
3115
// HostTraceOutputTL(appErrorClass, "IST:withinbrg4 =|%hd|", (Int16)withinbrg);
3175
3116
}
3176
3117
3177
- // Determine if currently within the defined range limits
3178
- if (currng >= inrng && currng <= outrng ) {
3179
- withinrng = true;
3180
- // HostTraceOutputTL(appErrorClass, "IST:withinrng =|%hd|", (Int16)withinrng);
3181
- }
3182
- if (withinbrg && withinrng ) {
3183
- // HostTraceOutputTL(appErrorClass, "IST:return(true)");
3184
- // HostTraceOutputTL(appErrorClass, "IST:--------------------------------");
3185
- return (true);
3186
- } else {
3187
- // HostTraceOutputTL(appErrorClass, "IST:return(false)");
3188
- // HostTraceOutputTL(appErrorClass, "IST:--------------------------------");
3189
- return (false);
3190
- }
3118
+ return (withinbrg );
3191
3119
}
3192
3120
3193
3121
// Doesn't matter whether bearings are true or magnectic
@@ -4478,8 +4406,7 @@ void HandleTaskAutoZoom(double range, double radius, Boolean reset)
4478
4406
// HostTraceOutputTL(appErrorClass, "ct %s", DblToStr(ct,0));
4479
4407
ct ++ ;
4480
4408
}
4481
- // do once - progressive zoom in
4482
- // HandleTaskAutoZoom2(range, radius, reset);
4409
+ return ;
4483
4410
}
4484
4411
4485
4412
// new method - based on range to target point
@@ -4555,21 +4482,21 @@ Boolean HandleTaskAutoZoom2(double range, double radius, Boolean reset)
4555
4482
actualmapscale = curmapscale * data .input .disconst ;
4556
4483
savemapscale = 0.0 ;
4557
4484
tempscale = 100 ;
4558
- data .input .logpollint = data .config .slowlogint ;
4559
4485
// HostTraceOutputTL(appErrorClass, "Zoom Out Reset");
4560
4486
}
4561
4487
}
4562
4488
}
4563
-
4564
4489
// HostTraceOutputTL(appErrorClass, "Zoom act %s", DblToStr(curmapscale,1));
4565
4490
4566
4491
// // Change the logger interval to fast if getting close to the task point
4567
- // if (range <= radius * 1.5) {
4568
- // data.input.logpollint = data.config.fastlogint;
4569
- // } else {
4570
- // data.input.logpollint = data.config.slowlogint;
4571
- // }
4492
+ if (range > radius + 0.5 ) {
4493
+ // more than 0.5nm away, so set to slow logging
4494
+ data .input .logpollint = data .config .slowlogint ;
4495
+ } else {
4496
+ data .input .logpollint = data .config .fastlogint ;
4497
+ }
4572
4498
}
4499
+
4573
4500
return (zoomchg );
4574
4501
}
4575
4502
@@ -6074,7 +6001,7 @@ Boolean form_waypoint_sector_event_handler(EventPtr event)
6074
6001
double sect1 , sect2 ;
6075
6002
double truecse , xfactor , yfactor ;
6076
6003
Int16 y ;
6077
- static Boolean origmanualzoomchg ;
6004
+ static Boolean origmanualzoomchg , targetmoved ;
6078
6005
6079
6006
#define zoomfactor 3.0
6080
6007
#define buttonsize 30
@@ -6232,6 +6159,7 @@ Boolean form_waypoint_sector_event_handler(EventPtr event)
6232
6159
data .config .sectormaporient = NORTHUP ;
6233
6160
data .input .curmaporient = NORTHUP ;
6234
6161
}
6162
+ targetmoved = false;
6235
6163
UpdateMap2 (false, sectorlat , sectorlon , sectorscale , false, tsktoedit , false);
6236
6164
6237
6165
handled = true;
@@ -6279,13 +6207,22 @@ Boolean form_waypoint_sector_event_handler(EventPtr event)
6279
6207
// question->type = Qacttaskchg;
6280
6208
// FrmPopupForm(form_question);
6281
6209
// }
6210
+ // load terrain on task
6211
+ tskoffterrain = !loadtskterrain (tsktoedit );
6282
6212
} else if (!gototskwpt ) {
6283
6213
// restore edittsk prior to changes
6284
6214
MemMove (temptsk , edittsk , sizeof (TaskData ));
6285
6215
}
6286
6216
gototskwpt = false;
6287
6217
goingtomenu = false;
6288
6218
break ;
6219
+ case nilEvent :
6220
+ if (targetmoved ) {
6221
+ // load terrain on task if target point has changed in active task
6222
+ if (activetasksector ) tskoffterrain = !loadtskterrain (tsktoedit );
6223
+ targetmoved = false;
6224
+ }
6225
+ break ;
6289
6226
case ctlSelectEvent :
6290
6227
PlayKeySound ();
6291
6228
// if (taskIndex == 0) set_task_changed = true;
@@ -6303,6 +6240,7 @@ Boolean form_waypoint_sector_event_handler(EventPtr event)
6303
6240
}
6304
6241
tsktoedit -> aataimtype = AATusr ;
6305
6242
updatemap = true;
6243
+ targetmoved = true;
6306
6244
break ;
6307
6245
case form_waypoint_sector_min :
6308
6246
// HostTraceOutputTL(appErrorClass, "Min");
@@ -6317,6 +6255,7 @@ Boolean form_waypoint_sector_event_handler(EventPtr event)
6317
6255
}
6318
6256
tsktoedit -> aataimtype = AATusr ;
6319
6257
updatemap = true;
6258
+ targetmoved = true;
6320
6259
break ;
6321
6260
case form_waypoint_sector_center :
6322
6261
// HostTraceOutputTL(appErrorClass, "Center");
@@ -6338,6 +6277,7 @@ Boolean form_waypoint_sector_event_handler(EventPtr event)
6338
6277
}
6339
6278
tsktoedit -> aataimtype = AATusr ;
6340
6279
updatemap = true;
6280
+ targetmoved = true;
6341
6281
break ;
6342
6282
default :
6343
6283
break ;
@@ -6533,7 +6473,7 @@ Boolean form_waypoint_sector_event_handler(EventPtr event)
6533
6473
//}
6534
6474
tsktoedit -> aataimtype = AATusr ;
6535
6475
updatemap = true;
6536
- // if (taskIndex == 0) set_task_changed = true;
6476
+ targetmoved = true;
6537
6477
handled = true;
6538
6478
}
6539
6479
@@ -6569,11 +6509,12 @@ Boolean form_waypoint_sector_event_handler(EventPtr event)
6569
6509
} else {
6570
6510
temprng = tsktoedit -> arearadii2 [selectedTaskWayIdx ];
6571
6511
}
6572
- RangeBearingToLatLonLinearInterp (tsktoedit -> wayptlats [selectedTaskWayIdx ], tsktoedit -> wayptlons [selectedTaskWayIdx ], temprng , nice_brg (tempbrg + 180 ), & tsktoedit -> targetlats [selectedTaskWayIdx ], & tsktoedit -> targetlons [selectedTaskWayIdx ]);
6512
+ RangeBearingToLatLonLinearInterp (tsktoedit -> wayptlats [selectedTaskWayIdx ], tsktoedit -> wayptlons [selectedTaskWayIdx ], temprng , nice_brg (tempbrg + 180 ), & tsktoedit -> targetlats [selectedTaskWayIdx ], & tsktoedit -> targetlons [selectedTaskWayIdx ]);
6573
6513
}
6574
6514
tsktoedit -> aataimtype = AATusr ;
6575
6515
// if (taskIndex == 0) set_task_changed = true;
6576
6516
updatemap = true;
6517
+ targetmoved = true;
6577
6518
handled = true;
6578
6519
}
6579
6520
@@ -6609,11 +6550,12 @@ Boolean form_waypoint_sector_event_handler(EventPtr event)
6609
6550
} else {
6610
6551
temprng = tsktoedit -> arearadii2 [selectedTaskWayIdx ];
6611
6552
}
6612
- RangeBearingToLatLonLinearInterp (tsktoedit -> wayptlats [selectedTaskWayIdx ], tsktoedit -> wayptlons [selectedTaskWayIdx ], temprng , nice_brg (tempbrg + 180 ), & tsktoedit -> targetlats [selectedTaskWayIdx ], & tsktoedit -> targetlons [selectedTaskWayIdx ]);
6553
+ RangeBearingToLatLonLinearInterp (tsktoedit -> wayptlats [selectedTaskWayIdx ], tsktoedit -> wayptlons [selectedTaskWayIdx ], temprng , nice_brg (tempbrg + 180 ), & tsktoedit -> targetlats [selectedTaskWayIdx ], & tsktoedit -> targetlons [selectedTaskWayIdx ]);
6613
6554
}
6614
6555
tsktoedit -> aataimtype = AATusr ;
6615
6556
// if (taskIndex == 0) set_task_changed = true;
6616
6557
updatemap = true;
6558
+ targetmoved = true;
6617
6559
handled = true;
6618
6560
}
6619
6561
@@ -6648,11 +6590,12 @@ Boolean form_waypoint_sector_event_handler(EventPtr event)
6648
6590
} else {
6649
6591
temprng = tsktoedit -> arearadii2 [selectedTaskWayIdx ];
6650
6592
}
6651
- RangeBearingToLatLonLinearInterp (tsktoedit -> wayptlats [selectedTaskWayIdx ], tsktoedit -> wayptlons [selectedTaskWayIdx ], temprng , nice_brg (tempbrg + 180 ), & tsktoedit -> targetlats [selectedTaskWayIdx ], & tsktoedit -> targetlons [selectedTaskWayIdx ]);
6593
+ RangeBearingToLatLonLinearInterp (tsktoedit -> wayptlats [selectedTaskWayIdx ], tsktoedit -> wayptlons [selectedTaskWayIdx ], temprng , nice_brg (tempbrg + 180 ), & tsktoedit -> targetlats [selectedTaskWayIdx ], & tsktoedit -> targetlons [selectedTaskWayIdx ]);
6652
6594
}
6653
6595
tsktoedit -> aataimtype = AATusr ;
6654
6596
// if (taskIndex == 0) set_task_changed = true;
6655
6597
updatemap = true;
6598
+ targetmoved = true;
6656
6599
handled = true;
6657
6600
}
6658
6601
@@ -6683,11 +6626,12 @@ Boolean form_waypoint_sector_event_handler(EventPtr event)
6683
6626
} else {
6684
6627
temprng = tsktoedit -> arearadii2 [selectedTaskWayIdx ];
6685
6628
}
6686
- RangeBearingToLatLonLinearInterp (tsktoedit -> wayptlats [selectedTaskWayIdx ], tsktoedit -> wayptlons [selectedTaskWayIdx ], temprng , nice_brg (tempbrg + 180 ), & tsktoedit -> targetlats [selectedTaskWayIdx ], & tsktoedit -> targetlons [selectedTaskWayIdx ]);
6629
+ RangeBearingToLatLonLinearInterp (tsktoedit -> wayptlats [selectedTaskWayIdx ], tsktoedit -> wayptlons [selectedTaskWayIdx ], temprng , nice_brg (tempbrg + 180 ), & tsktoedit -> targetlats [selectedTaskWayIdx ], & tsktoedit -> targetlons [selectedTaskWayIdx ]);
6687
6630
}
6688
6631
tsktoedit -> aataimtype = AATusr ;
6689
6632
// if (taskIndex == 0) set_task_changed = true;
6690
6633
updatemap = true;
6634
+ targetmoved = true;
6691
6635
handled = true;
6692
6636
}
6693
6637
0 commit comments