Example #1
0
        /// <summary>
        /// 整合坡度线(Line)
        /// </summary>
        /// <param name="subPdx"></param>
        /// <returns></returns>
        public static string zhengHePdLine(List <string> subPdx)
        {
            OSGeo.OGR.Ogr.RegisterAll();
            OSGeo.OGR.Driver dr = OSGeo.OGR.Ogr.GetDriverByName("ESRI shapefile");

            string newPath = StaticTools.tempFilePath("shp", "整合线");

            OSGeo.OGR.DataSource newDs    = dr.CreateDataSource(newPath, null);/////////////////
            OSGeo.OGR.Layer      newLayer = newDs.CreateLayer("Lines",
                                                              dr.Open(subPdx[0], 0).GetLayerByIndex(0).GetSpatialRef(),
                                                              dr.Open(subPdx[0], 0).GetLayerByIndex(0).GetGeomType(), null);

            for (int i = 0; i < subPdx.Count; i++)
            {
                OSGeo.OGR.DataSource dsLine    = dr.Open(subPdx[i], 0);///////////////////////
                OSGeo.OGR.Layer      lineLayer = dsLine.GetLayerByIndex(0);
                for (int j = 0; j < lineLayer.GetFeatureCount(0); j++)
                {
                    newLayer.CreateFeature(lineLayer.GetFeature(j));
                }
                dsLine.Dispose();
            }
            newDs.Dispose();
            return(newPath);
        }
Example #2
0
        public async Task <IActionResult> GetProjectPreFactors(string projectId)
        {
            try
            {
                var user = await _unitOfWork.UserRepository.DbSet.Include(u => u.Projects).ThenInclude(p => p.PreFactors).SingleOrDefaultAsync(u => Guid.Parse((HttpContext.User.Identity as ClaimsIdentity).Claims.Select(c => c.Value).ToList()[0]) == u.Id);

                if (user == null)
                {
                    return(NotFound("user not found"));
                }
                var project = user.Projects.SingleOrDefault(p => p.Id == Guid.Parse(projectId));
                if (project == null)
                {
                    return(NotFound("Project not found"));
                }
                var x = from pf in project.PreFactors
                        select new
                {
                    pf.Id,
                    Images = StaticTools.GetImages(pf.Images, _configuration.GetValue <string>("url")),
                    pf.IsDone,
                    pf.Title,
                    pf.SubmittedFactorId
                };
                return(Ok(x));
            }
            catch (Exception e)
            {
                _logger.LogError(e, e.Message);
                return(Problem(e.Message));
            }
        }
Example #3
0
        public async Task <IActionResult> ResendCode([FromQuery] string phone)
        {
            try
            {
                SMSVerification model = await _unitOfWork.VerificationRepository.GetDbSet().SingleOrDefaultAsync(v => v.Phone == phone);

                if (model == null)
                {
                    return(BadRequest("Phone is not regestred yet"));
                }
                else
                {
                    long code = StaticTools.GenerateCode();
                    try
                    {
                        string response = await _messageService.SendSMS(phone, code);

                        model.Code = code;
                        _unitOfWork.VerificationRepository.Update(model);
                        _unitOfWork.Commit();
                        return(Ok("Code sent"));
                    }
                    catch (Exception ex)
                    {
                        return(BadRequest(ex.Message));
                    }
                }
            }
            catch (Exception e)
            {
                _logger.LogError(e, e.Message);
                return(Problem(e.Message));
            }
        }
Example #4
0
        /// <summary>
        /// 创建一个Buffer file,用于获取最小高度,juli是buffer的距离
        /// </summary>
        /// <param name="infile"></param>
        /// <param name="juli"></param>
        /// <returns></returns>
        private static string bufferFile(string infile, int juli)
        {
            Ogr.RegisterAll();
            string bufferFile = StaticTools.tempFilePath("shp", "Buf");

            OSGeo.OGR.Driver dr = Ogr.GetDriverByName("ESRI shapefile");

            DataSource infileDs = dr.Open(infile, 0);
            Layer      inLayer  = infileDs.GetLayerByIndex(0);

            DataSource bufferDs    = dr.CreateDataSource(bufferFile, null);
            Layer      bufferLayer = bufferDs.CreateLayer(inLayer.GetName(), inLayer.GetSpatialRef(), inLayer.GetGeomType(), null);

            int featCount = inLayer.GetFeatureCount(0);

            for (int i = 0; i < featCount; i++)
            {
                Feature  inFeat  = inLayer.GetFeature(i);
                Geometry inGeom  = inFeat.GetGeometryRef();
                Geometry outGeom = inGeom.Buffer(juli, 0);
                Feature  outFeat = new Feature(new FeatureDefn(""));
                outFeat.SetGeometry(outGeom);
                bufferLayer.CreateFeature(outFeat);
                inFeat.Dispose();
                outFeat.Dispose();
            }
            infileDs.Dispose();
            bufferDs.Dispose();
            return(bufferFile);
        }
