예제 #1
0
 public SceneryObject(SceneryObject n)
 {
     this.name   = n.name;
     this.lat    = n.lat;
     this.lon    = n.lon;
     this.marker = n.marker;
 }
예제 #2
0
        private void aggiungiScenarioBtn_Click(object sender, EventArgs e)
        {
            SceneryObject toAdd = GetSceneryObjectFromComboBox(ref singoloEffettoCB);

            if (toAdd == null)
            {
                MessageBox.Show("Non è stato possibile creare l'oggetto. Errore sulla GetSceneryObjectFromComboBox.", "Errore", MessageBoxButtons.OK, MessageBoxIcon.Error);
                SingoloFieldsClearAll();
                return;
            }
            else
            {
                if (toAdd.AddToXml(Makefire.filePath))
                {
                    listBox.Items.Add(toAdd);
                    toAdd.AddMarkerToMap(ref markerOverlay);

                    MessageBox.Show("Oggetto creato ed inserito correttamente nel file XML.", "OK", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    SingoloFieldsClearAll();
                    EnableSelezionatuttiAndCompilaBGL();
                    return;
                }
                else
                {
                    MessageBox.Show("Errore nell'inserire l'oggetto nel file XML. Riprova.", "Errore", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    SingoloFieldsClearAll();
                    return;
                }
            }
        }
예제 #3
0
        private static double Pendenza(SceneryObject start, SceneryObject end)
        {
            double ret = 0;

            try
            {
                ret = (end.Lng - start.Lng) / (end.Lat - start.Lat);
                return(ret);
            }
            catch
            {
                return(100000000);
            }
        }
예제 #4
0
 private static SceneryObject CreateObject(SceneryObject rifObj, double lat, double lon)
 {
     if (rifObj is Fire)
     {
         return(new Fire(rifObj.Nome, lat, lon));
     }
     else if (rifObj is Smoke)
     {
         return(new Smoke(rifObj.Nome, lat, lon));
     }
     else if (rifObj is Autocisterna)
     {
         return(new Autocisterna(lat, lon));
     }
     else
     {
         return(new CustomObject(((CustomObject)rifObj).Type, rifObj.Nome, lat, lon, rifObj.Marker.Type));
     }
 }
예제 #5
0
        public static List <SceneryObject> CreateLineFire(SceneryObject start, SceneryObject end)
        {
            List <SceneryObject> points = new List <SceneryObject>();

            double lat = start.Lat;
            double lon = start.Lng;
            double x   = 0;
            double m   = Pendenza(start, end);

            points.Add(start);

            double d     = Distance(start, end);
            double alpha = Math.Atan(m);

            if (m != 100000000)
            {
                if ((alpha >= 45 && alpha <= 135) || (alpha >= -45 || alpha <= -135))
                {
                    x = d * (d * 1.5);
                }
                else
                {
                    x = d * (d * 1);
                }
            }
            else
            {
                x = d * (d * 0.75);
            }
            if (lat < end.Lat)
            {
                while (x < 1e-05)
                {
                    x *= 10;
                }

                while (lat < end.Lat)
                {
                    lat += x;//Convert.ToDouble("0,0000930");
                    lon  = Y(start, end, lat);

                    if (lat != 0 && lon != 0)
                    {
                        points.Add(CreateObject(start, lat, lon) /*new Fire(start.Nome, lat, lon*/);
                    }
                }
            }
            else
            {
                while (x < 1e-05)
                {
                    x *= 10;
                }

                while (lat > end.Lat)
                {
                    lat -= x;//Convert.ToDouble("0,0000930");
                    lon  = Y(start, end, lat);

                    if (lat != 0 && lon != 0)
                    {
                        points.Add(CreateObject(start, lat, lon) /*new Fire(start.Nome, lat, lon)*/);
                    }
                }
            }
            points.Add(end);

            return(points);
        }
예제 #6
0
 private static double Distance(SceneryObject start, SceneryObject end)
 {
     return(Math.Sqrt(Math.Pow((end.Lat - start.Lat) + (end.Lng - start.Lng), 2)));
 }
예제 #7
0
 private static double Y(SceneryObject P1, SceneryObject P2, double x)
 {
     return((((x - P1.Lat) * (P2.Lng - P1.Lng)) / (P2.Lat - P1.Lat)) + P1.Lng);
 }