Ejemplo n.º 1
0
        private void btnOgr2Ogr_Click(object sender, EventArgs e)
        {
            GlobalSettings settings = new GlobalSettings();

            settings.ResetGdalError();
            UtilsClass utils   = new MapWinGIS.UtilsClass();
            string     options = "--config CONFIG_FILE \"D:\\dev\\GIS-Data\\Djordje\\osmconf.ini\" --config OSM_USE_CUSTOM_INDEXING NO -skipfailures -f \"ESRI Shapefile\"";
            bool       result  = utils.OGR2OGR(@"D:\dev\GIS-Data\Djordje\map.osm", @"D:\dev\GIS-Data\Djordje\osm-result", options);

            if (!result)
            {
                // Both line should be the same:
                Debug.WriteLine(utils.ErrorMsgFromObject(utils));
                Debug.WriteLine(utils.ErrorMsg[utils.LastErrorCode]);
                Debug.WriteLine(settings.GdalLastErrorMsg);
            }

            txtResults.Text = @"OGR2OGR result: " + result;
            if (!result)
            {
                return;
            }

            // Add files:
            string[] shapefileFilenames = Directory.GetFiles(@"D:\dev\GIS-Data\Djordje\osm-result\", "*.shp");
            foreach (string filename in shapefileFilenames)
            {
                axMap1.AddLayerFromFilename(filename, tkFileOpenStrategy.fosVectorLayer, true);
            }
        }
Ejemplo n.º 2
0
        private void btnGdalInfo_Click(object sender, EventArgs e)
        {
            GlobalSettings settings = new GlobalSettings();

            settings.ResetGdalError();
            UtilsClass utils = new MapWinGIS.UtilsClass();

            var filename = @"D:\dev\GIS-Data\HDF5\RAD_NL25_RAC_03H_201612040000.h5";
            var result   = utils.GDALInfo(filename, "");

            if (!string.IsNullOrEmpty(result))
            {
                txtResults.Text = result;
                var hndle = axMap1.AddLayerFromFilename(filename, tkFileOpenStrategy.fosAutoDetect, true);
                if (hndle >= 1)
                {
                    return;
                }

                txtResults.Text += @" GDAL Error: " + settings.GdalLastErrorMsg
                                   + axMap1.get_ErrorMsg(axMap1.LastErrorCode);
                var grd    = new GridClass();
                var opened = grd.Open(filename);
                if (!opened)
                {
                    txtResults.Text += @" Could not open grid: " + grd.ErrorMsg[grd.LastErrorCode];
                    return;
                }

                if (!grd.OpenBand(0))
                {
                    txtResults.Text += @" Could not open grid band: " + grd.ErrorMsg[grd.LastErrorCode];
                    return;
                }

                hndle = axMap1.AddLayer(grd, true);
                if (hndle >= 1)
                {
                    return;
                }

                txtResults.Text += @" Could not add grid: " + grd.ErrorMsg[grd.LastErrorCode];

                return;
            }

            txtResults.Text = @" GDAL Error: " + settings.GdalLastErrorMsg
                              + @" GdalPluginPath: " + settings.GdalPluginPath;
        }