예제 #1
0
        public Task <double[]> GetGdalExtentAsync(string source)
        {
            var process = new AsyncProcess <double[]>(@"%GDAL%\gdalinfo", parseRasterExtent)
            {
                EnvironmentVariables = EnvironmentVariables, WorkingFolder = WorkingFolder
            };

            return(process.RunAsync(string.Format(@"""{0}""", source)));
        }
예제 #2
0
        public Task <GdalInfoResult> GetGDALInfoAsync(string source)
        {
            var process = new AsyncProcess <GdalInfoResult>(@"%GDAL%\gdalinfo", parseGDALInfo)
            {
                EnvironmentVariables = EnvironmentVariables, WorkingFolder = WorkingFolder
            };

            return(process.RunAsync(string.Format(@"""{0}""", source)));
        }
예제 #3
0
        public Task <double[]> GetOgrExtentAsync(string source, string layer = null)
        {
            var process = new AsyncProcess <double[]>(@"%GDAL%\ogrInfo", parseExtent)
            {
                EnvironmentVariables = EnvironmentVariables, WorkingFolder = WorkingFolder
            };

            return(process.RunAsync(string.Format(@"-so -al ""{0}"" {1}", source, layer)));
        }
예제 #4
0
        public Task <int> AddSpatialIndexToMSQL(string connectionstring, string tablename)
        {
            var process = new AsyncProcess(@"%GDAL%\ogrinfo")
            {
                EnvironmentVariables = EnvironmentVariables, WorkingFolder = WorkingFolder
            };

            return(process.RunAsync(string.Format(@" ""{1}"" -sql ""create spatial index on {0}""", tablename, connectionstring)));
        }
예제 #5
0
        public Task <int> BuildVrtFileAsync(string filelist, string outputfile)
        {
            var process = new AsyncProcess(@"%GDAL%\gdalbuildvrt")
            {
                EnvironmentVariables = EnvironmentVariables, WorkingFolder = WorkingFolder
            };

            return(process.RunAsync(string.Format(@" -input_file_list ""{0}"" ""{1}""", filelist, outputfile)));
        }
예제 #6
0
        public Task <string> GetProj4TextAsync(string source, string layer = null)
        {
            var path    = Path.ChangeExtension(source, "prj");
            var process = new AsyncProcess <string>(@"%GDAL%\gdalsrsinfo", parseProj4)
            {
                EnvironmentVariables = EnvironmentVariables, WorkingFolder = WorkingFolder
            };

            return(process.RunAsync(string.Format(@"""{0}""", path)));
        }
예제 #7
0
        public Task <int> Ogr2OgrClipAsync(string source, string target, string t_srs, double[] extent)
        {
            var process = new AsyncProcess(@"%GDAL%\ogr2ogr")
            {
                EnvironmentVariables = EnvironmentVariables, WorkingFolder = WorkingFolder
            };

            return(process.RunAsync(string.Format(@"{0} {1} -t_srs {2} -spat {3}",
                                                  target, source, t_srs, string.Join(" ", extent))));
        }
예제 #8
0
        public Task <int> GdalExtractWithTranslate(string source, string target, string projwin, string outtype, int?outputsize = null, params string[] createOptions)
        {
            var process = new AsyncProcess(@"%GDAL%\gdal_translate")
            {
                EnvironmentVariables = EnvironmentVariables, WorkingFolder = WorkingFolder
            };

            return(process.RunAsync(string.Format(@" -of {2} {5} {4} -projwin {1} ""{0}"" ""{3}"" ",
                                                  source, projwin, outtype, target, outputsize.HasValue ?
                                                  string.Format("-outsize {0} {0}", outputsize.Value):"",
                                                  string.Join(" ", createOptions.Select(co => string.Format("-co {0}", co)))
                                                  )));
            //(outtype=="gtiff") ? "-co COMPRESS=LZW -co PREDICTOR=2" : (outtype=="png"?"-co WORLDFILE=YES":"")
        }