Beispiel #1
0
 public void Distance_Test()
 {
     double lat1 = 30.613085, lon1 = 104.073803;
     double lat2 = 30.634466, lon2 = 104.147967;
     var    distance1 = MapHelper.Distance(lat1, lon1, lat2, lon2);
     var    distance2 = AbpMapByGoogle.GetDistance(lat1, lon1, lat2, lon2);
 }
        public async Task <APIResultDto> ValidateLocationAsync(double lat, double lon, double latGrower, double lonGrower)
        {
            var distance  = AbpMapByGoogle.GetDistance(lat, lon, latGrower, lonGrower);
            var signRange = await _systemDataRepository.GetAll().Where(s => s.ModelId == ConfigModel.烟叶服务 && s.Type == ConfigType.烟叶公共 && s.Code == GYCode.SignRange).FirstOrDefaultAsync();

            var range = 500d;

            if (signRange != null)
            {
                range = double.Parse(signRange.Desc);
            }
            if (distance < range)
            {
                return(new APIResultDto()
                {
                    Code = 0, Msg = "ok"
                });
            }
            else
            {
                return(new APIResultDto()
                {
                    Code = 901, Msg = "当前位置不在拜访位置范围内"
                });
            }
        }