public APISuccessResponse AddCircle([FromBody] CircleArea circle)
        {
            try
            {
                if (circle.Radius == 0 || string.IsNullOrEmpty(circle.Name))
                {
                    HttpContext.Response.StatusCode = BadRequest().StatusCode;

                    return(new APISuccessResponse("One or more fields in the request contain invalid data"));
                }

                bool isSuccess = _GPSService.AddCircle(circle);

                if (isSuccess)
                {
                    HttpContext.Response.StatusCode = Ok().StatusCode;

                    return(new APISuccessResponse());
                }
                else
                {
                    return(new APISuccessResponse("Error in adding circle to database"));
                }
            }
            catch (Exception ex)
            {
                _logger.LogWarning("An error occurs, Exception: {Exception Message}", ex.Message);
                HttpContext.Response.StatusCode = 500;

                return(new APISuccessResponse("Internal Server Error"));
            }
        }
Exemple #2
0
 public static void CheckSelect2()
 {
     if (Choice == 1)
     {
         Console.Clear();
         CircleArea.CircleAreaShape();
     }
     else if (Choice == 2)
     {
         Console.Clear();
         SquareArea.SquareAreaShape();
     }
     else if (Choice == 3)
     {
         Console.Clear();
         TrapeziumArea.Trapezium();
     }
     else if (Choice == 8)
     {
         Console.Clear();
         SelectRUS.ChangeShapeOperation();
     }
     else
     {
         ExeptionFilter.ExeptionOutput();
         SelectShapes();
     }
 }
        public ApplicationState()
        {
            this.CurrentArea     = Utilities.Area.Circle;
            this.mCircleArea     = new CircleArea(new Point(-100, -100), 100);
            this.mPolygonArea    = new PolygonArea(new Point(-100, -100));
            this.mWholeImageArea = new WholeImageArea();

            Filter = Filter.Negative;
        }
        public static Shape ToShape(CircleArea circle)
        {
            var shape = new Shape()
            {
                TypeId = circle.TypeId,
                Name   = circle.Name
            };

            return(shape);
        }
        public static Circle ToCircle(CircleArea circleArea)
        {
            var circle = new Circle();

            circle.Longitude = circleArea.CenterCoordinate.Longitude;
            circle.Latitude  = circleArea.CenterCoordinate.Latitude;
            circle.Radius    = circleArea.Radius;

            return(circle);
        }
Exemple #6
0
        public bool AddCircle(CircleArea circleArea)
        {
            var circle = ObjectMapper.ToCircle(circleArea);
            var shape  = ObjectMapper.ToShape(circleArea);

            var shapeResult = _repository.InsertShape(shape);

            circle.ShapeId = shapeResult.Id;
            var circleResult = _repository.InsertCirlce(circle);

            if (shapeResult == null || circleResult == null)
            {
                return(false);
            }

            return(true);
        }
 public bool ValidateRestrictedArea(Observation observation)
 {
     if (this.Mission.RestrictedArea != null)
     {
         if (this.Mission.RestrictedArea.GetType() == typeof(CircleArea))
         {
             CircleArea cirleArea = (CircleArea)this.Mission.RestrictedArea;
             double     distance  = GeoHelper.CalculateDistance(new Position(cirleArea.Center.Coordinates.Latitude, cirleArea.Center.Coordinates.Longitude), new Position(observation.Coordinates.Coordinates.Latitude, observation.Coordinates.Coordinates.Longitude));
             return(distance < cirleArea.Radius);
         }
         else
         {
             PolygonArea polygonArea = (PolygonArea)this.Mission.RestrictedArea;
             return(GeoHelper.IsPointInPolygon(polygonArea.Polygon.Coordinates.Exterior.Positions.Select(x => new Position(x.Latitude, x.Longitude)).ToArray(), new Position(observation.Coordinates.Coordinates.Latitude, observation.Coordinates.Coordinates.Longitude)));
         }
     }
     return(true);
 }
    void drawArea()
    {
        IArea area = gs.area;

        switch (area.type)
        {
        case GameArea.AreaType.circle:
            CircleArea cr = area as CircleArea;
            rectMat.SetFloat("_HalfWidth", cr.R);
            rectMat.SetFloat("_Ang", 360f);
            rectMesh.get(2 * area.R, 2 * area.R, new Vector3(0, 0.02f, 0));
            rectMesh.draw(sticker.localToWorldMatrix * mLocalMX, rectMat);
            break;

        case GameArea.AreaType.Fan:
            FanArea fr = area as FanArea;
            rectMat.SetFloat("_HalfWidth", fr.R);
            rectMat.SetFloat("_Ang", fr.ang);
            rectMesh.get(2 * area.R, 2 * area.R, new Vector3(0, 0.02f, 0));
            rectMesh.draw(sticker.localToWorldMatrix * mLocalMX, rectMat);
            break;

        case GameArea.AreaType.Rectangle:
            RectangleArea rar = area as RectangleArea;
            rectMat.SetFloat("_HalfWidth", rar.w / 2);
            rectMat.SetFloat("_HalfHeight", rar.R / 2);
            rectMat.SetFloat("_Ang", 0);
            rectMesh.get(area.R, area.R, new Vector3(0, 0.02f, rar.R / 2));
            rectMesh.draw(sticker.localToWorldMatrix * mLocalMX, rectMat);
            break;

        case GameArea.AreaType.Square:
            SquareArea sr = area as SquareArea;
            rectMat.SetFloat("_HalfWidth", sr.R / 2);
            rectMat.SetFloat("_HalfHeight", sr.R / 2);
            rectMat.SetFloat("_Ang", 0);
            rectMesh.get(area.R, area.R, new Vector3(0, 0.02f, sr.R / 2));
            rectMesh.draw(sticker.localToWorldMatrix * mLocalMX, rectMat);
            break;
        }
    }
Exemple #9
0
 public override string ToString()
 {
     return(base.ToString() + $"\n- Radius: {Radius}m\n- Area: {CircleArea.ToString("0.00")}m^2" +
            $"\n- Circumference: {CircleCircumference.ToString("0.00")}m\n");
 }