示例#1
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);
        }
示例#2
0
        public void TranslateAction(List <string> files)
        {
            GDALTranslateOptions transOptions = new GDALTranslateOptions(new[] { "-of", "KMLSUPEROVERLAY", "-co", "format=png" });

            var vrtOptions = new GDALBuildVRTOptions(new[] { "-overwrite" });
            var vrtFile    = BuildVRT("tempVRT", files, vrtOptions);

            Gdal.wrapper_GDALTranslate(Path.Combine(OutputDirName, KMZFileName), vrtFile, transOptions, null, null);
        }
示例#3
0
        private bool SetVrtCreateInfo()
        {
            _vrtCreateInfo = new VrtCreateInfo();

            PathInfo pathInfo = _vrtCreatePathSettingControl.GetVrtCreatePathInfo();

            if (pathInfo.InputPathList.Count < 1)
            {
                MessageBox.Show("변환 경로 정보를 확인해주세요.", "변환", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return(false);
            }

            if (pathInfo.OutputPathString.Length < 1)
            {
                MessageBox.Show("변환 경로 정보를 확인해주세요.", "변환", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return(false);
            }

            _vrtCreateInfo.VrtCreatePathInfo = pathInfo;

            List <string>       options         = _vrtCreateOptionControl.GetVrtCreateOptions();
            GDALBuildVRTOptions buildVrtOptions = CreateGdalBuildVrtOptions(options.ToArray());

            if (buildVrtOptions == null)
            {
                return(false);
            }

            _vrtCreateInfo.CreateOptions   = options;
            _vrtCreateInfo.BuildVrtOptions = buildVrtOptions;

            string outputDirectory = Path.GetDirectoryName(pathInfo.OutputPathString);

            DirectoryInfo di = new DirectoryInfo(outputDirectory);

            if (!di.Exists)
            {
                di.Create();
                //Directory.CreateDirectory(outputDirectory);
            }

            LoggerManager.WriteVrtCreateInfoLog(_vrtCreateInfo);

            return(true);
        }
示例#4
0
        private GDALBuildVRTOptions CreateGdalBuildVrtOptions(string[] options)
        {
            GDALBuildVRTOptions buildVrtOptions = null;

            try
            {
                buildVrtOptions = new GDALBuildVRTOptions(options);
            }
            catch (Exception ex)
            {
                string errorMsg = "VRT 생성 옵션 정보를 확인해주세요.";
                errorMsg += Environment.NewLine;
                errorMsg += ex.Message;

                MessageBox.Show(errorMsg, "VRT 생성 옵션 설정", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }

            return(buildVrtOptions);
        }
示例#5
0
 private Dataset BuildVRT(string vrtFile, List <string> tiffFiles, GDALBuildVRTOptions vrtOptions)
 {
     return(Gdal.wrapper_GDALBuildVRT_names(vrtFile, tiffFiles.ToArray(), vrtOptions, null, null));
 }