コード例 #1
0
        public IActionResult Merge([FromBody] NbombBO bo)
        {
            var fireball         = _geometryAnalysisService.GetFireBallRadius(bo);
            var nuclearradiation = _geometryAnalysisService.Nuclearradiation(bo);
            var airblast         = _geometryAnalysisService.ShockWave(bo);
            var thermalradiation = _geometryAnalysisService.ThermalRadiation(bo);
            var nuclearpulse     = _geometryAnalysisService.GetNuclearPulseRadius(bo);


            List <MergeVO> list = new List <MergeVO>();

            list.Add(new MergeVO("核火球",
                                 new DamageResultVO(bo.nuclearExplosionID, fireball.DamageRadius, bo.Lon.GetValueOrDefault(), bo.Lat.GetValueOrDefault(), bo.Alt.GetValueOrDefault(), 0, "")));
            list.Add(new MergeVO("早期核辐射",
                                 new DamageResultVO(bo.nuclearExplosionID, nuclearradiation.DamageRadius, bo.Lon.GetValueOrDefault(), bo.Lat.GetValueOrDefault(), bo.Alt.GetValueOrDefault(), nuclearradiation.value, nuclearradiation.unit)));
            list.Add(new MergeVO("冲击波",
                                 new DamageResultVO(bo.nuclearExplosionID, airblast.DamageRadius, bo.Lon.GetValueOrDefault(), bo.Lat.GetValueOrDefault(), bo.Alt.GetValueOrDefault(), airblast.value, airblast.unit)));
            list.Add(new MergeVO("光辐射",
                                 new DamageResultVO(bo.nuclearExplosionID, thermalradiation.DamageRadius, bo.Lon.GetValueOrDefault(), bo.Lat.GetValueOrDefault(), bo.Alt.GetValueOrDefault(), thermalradiation.value, thermalradiation.unit)));
            list.Add(new MergeVO("核电磁脉冲",
                                 new DamageResultVO(bo.nuclearExplosionID, nuclearpulse.DamageRadius, bo.Lon.GetValueOrDefault(), bo.Lat.GetValueOrDefault(), bo.Alt.GetValueOrDefault(), nuclearpulse.value, nuclearpulse.unit)));

            return(new JsonResult(new
            {
                return_status = 0,
                return_msg = "",
                return_data = list
            }));
        }
コード例 #2
0
        public FalloutResultVO GetFalloutGeometryJson(NbombBO bo, double wind_speed, double wind_dir, int radshour)
        {
            var geometry = MyCore.NuclearAlgorithm.GetFalloutGeometryJson(bo.Yield.GetValueOrDefault(), bo.Lon.GetValueOrDefault(), bo.Lat.GetValueOrDefault(),
                                                                          bo.Alt.GetValueOrDefault(), wind_speed, wind_dir, radshour);

            return(new FalloutResultVO(bo.nuclearExplosionID, geometry, 1, 1, "rads/h"));
        }
コード例 #3
0
        public IActionResult Area([FromBody] NbombBO bo)
        {
            if (bo.Yield <= 0 || bo.Yield / 1000 > 100000)
            {
                return(new JsonResult(new
                {
                    return_status = 1,
                    return_msg = "当量必须大于0并且小于100000千吨",
                    return_data = ""
                }));
            }

            //var fireball = _geometryAnalysisService.GetFireBallRadius(bo);
            //var nuclearradiation = _geometryAnalysisService.Nuclearradiation(bo);
            //var airblast = _geometryAnalysisService.ShockWave(bo);
            //var thermalradiation = _geometryAnalysisService.ThermalRadiation(bo);
            var nuclearpulse = _geometryAnalysisService.GetNuclearPulseRadius(bo);


            return(new JsonResult(new
            {
                return_status = 0,
                return_msg = "",
                return_data = new
                {
                    damageRadius = nuclearpulse.DamageRadius,
                    lon = bo.Lon,
                    lat = bo.Lat,
                    alt = bo.Alt
                }
            }));
        }