Example #5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="wholeSudoku">完整数独</param>
        /// <param name="noticeValue">提示数个数</param>
        /// <param name="list1">提示数位置</param>
        /// <returns></returns>
        public SudokuMarket SubAutoQuestion(List <List <int> > wholeSudoku, int noticeValue, ref List <int> list1)
        {
            Random             rm = new Random();
            List <List <int> > tempquestion;

            do
            {
                tempquestion =
                    JsonConvert.DeserializeObject <List <List <int> > >(JsonConvert.SerializeObject(wholeSudoku));

                do
                {
                    List <int> temp1 = new List <int>();
                    var        temp  = RandomHelper.GetRandom(0, true, 39, true, noticeValue / 2, rm, false);
                    foreach (var upper in temp)
                    {
                        temp1.AddRange(StaticTools.symmetry[upper]);
                    }

                    if (noticeValue % 2 != 0)
                    {
                        //添加对称位置
                        temp1.Add(40);
                    }

                    list1 = temp1;
                } while (!StaticTools.ValidNoticeList(list1));

                StaticTools.InitQuestion(list1, tempquestion);
            } while (!StaticTools.IsVaildSudoku(tempquestion));

            return(new SudokuMarket(tempquestion, list1));
        }
Example #6
0
        public async Task <IActionResult> GetFactor([FromQuery] string id)
        {
            try
            {
                PreFactor factor = await _unitOfWork.PreFactorRepository.GetDbSet().Include(f => f.Images).Include(f => f.User).SingleOrDefaultAsync(f => f.Id == Guid.Parse(id));

                if (factor != null)
                {
                    var x = new
                    {
                        factor.Id,
                        Images = StaticTools.GetImages(factor.Images, _configuration.GetValue <string>("url")),
                        factor.IsDone,
                        factor.SubmittedFactorId,
                        UserPhone = factor.User.Phone
                    };
                    return(Ok(x));
                }
                else
                {
                    return(NotFound("factor not found"));
                }
            }
            catch (Exception e)
            {
                _logger.LogError(e, e.Message);
                return(Problem(e.Message));
            }
        }
Example #7
0
        public async Task <IActionResult> IsUserVerified([FromQuery] string phone)
        {
            try
            {
                if (StaticTools.PhoneValidator(phone))
                {
                    User user = await _unitOfWork.UserRepository.GetDbSet().SingleOrDefaultAsync(u => u.Phone == phone);

                    if (user == null)
                    {
                        return(NotFound("user not found"));
                    }
                    else
                    {
                        return(Ok(user.IsVerified()));
                    }
                }
                else
                {
                    return(BadRequest(StaticTools.PhoneValidationError));
                }
            }
            catch (Exception e)
            {
                _logger.LogError(e, e.Message);
                return(Problem(e.Message));
            }
        }
Example #8
0
    public void UpdateHealth()
    {
        if (!IsInfected)
        {
            if (_health < MaxHealth && (Time.time - _lastInfectedTime >= _healthRegenerationWaitTime))
            {
                if (_isInitializing)
                {
                    _health += _initialRegenerationRate;
                }
                else
                {
                    _health += _healthRegenerationRate;
                }

                if (_health >= MaxHealth)
                {
                    _health = MaxHealth;

                    if (InfectionAudioSource && InfectionAudioSource.isPlaying)
                    {
                        InfectionAudioSource.Stop();
                    }

                    if (_isInitializing)
                    {
                        TutorialManager.Instance.BroadcastTutorialAction("initialized");
                        _isInitializing = false;
                    }
                }
            }

            if (_health <= (MaxHealth / 2.5f))
            {
                float newSpeedModifier = StaticTools.Remap(_health, 0, MaxHealth, 0, 1);
                _firstPersonController.ModifySpeed(newSpeedModifier / _oldSpeedModifier);

                _oldSpeedModifier = newSpeedModifier;
            }
            else
            {
                _firstPersonController.ModifySpeed(1 / _oldSpeedModifier);
                _oldSpeedModifier = 1;
            }

            if (_health < MaxHealth)
            {
                if (InfectionAudioSource && !InfectionAudioSource.isPlaying)
                {
                    InfectionAudioSource.time = 4.5f;
                    InfectionAudioSource.Play();
                }
            }

            if (InfectionAudioSource)
            {
                InfectionAudioSource.volume = StaticTools.Remap(_health, 0, MaxHealth, 0.6f, 0.3f);
            }
        }
    }
