Example #1
0
        public void CyrillicSymbols_NO_Option()
        {
            Gdal.SetConfigOption("GDAL_FILENAME_IS_UTF8", "NO");

            var currentState = Gdal.GetConfigOption("GDAL_FILENAME_IS_UTF8", "YES");

            _outputHelper.WriteLine($"Test 4 - GDAL_FILENAME_IS_UTF8 is set to {currentState} before the test");

            var outputFilePath = Path.Combine(dataDirectoryPath, "test4.vrt");

            var result = RunTest(cyrillicInputFilePath, dataDirectoryPath, outputFilePath);

            // this works like a charm on linux even without config flag
            if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
            {
                Assert.True(result);
            }

            // windows can't find a file though
            else if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
            {
                Assert.False(result);
            }
            else
            {
                throw new XunitException("This test was not created for current os platform");
            }
        }
Example #2
0
 public static void Main(string[] args)
 {
     Gdal.SetConfigOption("GDAL_FILENAME_IS_UTF8", "NO");
     //Gdal.AllRegister();
     //Console.WriteLine("Hello World!");
     BuildWebHost(args).Run();
 }
        public static void SetProfileSettingDefault(string optionString)
        {
            if (optionString.Length < 1)
            {
                return;
            }

            string[] options = optionString.Split(' ');

            if (options.Length < 1)
            {
                return;
            }

            foreach (var opt in options)
            {
                string[] option = opt.Split('=');

                if (option.Length != 2)
                {
                    continue;
                }
                Gdal.SetConfigOption(option[0], null);
            }

            Gdal.SetConfigOption("BIGTIFF_OVERVIEW", "IF_SAFER");
        }
Example #4
0
        public TileGenerator(string mapfile, string savePath, string tileListId)
        {
            try
            {
                id = tileListId;

                string version = mapscript.msGetVersion();

                if (Directory.Exists(Environment.CurrentDirectory + "\\gdalplugins"))
                {
                    Gdal.SetConfigOption("GDAL_DRIVER_PATH", Environment.CurrentDirectory + "\\gdalplugins");
                }

                Gdal.AllRegister();
                Ogr.RegisterAll();
                mapscript.SetEnvironmentVariable("CURL_CA_BUNDLE=" + Environment.CurrentDirectory + "\\curl-ca-bundle.crt");

                MapUtils.SetPROJ_LIB(Environment.CurrentDirectory + "\\ProjLib");

                Gdal.SetConfigOption("GDAL_DATA", Environment.CurrentDirectory);

                map = new mapObj(mapfile);

                ProcessTileList(savePath, tileListId);
            }
            catch (Exception ex)
            {
                ExceptionDump(ex);
            }
        }
Example #5
0
        /// <summary>
        /// 在指定路径下构建shp数据源(此操作不会生成实际的shp文件)
        /// </summary>
        /// <param name="shpFilePath">shp文件路径</param>
        /// <returns></returns>
        public static DataSource CreateShapefileSource(string shpFilePath)
        {
            Driver driver = Ogr.GetDriverByName("ESRI Shapefile");

            if (driver == null)
            {
                throw new Exception("ESRI Shapefile 驱动不可使用");
            }

            Gdal.SetConfigOption("GDAL_FILENAME_IS_UTF8", "YES"); // 为了支持中文路径
            DataSource dataSource = driver.CreateDataSource(shpFilePath, null);

            if (dataSource == null)
            {
                throw new Exception("创建SHP文件" + shpFilePath + "失败");
            }

            DirectoryInfo directoryInfo = new DirectoryInfo(Path.GetDirectoryName(shpFilePath));

            if (!directoryInfo.Exists)
            {
                directoryInfo.Create();
            }

            driver.Dispose();

            return(dataSource);
        }
        public static void SetProfileSetting(string optionString)
        {
            if (optionString.Length < 1)
            {
                return;
            }

            string[] options = optionString.Split(' ');

            if (options.Length < 1)
            {
                return;
            }

            foreach (var opt in options)
            {
                string[] option = opt.Split('=');

                if (option.Length != 2)
                {
                    continue;
                }
                Gdal.SetConfigOption(option[0], option[1]);
            }
        }