コード例 #4
0
        //火球
        public DamageResultVO GetFireBallRadius(NbombBO bo)
        {
            double radius = MyCore.NuclearAlgorithm.GetFireBallRadius(bo.Yield.GetValueOrDefault(), bo.Alt.GetValueOrDefault());

            return(new DamageResultVO(bo.nuclearExplosionID,
                                      Math.Round(radius, 2),
                                      bo.Lon.GetValueOrDefault(), bo.Lat.GetValueOrDefault(), bo.Alt.GetValueOrDefault(), 0, ""));
        }
コード例 #5
0
 public IActionResult Nuclearpulse([FromBody] NbombBO bo)
 {
     return(new JsonResult(new
     {
         return_status = 0,
         return_msg = "",
         return_data = _geometryAnalysisService.GetNuclearPulseRadius(bo)
     }));
 }
コード例 #6
0
 public IActionResult Nuclearradiation([FromBody] NbombBO bo)
 {
     return(new JsonResult(new
     {
         return_status = 0,
         return_msg = "",
         return_data = _geometryAnalysisService.Nuclearradiation(bo)
     }));
 }
コード例 #7
0
 public IActionResult Airblast([FromBody] NbombBO bo)
 {
     return(new JsonResult(new
     {
         return_status = 0,
         return_msg = "",
         return_data = _geometryAnalysisService.ShockWave(bo)
     }));
 }
コード例 #8
0
 public IActionResult Fireball([FromBody] NbombBO bo)
 {
     return(new JsonResult(new
     {
         return_status = 0,
         return_msg = "",
         return_data = _geometryAnalysisService.GetFireBallRadius(bo)
     }));
 }
コード例 #9
0
        //核电磁脉冲
        public DamageResultVO GetNuclearPulseRadius(NbombBO bo)
        {
            var rule = _mongoService.QueryRule("核电磁脉冲");

            if (rule != null)
            {
                double radius = MyCore.NuclearAlgorithm.GetNuclearPulseRadius(bo.Yield.GetValueOrDefault(), bo.Alt.GetValueOrDefault(), rule.limits);
                return(new DamageResultVO(bo.nuclearExplosionID, Math.Round(radius, 2),
                                          bo.Lon.GetValueOrDefault(), bo.Lat.GetValueOrDefault(), bo.Alt.GetValueOrDefault(), rule.limits, rule.unit));
            }
            return(null);
        }
コード例 #10
0
        public IActionResult MergeGet(string nuclearExplosionID, string OccurTime, double Lon, double Lat, double Alt, double Yield)
        {
            List <String> errors = new List <string>();

            if (nuclearExplosionID == null)
            {
                errors.Add("nuclearExplosionID不能为空");
            }
            if (OccurTime == null)
            {
                errors.Add("OccurTime不能为空");
            }
            if (Lon > 180 || Lon < -180)
            {
                errors.Add("Lon必须介于-180~180");
            }
            if (Lat > 90 || Lat < -90)
            {
                errors.Add("Lon必须介于-90~90");
            }
            if (Alt < 0)
            {
                errors.Add("Lon必须大于等于0");
            }
            if (Yield <= 0)
            {
                errors.Add("Yield必须大于0");
            }
            if (errors.Count > 0)
            {
                return(new JsonResult(new
                {
                    return_status = 1,
                    return_msg = errors,
                    return_data = ""
                }));
            }

            NbombBO bo               = new NbombBO(nuclearExplosionID, OccurTime, Lon, Lat, Alt, Yield);
            var     fireball         = _geometryAnalysisService.GetFireBallRadius(bo);
            var     nuclearradiation = _geometryAnalysisService.Nuclearradiation(bo);
            var     airblast         = _geometryAnalysisService.ShockWave(bo);
            var     thermalradiation = _geometryAnalysisService.ThermalRadiation(bo);
            var     nuclearpulse     = _geometryAnalysisService.GetNuclearPulseRadius(bo);


            List <MergeVO> list = new List <MergeVO>();

            list.Add(new MergeVO("核火球",
                                 new DamageResultVO(bo.nuclearExplosionID, fireball.DamageRadius, bo.Lon.GetValueOrDefault(), bo.Lat.GetValueOrDefault(), bo.Alt.GetValueOrDefault(), 0, "")));
            list.Add(new MergeVO("早期核辐射",
                                 new DamageResultVO(bo.nuclearExplosionID, nuclearradiation.DamageRadius, bo.Lon.GetValueOrDefault(), bo.Lat.GetValueOrDefault(), bo.Alt.GetValueOrDefault(), nuclearradiation.value, nuclearradiation.unit)));
            list.Add(new MergeVO("冲击波",
                                 new DamageResultVO(bo.nuclearExplosionID, airblast.DamageRadius, bo.Lon.GetValueOrDefault(), bo.Lat.GetValueOrDefault(), bo.Alt.GetValueOrDefault(), airblast.value, airblast.unit)));
            list.Add(new MergeVO("光辐射",
                                 new DamageResultVO(bo.nuclearExplosionID, thermalradiation.DamageRadius, bo.Lon.GetValueOrDefault(), bo.Lat.GetValueOrDefault(), bo.Alt.GetValueOrDefault(), thermalradiation.value, thermalradiation.unit)));
            list.Add(new MergeVO("核电磁脉冲",
                                 new DamageResultVO(bo.nuclearExplosionID, nuclearpulse.DamageRadius, bo.Lon.GetValueOrDefault(), bo.Lat.GetValueOrDefault(), bo.Alt.GetValueOrDefault(), nuclearpulse.value, nuclearpulse.unit)));

            return(new JsonResult(new
            {
                return_status = 0,
                return_msg = "",
                return_data = list
            }));
        }
