Exemple #1
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.Info);

            noFlyZoneLayout = FindViewById <LinearLayout>(Resource.Id.noFlyZoneLayout);
            notamZoneLayout = FindViewById <LinearLayout>(Resource.Id.notamLayout);

            lblId        = FindViewById <TextView>(Resource.Id.lblId);
            lblReference = FindViewById <TextView>(Resource.Id.lblReference);
            lblMeaning   = FindViewById <TextView>(Resource.Id.lblMeaning);
            lblSuffix    = FindViewById <TextView>(Resource.Id.lblSuffix);

            lblCategory    = FindViewById <TextView>(Resource.Id.lblCategory);
            lblName        = FindViewById <TextView>(Resource.Id.lblName);
            lblType        = FindViewById <TextView>(Resource.Id.lblType);
            lblFlightLower = FindViewById <TextView>(Resource.Id.lblFlightLower);
            lblFlightUpper = FindViewById <TextView>(Resource.Id.lblFlightUpper);

            string rawAirspaceType = Intent.GetStringExtra("airspaceType");
            Type   airspaceType    = Type.GetType(rawAirspaceType);

            if (airspaceType == typeof(NOTAMZone))
            {
                string notamInfoJSON = Intent.GetStringExtra("airspaceInfo");
                if (!string.IsNullOrEmpty(notamInfoJSON))
                {
                    notamZone = JsonConvert.DeserializeObject <NOTAMZone>(notamInfoJSON);

                    notamZoneLayout.Visibility = Android.Views.ViewStates.Visible;

                    lblId.Text        = notamZone.Id.ToString();
                    lblMeaning.Text   = notamZone.Meaning;
                    lblReference.Text = notamZone.Reference;
                    lblSuffix.Text    = notamZone.Suffix;
                }
            }
            else
            {
                string noFlyZoneJSON = Intent.GetStringExtra("airspaceInfo");
                if (!string.IsNullOrEmpty(noFlyZoneJSON))
                {
                    noFlyZone = JsonConvert.DeserializeObject <NoFlyZone>(noFlyZoneJSON);

                    noFlyZoneLayout.Visibility = Android.Views.ViewStates.Visible;

                    lblCategory.Text    = noFlyZone.Category.ToString();
                    lblName.Text        = noFlyZone.Name;
                    lblType.Text        = noFlyZone.Name;
                    lblFlightLower.Text = noFlyZone.FlightLower.ToString();
                    lblFlightUpper.Text = noFlyZone.FlightUpper.ToString();
                }
            }

            //string weatherInfoJSON = Intent.GetStringExtra("weatherInfo");

            //if (!string.IsNullOrEmpty(weatherInfoJSON))
            //    climate = JsonConvert.DeserializeObject<Climate>(weatherInfoJSON);
        }
        public IHttpActionResult PutNoFlyZone(int id, NoFlyZone noFlyZone)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != noFlyZone.ID)
            {
                return(BadRequest());
            }

            db.Entry(noFlyZone).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!NoFlyZoneExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Exemple #3
0
    public static Improbable.Controller.NoFlyZone CreateCustomNoFlyZone(Improbable.Collections.List <Vector3f> vertices)
    {
        Improbable.Controller.NoFlyZone nfz = new Improbable.Controller.NoFlyZone();
        nfz.vertices = vertices;
        NoFlyZone.setBoundingBoxCoordinates(ref nfz);

        return(nfz);
    }
        public IHttpActionResult GetNoFlyZone(int id)
        {
            NoFlyZone noFlyZone = db.NoFlyZones.Find(id);

            if (noFlyZone == null)
            {
                return(NotFound());
            }

            return(Ok(noFlyZone));
        }
Exemple #5
0
 public bool isPointInNoFlyZone(Improbable.Vector3f point)
 {
     foreach (Improbable.Controller.NoFlyZone zone in zones)
     {
         if (NoFlyZone.hasCollidedWith(zone, point))
         {
             return(true);
         }
     }
     return(false);
 }
Exemple #6
0
 public NFZData(SNoFlyZone data, NoFlyZone src)
 {
     _source                       = src;
     UID                           = data.uid;
     Count                         = data.count;
     droneEntryCount               = data.droneEntry;
     hubEntryCount                 = data.hubEntry;
     _source.transform.position    = data.position;
     _source.transform.eulerAngles = data.orientation;
     _source.transform.localScale  = data.size;
 }
        public IHttpActionResult PostNoFlyZone(NoFlyZone noFlyZone)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.NoFlyZones.Add(noFlyZone);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = noFlyZone.ID }, noFlyZone));
        }
        void MakeNFZ()
        {
            NoFlyZone nfz  = NoFlyZone.New();
            var       pos  = new Vector3(Screen.width / 2, Screen.height / 2, 0);
            var       pos2 = nfz.transform.position;

            pos    = Selectable.Cam.ScreenToWorldPoint(pos);
            pos2.x = pos.x;
            pos2.y = nfz.transform.localScale.y / 2 + 0.1f;
            pos2.z = pos.z;
            nfz.transform.position = pos2;
        }
 public NoFlyZoneEntry(IDataSource obj, NoFlyZone nfz)
 {
     Type       = EventType.EnteredNoFlyZone;
     OpenWindow = () => { if (ID == obj.ToString())
                          {
                              obj.OpenInfoWindow();
                          }
     };
     ID      = obj.ToString();
     Target  = nfz.Position.ToArray();
     Time    = TimeKeeper.Chronos.Get();
     Message = Time + " - " + ID + " entered illegal airspace " + nfz.Name;
 }
        public IHttpActionResult DeleteNoFlyZone(int id)
        {
            NoFlyZone noFlyZone = db.NoFlyZones.Find(id);

            if (noFlyZone == null)
            {
                return(NotFound());
            }

            db.NoFlyZones.Remove(noFlyZone);
            db.SaveChanges();

            return(Ok(noFlyZone));
        }
Exemple #11
0
    public static Improbable.Controller.NoFlyZone GetNoFlyZone(NFZTemplate template)
    {
        Improbable.Controller.NoFlyZone nfz = new Improbable.Controller.NoFlyZone();
        nfz.vertices = new Improbable.Collections.List <Improbable.Vector3f>();

        float[] coords = getPoints(template);
        for (int i = 0; i < coords.Length; i += 2)
        {
            nfz.vertices.Add(new Improbable.Vector3f(coords[i], 0, coords[i + 1]));
        }

        NoFlyZone.setBoundingBoxCoordinates(ref nfz);

        return(nfz);
    }
    private Vector3f GetNonNFZPoint()
    {
        float    randX, randZ;
        Vector3f point        = new Vector3f();
        bool     invalidPoint = false;

        //10 attempts per second to get a valid point
        for (int i = 0; i < 10; i++)
        {
            point.x      = UnityEngine.Random.Range(-SimulationSettings.maxX, SimulationSettings.maxX);
            point.z      = UnityEngine.Random.Range(-SimulationSettings.maxZ, SimulationSettings.maxZ);
            invalidPoint = NoFlyZone.hasCollidedWithAny(OrderWriter.Data.zones, point);

            if (!invalidPoint)
            {
                return(point);
            }
        }

        return(new Vector3f(0, -1, 0));
    }
Exemple #13
0
 public NfzData(NoFlyZone src)
 {
     UID     = ++Count;
     _source = src;
 }