Example #9
0
        async static void GetSlopeFile(string filePath, int jiao, int s, int ss)
        {
            await Task.Run(() =>
            {
                Console.WriteLine("开始处理{0}号图Lev{1},共{2}", s + 1, 18 - jiao / 5, ss);
                string inSubfile = filePath;
                string slopeMap  = StaticTools.tempFilePath("img", jiao.ToString() + "_slop_" + s.ToString());
                string slopePoly = StaticTools.tempFilePath("shp", jiao.ToString() + "_slopPoly_" + s.ToString());
                string slopLine  = StaticTools.tempFilePath("shp", jiao.ToString() + "_shpLine_" + s.ToString());
                lock (@"D:\TEMPFORGETDATATOOLS\log")
                {
                    slopeMap.writeInLog("slopMap");
                    slopePoly.writeInLog("slopePoly");
                    slopLine.writeInLog("slopLine");
                }

                (new SlopeDem()).Slope(inSubfile, slopeMap);
                Console.WriteLine("{0}号图Lev{1},slopMap=>slopPolygon", s + 1, 18 - jiao / 5);
                (new SlopeDem()).CreatePolygon(inSubfile, slopeMap, slopePoly, slopLine, jiao);
                subPdPoly.Add(slopePoly);
                subPdLine.Add(slopLine);
                aRound++;
                Console.WriteLine("{0}号图Lev{3}处理完成,{1}/{2}完成", s + 1, subPdPoly.Count, ss, 18 - jiao / 5);
            });
        }
Example #10
0
        public async Task <IActionResult> GetAllUndoneFactorsGroupedByUser()
        {
            try
            {
                List <PreFactor> factors = await _unitOfWork.PreFactorRepository.GetDbSet().Include(f => f.Images).Include(f => f.User).Where(f => !f.IsDone).OrderBy(f => f.CreationDate).ToListAsync();

                var x = from factor in factors
                        select new
                {
                    factor.Id,
                    factor.CreationDate,
                    factor.Title,
                    Images = StaticTools.GetImages(factor.Images, _configuration.GetValue <string>("url")),
                    factor.SubmittedFactorId,
                    factor.User
                };
                var query = x.GroupBy(f => f.User, (u, pf) => new { UserId = u.Id, PreFactor = pf });
                return(Ok(query));
            }
            catch (Exception e)
            {
                _logger.LogError(e, e.Message);
                return(Problem(e.Message));
            }
        }
Example #11
0
        static void 读取当前行及值fitting(Dataset inds, int line)
        {
            double[] values = new double[inds.RasterXSize];
            inds.GetRasterBand(1).ReadRaster(0, line, inds.RasterXSize, 1, values, inds.RasterXSize, 1, 0, 0);
            if (Array.IndexOf(values, 9999) < 0)
            {
                return;
            }
            int           a       = Array.IndexOf(values, 9999) - 5 < 0 ? 0 : Array.IndexOf(values, 9999) - 5;
            int           b       = Array.LastIndexOf(values, 9999) + 5 > inds.RasterXSize ? inds.RasterXSize : Array.LastIndexOf(values, 9999) + 5;
            List <double> xArray  = new List <double>();
            List <double> valArry = new List <double>();

            for (int i = a; i < b; i++)
            {
                if (values[i] != 9999)
                {
                    xArray.Add(i);
                    valArry.Add(values[i]);
                }
            }
            double[] fitting = StaticTools.MultiLine(xArray.ToArray(), valArry.ToArray(), xArray.Count, 3);
            for (int i = 0; i < values.Length; i++)
            {
                if (values[i] == 9999)
                {
                    values[i] = fitting[0] + fitting[1] * i + fitting[2] * i * i + fitting[3] * i * i * i;
                }
            }
            inds.GetRasterBand(1).WriteRaster(0, line, inds.RasterXSize, 1, values, inds.RasterXSize, 1, 0, 0);
        }
Example #12
0
        public void SendMsg(BodyMsg body, List <Socket> list = null)
        {
            MessageData data = new MessageData();
            HeadMsg     head = new HeadMsg();

            data.Head = head;
            data.Body = body;
            ByteBuffer _buff = new ByteBuffer();

            byte[] bytes = StaticTools.Serialize(data);
            _buff.WriteInt32(bytes.Length);
            _buff.WriteBytes(bytes);
            bytes = _buff.ToBytes();
            if (list == null)
            {
                list = GlobalData.GetAllPlayer();
            }
            foreach (var socket in list)
            {
                if (socket.Connected)
                {
                    socket.Send(bytes);
                }
            }
        }