コード例 #11
0
        public IActionResult Fallout([FromBody] NbombBO bo)
        {
            if (bo.Yield < 1000 || bo.Yield > 100000000)
            {
                return(new JsonResult(new
                {
                    return_status = 1,
                    return_msg = "当量必须在1000 - 100,000,000吨之间",
                    return_data = ""
                }));
            }

            // 需要调用天气的接口获取风速和风向
            // 接口:  POST http://192.168.10.202/commonapi/weatherservice/info

            /* 请求体 */

            //   {
            //       "lon":110.12,
            //       "lat":23.23,
            //       "impactTimeUtc":1589270745.12
            //    }

            /* 返回值 */

            //{
            //    "return_status": 0,
            //    "return_msg": "查询成功",
            //    "return_data": {
            //        "season":2,
            //        "wind_speed":12.3,
            //        "wind_dir":23.12,
            //        "temperature":23.2,
            //        "humidity":23.4,
            //        "rainfall":34.1,
            //        "snowfall":21.2
            //    }
            //}

            var str = JsonConvert.SerializeObject(bo);

            double wind_speed = 15;
            double wind_dir   = 225;

            string url = Configuration["ServiceUrls:Weather"];//https://localhost:5001/weather

            var timeUtc = (DateTime.Now.ToUniversalTime().Ticks - 621355968000000000) / 10000000;

            WeatherBO weatherBO = new WeatherBO(bo.Lon.GetValueOrDefault(), bo.Lat.GetValueOrDefault(), bo.Alt.GetValueOrDefault(), timeUtc);
            string    postBody  = JsonConvert.SerializeObject(weatherBO);

            try
            {
                Task <string> s = MyCore.Utils.HttpCli.PostAsyncJson(url, postBody);
                s.Wait();
                JObject jo = (JObject)JsonConvert.DeserializeObject(s.Result);//或者JObject jo = JObject.Parse(jsonText);

                wind_speed = Double.Parse(jo["return_data"]["wind_speed"].ToString());
                wind_dir   = Double.Parse(jo["return_data"]["wind_dir"].ToString());
            }
            catch (Exception)
            {
            }


            var result = _geometryAnalysisService.GetFalloutGeometryJson(bo, wind_speed, wind_dir, 1);

            return(new JsonResult(new
            {
                return_status = 0,
                return_msg = "",
                return_data = result
            }));
        }