Example #7
0
        private bool CreatePyramids(string filename)
        {
            Gdal.SetConfigOption("USE_RRD", "YES");
            Dataset ds  = Gdal.Open(filename, Access.GA_Update);
            Driver  drv = ds.GetDriver();
            // System.Type szDriver = drv.ShortName.GetType();
            int iWidth    = ds.RasterXSize;
            int iHeight   = ds.RasterYSize;
            int iPixelNum = iWidth * iHeight;    //图像中的总像元个数
            int iTopNum   = 4096;                //顶层金字塔大小,64*64
            int iCurNum   = iPixelNum / 4;

            int[] anLevels    = new int[1024];
            int   nLevelCount = 0;               //金字塔级数

            do
            {
                anLevels[nLevelCount] = Convert.ToInt32(Math.Pow(2.0, nLevelCount + 2));
                nLevelCount++;
                iCurNum /= 4;
            } while (iCurNum > iTopNum);

            int[] levels = new int[nLevelCount];
            for (int a = 0; a < nLevelCount; a++)
            {
                levels[a] = anLevels[a];
            }
            int ret = ds.BuildOverviews("nearest", levels);

            ds.Dispose();
            drv.Dispose();
            return(true);
        }
Example #8
0
        public void geometryTest()
        {
            Gdal.AllRegister();
            Gdal.SetConfigOption("GDAL_FILENAME_IS_UTF8", "YES");
            Gdal.SetConfigOption("SHAPE_ENCODING", "");
            Ogr.RegisterAll();


            Geometry line = new Geometry(wkbGeometryType.wkbLinearRing);

            line.AddPoint(0, 0, 0);
            line.AddPoint(0, 1, 0);
            line.AddPoint(1, 1, 0);
            line.AddPoint(1, 0, 0);
            line.AddPoint(0, 0, 0);



            String a = "";

            line.ExportToWkt(out a);
            Console.WriteLine(a);

            Console.WriteLine(line.GetGeometryCount());


            for (int i = 0; i < line.GetGeometryCount(); i++)
            {
                line.GetGeometryRef(i).ExportToWkt(out a);

                Console.WriteLine(a);
            }
        }
Example #9
0
        public static bool Create(string outputPath, string[] inputPaths, GDALBuildVRTOptions options, Gdal.GDALProgressFuncDelegate progressFuncDelegate)
        {
            bool result = false;

            Dataset newDs = null;

            try {
                Gdal.SetConfigOption("GDAL_FILENAME_IS_UTF8", "NO");

                //Gdal.PushErrorHandler(GdalConfig.GdalHandlers.ErrorHandler);
                newDs = Gdal.wrapper_GDALBuildVRT_names(outputPath, inputPaths, options, progressFuncDelegate, null);
                //Gdal.PopErrorHandler();


                Gdal.SetConfigOption("GDAL_FILENAME_IS_UTF8", "YES");
            }
            catch (Exception ex)
            {
                LoggerManager.WriteErrorLog(ex.Message);
            }
            finally
            {
                if (newDs != null)
                {
                    newDs.FlushCache();
                    newDs.Dispose();

                    result = true;
                }

                Gdal.SetConfigOption("GDAL_FILENAME_IS_UTF8", "YES");
            }

            return(result);
        }
Example #10
0
        public void centreTest()
        {
            Gdal.AllRegister();
            Gdal.SetConfigOption("GDAL_FILENAME_IS_UTF8", "YES");
            Gdal.SetConfigOption("SHAPE_ENCODING", "");
            Ogr.RegisterAll();

            String   a    = "";
            Geometry line = new Geometry(wkbGeometryType.wkbLineString);

            line.AddPoint(0, 0, 0);
            line.AddPoint(1, 1, 0);
            line.AddPoint(2, 0, 0);
            line.ExportToWkt(out a);
            // Console.WriteLine(a);


            Geometry g = line.Centroid();

            g.ExportToWkt(out a);
            //  Console.WriteLine(a);


            double d = line.GetX(line.GetPointCount() - 1);

            double e = line.GetY(line.GetPointCount() - 1);

            Console.WriteLine(d);
            Console.WriteLine(e);
        }
