Exemple #1
0
        /// <summary> 
        /// Imports a DxfFile that is in the specified Format. Any changes on the import schema may cause Errors!
        /// </summary>
        /// <param name="filepath"></param>
        public static void importFromDxf(string filepath, string DB_PATH)
        {
            StreamReader sr = new StreamReader(filepath);
            DatabaseDataContext dataContext = new DatabaseDataContext(DB_PATH);
            foreach (t_PolygonPoint tp in dataContext.t_PolygonPoints)
            {
                dataContext.t_PolygonPoints.DeleteOnSubmit(tp);
            }
               ///dataContext.t_PolygonPoints.DeleteAllOnSubmit(dataContext.t_PolygonPoints.ToList());
            dataContext.SubmitChanges();
            dataContext.t_Polygons.DeleteAllOnSubmit(dataContext.t_Polygons);
            dataContext.SubmitChanges();
            int id = 1;

            List<string> lineList = new List<string>();
            while (!sr.EndOfStream)
            {
                lineList.Add(sr.ReadLine());
            }
            string[] lines = lineList.ToArray();
            for (int i = 1; i < lines.Length; i++) //Looping through Array, starting with 1 (lines[0] is "0")
            {
                //Find Lines Containing a new Element Definition
                if (lines[i] == "LWPOLYLINE" && lines[i - 1] == "  0") //
                {
                    //Reading out Layer ( "8" [\n] layerName) = Type of Element
                    if (lines[i + 5] == "  8" && lines[i + 6].Contains("PROH")) // "Prohibited Zone" = ForbiddenZone
                    {
                        if (lines[i + 9] == " 90")
                        {
                            int numberOfVertexes = int.Parse(lines[i + 10]);
                            t_Polygon p = new t_Polygon();
                            p.ID = id++;

                            for (int j = 0; j < numberOfVertexes; j++)
                            {
                                t_PolygonPoint point = new t_PolygonPoint();
                                GpsPoint gp = new GpsPoint(double.Parse(lines[i + (j * 4) + 18], NumberFormatInfo.InvariantInfo) * 1000, double.Parse(lines[i + (j * 4) + 16], NumberFormatInfo.InvariantInfo) * 1000, GpsPointFormatImport.Swiss);
                                point.longitude = (decimal)gp.Longitude;
                                point.latitude = (decimal)gp.Latitude;
                                point.ID_Polygon = p.ID;
                                dataContext.t_PolygonPoints.InsertOnSubmit(point);
                            }
                            dataContext.t_Polygons.InsertOnSubmit(p);
                        }
                    }
                }
            }

            dataContext.SubmitChanges();
        }
Exemple #2
0
 partial void Deletet_PolygonPoint(t_PolygonPoint instance);
Exemple #3
0
 partial void Updatet_PolygonPoint(t_PolygonPoint instance);
Exemple #4
0
 partial void Insertt_PolygonPoint(t_PolygonPoint instance);
Exemple #5
0
		private void detach_t_PolygonPoints(t_PolygonPoint entity)
		{
			this.SendPropertyChanging();
			entity.t_Polygon = null;
		}
Exemple #6
0
        /// <summary>
        /// List of all PolygonPoints
        /// </summary>
        /// <returns>List of PolygonPoints</returns>
        public List<t_PolygonPoint> GetPolygons()
        {
            try
            {
                LogManager.AddLog(DB_PATH, 4, "ANRLDataService.svc.cs:GetPolygons", "");
                DatabaseDataContext dataContext = new DatabaseDataContext(DB_PATH);

                List<t_PolygonPoint> tmp = new List<t_PolygonPoint>();

                t_PolygonPoint tmp_t_PolygonPoint;

                foreach (t_PolygonPoint t in dataContext.t_PolygonPoints)
                {
                    tmp_t_PolygonPoint = new t_PolygonPoint();
                    tmp_t_PolygonPoint.ID = t.ID;
                    tmp_t_PolygonPoint.latitude = t.latitude;
                    tmp_t_PolygonPoint.altitude = t.altitude;
                    tmp_t_PolygonPoint.longitude = t.longitude;
                    tmp_t_PolygonPoint.ID_Polygon = t.ID_Polygon;
                    tmp.Add(tmp_t_PolygonPoint);
                }
                return tmp;
            }
            catch (Exception ex)
            {
                LogManager.AddLog(DB_PATH, 0, "ANRLDataService.svc.cs:GetPolygons", ex.ToString());
            }
            return null;
        }
