geoSearchStore method
GEOSEARCHSTORE destination source FROMMEMBER member
FROMLONLAT longitude latitude BYRADIUS radius m|km|ft|mi
BYBOX width height m|km|ft|mi ASC|DESC [COUNT count ANY]
[STOREDIST]
This command is like GEOSEARCH, but stores the result in
destination key.
Implementation
Future<int> geoSearchStore(
String destination,
String source, {
String? fromMember,
List<double>? fromLonLat,
List<dynamic>? byRadius, // [radius, unit]
List<dynamic>? byBox, // [width, height, unit]
String? sort, // ASC or DESC
int? count,
bool any = false,
bool storeDist = false,
}) async {
final cmd = <String>['GEOSEARCHSTORE', destination, source];
// Center point
if (fromMember != null) {
cmd.add('FROMMEMBER');
cmd.add(fromMember);
} else if (fromLonLat != null && fromLonLat.length == 2) {
cmd.add('FROMLONLAT');
cmd.add(fromLonLat[0].toString());
cmd.add(fromLonLat[1].toString());
} else {
throw ArgumentError('Either fromMember or fromLonLat must be provided.');
}
// Search area
if (byRadius != null && byRadius.length == 2) {
cmd.add('BYRADIUS');
cmd.add(byRadius[0].toString());
cmd.add(byRadius[1].toString());
} else if (byBox != null && byBox.length == 3) {
cmd.add('BYBOX');
cmd.add(byBox[0].toString());
cmd.add(byBox[1].toString());
cmd.add(byBox[2].toString());
} else {
throw ArgumentError('Either byRadius or byBox must be provided.');
}
// Options
if (sort != null) cmd.add(sort);
if (count != null) {
cmd.add('COUNT');
cmd.add(count.toString());
if (any) cmd.add('ANY');
}
if (storeDist) cmd.add('STOREDIST');
return executeInt(cmd);
}