Example #11
0
        public void testStaticPartition()
        {
            Gdal.AllRegister();
            Gdal.SetConfigOption("GDAL_FILENAME_IS_UTF8", "YES");
            Gdal.SetConfigOption("SHAPE_ENCODING", "");
            Ogr.RegisterAll();

            //读取文件
            DataSource ds     = Ogr.Open(fromPath, 0);
            Layer      oLayer = ds.GetLayerByIndex(0);

            // 写入文件

            OSGeo.OGR.Driver oDriver = Ogr.GetDriverByName("ESRI Shapefile");

            // 创建数据源

            DataSource oDS;

            if (Ogr.Open(toPath, 0) != null)
            {
                oDS = Ogr.Open(toPath, 1);
                oDS.DeleteLayer(0);
            }
            else
            {
                oDS = oDriver.CreateDataSource(toPath, null);
            }


            Layer       toLayer  = oDS.CreateLayer("POINT", oLayer.GetSpatialRef(), wkbGeometryType.wkbPoint, null);
            Random      ran      = new Random();
            Feature     oFeature = null;
            Geometry    lines    = null;
            FeatureDefn oDefn    = oLayer.GetLayerDefn();

            FieldDefn oFieldID = new FieldDefn("HEIGHT_G", FieldType.OFTReal);

            toLayer.CreateField(oFieldID, 1);

            FieldDefn oFieldName = new FieldDefn("PWLs", FieldType.OFTReal);

            toLayer.CreateField(oFieldName, 1);

            while ((oFeature = oLayer.GetNextFeature()) != null)
            {
                //read current feature

                lines = oFeature.GetGeometryRef();
                Feature feature = new Feature(oDefn);
                feature.SetGeometry(Line.getPoint(lines, lines.Centroid()));
                feature.SetField(0, 4.0);
                feature.SetField(1, ran.Next(40, 120));
                toLayer.CreateFeature(feature);
            }

            oDS.SyncToDisk();
        }
Example #12
0
 /// <summary>
 /// 生成穹窿模型
 /// </summary>
 public static void GenModel()
 {
     Gdal.SetConfigOption("GDAL_FILENAME_IS_UTF8", "NO");
     Gdal.SetConfigOption("SHAPE_ENCODING", "");
     Ogr.RegisterAll();// 注册所有的驱动
     //由带值点要素生成穹窿模型
     createFornixModelByPoint();
     MessageBox.Show("穹窿生成成功!");
 }
Example #13
0
 static GdalWmtsService()
 {
     Gdal.AllRegister();
     // 为了支持中文路径,请添加下面这句代码
     Gdal.SetConfigOption("GDAL_FILENAME_IS_UTF8", "NO");
     // 为了使属性表字段支持中文,请添加下面这句
     Gdal.SetConfigOption("SHAPE_ENCODING", "");
     Ogr.RegisterAll();
 }
Example #14
0
 public Form1()
 {
     GdalConfiguration.ConfigureGdal();
     GdalConfiguration.ConfigureOgr();
     Gdal.SetConfigOption("GDAL_FILENAME_IS_UTF8", "YES");
     Gdal.AllRegister();
     Gdal.SetConfigOption("SHAPE_ENCODING", "");
     Ogr.RegisterAll();
     InitializeComponent();
 }
        public static void Initialize()
        {
            GdalConfiguration.ConfigureGdal();

            //gdaladdo -ro -r average --config BIGTIFF_OVERVIEW IF_SAFER --config COMPRESS_OVERVIEW JPEG {orthophoto} 2 4 8 16 > {log}

            //Gdal.SetConfigOption("CPL_DEBUG", "ON");
            Gdal.SetConfigOption("BIGTIFF_OVERVIEW", "IF_SAFER");
            //Gdal.SetConfigOption("GDAL_FILENAME_IS_UTF8", "NO");

            SetGdalCacheMaxValue(4000);
        }
Example #16
0
        public void LatinSymbols_YES_OptionDefault()
        {
            Gdal.SetConfigOption("GDAL_FILENAME_IS_UTF8", "YES");

            string currentState = Gdal.GetConfigOption("GDAL_FILENAME_IS_UTF8", "YES");

            _outputHelper.WriteLine($"Test 1 - GDAL_FILENAME_IS_UTF8 is set to {currentState} by default");

            var outputFilePath = Path.Combine(dataDirectoryPath, "test1.vrt");

            Assert.True(RunTest(englishInputFilePath, dataDirectoryPath, outputFilePath));
        }
Example #17
0
        public void CyrillicSymbols_YES_OptionDefault()
        {
            Gdal.SetConfigOption("GDAL_FILENAME_IS_UTF8", "YES");

            string currentState = Gdal.GetConfigOption("GDAL_FILENAME_IS_UTF8", "YES");

            _outputHelper.WriteLine($"Test 2 - GDAL_FILENAME_IS_UTF8 is set to {currentState} before the test");

            var outputFilePath = Path.Combine(dataDirectoryPath, "test2.vrt");

            Assert.True(RunTest(cyrillicInputFilePath, dataDirectoryPath, outputFilePath));
        }
