4
有沒有辦法使用單聲道添加SQLite自定義函數? (Mono.Data.Sqlite)自定義函數與單聲道SQLite
我想補充一點,返回兩個地理地點
[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)))));
}
}
,它給我一個錯誤之間的距離,距離函數:
Attempting to JIT compile method '(wrapper native-to-managed) Mono.Data.Sqlite.SqliteFunction:ScalarCallback (intptr,int,intptr)' while running with --aot-only. See http://docs.xamarin.com/ios/about/limitations for more information.
關於如何實現像這樣的自定義方法的任何示例? 我需要實現acos,cos,sin和其他數學函數...... – Miros