Example #13
0
    // Draw outline of potential new Player Cube

    private void OnRenderObject()
    {
        if (ActionAllowed == true && BuildMode == true)
        {
            StaticTools.DrawSquare(NewCube, 1, FrameColor);
        }
    }
Example #14
0
        /// <summary>
        /// 暴力搜索
        /// </summary>
        /// <param name="sodukuString"></param>
        /// <returns></returns>
        private string ForceSearch(string sodukuString)
        {
            var list = StaticTools.GetSubString(sodukuString);

            var index = 1;

            foreach (var subString in list)
            {
                Console.WriteLine("处理字符串   " + index + "  " + subString);
                index += 1;
                var market = new SudokuMarket(subString);
                var result = market.GetCellInfos().Where(c => c.Value.Value == 0).

                             Select(c1 => c1.Value).ToList();
                Dictionary <int, List <int> > locationRest = new Dictionary <int, List <int> >();
                foreach (var cell in result)
                {
                    locationRest.Add(cell.location, cell.initrest);
                }

                var locationcombine = PermutationAndCombination <int> .GetCombination(locationRest.Keys.ToArray(), 2);

                foreach (var combine in locationcombine)
                {
                    var location1 = combine[0];
                    var location2 = combine[1];
                    var rest1     = locationRest[location1];
                    var rest2     = locationRest[location2];

                    foreach (var value1 in rest1)
                    {
                        Dictionary <int, string> one = new Dictionary <int, string> {
                            { location1, "" + value1 }
                        };
                        if (new DanceLink().solution_count(StaticTools.SetValues(sodukuString, one)) > 0)
                        {
                            foreach (var value2 in rest2)
                            {
                                Dictionary <int, string> two = new Dictionary <int, string> {
                                    { location1, "" + value1 }, { location2, "" + value2 }
                                };
                                var result1 = StaticTools.SetValues(sodukuString, two);
                                if (StaticTools.IsPearl(result1))
                                {
                                    string dir         = AppDomain.CurrentDomain.BaseDirectory;
                                    var    noticeCount = StaticTools.GetLocations(result1).Count;
                                    string configName  = Path.Combine(dir, "提示数个数" + noticeCount + "生成于" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".txt");
                                    File.WriteAllText(configName, result1);

                                    Console.WriteLine("当前表达式为:" + result1 + "提示数个数为:" + noticeCount);
                                    return(result1);
                                }
                            }
                        }
                    }
                }
            }

            return("");
        }
Example #15
0
        /// <summary>
        /// 简单随机搜索
        /// </summary>
        /// <param name="sodukuString"></param>
        /// <returns></returns>
        private string EasySearch(string sodukuString)
        {
            var matrix         = StaticTools.StringToList(sodukuString);
            var locations      = StaticTools.GetLocations(matrix);
            var otherLocations = StaticTools.allLocations.Except(locations).ToList();
            Dictionary <string, int> sodukumap = new Dictionary <string, int>();

            foreach (var loc in locations)
            {
                var newstr      = StaticTools.SetZero(sodukuString, loc);
                var answerCount = new DanceLink().solution_count(newstr);
                sodukumap.Add(newstr, answerCount);
            }

            var tempResult = "";
            var index      = 1;

            foreach (var newGene in sodukumap)
            {
                //Console.WriteLine("存在多解的提示数  \r\n" + newGene);
                //Console.WriteLine("进展:   " +"处理了"+ index+"条,总数是  "+ sodukumap.Count);
                index     += 1;
                tempResult = newClues(newGene.Key, otherLocations);
            }


            Console.WriteLine("最终提示数表达式为\r\n" + tempResult);


            return(tempResult);
        }
Example #16
0
        /// <summary>
        /// 清理重复的Featuer----------单线程
        /// </summary>
        /// <param name="pdx"></param>
        public static void cleanPdx(string pdx)
        {
            Ogr.RegisterAll();
            OSGeo.OGR.Driver dr       = OSGeo.OGR.Ogr.GetDriverByName("ESRI shapefile");
            DataSource       ds       = dr.Open(pdx, 1);
            Layer            newLayer = ds.GetLayerByIndex(0);
            int 重复的 = 0;

            for (int i = 0; i < newLayer.GetFeatureCount(0) - 1; i++)
            {
                Feature ori = newLayer.GetFeature(i);
                for (int j = i + 1; j < newLayer.GetFeatureCount(0); j++)
                {
                    Feature next = newLayer.GetFeature(j);
                    bool    a    = StaticTools.isSame(ori, next, 1);
                    if (a)
                    {
                        newLayer.DeleteFeature(i);
                        重复的++;
                        Console.WriteLine("已删除{0}个重复Featuer,allFeat is {1}/{2}", 重复的, i + 1, newLayer.GetFeatureCount(0));
                        break;
                    }
                    next.Dispose();
                }
                ori.Dispose();
            }
            string layerName = newLayer.GetName();

            ds.ExecuteSQL("REPACK " + layerName, null, "");
            ds.Dispose();
        }