Example #18
0
        public void LatinSymbols_NO_Option()
        {
            Gdal.SetConfigOption("GDAL_FILENAME_IS_UTF8", "NO");

            var currentState = Gdal.GetConfigOption("GDAL_FILENAME_IS_UTF8", "YES");

            _outputHelper.WriteLine($"Test 3 - GDAL_FILENAME_IS_UTF8 is set to {currentState} before the test");

            var outputFilePath = Path.Combine(dataDirectoryPath, "test3.vrt");

            Assert.True(RunTest(englishInputFilePath, dataDirectoryPath, outputFilePath));
        }
 /// <summary>
 /// 初始化Gdal,注册所有驱动并支持中文
 /// </summary>
 public static void GdalInit()
 {
     //若出现【无法加载 DLL“ogr_wrap”: 找不到指定的模块】,
     //请将附带的DLL.rar中的全部文件解压复制到生成目录bin\x86\Debug(或bin\x86\Debug\DLL),同时安装附带的VC++包(Vcredist_x86.exe)
     //Exception: Unable to load DLL "ogr_wrap": Cannot find the specified module.
     //Solution: ① Please unzip all the files in the attached DLL.rar to the build directory bin\x86\Debug(or bin\x86\Debug\DLL)
     //          ② Install VC++ package (Vcredist_x86.exe)
     Ogr.RegisterAll();                                                                 // 注册所有GDAL的驱动,Register all GDAL drivers
     Gdal.AllRegister();
     Gdal.SetConfigOption("GDAL_FILENAME_IS_UTF8", "YES");                              // 为了支持中文路径
     Gdal.SetConfigOption("SHAPE_ENCODING", "CP936");                                   // 为了使属性表字段支持中文CP936
     Gdal.SetConfigOption("GDAL_DATA", AppDomain.CurrentDomain.BaseDirectory + "Data"); //设置GDAL Data文件夹位置
 }
Example #20
0
        public void InitGDAL()
        {
            Gdal.SetConfigOption("GDAL_FILENAME_IS_UTF8", "YES");
            Gdal.SetConfigOption("SHAPE_ENCODING", "");
            Gdal.AllRegister();
            Ogr.RegisterAll();

            oDriver = Ogr.GetDriverByName("ESRI Shapefile");
            if (oDriver == null)
            {
                // MessageBox.Show("文件不能打开,请检查");
            }
        }
Example #21
0
 public override void OpenFile(string path, FileType fileType)
 {
     try
     {
         Gdal.AllRegister();
     }
     catch (Exception e)
     {
         throw new ApplicationException("GDAL libraries missing!", e);
     }
     Gdal.SetConfigOption("NODATA_value", "-9999");
     dataset = Gdal.Open(path, Access.GA_ReadOnly);
     info    = new GDAL_Info(dataset);
 }
Example #22
0
        static void RGBLayerStacking(string sBlueBand, string sGreenBand, string sRedBand, string sOut_Path)
        {
            //register gdal and set to support chinese path
            Gdal.AllRegister();
            Gdal.SetConfigOption("GDAL_FILENAME_IS_UTF8", "YES");

            Dataset dsB = Gdal.Open(sBlueBand, Access.GA_ReadOnly);
            Dataset dsG = Gdal.Open(sGreenBand, Access.GA_ReadOnly);
            Dataset dsR = Gdal.Open(sRedBand, Access.GA_ReadOnly);

            Band bB = dsB.GetRasterBand(1);
            Band bG = dsG.GetRasterBand(1);
            Band bR = dsR.GetRasterBand(1);

            //get xy size and projection
            int    iXSize      = bB.XSize;
            int    iYSize      = bB.YSize;
            string sProjection = dsB.GetProjection();

            //create output image and set its projection
            Driver  driverOut = Gdal.GetDriverByName("GTiff");
            Dataset dsOut     = driverOut.Create(sOut_Path, iXSize, iYSize, 3, bB.DataType, null);

            dsOut.SetProjection(sProjection);

            //create 3 one dimension arrays to save data of each band
            double[] B = new double[iXSize * iYSize];
            double[] G = new double[iXSize * iYSize];
            double[] R = new double[iXSize * iYSize];

            //read the data of red band and write it to band 1 of output image
            bB.ReadRaster(0, 0, iXSize, iYSize, B, iXSize, iYSize, 0, 0);
            dsB.Dispose();
            bB.Dispose();
            dsOut.GetRasterBand(3).WriteRaster(0, 0, iXSize, iYSize, B, iXSize, iYSize, 0, 0);

            bG.ReadRaster(0, 0, iXSize, iYSize, G, iXSize, iYSize, 0, 0);
            dsG.Dispose();
            bG.Dispose();
            dsOut.GetRasterBand(2).WriteRaster(0, 0, iXSize, iYSize, G, iXSize, iYSize, 0, 0);

            bR.ReadRaster(0, 0, iXSize, iYSize, R, iXSize, iYSize, 0, 0);
            dsR.Dispose();
            bR.Dispose();
            dsOut.GetRasterBand(1).WriteRaster(0, 0, iXSize, iYSize, R, iXSize, iYSize, 0, 0);

            //release the memory
            dsOut.Dispose();
        }
