Hi, and thanks for the great package!
I'm using a custom function to calculate the distance between two points from the database and using that function to order results by the distance from a reference point.
This works fine in the iOS Simulator but when running on an old 32-bit iPad (iOS 10.3.3) the same SELECT statement returns completely different and invalid results. Running the app on a 64-bit iOS device returns the correct result.
Could there be overflow issues with the returned value from my function?
Is there anything I can do to make my function "32-bit safe"?
sqlite3: ^1.5.0
sqlite3_flutter_libs: ^0.5.3
Code snippets below:
db.createFunction(
functionName: 'distance',
argumentCount: const AllowedArgumentCount(4),
deterministic: true,
function: _distance,
);
final result = db.select(
'SELECT id FROM Column ORDER BY distance(Latitude, Longitude, ?, ?),
[position.latitude, position.longitude],
);
Object? _distance(List<Object?> arguments) {
// Setup constants
//
const toRad = 0.0174532925; // M_PI / 180.0
// Get the four argument values
//
final lat1 = (arguments[0] as double) * toRad;
final lon1 = (arguments[1] as double) * toRad;
final lat2 = (arguments[2] as double) * toRad;
final lon2 = (arguments[3] as double) * toRad;
// Apply the spherical law of cosines to get distance
//
return acos(
sin(lat1) * sin(lat2) + cos(lat1) * cos(lat2) * cos(lon2 - lon1),
) *
earthRadius;
}
Hi, and thanks for the great package!
I'm using a custom function to calculate the distance between two points from the database and using that function to order results by the distance from a reference point.
This works fine in the iOS Simulator but when running on an old 32-bit iPad (iOS 10.3.3) the same SELECT statement returns completely different and invalid results. Running the app on a 64-bit iOS device returns the correct result.
Could there be overflow issues with the returned value from my function?
Is there anything I can do to make my function "32-bit safe"?
sqlite3: ^1.5.0
sqlite3_flutter_libs: ^0.5.3
Code snippets below: