コード例 #1
0
ファイル: GeoLocationService.cs プロジェクト: mrtcn/upope
        public double GetDistance(CoordinateModel actualCoordinates, CoordinateModel destinationCoordinates)
        {
            var actualGeoCoordinate      = new GeoCoordinate(actualCoordinates.Latitude, actualCoordinates.Longitude);
            var destinationGeoCoordinate = new GeoCoordinate(destinationCoordinates.Latitude, destinationCoordinates.Longitude);

            return(actualGeoCoordinate.GetDistanceTo(destinationGeoCoordinate));
        }
コード例 #2
0
        public override async void OnNavigatedTo(INavigationParameters parameters)
        {
            base.OnNavigatedTo(parameters);

            try
            {
                if (parameters.GetNavigationMode() == NavigationMode.New)
                {
                    if (parameters.TryGetValue("TripDetails", out TripModel trip))
                    {
                        Name         = trip.Name;
                        StartTime    = trip.StartTime;
                        EndTime      = trip.EndTime;
                        Duration     = trip.Duration;
                        AverageSpeed = trip.AverageSpeed;
                        trip.Route.ForEach(x => Route.Add(x));

                        CurrentLocation = new CoordinateModel
                        {
                            Latitude  = trip.Route.Average(x => x.Latitude),
                            Longitude = trip.Route.Average(x => x.Longitude),
                        };
                        return;
                    }
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
            }
        }
コード例 #3
0
        public static bool ValidateSpot(string coordinate, List <CoordinateModel> coordinatesList, GridSpotStatus status)
        {
            bool output = false;

            (char row, int column) = SplitShotIntoRowColumn(coordinate);
            bool isValidCoordinate = ValidateCoordinates(row, column);

            if (isValidCoordinate == true)
            {
                CoordinateModel spot = new CoordinateModel {
                    RowChar   = row,
                    ColumnInt = column,
                    Status    = status
                };

                if (coordinatesList.Contains(spot) == false && status == GridSpotStatus.Ship)
                {
                    coordinatesList.Add(spot);
                    output = true;
                }

                if (coordinatesList.Contains(spot) == true && status == GridSpotStatus.Empty)
                {
                    output = true;
                }
            }

            return(output);
        }
コード例 #4
0
ファイル: GpsService.cs プロジェクト: ciani/NativeFormsLabs
        public Task <CoordinateModel> GetCurrentPositionAsync()
        {
            TaskCompletionSource <CoordinateModel> tcs = new TaskCompletionSource <CoordinateModel>();
            CoordinateModel currentPosition            = null;

            Permission locationPermission = ContextCompat.CheckSelfPermission(Android.App.Application.Context, Manifest.Permission.AccessCoarseLocation);

            if (locationPermission == Permission.Granted)
            {
                locationManager = Application.Context.GetSystemService(Context.LocationService) as LocationManager;
                string provider = GetBestLocationProvider();
                var    result   = locationManager.GetLastKnownLocation(provider);
                if (result != null)
                {
                    currentPosition = new CoordinateModel()
                    {
                        Latitude  = result.Latitude,
                        Longitude = result.Longitude,
                        Altitude  = result.Altitude
                    };

                    tcs.SetResult(currentPosition);
                }
                else
                {
                    tcs.SetResult(default(CoordinateModel));
                }
            }

            return(tcs.Task);
        }
コード例 #5
0
ファイル: SpotController.cs プロジェクト: mrtcn/App1
        public IActionResult Spots([FromBody] CoordinateModel model)
        {
            var spotEntityParamsList = _spotService.GetSpotList(model);
            var spotListViewModel    = _mapper.Map <List <SpotEntityParams>, List <SpotListViewModel> >(spotEntityParamsList);

            return(Ok(spotListViewModel));
        }
コード例 #6
0
        private void SetCurrentLocation(CLLocation currentLocation)
        {
            CoordinateModel currentPosition = new CoordinateModel();

            currentPosition.Latitude  = currentLocation.Coordinate.Latitude;
            currentPosition.Longitude = currentLocation.Coordinate.Longitude;
            currentPosition.Altitude  = currentLocation.Altitude;

            tcs.TrySetResult(currentPosition);
        }
コード例 #7
0
 public static Coordinate Map(CoordinateModel model)
 {
     return(new Coordinate()
     {
         Value = model.Value,
         X = model.X,
         Y = model.Y,
         Z = model.Z
     });
 }
コード例 #8
0
 public MainViewModel()
 {
     DialogService = new DefaultDialogService();
     XCoordinate   = new CoordinateModel('X');
     YCoordinate   = new CoordinateModel('Y');
     ZCoordinate   = new CoordinateModel('Z');
     CoordinateModel.SetLogger(Log);
     SourceFileName  = "Файл не выбран";
     PrinterSettings = new PrinterSettings();
     isFileSelected  = false;
 }
コード例 #9
0
        private static double PerpendicularDistance(CoordinateModel point1, CoordinateModel point2, CoordinateModel point)
        {
            var area = Math.Abs(.5 * (point1.Latitude * point2.Longitude + point2.Latitude *
                                      point.Longitude + point.Latitude * point1.Longitude - point2.Latitude * point1.Longitude - point.Latitude *
                                      point2.Longitude - point1.Latitude * point.Longitude));
            var bottom = Math.Sqrt(Math.Pow(point1.Latitude - point2.Latitude, 2) +
                                   Math.Pow(point1.Longitude - point2.Longitude, 2));
            var height = area / bottom * 2;

            return(height);
        }
コード例 #10
0
    static void Main(string[] args)
    {
        CoordinateModel model = new CoordinateModel {
            Latitude = 12.345678, Longitude = 98.765543
        };
        var vc      = new ValidationContext(model);
        var isValid = Validator.TryValidateObject(model, vc, null, true);    //isValid == true
        var json    = "{ \"Latitude\": 12.345678, \"Longitude\": 98.765543 }";

        model   = JsonConvert.DeserializeObject <CoordinateModel>(json);
        vc      = new ValidationContext(model);
        isValid = Validator.TryValidateObject(model, vc, null, true);     //isValid == true
    }
コード例 #11
0
        /// <summary>
        /// Create a new Coordinate Model for an Axis.
        /// Typically used when switching Axes or setting new Axis parameters.
        /// </summary>
        /// <param name="axisID"></param>
        /// <param name="position"></param>
        /// <param name="minPosition"></param>
        /// <param name="maxPosition"></param>
        public void SetNewXYZCoord(char axisID, double position, double minPosition, double maxPosition)
        {
            switch (axisID)
            {
            case 'X':
                _xCoord = new CoordinateModel(CoordinateType.X, true, this, position, minPosition, maxPosition);
                break;

            case 'Y':
                _yCoord = new CoordinateModel(CoordinateType.Y, true, this, position, minPosition, maxPosition);
                break;

            case 'Z':
                _zCoord = new CoordinateModel(CoordinateType.Z, true, this, position, minPosition, maxPosition);
                break;
            }
        }
コード例 #12
0
        public static List <CoordinateModel> ParseDatabasePolygonString(string polygonString)
        {
            var coordinateList = new List <CoordinateModel>();
            var itemArray      = polygonString.Split('(', ')');

            foreach (var coordDesc in itemArray)
            {
                if (coordDesc.Length < 3)
                {
                    continue;
                }
                var coordArray = coordDesc.Split(',');
                var coordModel = new CoordinateModel(double.Parse(coordArray[0], CultureInfo.InvariantCulture), double.Parse(coordArray[1], CultureInfo.InvariantCulture));
                coordinateList.Add(coordModel);
            }
            return(coordinateList);
        }
コード例 #13
0
ファイル: MixUnitTest.cs プロジェクト: topnguyen/Elect
        public void PolygonTestCase()
        {
            var polygon = new List <CoordinateModel>
            {
                new CoordinateModel(103.77819210947298, 1.5149825899642049),
                new CoordinateModel(103.79741818369173, 1.4888990253023116),
                new CoordinateModel(103.84685666025423, 1.434671685599842),
                new CoordinateModel(103.87844235361361, 1.4593830407129205),
                new CoordinateModel(103.87088925302767, 1.4882126115142948),
                new CoordinateModel(103.86998011691315, 1.4805007218490491)
            };

            var pointToCheck = new CoordinateModel(103.8727266972518, 1.4708908432922319);

            var isInPolygon = PolygonUtils.IsInPolygon(pointToCheck, polygon);

            Assert.IsTrue(isInPolygon);
        }
コード例 #14
0
        public PointStateExampleViewModel()
        {
            ListResult = new ObservableCollection <CoordinateModel>(App.ListResult);
            Values     = new ChartValues <CoordinateModel>();
            foreach (var item in ListResult)
            {
                CoordinateModel coordinate = new CoordinateModel();
                coordinate = item;

                Values.Add(coordinate);
            }

            //Lets define a custom mapper, to set fill and stroke
            //according to chart values...
            Mapper = Mappers.Xy <CoordinateModel>()
                     .X(model => model.Xcoord)
                     .Y(model => model.Value);
        }
コード例 #15
0
        public void SecondTestScenario()
        {
            var process         = new ProcessManager();
            var coordinateModel = new CoordinateModel {
                XCoord = 3, YCoord = 3
            };
            var result = process.StartMoveOrientation(coordinateModel, "MMRMMRMRRM", new PlateauModel {
                Height = 5, Width = 5
            }, DirectionEnum.E);

            if (!result.Success)
            {
                Assert.IsTrue(result.Success);
            }
            else
            {
                Assert.AreEqual("XCoord : " + 5 + " YCoord : " + 1 + " Direction : E", result.Result);
            }
        }
コード例 #16
0
        public void FirstTestScenario()
        {
            var process         = new ProcessManager();
            var coordinateModel = new CoordinateModel {
                XCoord = 1, YCoord = 2
            };
            var result = process.StartMoveOrientation(coordinateModel, "LMLMLMLMM", new PlateauModel {
                Height = 5, Width = 5
            }, DirectionEnum.N);

            if (!result.Success)
            {
                Assert.IsTrue(result.Success);
            }
            else
            {
                Assert.AreEqual("XCoord : " + 1 + " YCoord : " + 3 + " Direction : N", result.Result);
            }
        }