Example #1
0
 private static void GetPolygonsFromServer()
 {
     List<t_Polygon> pg = InformationPool.Client.GetPolygonsByGroup(InformationPool.PolygonGroupToDraw.ID);
     foreach (t_Polygon p in pg)
     {
         List<t_PolygonPoint> ppl = InformationPool.Client.GetPolygonPoints(p.ID);
         Polygon TmpPolygon = new Polygon();
         TmpPolygon.ID = p.ID;
         TmpPolygon.Type = (PolygonType)p.Type;
         #region Polygon Points
         TmpPolygon.Points = new List<PolygonPoint>();
         foreach (t_PolygonPoint pgp in ppl)
         {
             PolygonPoint pgpp = new PolygonPoint();
             pgpp.Altitude = pgp.altitude;
             pgpp.Longitude = pgp.longitude;
             pgpp.Latitude = pgp.latitude;
             pgpp.ID = pgp.ID;
             TmpPolygon.Points.Add(pgpp);
         }
         #endregion
         InformationPool.PolygonGroupToDraw.Polygons.Add(TmpPolygon);
     }
 }
Example #2
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 PolygonGroup importFromDxf(string filepath)
        {
            PolygonGroup g=new PolygonGroup();

            StreamReader sr = new StreamReader(filepath);
            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]);
                            Polygon p = new Polygon();
                            p.ID = g.PolygonIdGen++;
                            p.Type = PolygonType.PenaltyZone;

                            for (int j = 0; j < numberOfVertexes; j++)
                            {
                                PolygonPoint point = new PolygonPoint();
                                point.Longitude = (decimal)CHtoWGSlng(double.Parse(lines[i + (j * 4) + 16], NumberFormatInfo.InvariantInfo) * 1000, double.Parse(lines[i + (j * 4) + 18], NumberFormatInfo.InvariantInfo) * 1000);
                                point.Latitude = (decimal)CHtoWGSlat(double.Parse(lines[i + (j * 4) + 16], NumberFormatInfo.InvariantInfo) * 1000, double.Parse(lines[i + (j * 4) + 18], NumberFormatInfo.InvariantInfo) * 1000);
                                point.ID = p.ID;
                                p.Points.Add(point);
                            }
                            g.Polygons.Add(p);
                        }
                    }
                    else if (lines[i + 5] == "  8" && lines[i + 6].Contains("STARTPOINT-"))
                    {
                        Polygon p = new Polygon();
                        p.ID = g.PolygonIdGen++;
                        p.Type = PolygonType.GateStartA;

                        PolygonPoint point = new PolygonPoint();
                        PolygonPoint point2 = new PolygonPoint();

                        point.Longitude = (decimal)CHtoWGSlng(double.Parse(lines[i + 16], NumberFormatInfo.InvariantInfo) * 1000, double.Parse(lines[i + 18], NumberFormatInfo.InvariantInfo) * 1000);
                        point.Latitude = (decimal)CHtoWGSlat(double.Parse(lines[i + 16], NumberFormatInfo.InvariantInfo) * 1000, double.Parse(lines[i + 18], NumberFormatInfo.InvariantInfo) * 1000);
                        point.ID = p.ID;
                        p.Points.Add(point);

                        point2.Longitude = (decimal)CHtoWGSlng(double.Parse(lines[i + 20], NumberFormatInfo.InvariantInfo) * 1000, double.Parse(lines[i + 22], NumberFormatInfo.InvariantInfo) * 1000);
                        point2.Latitude = (decimal)CHtoWGSlat(double.Parse(lines[i + 20], NumberFormatInfo.InvariantInfo) * 1000, double.Parse(lines[i + 22], NumberFormatInfo.InvariantInfo) * 1000);
                        point2.ID = p.ID;
                        p.Points.Add(point2);

                        string gatename = lines[i + 6].Substring(11, 1);
                        g.Polygons.Add(p);
                    }
                    else if (lines[i + 5] == "  8" && lines[i + 6].Contains("ENDPOINT-"))
                    {
                        Polygon p = new Polygon();
                        p.ID = g.PolygonIdGen++;
                        p.Type = PolygonType.GateEndA;

                        PolygonPoint point = new PolygonPoint();
                        PolygonPoint point2 = new PolygonPoint();

                        point.Longitude = (decimal)CHtoWGSlng(double.Parse(lines[i + 16], NumberFormatInfo.InvariantInfo) * 1000, double.Parse(lines[i + 18], NumberFormatInfo.InvariantInfo) * 1000);
                        point.Latitude = (decimal)CHtoWGSlat(double.Parse(lines[i + 16], NumberFormatInfo.InvariantInfo) * 1000, double.Parse(lines[i + 18], NumberFormatInfo.InvariantInfo) * 1000);
                        point.ID = p.ID;
                        p.Points.Add(point);

                        point2.Longitude = (decimal)CHtoWGSlng(double.Parse(lines[i + 20], NumberFormatInfo.InvariantInfo) * 1000, double.Parse(lines[i + 22], NumberFormatInfo.InvariantInfo) * 1000);
                        point2.Latitude = (decimal)CHtoWGSlat(double.Parse(lines[i + 20], NumberFormatInfo.InvariantInfo) * 1000, double.Parse(lines[i + 22], NumberFormatInfo.InvariantInfo) * 1000);
                        point2.ID = p.ID;
                        p.Points.Add(point2);

                        string gatename = lines[i + 6].Substring(9, 1);
                        g.Polygons.Add(p);
                    }
                    else if (lines[i + 5] == "  8" && lines[i + 6].Contains("NBLINE"))
                    {
                        if (lines[i + 9] == " 90" && double.Parse(lines[10], NumberFormatInfo.InvariantInfo) == 2)
                        {
                            Polygon p = new Polygon();
                            p.ID = g.PolygonIdGen++;
                            p.Type = PolygonType.EndLine;

                            PolygonPoint point = new PolygonPoint();
                            PolygonPoint point2 = new PolygonPoint();

                            point.Longitude = (decimal)CHtoWGSlng(double.Parse(lines[i + 16], NumberFormatInfo.InvariantInfo) * 1000, double.Parse(lines[i + 18], NumberFormatInfo.InvariantInfo) * 1000);
                            point.Latitude = (decimal)CHtoWGSlat(double.Parse(lines[i + 16], NumberFormatInfo.InvariantInfo) * 1000, double.Parse(lines[i + 18], NumberFormatInfo.InvariantInfo) * 1000);
                            point.ID = p.ID;
                            p.Points.Add(point);

                            point2.Longitude = (decimal)CHtoWGSlng(double.Parse(lines[i + 20], NumberFormatInfo.InvariantInfo) * 1000, double.Parse(lines[i + 22], NumberFormatInfo.InvariantInfo) * 1000);
                            point2.Latitude = (decimal)CHtoWGSlat(double.Parse(lines[i + 20], NumberFormatInfo.InvariantInfo) * 1000, double.Parse(lines[i + 22], NumberFormatInfo.InvariantInfo) * 1000);
                            point2.ID = p.ID;
                            p.Points.Add(point2);

                            g.Polygons.Add(p);
                        }
                    }
                }
            }
            PolygonGroupToDraw = g;
            return g;
        }