Exemplo n.º 1
0
        public double CompareDistance(Geography2dPoint from, int id)
        {
            var fromPoint = new GeographyPointEntity {
                Location = new Point(from.Lon, from.Lat)
            };
            var comparePoint = _dbContext.Points.FirstOrDefault(x => x.Id == id) ?? new GeographyPointEntity {
                Location = new Point(0, 0)
            };

            return(comparePoint.Location.Distance(fromPoint.Location));
        }
Exemplo n.º 2
0
        public double CalculateDistance(GetDistanceViewModel model)
        {
            var startPoint = new GeographyPointEntity {
                Location = new Point(model.From.Lon, model.From.Lat)
            };
            var endPoint = new GeographyPointEntity {
                Location = new Point(model.To.Lon, model.To.Lat)
            };
            var result = startPoint.Location.Distance(endPoint.Location);

            return(result);
        }