Exemple #7
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="ID_Polygon"></param>
 /// <returns></returns>
 public List<t_PolygonPoint> GetPolygonPoints(int ID_Polygon)
 {
     try
     {
         DatabaseDataContext dataContext = new DatabaseDataContext(DB_PATH);
         List<t_PolygonPoint> Result = new List<t_PolygonPoint>();
         foreach (t_PolygonPoint p in dataContext.t_PolygonPoints.Where(p => p.ID_Polygon == ID_Polygon))
         {
             t_PolygonPoint tmp = new t_PolygonPoint();
             tmp.ID = p.ID;
             tmp.ID_Polygon = p.ID_Polygon;
             tmp.latitude = p.latitude;
             tmp.longitude = p.longitude;
             tmp.altitude = p.altitude;
             Result.Add(tmp);
         }
         return Result;
     }
     catch (Exception ex)
     {
         LogManager.AddLog(DB_PATH, 0, "ANRLDataService.svc.cs:GetPolygonPoints", ex.ToString());
     }
     return null;
 }
Exemple #8
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="Race"></param>
        public void AddRace(t_Race Race)
        {
            try
            {
                LogManager.AddLog(DB_PATH, 4, "ANRLDataService.svc.cs:AddRace", "");
                DatabaseDataContext dataContext = new DatabaseDataContext(DB_PATH);
                t_PolygonGroup PolygonGroup = new t_PolygonGroup();

                #region Polygongroup & Polygons & PolygonPoints
                if (Race.t_PolygonGroup != null)
                {
                    if (Race.ID_PolygonGroup == 0)
                    {
                        PolygonGroup.Name = Race.t_PolygonGroup.Name;
                        dataContext.t_PolygonGroups.InsertOnSubmit(PolygonGroup);
                        dataContext.SubmitChanges();

                        if (Race.t_PolygonGroup.t_Polygons.Count > 0)
                        {
                            foreach (t_Polygon poly in Race.t_PolygonGroup.t_Polygons)
                            {
                                t_Polygon tmp_poly = new t_Polygon();
                                tmp_poly.Type = poly.Type;
                                tmp_poly.ID_PolygonGroup = PolygonGroup.ID;
                                dataContext.t_Polygons.InsertOnSubmit(tmp_poly);
                                dataContext.SubmitChanges();
                                foreach (t_PolygonPoint pp in poly.t_PolygonPoints)
                                {
                                    t_PolygonPoint tmpPoint = new t_PolygonPoint();
                                    tmpPoint.ID_Polygon = tmp_poly.ID;
                                    tmpPoint.longitude = pp.longitude;
                                    tmpPoint.latitude = pp.latitude;
                                    tmpPoint.altitude = pp.altitude;
                                    dataContext.t_PolygonPoints.InsertOnSubmit(tmpPoint);
                                }
                            }
                        }
                    }
                    else
                    {
                        PolygonGroup.ID = (int)Race.ID_PolygonGroup;
                    }
                    dataContext.SubmitChanges();
                }
                #endregion
                t_Race r = new t_Race();
                if (Race.ID_Pilot_0 != 0) r.ID_Pilot_0 = Race.ID_Pilot_0;
                if (Race.ID_Pilot_1 != 0) r.ID_Pilot_1 = Race.ID_Pilot_1;
                if (Race.ID_Pilot_2 != 0) r.ID_Pilot_2 = Race.ID_Pilot_2;
                if (Race.ID_Pilot_3 != 0) r.ID_Pilot_3 = Race.ID_Pilot_3;
                if (Race.ID_PolygonGroup != 0)
                {
                    r.ID_PolygonGroup = Race.ID_PolygonGroup;
                }
                else
                {
                    r.ID_PolygonGroup = PolygonGroup.ID;
                }
                r.Name = Race.Name;
                r.TimeEnd = Race.TimeEnd;
                r.TimeStart = Race.TimeStart;
                dataContext.t_Races.InsertOnSubmit(r);
                dataContext.SubmitChanges();
                LogManager.AddLog(DB_PATH, 4, "ANRLDataService.svc.cs:AddRace", "Sucessfull Added " + r.ID);
            }
            catch (Exception ex)
            {
                LogManager.AddLog(DB_PATH, 0, "ANRLDataService.svc.cs:AddRace", ex.ToString());
            }
        }