public RRExtension() { if (SDK.Created == false) { SDK.SetSDK(); } if (IdDistList.Created == false) { IdDistList.SetIdList(); } if (IdWidthList.Created == false) { IdWidthList.SetIdWidthList(); } }
public Point(XmlNode x) { id = "no"; // Номер точки name = "noname"; lattitude = 0; // Широта longitude = 0; // Долгота hdg = 360; // Азимут hdg_back = 360; // Обратный азимут deltahdg = 360; // Угол проверки азимута dist = 150; // Расстояние до точки в метрах width = 50; skincommand = "no"; // Команда передаваемая в Road Runner skincommand_out = "no"; InSeach = true; real_dist = 0; CultureInfo en = new CultureInfo("en-US"); for (int i = 0; i < x.Attributes.Count; i++) { switch (x.Attributes[i].Name.ToLower()) { case "id": id = x.Attributes[i].Value; break; case "name": name = x.Attributes[i].Value; { string tmp_w = IdWidthList.GetValue("PoiWidthId" + id); if (tmp_w == "") { width = 50; } else { width = Convert.ToInt16(tmp_w); } if (width == 0) { width = 50; } } break; case "lattitude": lattitude = Convert.ToDouble(x.Attributes[i].Value, en); break; case "longitude": longitude = Convert.ToDouble(x.Attributes[i].Value, en); break; case "hdg": hdg = Convert.ToInt16(x.Attributes[i].Value); break; case "hdg_back": hdg_back = Convert.ToInt16(x.Attributes[i].Value); break; case "deltahdg": deltahdg = Convert.ToInt16(x.Attributes[i].Value); break; case "dist": { string tmp_w = IdDistList.GetValue("PoiDistId" + id); if (tmp_w == "") { dist = 0; } else { dist = Convert.ToInt16(tmp_w); } if (dist == 0) { dist = Convert.ToInt16(x.Attributes[i].Value); } } break; case "skincommand": skincommand = x.Attributes[i].Value; break; case "skincommand_out": skincommand_out = x.Attributes[i].Value; break; } } }
public int ProcessCommand(string CMD, object frm) { int result = 0; bool NoStoped = true; switch (CMD.ToLower()) { case "poi_stop": // isStop = true; break; case "poi_start": // isStop = false; break; case "onsuspend": // break; case "onresume": // break; case "onskinend": Poi_Open.Abort(); SDK.RRSDK = null; GC.Collect(); break; case "poi_new": lock (locked) { try { string tmp_lattitude = SDK.GetInfo("=$POI_lattitude$"); if (tmp_lattitude == "") { tmp_lattitude = "0"; } string tmp_longitude = SDK.GetInfo("=$POI_longitude$"); if (tmp_longitude == "") { tmp_longitude = "0"; } points_list.Add(new Point()); int i = points_list.Count - 1; ((Point)points_list[i]).id = SDK.GetInfo("=$POI_id$"); // Номер точки ((Point)points_list[i]).name = SDK.GetInfo("=$POI_name$"); // Номер точки ((Point)points_list[i]).lattitude = Convert.ToDouble(tmp_lattitude); // Широта ((Point)points_list[i]).longitude = Convert.ToDouble(tmp_longitude); // Долгота ((Point)points_list[i]).hdg = Convert.ToInt16(SDK.GetInfo("=$POI_hdg$")); // Азимут ((Point)points_list[i]).hdg_back = Convert.ToInt16(SDK.GetInfo("=$POI_hdg_back$")); // Обратный азимут ((Point)points_list[i]).deltahdg = Convert.ToInt16(SDK.GetInfo("=$POI_deltahdg$")); // Угол проверки азимута ((Point)points_list[i]).dist = Convert.ToInt16(SDK.GetInfo("=$POI_dist$")); // Расстояние до точки в метрах ((Point)points_list[i]).skincommand = SDK.GetInfo("=$POI_skincommand$"); // Команда передаваемая в Road Runner ((Point)points_list[i]).skincommand_out = SDK.GetInfo("=$POI_skincommand_out$"); // Команда передаваемая в Road Runner ((Point)points_list[i]).InSeach = true; { string tmp_w = IdWidthList.GetValue("PoiWidthId" + ((Point)points_list[i]).id); if (tmp_w == "") { ((Point)points_list[i]).width = 50; } else { ((Point)points_list[i]).width = Convert.ToInt16(tmp_w); } if (((Point)points_list[i]).width == 0) { ((Point)points_list[i]).width = 50; } } (new Thread(SaveXml)).Start(); } catch (System.Exception ex) { System.IO.File.AppendAllText(@log_file, ex.Message); } } break; case "poi_delete": // lock (locked) { string tmp_id = SDK.GetInfo("=$POI_id$"); // Номер точки double tmp_lattitude = Convert.ToDouble(SDK.GetInfo("=$POI_lattitude$")); // Широта double tmp_longitude = Convert.ToDouble(SDK.GetInfo("=$POI_longitude$")); // Долгота bool isDelete = false; for (int i = 0; i < points_list.Count; i++) { if (((Point)points_list[i]).id == tmp_id && ((Point)points_list[i]).lattitude == tmp_lattitude && ((Point)points_list[i]).longitude == tmp_longitude) { points_list.RemoveAt(i); isDelete = true; } } if (isDelete) { (new Thread(SaveXml)).Start(); } } break; case "poi_edit": break; case "poi_save_to_kml": lock (locked) { SaveToKml(SDK.GetInfo("=$kml_id$"), SDK.GetInfo("=$kml_name$")); } break; case "poi_add_kml": // lock (locked) { string KmlFileName = SDK.GetInfo("=$Poi_KmlFileName$"); XmlDocument kml_file = new XmlDocument(); kml_file.LoadXml(System.IO.File.ReadAllText(@KmlFileName)); XmlNodeList Placemark = kml_file.GetElementsByTagName("Placemark"); // CultureInfo en = new CultureInfo("en-US"); string poi_id = SDK.GetInfo("=$POI_id$"); foreach (XmlNode x in Placemark) { points_list.Add(new Point()); //i++; int i = points_list.Count - 1; ((Point)points_list[i]).id = poi_id; /* ((Point)points_list[i]).id = SDK.GetInfo("=$POI_id$"); // Номер точки * ((Point)points_list[i]).lattitude = Convert.ToDouble(SDK.GetInfo("=$POI_lattitude$")); // Широта * ((Point)points_list[i]).longitude = Convert.ToDouble(SDK.GetInfo("=$POI_longitude$")); // Долгота * ((Point)points_list[i]).hdg = Convert.ToInt16(SDK.GetInfo("=$POI_hdg$")); // Азимут * ((Point)points_list[i]).hdg_back = Convert.ToInt16(SDK.GetInfo("=$POI_hdg_back$")); // Обратный азимут * ((Point)points_list[i]).deltahdg = Convert.ToInt16(SDK.GetInfo("=$POI_deltahdg$")); // Угол проверки азимута * ((Point)points_list[i]).dist = Convert.ToInt16(SDK.GetInfo("=$POI_dist$")); // Расстояние до точки в метрах * ((Point)points_list[i]).skincommand = SDK.GetInfo("=$POI_skincommand$"); // Команда передаваемая в Road Runner * ((Point)points_list[i]).InSeach = true; */ foreach (XmlNode xc in x.ChildNodes) { switch (xc.Name.ToLower()) { case "name": ((Point)points_list[i]).name = xc.InnerText; break; case "point": { foreach (XmlNode xcc in xc.ChildNodes) { if (xcc.Name.ToLower() == "coordinates") { string[] coordinates = xcc.InnerText.Split((new Char[] { ',' })); int ii = 0; foreach (string s in coordinates) { switch (ii) { case 0: ((Point)points_list[i]).longitude = Convert.ToDouble(s, en); break; case 1: ((Point)points_list[i]).lattitude = Convert.ToDouble(s, en); break; } ii++; } } } } break; } } } } (new Thread(SaveXml)).Start(); if (NoStoped) { isStop = false; } break; } return(result); }