@@ -46,47 +46,47 @@ def do_ls(self, name: str = ""):
46
46
list_cities (query .find ())
47
47
48
48
def do_city_neighbors (self , args : str ):
49
- """find <count > (default: 5) next neighbors to city <name>\n usage: city_neighbors <name>, [,<count >]"""
49
+ """find <num > (default: 5) next neighbors to city <name>\n usage: city_neighbors <name> [,<num >]"""
50
50
try :
51
51
args = args .split (',' )
52
52
if len (args ) > 2 :
53
53
raise ValueError ()
54
54
city = args [0 ]
55
55
if len (city ) == 0 :
56
56
raise ValueError ()
57
- count = 5
57
+ num = 5
58
58
if len (args ) == 2 :
59
- count = int (args [1 ])
59
+ num = int (args [1 ])
60
60
qb = self ._box .query ()
61
61
qb .equals_string (self ._name_prop , city )
62
62
query = qb .build ()
63
63
cities = query .find ()
64
64
if len (cities ) == 1 :
65
65
location = cities [0 ].location
66
66
qb = self ._box .query ()
67
- qb .nearest_neighbors_f32 (self ._location_prop , location , count + 1 ) # +1 for the city
67
+ qb .nearest_neighbors_f32 (self ._location_prop , location , num + 1 ) # +1 for the city
68
68
qb .not_equals_string (self ._name_prop , city )
69
69
neighbors = qb .build ().find_with_scores ()
70
70
list_cities_with_scores (neighbors )
71
71
else :
72
72
print (f"no city found named '{ city } '" )
73
73
except ValueError :
74
- print ("usage: city_neighbors <name>[,<count >]" )
74
+ print ("usage: city_neighbors <name>[,<num: default 5 >]" )
75
75
76
76
def do_neighbors (self , args ):
77
- """find <count > neighbors to geo-coord <lat> <long>.\n usage: neighbors <count >,<latitude>,<longitude>"""
77
+ """find <num > neighbors next to geo-coord <lat> <long>.\n usage: neighbors <num >,<latitude>,<longitude>"""
78
78
try :
79
79
args = args .split (',' )
80
80
if len (args ) != 3 :
81
81
raise ValueError ()
82
- count = int (args [0 ])
82
+ num = int (args [0 ])
83
83
geocoord = [ float (args [1 ]), float (args [2 ]) ]
84
84
qb = self ._box .query ()
85
- qb .nearest_neighbors_f32 (self ._location_prop , geocoord , count )
85
+ qb .nearest_neighbors_f32 (self ._location_prop , geocoord , num )
86
86
neighbors = qb .build ().find_with_scores ()
87
87
list_cities_with_scores (neighbors )
88
88
except ValueError :
89
- print ("usage: neighbors <count >,<latitude>,<longitude>" )
89
+ print ("usage: neighbors <num >,<latitude>,<longitude>" )
90
90
91
91
def do_add (self , args : str ):
92
92
"""add new location\n usage: add <name>,<lat>,<long>"""
0 commit comments