Example #23
0
        /// <summary>
        /// 初始化Gdal
        /// </summary>
        public void InitinalGdal()
        {
            // 为了支持中文路径
            OSGeo.GDAL.Gdal.SetConfigOption("GDAL_FILENAME_IS_UTF8", "YES");
            // 为了使属性表字段支持中文
            Gdal.SetConfigOption("SHAPE_ENCODING", "");
            Gdal.AllRegister();
            Ogr.RegisterAll();

            oDerive = Ogr.GetDriverByName("ESRI Shapefile");
            if (oDerive == null)
            {
                MessageBox.Show("文件不能打开,请检查");
            }
        }
Example #24
0
        /// <summary>
        /// 初始化Gdal
        /// </summary>
        public void InitinalGdal()
        {
            // 为了支持中文路径
            Gdal.SetConfigOption("GDAL_FILENAME_IS_UTF8", "NO");
            // 为了使属性表字段支持中文
            Gdal.SetConfigOption("SHAPE_ENCODING", "");
            Gdal.AllRegister();
            Ogr.RegisterAll();

            oDerive = Ogr.GetDriverByName("ESRI Shapefile");
            if (oDerive == null)
            {
                LoggerHelper.Logger.Info("文件不能打开,请检查");
            }
        }
Example #25
0
        static void Main(string[] args)
        {
            // Set global exception handler
            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);

            // Enable Tracing
            TRACE_SWITCH = new TraceSwitch("TraceSwitch", "Default trace switch", "3");

            // Get SQL Server configs
            string MSSQLConnectionString = ConfigurationManager.ConnectionStrings["MSSQLConnectionString"].ConnectionString;
            int    SQLBatchSize          = int.Parse(ConfigurationManager.AppSettings["SQLBatchSize"]);
            int    SQLThreads            = int.Parse(ConfigurationManager.AppSettings["SQLThreads"]);

            // Configure SQL Server spatial types
            SqlServerTypes.Utilities.LoadNativeAssemblies(AppDomain.CurrentDomain.BaseDirectory);

            // Configure OGR
            GdalConfiguration.ConfigureOgr();
            Gdal.SetConfigOption("OGR_INTERLEAVED_READING", "YES");
            Gdal.SetConfigOption("OSM_COMPRESS_NODES", "YES");
            Gdal.SetConfigOption("CPL_TMPDIR", ConfigurationManager.AppSettings["OSMTmpPath"]);
            Gdal.SetConfigOption("OSM_MAX_TMPFILE_SIZE", ConfigurationManager.AppSettings["OSMTmpFileSize"]);
            Gdal.SetConfigOption("OSM_CONFIG_FILE", ConfigurationManager.AppSettings["OSMConfigFile"]);
            DataSource OGRDataSource = Ogr.Open(ConfigurationManager.AppSettings["OSMFile"], 0);

            // Drop SQL tables
            //DropTables(OGRDataSource, MSSQLConnectionString);

            // Create SQL tables and return ADO.NET DataSet of with DataTables
            // DataTables will be used buffer records before SQL bulk insert
            DataSet OSMDataSet = CreateTables(OGRDataSource, MSSQLConnectionString);

            // Start Timer
            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();

            // Do work son!
            log(TraceLevel.Info, "Begin Processing...");
            DoWork(OGRDataSource, OSMDataSet, MSSQLConnectionString, SQLThreads, SQLBatchSize);

            // Create Indexes
            CreateIndexes(OGRDataSource, MSSQLConnectionString);

            // Stop Timer
            stopwatch.Stop();
            log(TraceLevel.Info, string.Format("Time elapsed: {0}", stopwatch.Elapsed));
        }
