@@ -311,34 +311,7 @@ def cmd_map(self, args):
311
311
self .vehicle_type_override [sysid ] = vtype
312
312
print ("Set sysid %u to vehicle type %u" % (sysid , vtype ))
313
313
elif args [0 ] == "circle" :
314
- if len (args ) < 4 :
315
- # map circle -27.70533373 153.23404844 5 red
316
- print ("Usage: map circle <lat> <lon> <radius> <colour>" )
317
- else :
318
- lat = args [1 ]
319
- lon = args [2 ]
320
- radius = args [3 ]
321
- colour = 'red'
322
- if len (args ) > 4 :
323
- colour = args [4 ]
324
- if colour == "red" :
325
- colour = (255 ,0 ,0 )
326
- elif colour == "green" :
327
- colour = (0 ,255 ,0 )
328
- elif colour == "blue" :
329
- colour = (0 ,0 ,255 )
330
- else :
331
- colour = eval (colour )
332
- circle = mp_slipmap .SlipCircle (
333
- "circle %u" % self .circle_counter ,
334
- 3 ,
335
- (float (lat ), float (lon )),
336
- float (radius ),
337
- colour ,
338
- linewidth = 1 ,
339
- )
340
- self .map .add_object (circle )
341
- self .circle_counter += 1
314
+ self .cmd_map_circle (args [1 :])
342
315
elif args [0 ] == "set" :
343
316
self .map_settings .command (args [1 :])
344
317
self .map .add_object (mp_slipmap .SlipBrightness (self .map_settings .brightness ))
@@ -365,6 +338,64 @@ def cmd_map(self, args):
365
338
else :
366
339
print ("usage: map <icon|set>" )
367
340
341
+ def cmd_map_circle (self , args ):
342
+ usage = '''
343
+ Usage: map circle <lat> <lon> <radius> <colour>
344
+ Usage: map circle <radius> <colour>
345
+ '''
346
+
347
+ lat = None
348
+ colour = None
349
+ # syntax 1, lat/lon/radius/colour
350
+ if len (args ) == 4 :
351
+ colour = args [3 ]
352
+ args = args [0 :3 ]
353
+ if len (args ) == 3 :
354
+ lat = args [0 ]
355
+ lon = args [1 ]
356
+ radius = args [2 ]
357
+
358
+ # syntax 2, radius/colour, uses click position
359
+ if len (args ) == 2 :
360
+ colour = args [1 ]
361
+ args = args [0 :1 ]
362
+ if len (args ) == 1 :
363
+ pos = self .mpstate .click_location
364
+ if pos is None :
365
+ print ("Need click or location" )
366
+ print (usage )
367
+ return
368
+
369
+ (lat , lon ) = pos
370
+ radius = args [0 ]
371
+
372
+ if lat is None :
373
+ print (usage )
374
+ return
375
+
376
+ if colour is None :
377
+ colour = "red"
378
+
379
+ if colour == "red" :
380
+ colour = (255 ,0 ,0 )
381
+ elif colour == "green" :
382
+ colour = (0 ,255 ,0 )
383
+ elif colour == "blue" :
384
+ colour = (0 ,0 ,255 )
385
+ else :
386
+ colour = eval (colour )
387
+
388
+ circle = mp_slipmap .SlipCircle (
389
+ "circle %u" % self .circle_counter ,
390
+ 3 ,
391
+ (float (lat ), float (lon )),
392
+ float (radius ),
393
+ colour ,
394
+ linewidth = 1 ,
395
+ )
396
+ self .map .add_object (circle )
397
+ self .circle_counter += 1
398
+
368
399
def colour_for_wp (self , wp_num ):
369
400
'''return a tuple describing the colour a waypoint should appear on the map'''
370
401
wp = self .module ('wp' ).wploader .wp (wp_num )
0 commit comments