Example #17
0
 public async Task <IActionResult> AdminLogin([FromQuery] string phone)
 {
     try
     {
         if (StaticTools.PhoneValidator(phone))
         {
             bool check = _configuration.GetSection("AdminPhones").Get <string[]>().Any(s => s == phone);
             if (check)
             {
                 return(await AdminLoginHandler(phone));
             }
             else
             {
                 return(Unauthorized("access denied"));
             }
         }
         else
         {
             return(BadRequest(StaticTools.PhoneValidationError));
         }
     }
     catch (Exception e)
     {
         _logger.LogError(e, e.Message);
         return(Problem(e.Message));
     }
 }
Example #18
0
 async static void getDoubFeat(string filePath, int s, int ss)
 {
     await Task.Run(() =>
     {
         OSGeo.OGR.Ogr.RegisterAll();
         OSGeo.OGR.Driver dr       = OSGeo.OGR.Ogr.GetDriverByName("ESRI shapefile");
         OSGeo.OGR.DataSource ds   = dr.Open(filePath, 0);
         OSGeo.OGR.Layer layer     = ds.GetLayerByIndex(0);
         OSGeo.OGR.Feature oriFeat = layer.GetFeature(s);
         for (int i = s + 1; i < ss; i++)
         {
             OSGeo.OGR.Feature nextFeat = layer.GetFeature(i);
             if (StaticTools.isSame(oriFeat, nextFeat, 1))
             {
                 ids.Add(s);
                 break;
             }
             nextFeat.Dispose();
         }
         oriFeat.Dispose();
         layer.Dispose();
         ds.Dispose();
         tickTime++;
     }
                    );
 }
Example #19
0
        public IActionResult GetUserUndoneFactors([FromQuery] string phone)
        {
            try
            {
                if (StaticTools.PhoneValidator(phone))
                {
                    if (!_unitOfWork.UserRepository.GetDbSet().Any(u => u.Phone == phone))
                    {
                        return(NotFound("User not found"));
                    }

                    IEnumerable <PreFactor> result = _unitOfWork.PreFactorRepository.GetDbSet().Include(f => f.Images).Include(f => f.User).Where(f => f.User.Phone == phone && !f.IsDone).OrderBy(f => f.CreationDate).AsEnumerable();
                    var x = from item in result
                            select new
                    {
                        item.Id,
                        item.Title,
                        UserId = item.User.Id,
                        Images = StaticTools.GetImages(item.Images, _configuration.GetValue <string>("url")),
                        item.IsDone,
                        item.SubmittedFactorId
                    };
                    return(Ok(x));
                }
                else
                {
                    return(BadRequest(StaticTools.PhoneValidationError));
                }
            }
            catch (Exception e)
            {
                _logger.LogError(e, e.Message);
                return(Problem(e.Message));
            }
        }
Example #20
0
        /// <summary>
        /// 整合坡度多边形(Polygon),并清除重叠部份
        /// </summary>
        /// <param name="subPdx"></param>
        /// <returns></returns>
        public static string zhengHePdx(List <string> subPdx)
        {
            OSGeo.OGR.Ogr.RegisterAll();
            OSGeo.OGR.Driver dr  = OSGeo.OGR.Ogr.GetDriverByName("ESRI shapefile");
            string           res = StaticTools.tempFilePath("shp", "整合");

            OSGeo.OGR.DataSource newDS = dr.CreateDataSource(res, null);                                              //////////////待关闭1  has
            Layer newLayer             = newDS.CreateLayer("podu", null, OSGeo.OGR.wkbGeometryType.wkbPolygon, null); //////////////待关闭2

            for (int i = 0; i < subPdx.Count; i++)
            {
                OSGeo.OGR.DataSource ds = dr.Open(subPdx[i], 0);//////////////待关闭3   has
                Layer layer             = ds.GetLayerByIndex(0);
                for (int j = 0; j < layer.GetFeatureCount(0); j++)
                {
                    OSGeo.OGR.Feature  subFeat  = layer.GetFeature(j);
                    OSGeo.OGR.Geometry subGeom  = subFeat.GetGeometryRef();
                    double             thisArea = subGeom.GetArea();
                    // 清理过小Featuer
                    if (thisArea > 200)
                    {
                        newLayer.CreateFeature(layer.GetFeature(j));
                    }
                }
                ds.Dispose();
                Console.WriteLine("完成整合{0}/{1}", i + 1, subPdx.Count);
            }
            newDS.Dispose();
            cleanPdx(res);
            return(res);
        }