Example #26
0
        /// <summary>
        /// 初始化Gdal
        /// </summary>
        public void InitinalGdal()
        {
            // 为了支持中文路径
            Gdal.SetConfigOption("GDAL_FILENAME_IS_UTF8", "YES");
            // 为了使属性表字段支持中文
            Gdal.SetConfigOption("SHAPE_ENCODING", "");
            //Gdal.AllRegister();

            Ogr.RegisterAll();

            oDriver = Ogr.GetDriverByName("ESRI Shapefile");
            if (oDriver == null)
            {
                Console.WriteLine("驱动不可用,请检查");
            }
        }
Example #27
0
        protected override void Initialize(string path)
        {
            this.Type = DataSourceTypePredefined.RasterImage.ToString();
            base.Initialize(path);

            try
            {
                Gdal.AllRegister();
                Gdal.SetConfigOption("GDAL_FILENAME_IS_UTF8", "NO");
            }
            catch (Exception e)
            {
                throw new Exception("Can not load GDAL assembly!\r\n" + e.Message);
            }
            //关于GDAL180中文路径不能打开的问题分析与解决:http://blog.csdn.net/liminlu0314/article/details/6610069
            Dataset ds = Gdal.Open(this.Path, Access.GA_ReadOnly);

            if (ds == null)
            {
                throw new Exception("Raster format is not supported.");
            }
            Driver drv = ds.GetDriver();

            if (drv == null)
            {
                throw new Exception("Can't get driver for gdal.");
            }
            if (ds.RasterCount < 3)
            {
                throw new Exception("The number of the raster bands is not enough.(bands count must = 3)");
            }
            //提取两个sp第一个,之前的字符串中的所有字母和数字,判断是否想等
            if (ds.GetProjectionRef() != string.Empty)//GetProjectionRef() can't be trust
            {
                HasProjectionFromGDAL = true;
                if (!string.Equals(Regex.Replace(TilingScheme.WKT.Split(new char[] { ',' })[0], @"[^a-zA-Z0-9]", ""), Regex.Replace(ds.GetProjectionRef().Split(new char[] { ',' })[0], @"[^a-zA-Z0-9]", "")))
                {
                    throw new Exception("The spatial reference in TilingScheme file is not equal to the spatial reference of Raster file!\r\nReprojection is not supported.");
                }
            }
            else
            {
                HasProjectionFromGDAL = false;
            }
            ds.Dispose();
        }
Example #28
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            //若出现【无法加载 DLL“ogr_wrap”: 找不到指定的模块】,
            //请将附带的DLL.rar中的全部文件解压复制到生成目录bin\x86\Debug(或bin\x86\Debug\DLL),同时安装附带的VC++包(Vcredist_x86.exe)
            //Exception: Unable to load DLL "ogr_wrap": Cannot find the specified module.
            //Solution: ① Please unzip all the files in the attached DLL.rar to the build directory bin\x86\Debug(or bin\x86\Debug\DLL)
            //          ② Install VC++ package (Vcredist_x86.exe)
            //Exception: Unable to open EPSG support file gcs.csv.
            //Solution: Please unzip all the files in the attached Data.rar to the build directory bin\x86\Debug\Data
            GdalHelper.GdalInit();
            Gdal.SetConfigOption("SHAPE_RESTORE_SHX", "YES"); //尝试还原/生成缺少的.shx文件

            Application.Run(new ConverterForm());
        }
Example #29
0
 public static void Main(string[] args)
 {
     Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);//todo 注册编码,注册gdal使用的GBK编码
     Gdal.AllRegister();
     Ogr.RegisterAll();
     // 为了支持中文路径,请添加下面这句代码
     if (Encoding.Default.EncodingName == Encoding.UTF8.EncodingName && Encoding.Default.CodePage == Encoding.UTF8.CodePage)
     {
         Gdal.SetConfigOption("GDAL_FILENAME_IS_UTF8", "YES");
     }
     else
     {
         Gdal.SetConfigOption("GDAL_FILENAME_IS_UTF8", "NO");
     }
     // 为了使属性表字段支持中文,请添加下面这句
     Gdal.SetConfigOption("SHAPE_ENCODING", "");
     CreateWebHostBuilder(args).Build().Run();
 }
Example #30
0
 public override void BuildOverviews(int[] levels, Action <int, string> progressTracker)
 {
     if (_dataset == null)
     {
         return;
     }
     if (levels == null)
     {
         levels = GetLevels();
     }
     if (levels.Length == 0)
     {
         return;
     }
     _progressTracker = progressTracker;
     Gdal.SetConfigOption("USE_RRD", "YES");
     _dataset.BuildOverviews("NEAREST", levels, new Gdal.GDALProgressFuncDelegate(ProgressFunc), string.Empty);
 }