Is there a way to add a custom SQLite function using Mono? (Mono.Data.Sqlite)
I tried to add a distance function that returns the distance between two geographic locations
[SqliteFunctionAttribute(Name = "distance", Arguments = 4, FuncType = FunctionType.Scalar)] class SqliteDistance : SqliteFunction { public override object Invoke(object[] args) { double radius = 6367; double lat1 = System.Convert.ToDouble(args[0]); double lng1 = System.Convert.ToDouble(args[1]); double lat2 = System.Convert.ToDouble(args[2]); double lng2 = System.Convert.ToDouble(args[3]); return radius * 2 * Math.Asin( Math.Min(1, Math.Sqrt( ( Math.Pow(Math.Sin((lat2* (Math.PI / 180) - lat1 * (Math.PI / 180) ) / 2.0), 2.0) + Math.Cos(lat1* (Math.PI / 180)) * Math.Cos(lat2* (Math.PI / 180)) * Math.Pow(Math.Sin(( lng2* (Math.PI / 180)-lng1* (Math.PI / 180)) / 2.0), 2.0) ) ) ) ); } }
and this gives me an error:
Attempted JIT compilation method (shell controlled in Russian) Mono.Data.Sqlite.SqliteFunction: ScalarCallback (intptr, int, intptr) 'when working with -aot-only. See http://docs.xamarin.com/ios/about/limitations for more details.
source share