Example #21
0
    void UpdateGlitchness()
    {
        _glitchness = StaticTools.Remap(_health, 0, MaxHealth, MaxGlitchness, 0);

        _glitchEffect.intensity      = _glitchness + DefaultGlitchIntensity;
        _glitchEffect.colorIntensity = _glitchness;
        _glitchEffect.flipIntensity  = _glitchness + ((Time.timeScale > 0) ? DefaultGlitchIntensity : 0f);
    }
Example #22
0
        /************************************   生成等值线  **********************************************/

        public static string dzx(string filePath)
        {
            Console.WriteLine("开始创建等值线!");
            OSGeo.OGR.Ogr.RegisterAll();
            OSGeo.GDAL.Gdal.AllRegister();
            //无效值
            double noDataValue;

            //0不使用无效值,1使用无效值
            int hasDataValue;

            //读入数据源
            OSGeo.GDAL.Dataset inData = OSGeo.GDAL.Gdal.Open(filePath, OSGeo.GDAL.Access.GA_ReadOnly);

            //分析数据源
            inData.GetRasterBand(1).GetNoDataValue(out noDataValue, out hasDataValue);

            double min, max, mean, std;

            inData.GetRasterBand(1).GetStatistics(0, 1, out min, out max, out mean, out std);

            int jianG = 2;

            int count = Convert.ToInt32((max - min) / jianG + 0.5);

            double[] shu = new double[count];

            for (int i = 0; i < count; i++)
            {
                shu[i] = min + jianG * i;
            }

            //创建空的SHP
            OSGeo.OGR.Ogr.RegisterAll();
            OSGeo.OGR.Driver dr = OSGeo.OGR.Ogr.GetDriverByName("ESRI shapefile");
            string           a  = StaticTools.tempFilePath("shp", "原始等值线");

            OSGeo.OGR.DataSource ds       = dr.CreateDataSource(a, null);
            OSGeo.OGR.Layer      dzxLayer = ds.CreateLayer("", null, OSGeo.OGR.wkbGeometryType.wkbMultiLineString, null);
            OSGeo.OGR.FieldDefn  fieldDf0 = new OSGeo.OGR.FieldDefn("LID", OSGeo.OGR.FieldType.OFTInteger);
            OSGeo.OGR.FieldDefn  fieldDf1 = new OSGeo.OGR.FieldDefn("EVE", OSGeo.OGR.FieldType.OFTReal);
            dzxLayer.CreateField(fieldDf0, 1); //ID
            dzxLayer.CreateField(fieldDf1, 1); //Value
            //Band(1), 间隔, 起始高度, 分段数量, 分段值数组, 是否有无效值, 无效值, 预置图层. ID字段, 高度值字段, null , null
            OSGeo.GDAL.Gdal.ContourGenerate(inData.GetRasterBand(1), jianG, min, count, shu, hasDataValue, noDataValue, dzxLayer, 0, 1, null, null);
            if (dzxLayer.GetFeatureCount(0) > 0)
            {
                Console.WriteLine("等值线创建完成!");
            }
            else
            {
                Console.WriteLine("等值线创建失败!");
            }
            ds.Dispose();
            inData.Dispose();
            return(a);
        }
