Exemplo n.º 1
0
 public JsonResult GetGeoData(double[] latlng)
 {
     using (GisAccess gis = new GisAccess(ConfigurationManager.AppSettings["SpatialDataSource"]))
     {
         //System.Threading.Thread.Sleep(2000);
         Country country = gis.GetCountryByCoordinates(latlng[1], latlng[0]);
         return(country != null?Json(country) : Json(new object()));
     }
 }
Exemplo n.º 2
0
        public JsonResult GetInfo(double x, double y)
        {
            string featureInfo;
            var    layer = _layersList.Value.FirstOrDefault(o => o.Name == "const_poly_year_wgs");

            if (layer != null)
            {
                using (GisAccess gis = new GisAccess(layer))
                {
                    featureInfo = gis.GetObjectByCoordinates(x, y);
                }
                if (featureInfo == null)
                {
                    return(new JsonResult(new { error = true }));
                }
                return(new JsonResult(new { featureInfo = featureInfo }));
            }
            return(new JsonResult(new { error = true, message = "Layer not found" }));
        }
Exemplo n.º 3
0
        public IActionResult EditBuilding(UserBuilding userbuilding)
        {
            if (ModelState.IsValid)
            {
                userbuilding.IpAddressUser = HttpContext.Connection.RemoteIpAddress.ToString();
                var usersTable = _layersList.Value.FirstOrDefault(o => o.Name == "users_data");
                if (usersTable != null)
                {
                    using (GisAccess gis = new GisAccess(usersTable))
                    {
                        //if (gis.IsMaxEditesPerDay())
                        //{
                        int retry_cnt = 5;
                        int cnt       = retry_cnt;
                        do
                        {
                            --cnt;
                            try
                            {
                                gis.WriteUserData(userbuilding);
                                EditesChecker.AddEditsCnt();
                                break;
                            }
                            catch (Exception ex)
                            {
                                _logger.LogError($"Not write userdata {retry_cnt - cnt}/{retry_cnt}. {ex.Message}");
                                Thread.Sleep(2);
                            }
                        } while (cnt > 0);
                        //}
                    }
                }
            }

            return(PartialView("EditBuildingModal", userbuilding));
        }