From b8d7b4fa382f7c779fb9e81a9f049d94a9083fa3 Mon Sep 17 00:00:00 2001 From: JLChen <551775569@qq.com> Date: 星期二, 16 十一月 2021 18:41:01 +0800 Subject: [PATCH] 2021-11-16-01 --- HDL_ON/UI/UI2/3-Intelligence/Automation/PublicInterface.cs | 8 HDL-ON_Android/Properties/AndroidManifest.xml | 2 HDL-ON_Android/Assets/Language.ini | 7 HDL_ON/UI/UI2/3-Intelligence/Automation/InpOrOutLogicMethod.cs | 32 +++ HDL-ON_iOS/AppDelegate.cs | 3 HDL_ON/HDL_ON.projitems | 1 HDL_ON/UI/UI2/3-Intelligence/Automation/MainView.cs | 6 HDL_ON/UI/UI2/3-Intelligence/Automation/AddInputType.cs | 177 +++++++++++++++++++ HDL-ON_iOS/Resources/Language.ini | 8 HDL_ON/UI/UI2/3-Intelligence/Automation/LogicMethod.cs | 172 +++++++++++++++++++ HDL_ON/UI/UI2/3-Intelligence/Automation/Logic.cs | 2 HDL_ON/UI/UI2/3-Intelligence/Automation/Send.cs | 17 + HDL_ON/Common/R.cs | 12 + HDL_ON/UI/UI2/3-Intelligence/Automation/CalculatedDistance.cs | 63 +++++++ HDL_ON/UI/MainPage.cs | 4 15 files changed, 503 insertions(+), 11 deletions(-) diff --git a/HDL-ON_Android/Assets/Language.ini b/HDL-ON_Android/Assets/Language.ini index df14822..79bfdd8 100644 --- a/HDL-ON_Android/Assets/Language.ini +++ b/HDL-ON_Android/Assets/Language.ini @@ -1009,6 +1009,9 @@ 7149=Manually 7150=Smart 7151=Good +7152=Leave or arrive at a place +7153=Leave +7154=Arrive @@ -2113,6 +2116,10 @@ 7149=鎵嬪姩 7150=鏅鸿兘 7151=鑹ソ +7152=绂诲紑鎴栧埌杈炬煇鍦� +7153=绂诲紑 +7154=鍒拌揪 + diff --git a/HDL-ON_Android/Properties/AndroidManifest.xml b/HDL-ON_Android/Properties/AndroidManifest.xml index a12415b..e687343 100644 --- a/HDL-ON_Android/Properties/AndroidManifest.xml +++ b/HDL-ON_Android/Properties/AndroidManifest.xml @@ -176,5 +176,7 @@ <meta-data android:name="OPPO_APPID" android:value="OP-30619979" /> <meta-data android:name="OPPO_APPSECRET" android:value="OP-11d511c42f654cafac99588322681003" /> <!-- 鏋佸厜鎺ㄩ�佺粨鏉� --> + <!-- 璁剧疆楂樺痉鍦板浘key --> + <meta-data android:name="com.amap.api.v2.apikey" android:value="9901dd06e30b229efdd4c5bf5e076224" /> </application> </manifest> \ No newline at end of file diff --git a/HDL-ON_iOS/AppDelegate.cs b/HDL-ON_iOS/AppDelegate.cs index 03ce2b3..e2fb0ec 100644 --- a/HDL-ON_iOS/AppDelegate.cs +++ b/HDL-ON_iOS/AppDelegate.cs @@ -275,7 +275,8 @@ //{ // //RemoteInfo.Current.ReadMsgList(true); //} - + //楂樺痉key + GDMapKit.setGDApiKey("f0635ea15c5d579c6e93d9f07a06da69"); Console.WriteLine("FinishedLaunching"); return true; } diff --git a/HDL-ON_iOS/Resources/Language.ini b/HDL-ON_iOS/Resources/Language.ini index df14822..ad70402 100644 --- a/HDL-ON_iOS/Resources/Language.ini +++ b/HDL-ON_iOS/Resources/Language.ini @@ -1009,6 +1009,9 @@ 7149=Manually 7150=Smart 7151=Good +7152=Leave or arrive at a place +7153=Leave +7154=Arrive @@ -2113,6 +2116,11 @@ 7149=鎵嬪姩 7150=鏅鸿兘 7151=鑹ソ +7152=绂诲紑鎴栧埌杈炬煇鍦� +7153=绂诲紑 +7154=鍒拌揪 + + diff --git a/HDL_ON/Common/R.cs b/HDL_ON/Common/R.cs index b4a8bf3..8827fcf 100644 --- a/HDL_ON/Common/R.cs +++ b/HDL_ON/Common/R.cs @@ -2620,6 +2620,18 @@ /// 鑹ソ /// </summary> public const int lianghao = 7151; + /// <summary> + /// 绂诲紑鎴栧埌杈炬煇鍦� + /// </summary> + public const int likiadaoda = 7152; + /// <summary> + /// 绂诲紑 + /// </summary> + public const int likai = 7153; + /// <summary> + /// 鍒拌揪 + /// </summary> + public const int daoda = 7154; diff --git a/HDL_ON/HDL_ON.projitems b/HDL_ON/HDL_ON.projitems index 4830611..8208893 100644 --- a/HDL_ON/HDL_ON.projitems +++ b/HDL_ON/HDL_ON.projitems @@ -486,6 +486,7 @@ <Compile Include="$(MSBuildThisFileDirectory)DAL\ThirdPartySdk\HDLLinphone.cs" /> <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\FuntionControlView\EnvironmentalScience\A_EnvironmentalDataCenter.cs" /> <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\2-Classification\SceneControlZone.cs" /> + <Compile Include="$(MSBuildThisFileDirectory)UI\UI2\3-Intelligence\Automation\CalculatedDistance.cs" /> </ItemGroup> <ItemGroup> <Folder Include="$(MSBuildThisFileDirectory)Entity\Device\" /> diff --git a/HDL_ON/UI/MainPage.cs b/HDL_ON/UI/MainPage.cs index 9f34580..63929be 100644 --- a/HDL_ON/UI/MainPage.cs +++ b/HDL_ON/UI/MainPage.cs @@ -10,6 +10,7 @@ { public static class MainPage { + /// <summary> /// BaseView /// </summary> @@ -144,7 +145,8 @@ BaseView = Application.MainPage; Application.MainPage.BackgroundColor = CSS_Color.MainBackgroundColor; - + ///鐩戝惉缁忕含搴� + HDL_ON.UI.UI2.Intelligence.Automation.LogicMethod.CurrLogicMethod.AppLatAndLonEvent(); //#region 娴嬭瘯 //var ddd = new UI.test.TestDialog(); diff --git a/HDL_ON/UI/UI2/3-Intelligence/Automation/AddInputType.cs b/HDL_ON/UI/UI2/3-Intelligence/Automation/AddInputType.cs index 46264c7..5ec11e6 100644 --- a/HDL_ON/UI/UI2/3-Intelligence/Automation/AddInputType.cs +++ b/HDL_ON/UI/UI2/3-Intelligence/Automation/AddInputType.cs @@ -61,17 +61,29 @@ shiwaiView.frameLayout.Y = sceneView.frameLayout.Bottom; shiwaiView.btnText.TextID = StringId.shiwaibainhua; shiwaiView.btnIcon.UnSelectedImagePath = "LogicIcon/changesinoutdoor.png"; - + if (MainView.IsGatewayType) { viewLayout.AddChidren(shiwaiView.FLayoutView()); } - + + //鍦扮悊鍥存爮 + LogicView.SelectTypeView likiadaodaView = new LogicView.SelectTypeView(); + likiadaodaView.frameLayout.Y = shiwaiView.frameLayout.Bottom; + likiadaodaView.btnText.TextID = StringId.likiadaoda; + likiadaodaView.btnIcon.UnSelectedImagePath = "LogicIcon/location.png"; + + if (MainView.IsGatewayType) + { + viewLayout.AddChidren(likiadaodaView.FLayoutView()); + } + #endregion #region 鎵�鏈夌偣鍑讳簨浠� //鏃堕棿 - timeView.btnClick.MouseUpEventHandler += (sen, e) => { + timeView.btnClick.MouseUpEventHandler += (sen, e) => + { TimeTpye timeTpye = new TimeTpye(); MainPage.BasePageView.AddChidren(timeTpye); timeTpye.Show(); @@ -79,7 +91,8 @@ }; //鍔熻兘 - functionView.btnClick.MouseUpEventHandler += (sen, e) => { + functionView.btnClick.MouseUpEventHandler += (sen, e) => + { FunTpye funTpye = new FunTpye(); MainPage.BasePageView.AddChidren(funTpye); funTpye.Show(LogicMethod.condition_if); @@ -91,7 +104,8 @@ SceneMethod(); }; //瀹ゅ鍙樺寲 - shiwaiView.btnClick.MouseUpEventHandler += (sen, e) => { + shiwaiView.btnClick.MouseUpEventHandler += (sen, e) => + { if (string.IsNullOrEmpty(Entity.DB_ResidenceData.Instance.CurrentRegion.homeAddress))//.longitude == 0 && Entity.DB_ResidenceData.Instance.CurrentRegion.latitude == 0) { new PublicAssmebly().TipMsg(StringId.tip, StringId.GatewayLocationInformationIsNotConfigured); @@ -101,6 +115,12 @@ MainPage.BasePageView.AddChidren(weather); weather.Show(); MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1; + }; + + //鍦扮悊鍥存爮 + likiadaodaView.btnClick.MouseUpEventHandler += (sen, e) => + { + LocationView(this, false); }; #endregion @@ -141,6 +161,150 @@ } /// <summary> + /// 鍦扮悊鍥存爮View + /// </summary> + /// <param name="flMain">Fl main.</param> + /// <param name="edit">If set to <c>true</c> edit.</param> + public void LocationView(FrameLayout flMain, bool edit) + { + string strname = ""; + ///閫氳繃璋冭瘯瀹濈粰鐨勭粡绾害<鏍囧噯GPS> + double latitude = Entity.DB_ResidenceData.Instance.CurrentRegion.latitude;//绾害 + double longitude = Entity.DB_ResidenceData.Instance.CurrentRegion.longitude;//缁忓害 + //WGS84鍧愭爣杞珮寰峰潗鏍� + LogicMethod.CurrLogicMethod.WGS84_to_GCJ02(Entity.DB_ResidenceData.Instance.CurrentRegion.longitude, Entity.DB_ResidenceData.Instance.CurrentRegion.latitude, out longitude, out latitude); + int r = 500;//鍗婂緞 + if (edit) + { + for (var i = 0; i < Logic.currlogic.input.Count; i++) + { + var input = Logic.currlogic.input[i]; + if (input.condition_type != "8") + { + continue; + } + if (input.condition[0]["value"] == "arrive") + { + //鍒拌揪鏌愬湴 + strname = Language.StringByID(StringId.daoda); + } + else + { + //绂诲紑鍦扮偣 + strname = Language.StringByID(StringId.likai); + } + //绾害 + latitude = Convert.ToDouble(input.geo_fence.latitude); + //缁忓害 + longitude = Convert.ToDouble(input.geo_fence.longitude); + //鍗婂緞 + r = int.Parse(input.geo_fence.radius); + } + } + PublicInterface publicInterface = new PublicInterface(); + var list = publicInterface.GetViewList("鍦扮悊鍥存爮"); + publicInterface.SingleSelectionShow(flMain, list, Language.StringByID(StringId.likiadaoda), strname, (str) => + { + + string valueStr = "arrive"; + if (str == Language.StringByID(StringId.daoda)) + { + //鍒拌揪鏌愬湴 + valueStr = "arrive"; + } + else + { + //绂诲紑 + valueStr = "leave"; + } + +#if __Android__ + //鐢宠瀹氫綅鏉冮檺 + ((BaseActivity)Application.Activity).SetGPSLocationPermission((result1) => + { + if (result1 == false) { return; } + + //鐢宠鍏佽绋嬪簭鍐欏叆澶栭儴瀛樺偍锛屽SD鍗′笂鍐欐枃浠� + ((BaseActivity)Application.Activity).SetPermission((result2) => + { + if (result2 == false) { return; } + //璇诲彇鐢佃瘽鐘舵�佹潈闄� + ((BaseActivity)Application.Activity).SetPermission((result3) => + { + if (result3 == false) { return; } + + //璋冪敤鏂规硶锛岃烦杞〉闈� + GDMapKit.Show((mLatitude, mLongitude, mRadius, name) => + { + //楂樺痉鍧愭爣杞琖GS84鍧愭爣(楂樺痉鍦板浘璁剧疆GPS) + double out_lng, out_lat; + LogicMethod.CurrLogicMethod.GCJ02_to_WGS84(mLongitude, mLatitude, out out_lng, out out_lat); + Input input = new Input(); + input.sid = LogicMethod.CurrLogicMethod.NewSid(); + input.condition_type = "8"; + Dictionary<string, string> dic = new Dictionary<string, string>(); + LogicMethod.CurrLogicMethod.dictionary(dic, "key", "direction"); + LogicMethod.CurrLogicMethod.dictionary(dic, "comparator", "="); + LogicMethod.CurrLogicMethod.dictionary(dic, "data_type", "string"); + LogicMethod.CurrLogicMethod.dictionary(dic, "value", valueStr); + input.condition.Add(dic); + //绾害 + input.geo_fence.latitude = out_lat.ToString(); + //缁忓害 + input.geo_fence.longitude = out_lng.ToString(); + //鍗婂緞<鍗曚綅绫�> + input.geo_fence.radius = mRadius.ToString(); + AddCondition(input); + LogicMethod.CurrLogicMethod.RemoveAllView(); + AddLogic addLogic = new AddLogic(); + MainPage.BasePageView.AddChidren(addLogic); + addLogic.Show(); + MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1; + + }, strname, Language.StringByID(StringId.save), true, latitude, longitude, r); + + }, "android.permission.READ_PHONE_STATE"); + + }, "android.permission.WRITE_EXTERNAL_STORAGE"); + }); +#endif +#if __IOS__ + //璋冪敤鏂规硶锛岃烦杞〉闈� + GDMapKit.Show((mLatitude, mLongitude, mRadius, name) => + { + //楂樺痉鍧愭爣杞琖GS84鍧愭爣(楂樺痉鍦板浘璁剧疆GPS) + double out_lng, out_lat; + LogicMethod.CurrLogicMethod.GCJ02_to_WGS84(mLongitude, mLatitude, out out_lng, out out_lat); + + Input input = new Input(); + input.sid = LogicMethod.CurrLogicMethod.NewSid(); + input.condition_type = "8"; + Dictionary<string, string> dic = new Dictionary<string, string>(); + LogicMethod.CurrLogicMethod.dictionary(dic, "key", "direction"); + LogicMethod.CurrLogicMethod.dictionary(dic, "comparator", "="); + LogicMethod.CurrLogicMethod.dictionary(dic, "data_type", "string"); + LogicMethod.CurrLogicMethod.dictionary(dic, "value", "arrive"); + input.condition.Add(dic); + //绾害 + input.geo_fence.latitude = out_lat.ToString(); + //缁忓害 + input.geo_fence.longitude = out_lng.ToString(); + //鍗婂緞<鍗曚綅绫�> + input.geo_fence.radius = mRadius.ToString(); + AddCondition(input); + LogicMethod.CurrLogicMethod.RemoveAllView(); + AddLogic addLogic = new AddLogic(); + MainPage.BasePageView.AddChidren(addLogic); + addLogic.Show(); + MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1; + }, strname, Language.StringByID(R.MyInternationalizationString.uSave), true, latitude, longitude, r); +#endif + }); + + + } + + /// <summary> /// 娣诲姞鏉′欢 /// </summary> /// <param name="input"></param> @@ -151,8 +315,9 @@ for (var i = 0; i < Logic.currlogic.input.Count; i++) { var condition_type = Logic.currlogic.input[i].condition_type; - if (condition_type == "10") + if (condition_type == "10" || condition_type == "8") { + //鏀寔鍦烘櫙=10锛屽湴鐞嗗洿鏍�=8 ///鎵惧埌鏍囪绱㈠紩锛岄��鍑哄惊鐜綋 index = i; break; diff --git a/HDL_ON/UI/UI2/3-Intelligence/Automation/CalculatedDistance.cs b/HDL_ON/UI/UI2/3-Intelligence/Automation/CalculatedDistance.cs new file mode 100644 index 0000000..58e9b54 --- /dev/null +++ b/HDL_ON/UI/UI2/3-Intelligence/Automation/CalculatedDistance.cs @@ -0,0 +1,63 @@ +锘縰sing System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Infrastructure.Service.Helper +{ + public class CalculatedDistance + { + private static double HaverSin(double theta) + { + var v = Math.Sin(theta / 2); + return v * v; + } + + static double EARTH_RADIUS = 6371.0;//km 鍦扮悆鍗婂緞 骞冲潎鍊硷紝鍗冪背 + + /// <summary> + /// 缁欏畾鐨勭粡搴�1锛岀含搴�1锛涚粡搴�2锛岀含搴�2. 璁$畻2涓粡绾害涔嬮棿鐨勮窛绂汇�� + /// </summary> + /// <param name="lat1">缁忓害1</param> + /// <param name="lon1">绾害1</param> + /// <param name="lat2">缁忓害2</param> + /// <param name="lon2">绾害2</param> + /// <returns>璺濈锛堝叕閲屻�佸崈绫筹級</returns> + public static int Distance(double lat1, double lon1, double lat2, double lon2) + { + //鐢╤aversine鍏紡璁$畻鐞冮潰涓ょ偣闂寸殑璺濈銆� + //缁忕含搴﹁浆鎹㈡垚寮у害 + lat1 = ConvertDegreesToRadians(lat1); + lon1 = ConvertDegreesToRadians(lon1); + lat2 = ConvertDegreesToRadians(lat2); + lon2 = ConvertDegreesToRadians(lon2); + + //宸�� + var vLon = Math.Abs(lon1 - lon2); + var vLat = Math.Abs(lat1 - lat2); + + //h is the great circle distance in radians, great circle灏辨槸涓�涓悆浣撲笂鐨勫垏闈紝瀹冪殑鍦嗗績鍗虫槸鐞冨績鐨勪竴涓懆闀挎渶澶х殑鍦嗐�� + var h = HaverSin(vLat) + Math.Cos(lat1) * Math.Cos(lat2) * HaverSin(vLon); + + var distance = (int)((2 * EARTH_RADIUS * Math.Asin(Math.Sqrt(h))) * 1000); + + return distance; + } + + /// <summary> + /// 灏嗚搴︽崲绠椾负寮у害銆� + /// </summary> + /// <param name="degrees">瑙掑害</param> + /// <returns>寮у害</returns> + private static double ConvertDegreesToRadians(double degrees) + { + return degrees * Math.PI / 180; + } + + private static double ConvertRadiansToDegrees(double radian) + { + return radian * 180.0 / Math.PI; + } + } +} diff --git a/HDL_ON/UI/UI2/3-Intelligence/Automation/InpOrOutLogicMethod.cs b/HDL_ON/UI/UI2/3-Intelligence/Automation/InpOrOutLogicMethod.cs index 61973d1..cb26d92 100644 --- a/HDL_ON/UI/UI2/3-Intelligence/Automation/InpOrOutLogicMethod.cs +++ b/HDL_ON/UI/UI2/3-Intelligence/Automation/InpOrOutLogicMethod.cs @@ -521,6 +521,31 @@ } } break; + case "8": + { + inputView.btnIcon.UnSelectedImagePath = "LogicIcon/location.png"; + foreach (var dic in dicList) + { + string strtext = ""; + string value = dic["value"]; + switch (value) + { + case "arrive": + { + strtext = Language.StringByID(StringId.daoda); + } + break; + case "leave": + { + strtext = Language.StringByID(StringId.likai); + } + break; + } + inputView.btnText.TextID = StringId.likiadaoda; + inputView.btnState.Text = strtext; + } + } + break; case "9": { inputView.btnIcon.UnSelectedImagePath = "LogicIcon/changesinoutdoor.png"; @@ -851,6 +876,13 @@ MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1; } break; + + case "8": + { + AddInputType addInputType = new AddInputType(); + addInputType.LocationView(thisView,true); + } + break; case "9": { diff --git a/HDL_ON/UI/UI2/3-Intelligence/Automation/Logic.cs b/HDL_ON/UI/UI2/3-Intelligence/Automation/Logic.cs index 19c31ea..d865bad 100644 --- a/HDL_ON/UI/UI2/3-Intelligence/Automation/Logic.cs +++ b/HDL_ON/UI/UI2/3-Intelligence/Automation/Logic.cs @@ -142,7 +142,7 @@ /// </summary> public string latitude = string.Empty; /// <summary> - /// 鍗曚綅绫� + /// 鍗婂緞<鍗曚綅绫�> /// </summary> public string radius = string.Empty; } diff --git a/HDL_ON/UI/UI2/3-Intelligence/Automation/LogicMethod.cs b/HDL_ON/UI/UI2/3-Intelligence/Automation/LogicMethod.cs index 023a2d1..b896462 100644 --- a/HDL_ON/UI/UI2/3-Intelligence/Automation/LogicMethod.cs +++ b/HDL_ON/UI/UI2/3-Intelligence/Automation/LogicMethod.cs @@ -709,6 +709,178 @@ } } + #region 楂樺痉鍧愭爣杞琖GS84鍧愭爣 + /// <summary> + /// 楂樺痉鍧愭爣杞琖GS84鍧愭爣 + /// </summary> + /// <param name="in_lng"></param> + /// <param name="in_lat"></param> + /// <param name="out_lng"></param> + /// <param name="out_lat"></param> + public void GCJ02_to_WGS84(double in_lng, double in_lat, out double out_lng, out double out_lat) + { + if (OutOfChina(in_lat, in_lng)) + { + out_lng = in_lng; + out_lat = in_lat; + return; + } + + CalculateDev(in_lng, in_lat, out out_lng, out out_lat); + out_lng = in_lng - out_lng; + out_lat = in_lat - out_lat; + } + #endregion + + #region WGS84鍧愭爣杞珮寰峰潗鏍� + /// <summary> + /// WGS84鍧愭爣杞珮寰峰潗鏍� + /// </summary> + /// <param name="in_lng">缁忓害</param> + /// <param name="in_lat">绾害</param> + /// <param name="out_lng"></param> + /// <param name="out_lat"></param> + public void WGS84_to_GCJ02(double in_lng, double in_lat, out double out_lng, out double out_lat) + { + if (OutOfChina(in_lat, in_lng)) + { + out_lng = in_lng; + out_lat = in_lat; + return; + } + + CalculateDev(in_lng, in_lat, out out_lng, out out_lat); + out_lng = in_lng + out_lng; + out_lat = in_lat + out_lat; + } + #endregion + + /// <summary> + /// 鍧愭爣鏄惁鍦ㄤ腑鍥藉鍐� + /// </summary> + /// <param name="lat"></param> + /// <param name="lng"></param> + /// <returns></returns> + public bool OutOfChina(double lat, double lng) + { + if (lng < 72.004 || lng > 137.8347) + return true; + if (lat < 0.8293 || lat > 55.8271) + return true; + return false; + } + /// <summary> + /// 璁$畻鍋忓樊 + /// </summary> + /// <param name="in_lng"></param> + /// <param name="in_lat"></param> + /// <param name="dLng"></param> + /// <param name="dLat"></param> + private void CalculateDev(double in_lng, double in_lat, out double dLng, out double dLat) + { + dLat = TransformLat(in_lng - 105.0, in_lat - 35.0); + dLng = TransformLng(in_lng - 105.0, in_lat - 35.0); + + double radLat = in_lat / 180.0 * pi; + double magic = Math.Sin(radLat); + magic = 1 - ee * magic * magic; + double sqrtMagic = Math.Sqrt(magic); + dLat = (dLat * 180.0) / ((a * (1 - ee)) / (magic * sqrtMagic) * pi); + dLng = (dLng * 180.0) / (a / sqrtMagic * Math.Cos(radLat) * pi); + } + + private double TransformLat(double x, double y) + { + double ret = -100.0 + 2.0 * x + 3.0 * y + 0.2 * y * y + 0.1 * x * y + 0.2 * Math.Sqrt(Math.Abs(x)); + ret += (20.0 * Math.Sin(6.0 * x * pi) + 20.0 * Math.Sin(2.0 * x * pi)) * 2.0 / 3.0; + ret += (20.0 * Math.Sin(y * pi) + 40.0 * Math.Sin(y / 3.0 * pi)) * 2.0 / 3.0; + ret += (160.0 * Math.Sin(y / 12.0 * pi) + 320 * Math.Sin(y * pi / 30.0)) * 2.0 / 3.0; + return ret; + } + private double TransformLng(double x, double y) + { + double ret = 300.0 + x + 2.0 * y + 0.1 * x * x + 0.1 * x * y + 0.1 * Math.Sqrt(Math.Abs(x)); + ret += (20.0 * Math.Sin(6.0 * x * pi) + 20.0 * Math.Sin(2.0 * x * pi)) * 2.0 / 3.0; + ret += (20.0 * Math.Sin(x * pi) + 40.0 * Math.Sin(x / 3.0 * pi)) * 2.0 / 3.0; + ret += (150.0 * Math.Sin(x / 12.0 * pi) + 300.0 * Math.Sin(x / 30.0 * pi)) * 2.0 / 3.0; + return ret; + } + // 妞悆鍙傛暟-鍦嗗懆鐜� + private const double pi = 3.14159265358979324; + + // (鍖椾含54)妞悆闀垮崐杞达紝鍗槦妞悆鍧愭爣鎶曞奖鍒板钩闈㈠湴鍥惧潗鏍囩郴鐨勬姇褰卞洜瀛� + private const double a = 6378245.0; + /* + * Krasovsky 1940 (鍖椾含54)妞悆闀垮崐杞寸涓�鍋忓績鐜囧钩鏂� + * 璁$畻鏂瑰紡锛� + * 闀垮崐杞达細 + * a = 6378245.0 + * 鎵佺巼锛� + * 1/f = 298.3锛堝彉閲忕浉鍏宠绠椾负锛�(a-b)/a锛� + * 鐭崐杞达細 + * b = 6356863.0188 (鍙橀噺鐩稿叧璁$畻鏂规硶涓猴細b = a * (1 - f)) + * 绗竴鍋忓績鐜囧钩鏂�: + * e2 = (a^2 - b^2) / a^2; + */ + private const double ee = 0.00669342162296594323; + + /// <summary> + /// APP涓婃姤GPS缁忕含搴� + /// </summary> + public void AppLatAndLonEvent() + { + Application.LocationAction += (lon, lat) => + { + ////GPS鍧愭爣杞垚楂樺痉鍧愭爣 + //double out_lng, out_lat; + //this.WGS84_to_GCJ02(lon, lat, out out_lng, out out_lat); + //涓婃姤缁忕含搴� + this.AutomatedGeofenceStatusReporting(lon, lat); + }; + } + + /// <summary> + /// 鑷姩鍖栧湴鐞嗗洿鏍忕姸鎬佷笂鎶ヤ簯绔� + /// </summary> + /// <param name="out_lng">APP缁忓害</param> + /// <param name="out_lat">APP绾害</param> + private void AutomatedGeofenceStatusReporting(double out_lng, double out_lat) + { + List<LogicData> logicDataList = new List<LogicData>(); + //鑾峰彇閫昏緫ID鍒楄〃 + var idStr = Send.GetLogicIdList(); + if (idStr.Code == "0" && idStr.Data != null && idStr.Data.ToString() != "") + { + var date = Newtonsoft.Json.JsonConvert.SerializeObject(idStr.Data); + logicDataList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<LogicData>>(date); + } + ///鏈夎嚜鍔ㄥ垪琛ㄦ墠澶勭悊 + if (logicDataList.Count>0) { + ///閬嶅巻鎵�鏈夊垪琛� + for (int i = 0; i < logicDataList.Count; i++) + { + var logicDate = logicDataList[i]; + ///鑷姩鍖栨病鏈夐厤缃湴鐞嗗洿鏍忎笉澶勭悊 + if (string.IsNullOrEmpty(logicDate.geo_fence.latitude) || string.IsNullOrEmpty(logicDate.geo_fence.longitude)) + { + //缁忕含搴︿负绌猴紝涓嶅鐞� + continue; + } + //鑷姩鍖栫含搴� + double lat = Convert.ToDouble(logicDate.geo_fence.latitude); + //鑷姩鍖栫粡搴� + double lon = Convert.ToDouble(logicDate.geo_fence.longitude); + //鑷姩鍖栧崐寰�<鍗曚綅绫�> + int radius = int.Parse(logicDate.geo_fence.radius); + //璁$畻2涓粡绾害涔嬮棿鐨勮窛绂� + int r =Infrastructure.Service.Helper.CalculatedDistance.Distance(out_lat, out_lng, lat, lon); + //if () { } + + } + + } + + } } } diff --git a/HDL_ON/UI/UI2/3-Intelligence/Automation/MainView.cs b/HDL_ON/UI/UI2/3-Intelligence/Automation/MainView.cs index e933b09..f38003b 100644 --- a/HDL_ON/UI/UI2/3-Intelligence/Automation/MainView.cs +++ b/HDL_ON/UI/UI2/3-Intelligence/Automation/MainView.cs @@ -576,8 +576,10 @@ /// 閫昏緫浣胯兘锛堝紑锛屽叧锛� /// </summary> public string enable = ""; - //public CycleA cycle; - //public string modifyTime = ""; + /// <summary> + /// 鍦扮悊鍥存爮閰嶇疆 + /// </summary> + public Fence geo_fence = new Fence(); } class CycleA diff --git a/HDL_ON/UI/UI2/3-Intelligence/Automation/PublicInterface.cs b/HDL_ON/UI/UI2/3-Intelligence/Automation/PublicInterface.cs index b05eac1..7398574 100644 --- a/HDL_ON/UI/UI2/3-Intelligence/Automation/PublicInterface.cs +++ b/HDL_ON/UI/UI2/3-Intelligence/Automation/PublicInterface.cs @@ -736,6 +736,14 @@ }; } break; + case "鍦扮悊鍥存爮": + { + list = new List<string> { + Language.StringByID(StringId.likai ), + Language.StringByID(StringId.daoda), + }; + } + break; } return list; } diff --git a/HDL_ON/UI/UI2/3-Intelligence/Automation/Send.cs b/HDL_ON/UI/UI2/3-Intelligence/Automation/Send.cs index a4aeaed..35aa688 100644 --- a/HDL_ON/UI/UI2/3-Intelligence/Automation/Send.cs +++ b/HDL_ON/UI/UI2/3-Intelligence/Automation/Send.cs @@ -106,6 +106,14 @@ conditionArray.Add(conditionJOb); } inputTypeJOb.Add("condition",conditionArray); + if (dictionary.condition_type=="8") { + ///鍦扮悊鍥存爮 + var geo_fencejob = new JObject(); + geo_fencejob.Add("longitude", dictionary.geo_fence.longitude); + geo_fencejob.Add("latitude", dictionary.geo_fence.latitude); + geo_fencejob.Add("radius", dictionary.geo_fence.radius); + inputTypeJOb.Add("geo_fence", geo_fencejob); + } inputArray.Add(inputTypeJOb); } @@ -217,6 +225,15 @@ conditionJOb.Add("data_type", dic["data_type"]); conditionJOb.Add("value", dic["value"]); conditionArray.Add(conditionJOb); + if (dictionary.condition_type == "8") + { + ///鍦扮悊鍥存爮 + var geo_fencejob = new JObject(); + geo_fencejob.Add("longitude", dictionary.geo_fence.longitude); + geo_fencejob.Add("latitude", dictionary.geo_fence.latitude); + geo_fencejob.Add("radius", dictionary.geo_fence.radius); + inputTypeJOb.Add("geo_fence", geo_fencejob); + } } inputTypeJOb.Add("condition", conditionArray); inputArray.Add(inputTypeJOb); -- Gitblit v1.8.0