Example #23
0
        /// <summary>
        /// 将数独指定位置的数进行交换构成标准数独。
        ///
        /// </summary>
        /// <example>
        /// new ComfirmedPostion().GenConfirmedPosition(StaticTools.ListToString(sodukuMatrix));
        /// </example>
        /// <param name="sodukuString"></param>
        public string GenSudoku(string sodukuString, string fileName = "")
        {
            var matrix = StaticTools.StringToList(sodukuString);

            Console.WriteLine(sodukuString);
            var list = StaticTools.GetLocations(matrix);

            Console.WriteLine(JsonConvert.SerializeObject(list));


            var switchList = PermutationAndCombination <int> .GetCombination(list.ToArray(), 2);

            //switchList.Reverse();
            Console.WriteLine("list" + list.Count);
            Console.WriteLine("switchList" + switchList.Count);
            Dictionary <string, int> expressCount = new Dictionary <string, int>();
            List <string>            tryedList    = new List <string> {
                sodukuString
            };
            var min = GetMinCount(sodukuString, expressCount, switchList);

            while (min != 1)
            {
                var result = (from item1 in expressCount
                              where
                              !(tryedList.Any(item2 => item2 == item1.Key))
                              select item1).Where(c => c.Value != 0).ToList();
                if (result.Count == 0)
                {
                    //所有该尝试的组合都已经尝试过了
                    //表明已知提示数在固定位置的确无法构成唯一解。
                    return(null);
                }

                var newSeed = result.OrderBy(c => c.Value).Last();
                var newMin  = result.OrderBy(c => c.Value).First();


                if (true)
                {
                    Console.WriteLine(fileName + "最少的终盘个数: " + newMin.Value + "表达式为   " + newMin.Key + "   最多的终盘个数: " + newSeed.Value + "表达式为   " + newSeed.Key);
                }

                min = GetMinCount(newSeed.Key, expressCount, switchList);
                tryedList.Add(newSeed.Key);
            }


            string Value       = expressCount.Where(c => c.Value == 1).Select(c => c.Key).First();
            string dir         = AppDomain.CurrentDomain.BaseDirectory;
            var    noticeCount = StaticTools.GetLocations(Value).Count;
            string configName  = Path.Combine(dir, fileName + "生成于" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".txt");

            File.WriteAllText(configName, Value);
            return(Value);
        }
Example #24
0
        /// <summary>
        /// 通过Feature设置栅格无效值
        /// </summary>
        /// <param name="polyFeat"></param>
        /// <param name="inDs"></param>
        public static void setNoData(Feature polyFeat, Dataset inDs)
        {
            //注册库
            Gdal.AllRegister();
            Ogr.RegisterAll();

            //Get Geometry & Envelope
            Geometry Geom = polyFeat.GetGeometryRef();
            Envelope enve = new Envelope();

            Geom.GetEnvelope(enve);

            //Get all Transform
            double[] GeoTransform = new double[6];
            inDs.GetGeoTransform(GeoTransform);

            // Envelope Conver to ImgSpace -- off to end
            int xoff, yoff, xend, yend;

            StaticTools.geoToImageSpace(GeoTransform, enve.MinX, enve.MaxY, out xoff, out yoff);
            StaticTools.geoToImageSpace(GeoTransform, enve.MaxX, enve.MinY, out xend, out yend);
            int xsize = xend - xoff;
            int ysize = yend - yoff;

            //Get The Values
            double[] rasterValues = new double[xsize * ysize];
            inDs.GetRasterBand(1).ReadRaster(xoff, yoff, xsize, ysize, rasterValues, xsize, ysize, 0, 0);

            //Get new Transform
            double[] NewTransform = GeoTransform;
            NewTransform[0] = enve.MinX;
            NewTransform[3] = enve.MaxY;

            //无效值,特定值
            double noData = 9999;

            for (int iline = 0; iline < ysize; iline++)
            {
                for (int iPixel = 0; iPixel < xsize; iPixel++)
                {
                    Geometry poiGeom = new Geometry(wkbGeometryType.wkbPoint);
                    double   x, y;
                    StaticTools.imageToGeoSpace(NewTransform, iPixel, iline, out x, out y);
                    poiGeom.AddPoint_2D(x, y);
                    if (poiGeom.Within(Geom))
                    {
                        rasterValues[iline * xsize + iPixel] = noData;
                    }
                    poiGeom.Dispose();
                }
            }
            inDs.GetRasterBand(1).WriteRaster(xoff, yoff, xsize, ysize, rasterValues, xsize, ysize, 0, 0);
            inDs.Dispose();
            polyFeat.Dispose();
        }
Example #25
0
 public IActionResult GetFactorsWithTimeSpan([FromBody] TimeSpanRequestModel model)
 {
     try
     {
         return(Ok(_unitOfWork.PreFactorRepository.Where(f => StaticTools.DateChecker(f.CreationDate, model.StartDate, model.EndDate)).OrderBy(f => f.User).ThenBy(f => f.CreationDate).AsAsyncEnumerable()));
     }
     catch (Exception e)
     {
         _logger.LogError(e, e.Message);
         return(Problem(e.Message));
     }
 }
    private void ShowGameOverScreen()
    {
        Debug.Log("Showing Game Over Screen");
        if (gameOverScreenController)
        {
            gameOverScreenController.Show(() =>
            {
                Time.timeScale = 0;

                StaticTools.UpdateCursorLock(false);
            });
        }
    }
