spatialDistance method
The planar distance between the geometry in geomColumn of the row
where idColumn equals id, and the geometry described by wkt, in
the spatial reference system's units.
Returns null if no row matches.
Implementation
Future<double?> spatialDistance(
String table,
String geomColumn,
String wkt, {
required String idColumn,
required Object id,
}) async {
final rows = await rawQuery(
'SELECT ST_Distance($geomColumn, GeomFromText(?)) AS distance '
'FROM $table WHERE $idColumn = ?',
[wkt, id],
);
if (rows.isEmpty) {
return null;
}
return (rows.first['distance'] as num?)?.toDouble();
}