Example #27
0
        public ResponseMessage Logout()
        {
            string ip = StaticTools.GetIp(Request);

            try
            {
                Authentication.SignOut(CookieAuthenticationDefaults.AuthenticationType);
                return(Tools.ResponseMessage.Ok);
            }
            catch (Exception)
            {
                return(Tools.ResponseMessage.InternalError);
            }
        }
    public void addCurrentScore(int a)
    {
        currentScore += a;
        GameObject pecky = GameObject.FindGameObjectWithTag("pecky");

        GameObject scoreNotif = GameObject.Instantiate(scoreNotification, pecky.transform.position,
                                                       pecky.transform.rotation);
        TextMesh textmesh = scoreNotif.GetComponent <TextMesh>();

        textmesh.text = a.ToString();

        StartCoroutine(StaticTools.NotifyCollectible(scoreNotif, 10));
        updateCurrentScore();
    }
        /********************************   等值线转换为多边形   ***********************************************/

        /// <summary>
        /// 等值线转为POLYGON
        /// </summary>
        /// <param name="filePath"></param>
        /// <returns></returns>
        public static string dzPoly(string filePath)
        {
            OSGeo.OGR.Ogr.RegisterAll();
            OSGeo.OGR.Driver dr = OSGeo.OGR.Ogr.GetDriverByName("ESRI shapefile");

            string a = StaticTools.tempFilePath("shp", "等值线POLY");

            OSGeo.OGR.DataSource newDS     = dr.CreateDataSource(a, null);
            OSGeo.OGR.Layer      polyLayer = newDS.CreateLayer("", null, OSGeo.OGR.wkbGeometryType.wkbPolygon, null);
            OSGeo.OGR.FieldDefn  fieldDf0  = new OSGeo.OGR.FieldDefn("LID", OSGeo.OGR.FieldType.OFTInteger);
            OSGeo.OGR.FieldDefn  fieldDf1  = new OSGeo.OGR.FieldDefn("EVE", OSGeo.OGR.FieldType.OFTReal);
            polyLayer.CreateField(fieldDf0, 1); //ID
            polyLayer.CreateField(fieldDf1, 1); //Value
            OSGeo.OGR.FeatureDefn featDF = new OSGeo.OGR.FeatureDefn("");
            Console.WriteLine("开始等值线转POLY!");
            OSGeo.OGR.DataSource cleanDS    = dr.Open(filePath, 0);
            OSGeo.OGR.Layer      cleanLayer = cleanDS.GetLayerByIndex(0);
            for (int i = 0; i < cleanLayer.GetFeatureCount(0); i++)
            {
                OSGeo.OGR.Feature  lineFeat = cleanLayer.GetFeature(i);
                OSGeo.OGR.Geometry lineGeom = lineFeat.GetGeometryRef();

                OSGeo.OGR.Feature  polyFeat = new OSGeo.OGR.Feature(featDF);
                OSGeo.OGR.Geometry polyGeom = new OSGeo.OGR.Geometry(OSGeo.OGR.wkbGeometryType.wkbPolygon);
                OSGeo.OGR.Geometry subGeom  = new OSGeo.OGR.Geometry(OSGeo.OGR.wkbGeometryType.wkbLinearRing);
                int u = lineGeom.GetPointCount();
                for (int s = 0; s < u; s++)
                {
                    double x = lineGeom.GetX(s);
                    double y = lineGeom.GetY(s);
                    double z = lineGeom.GetZ(s);
                    subGeom.AddPoint(x, y, z);
                }
                polyGeom.AddGeometry(subGeom);
                polyFeat.SetGeometry(polyGeom);
                polyLayer.CreateFeature(polyFeat);
                lineGeom.Dispose();
                polyGeom.Dispose();
                subGeom.Dispose();
                lineFeat.Dispose();
                polyFeat.Dispose();
            }
            cleanLayer.Dispose();
            polyLayer.Dispose();
            cleanDS.Dispose();
            newDS.Dispose();
            Console.WriteLine("等值线转POLY完成!");
            return(a);
        }
Example #30
0
        public static void SendMsg(int cmd, int scmd, BodyMsg body)
        {
            MessageData data = new MessageData();
            HeadMsg     head = new HeadMsg();

            data.Head = head;
            data.Body = body;
            ByteBuffer _buff = new ByteBuffer();

            byte[] bytes = StaticTools.Serialize(data);
            _buff.WriteInt32(bytes.Length);
            _buff.WriteBytes(bytes);
            bytes = _buff.ToBytes();
            socket.Send(bytes);
        }