Exemplo n.º 1
0
        private void MakeGrid(sFLTData FLTData, string InitialFile, MapWinGIS.ICallback Callback)
        {
            //根据.flt文件及其数据文件,创建一个grid网格对象
            MapWinGIS.GridHeader h = new MapWinGIS.GridHeader();
            int i, j;

            h.dX          = FLTData.cellsize;
            h.dY          = FLTData.cellsize;
            h.Notes       = "Grid文件导入路径 " + System.IO.Path.GetFileName(InitialFile);
            h.NodataValue = FLTData.NODATA_value;
            h.NumberCols  = FLTData.ncols;
            h.NumberRows  = FLTData.nrows;
            h.XllCenter   = FLTData.xllcenter;
            h.YllCenter   = FLTData.yllcenter;

            base.Close();
            base.CreateNew("", h, MapWinGIS.GridDataType.FloatDataType, -1, true, MapWinGIS.GridFileType.Binary);

            for (i = 0; i < FLTData.ncols; i++)
            {
                for (j = 0; j < FLTData.nrows; j++)
                {
                    base.Value[i, j] = FLTData.Values[i, j];
                }
                if (Callback != null)
                {
                    Callback.Progress(base.Key, 50 + i / FLTData.ncols * 50, "创建 MapWinGIS grid");
                }
            }
        }
Exemplo n.º 2
0
        // check user input and set the values of private fields
        // prompts the user to fill in any missing data
        private void btnNext_Click(object sender, EventArgs e)
        {
            MapWinGIS.GridHeader hdr = new MapWinGIS.GridHeader();
            double cellSize          = 0F;
            double minX = 0F;
            double minY = 0F;
            double maxX = 0F;
            double maxY = 0F;

            Utils.string2double(txtCellSize.Text, out cellSize);
            if (cellSize <= 0)
            {
                MapWinUtility.Logger.Msg("The grid cell size must be a positive number.");
                txtCellSize.Focus();
                return;
            }
            if (!Utils.string2double(txtMinX.Text, out minX))
            {
                MapWinUtility.Logger.Msg("The minimum X value must be a number.");
                txtMinX.Focus();
                return;
            }
            if (!Utils.string2double(txtMinY.Text, out minY))
            {
                MapWinUtility.Logger.Msg("The minimum Y value must be a number.");
                txtMinY.Focus();
                return;
            }
            if (!Utils.string2double(txtMaxX.Text, out maxX))
            {
                MapWinUtility.Logger.Msg("The maximum X value must be a number");
                txtMaxX.Focus();
                return;
            }

            if (!Utils.string2double(txtMaxY.Text, out maxY))
            {
                MapWinUtility.Logger.Msg("The number of rows must be a positive integer.");
                txtMaxY.Focus();
                return;
            }

            if (MapWinUtility.Strings.IsEmpty(txtGridFile.Text))
            {
                MapWinUtility.Logger.Msg("Please select the result grid filename.");
                btnOpenFile.Focus();
                return;
            }

            //check data type - .bgd format only supports float data type
            if (this.GridDataType != MapWinGIS.GridDataType.FloatDataType &&
                this.GridFileType == MapWinGIS.GridFileType.Binary)
            {
                cmbDataType.SelectedItem = MapWinGIS.GridDataType.FloatDataType;
            }

            //update the "grid header" object with values from textboxes
            UpdateGridHeader(minX, minY, maxX, maxY, cellSize, cellSize, m_GridHeader);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Er... Changes a grid format?
        /// </summary>
        /// <param name="origFilename">Original Grid Filename</param>
        /// <param name="newFilename">Output Grid Filename</param>
        /// <param name="newFileType">Specifies the original file format of the grid</param>
        /// <param name="newFileFormat">Specifies the new file format</param>
        /// <param name="multFactor">Like Extrusion, this multiplies the Z value</param>
        /// <returns>Boolean, false if there was an error</returns>
        public static bool ChangeGridFormat(string origFilename, string newFilename, MapWinGIS.GridFileType newFileType, MapWinGIS.GridDataType newFileFormat, float multFactor)
        {
            bool Errors = false;

            MapWinGIS.Grid tGrd = new MapWinGIS.Grid();
            tGrd.Open(origFilename, MapWinGIS.GridDataType.UnknownDataType, true, MapWinGIS.GridFileType.UseExtension, null);

            Logger.Status("Writing Grid to New Format");

            //If we're multiplying by a factor, must
            //create the new grid and actually do it ourselves.
            //Otherwise, can save directly
            //Jiri Kadlec 1-28-2009 we still neet to create a new grid when the data or file type is different.
            if (multFactor == 1 && newFileFormat == tGrd.DataType)
            {
                Logger.Dbg("Saving directly to new format");
                tGrd.Save(newFilename, newFileType, null);
                // ProgressForm)
            }
            else
            {
                Logger.Dbg("Saving to new format with mult. factor: " + multFactor.ToString());

                MapWinGIS.GridHeader hdr = new MapWinGIS.GridHeader();
                hdr.CopyFrom(tGrd.Header);

                MapWinGIS.Grid newgrid = new MapWinGIS.Grid();
                if (!newgrid.CreateNew(newFilename, hdr, newFileFormat, hdr.NodataValue, true, newFileType, null))
                {
                    Logger.Message("Unable to create new grid!", "Error", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error, System.Windows.Forms.DialogResult.OK);
                    Errors = true;
                }
                else
                {
                    int     ncols  = tGrd.Header.NumberCols;
                    int     nrows  = tGrd.Header.NumberRows;
                    float[] oneRow = new float[ncols + 1];
                    for (int i = 0; i <= nrows - 1; i++)
                    {
                        tGrd.GetFloatWindow(i, i, 0, ncols, ref oneRow[0]);
                        for (int z = 0; z <= ncols - 1; z++)
                        {
                            oneRow[z] *= multFactor;
                        }
                        newgrid.PutFloatWindow(i, i, 0, ncols, ref oneRow[0]);
                    }
                    newgrid.Save(newFilename, newFileType, null);
                    newgrid.Close();
                }
            }

            return(!Errors);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Overloaded version of the function
        /// Sets the "grid extent" box to the same extention as the grid header
        /// </summary>
        /// <param name="header"></param>
        private void UpdateExtentBox(MapWinGIS.GridHeader header)
        {
            double xMin  = header.XllCenter - (header.dX / 2.0);
            double yMin  = header.YllCenter - (header.dY / 2.0);
            double nCols = header.NumberCols;
            double nRows = header.NumberRows;
            double xMax  = xMin + header.dX * nCols;
            double yMax  = yMin + header.dY * nRows;

            txtMinX.Text       = xMin.ToString();
            txtMinY.Text       = yMin.ToString();
            txtMaxX.Text       = xMax.ToString();
            txtMaxY.Text       = yMax.ToString();
            lblNumberCols.Text = nCols.ToString();
            lblNumberRows.Text = nRows.ToString();
        }
Exemplo n.º 5
0
        /// <summary>
        /// Creates a new instance of a MapWinGIS Grid according to the parameters required by IRaster
        /// </summary>
        /// <param name="Filename">The string full path filename of the grid</param>
        /// <param name="newFileType">A MapWindow.Interfaces.Type.GridFileType specifying a file format</param>
        /// <param name="dX">Double, specifies the cell width of a single "pixel" for the grid</param>
        /// <param name="dY">Double, specifies the cell height of a single pixel of the grid</param>
        /// <param name="xllCenter">Double, The longitude/X-coordinate of the lower left pixel in the grid</param>
        /// <param name="yllCenter">Double, The latitude/Y-coordinate of the lower left pixel of the grid</param>
        /// <param name="noDataVal">Double, The value to use as a no-data value in the grid</param>
        /// <param name="projection">String: the proj-4 string to use to describe the grid projection</param>
        /// <param name="nCols">Int, the number of columns in the grid</param>
        /// <param name="nrows">Int, the number of rows in the grid</param>
        /// <param name="DataType">A MapWindow.Interfaces.Type.GridDataType that specifies the numeric data format</param>
        /// <param name="CreateINRam">Boolean, if true, the entire element will be created in ram</param>
        /// <param name="initialValue">The intial value for the grid</param>
        /// <param name="applyinitialValue">I'm not sure this is an option in the old grid</param>
        public void CreateNew(string Filename, GridFileType newFileType, double dX, double dY, double xllCenter, double yllCenter, double noDataVal, string projection, int nCols, int nrows, GridDataType DataType, bool CreateINRam, double initialValue, bool applyinitialValue)
        {
            MapWinGIS.GridHeader gh = new MapWinGIS.GridHeader();
            gh.dX          = dX;
            gh.dY          = dY;
            gh.XllCenter   = xllCenter;
            gh.YllCenter   = yllCenter;
            gh.Projection  = projection;
            gh.NumberCols  = nCols;
            gh.NumberRows  = nrows;
            gh.NodataValue = noDataVal;

            if (m_Grid.CreateNew(Filename, gh, MapWinGeoProc.Compatibility.Convert.mwGridDataType(DataType),
                                 initialValue, CreateINRam, MapWinGeoProc.Compatibility.Convert.mwGridFileType(newFileType), null) == false)
            {
                MapWinUtility.Logger.Dbg("Error calling CreateNew in MapWinGIS.Grid");
                throw new MapWinException(m_Grid.LastErrorCode);
            }
        }
Exemplo n.º 6
0
        private static void CreateGridFromExtents(MapWinGIS.Extents InExtents, double CellSize, String Projection, double NoDataValue, string OutGridPath, out MapWinGIS.Grid OutGrid)
        {
            double height = Math.Abs(InExtents.yMax - InExtents.yMin);
            double width  = Math.Abs(InExtents.xMax - InExtents.xMin);

            OutGrid = new MapWinGIS.Grid();
            MapWinGIS.GridHeader hdr = new MapWinGIS.GridHeader();

            hdr.dX          = CellSize;
            hdr.dY          = CellSize;
            hdr.NodataValue = NoDataValue;
            hdr.NumberRows  = int.Parse(Math.Ceiling(height / CellSize).ToString());
            hdr.NumberCols  = int.Parse(Math.Ceiling(width / CellSize).ToString());
            hdr.Projection  = Projection;
            hdr.XllCenter   = InExtents.xMin + 0.5 * CellSize;
            hdr.YllCenter   = InExtents.yMin + 0.5 * CellSize;

            OutGrid.CreateNew(OutGridPath, hdr, MapWinGIS.GridDataType.DoubleDataType, NoDataValue, true, MapWinGIS.GridFileType.UseExtension, null);
        }
Exemplo n.º 7
0
        public bool GetGridInformation()
        {
            //now show the grid form
            bool    result   = false;
            frmGrid gridForm = new frmGrid(m_MapWin, m_ShpFileName);

            if (gridForm.ShowDialog() == DialogResult.OK)
            {
                m_GridHeader   = gridForm.GridHeader;
                m_GridDataType = gridForm.GridDataType;
                m_GridFileName = gridForm.GridFileName;
                m_GridFileType = gridForm.GridFileType;
                result         = true;
            }
            else
            {
                //the user clicked the BACK button - go back to 'select shapefile' dialog
                result = GetShapeInformation();
            }
            return(result);
        }
Exemplo n.º 8
0
        public int GetNumCellsByDEMAndMask(MapWinGIS.GridHeader head, string strMask)
        {
            int numCells = 0, maskCells = 0;

            numCells = head.NumberCols * head.NumberRows;
            MapWinGIS.Shapefile sf = new MapWinGIS.Shapefile();
            sf.Open(strMask);
            for (int iShape = 0; iShape < sf.NumShapes; iShape++)
            {
                MapWinGIS.Shape tempShape = sf.Shape[iShape];
                int             temp      = Convert.ToInt32(MapWinGeoProc.Utils.Area(ref tempShape) / (head.dX * head.dY));
                maskCells = maskCells + temp;
            }
            sf.Close();
            if (numCells > maskCells)
            {
                numCells = maskCells;
            }

            return(numCells);
        }
Exemplo n.º 9
0
        /// <summary>
        /// Creates a new form object for setting properties of the
        /// new grid
        /// </summary>
        /// <param name="IMapWin">The MapWindow interface</param>
        /// <param name="shpFileName">File name of the shapefile</param>
        /// <param name="fieldType">Type of field containing data</param>
        public frmGrid(MapWindow.Interfaces.IMapWin IMapWin,
            string shpFileName, MapWinGIS.FieldType fieldType)
        {
            InitializeComponent();

            //setup event handler
            this.txtCellSize.TextChanged += new EventHandler(txtCellSize_TextChanged);

            //initialize the global variables and default values
            m_MapWin = IMapWin;
            m_ShpFileName = shpFileName;
            m_FieldType = fieldType;
            m_DefaultCellSize = calcDefaultCellsize();
            m_DefaultNodataValue = -9999F;
            m_GridHeader = new MapWinGIS.GridHeader();

            //populate the combo boxes
            populateGridList();
            populateExtentLayers();
            populateDataTypes();
            populateFileTypes();
        }
Exemplo n.º 10
0
        /// <summary>
        /// Creates a new form object for setting properties of the
        /// new grid
        /// </summary>
        /// <param name="IMapWin">The MapWindow interface</param>
        /// <param name="shpFileName">File name of the shapefile</param>
        /// <param name="fieldType">Type of field containing data</param>
        public frmGrid(MapWindow.Interfaces.IMapWin IMapWin,
                       string shpFileName, MapWinGIS.FieldType fieldType)
        {
            InitializeComponent();

            //setup event handler
            this.txtCellSize.TextChanged += new EventHandler(txtCellSize_TextChanged);

            //initialize the global variables and default values
            m_MapWin             = IMapWin;
            m_ShpFileName        = shpFileName;
            m_FieldType          = fieldType;
            m_DefaultCellSize    = calcDefaultCellsize();
            m_DefaultNodataValue = -9999F;
            m_GridHeader         = new MapWinGIS.GridHeader();

            //populate the combo boxes
            populateGridList();
            populateExtentLayers();
            populateDataTypes();
            populateFileTypes();
        }
Exemplo n.º 11
0
        private void MakeGrid(sDEMData DEMData, MapWinGIS.ICallback Callback)
        {
            //根据.dem文件,生成一个网格文件对象
            MapWinGIS.GridHeader h = new MapWinGIS.GridHeader();
            int i;
            int j;
            int m;
            int n;

            h.dX          = 30;
            h.dY          = 30;
            h.Notes       = "DEMData.Notes";
            h.NodataValue = -1;
            h.NumberCols  = DEMData.NumCols;
            h.NumberRows  = System.Convert.ToInt32((DEMData.MaxY() - DEMData.MinY() / 30)) + 1;
            h.XllCenter   = DEMData.MinX();
            h.YllCenter   = DEMData.MinY();

            MapWinGIS.Utility.Logger.Dbg("根据.dem文件和其数据文件,生成一个网格文件对象");
            base.Close();
            MapWinGIS.Utility.Logger.Dbg("开始创建");
            base.CreateNew("", h, MapWinGIS.GridDataType.ShortDataType, h.NodataValue, true, MapWinGIS.GridFileType.Binary);
            MapWinGIS.Utility.Logger.Dbg("只带header的新的grid网格文件创建了");

            for (i = 0; i < DEMData.NumCols; i++)
            {
                for (j = 0; j < DEMData.NumElevs[i]; j++)
                {
                    base.ProjToCell(DEMData.ColStarts[i].X, System.Convert.ToInt32(DEMData.ColStarts[i].Y) + (30 * j), out m, out n);
                    base.Value[m, n] = DEMData.Values[i, j];
                }
                MapWinGIS.Utility.Logger.Dbg("创建 MapWinGIS grid 对象. numCols: " + i.ToString());
                if (Callback != null)
                {
                    Callback.Progress(base.Key, 50 + i / DEMData.NumCols * 50, "创建 MapWinGIS grid 对象");
                }
            }
            MapWinGIS.Utility.Logger.Dbg("生成一个网格文件对象完成");
        }
Exemplo n.º 12
0
        // updates the internal Grid header object which stores
        // the extent and cellsize of the new grid
        private void UpdateGridHeader(double xMin, double yMin, double xMax, double yMax,
                                      double dX, double dY, MapWinGIS.GridHeader hdr)
        {
            if (hdr == null)
            {
                hdr = new MapWinGIS.GridHeader();
            }

            double noData    = m_DefaultNodataValue;
            double halfX     = dX / 2F;
            double halfY     = dY / 2F;
            double xllCenter = xMin + halfX;
            double yllCenter = yMin + halfX;
            int    nCols     = (int)(Math.Abs(xMax - xMin) / dX);
            int    nRows     = (int)(Math.Abs(yMax - yMin) / dY);

            hdr.dX          = dX;
            hdr.dY          = dY;
            hdr.NumberCols  = nCols;
            hdr.NumberRows  = nRows;
            hdr.XllCenter   = xllCenter;
            hdr.YllCenter   = yllCenter;
            hdr.NodataValue = noData;
        }
Exemplo n.º 13
0
        // Dangerous. Too dangerous.
        // Does the caller want a reference to the header so they can change it?
        // Does the caller want a copy of the header that they can safely modify for creating a new (slightly different) grid?

        /*public MapWinGIS.GridHeader GetHeader()
         *      {
         *              return grid.Header;
         *      }*/
        // Create functions explcitly for each so those using it will choose the right one
        public MapWinGIS.GridHeader GetHeaderCopy()
        {
            MapWinGIS.GridHeader newHdr = new MapWinGIS.GridHeader();
            newHdr.CopyFrom(grid.Header);
            return(newHdr);
        }
Exemplo n.º 14
0
        // updates the internal Grid header object which stores
        // the extent and cellsize of the new grid
        private void UpdateGridHeader(double xMin, double yMin, double xMax, double yMax, 
            double dX, double dY, MapWinGIS.GridHeader hdr)
        {
            if (hdr == null)
            {
                hdr = new MapWinGIS.GridHeader();
            }

            double noData = m_DefaultNodataValue;
            double halfX = dX / 2F;
            double halfY = dY / 2F;
            double xllCenter = xMin + halfX;
            double yllCenter = yMin + halfX;
            int nCols = (int) ( Math.Abs( xMax - xMin ) / dX );
            int nRows = (int) ( Math.Abs( yMax - yMin ) / dY );

            hdr.dX = dX;
            hdr.dY = dY;
            hdr.NumberCols = nCols;
            hdr.NumberRows = nRows;
            hdr.XllCenter = xllCenter;
            hdr.YllCenter = yllCenter;
            hdr.NodataValue = noData;
        }
Exemplo n.º 15
0
        // check user input and set the values of private fields
        // prompts the user to fill in any missing data
        private void btnNext_Click(object sender, EventArgs e)
        {
            MapWinGIS.GridHeader hdr = new MapWinGIS.GridHeader();
            double cellSize = 0F;
            double minX = 0F;
            double minY = 0F;
            double maxX = 0F;
            double maxY = 0F;

            Utils.string2double(txtCellSize.Text, out cellSize);
            if (cellSize <= 0)
            {
                MapWinUtility.Logger.Msg("The grid cell size must be a positive number.");
                txtCellSize.Focus();
                return;
            }
            if (!Utils.string2double(txtMinX.Text, out minX))
            {
                MapWinUtility.Logger.Msg("The minimum X value must be a number.");
                txtMinX.Focus();
                return;
            }
            if (!Utils.string2double(txtMinY.Text, out minY))
            {
                MapWinUtility.Logger.Msg("The minimum Y value must be a number.");
                txtMinY.Focus();
                return;
            }
            if (!Utils.string2double(txtMaxX.Text, out maxX))
            {
                MapWinUtility.Logger.Msg("The maximum X value must be a number");
                txtMaxX.Focus();
                return;
            }

            if (!Utils.string2double(txtMaxY.Text, out maxY))
            {
                MapWinUtility.Logger.Msg("The number of rows must be a positive integer.");
                txtMaxY.Focus();
                return;
            }

            if (MapWinUtility.Strings.IsEmpty(txtGridFile.Text))
            {
                MapWinUtility.Logger.Msg("Please select the result grid filename.");
                btnOpenFile.Focus();
                return;
            }

            //check data type - .bgd format only supports float data type
            if (this.GridDataType != MapWinGIS.GridDataType.FloatDataType &&
                this.GridFileType == MapWinGIS.GridFileType.Binary)
            {
                cmbDataType.SelectedItem = MapWinGIS.GridDataType.FloatDataType;
            }

            //update the "grid header" object with values from textboxes
            UpdateGridHeader(minX, minY, maxX, maxY, cellSize, cellSize, m_GridHeader);
        }
Exemplo n.º 16
0
        /// <summary>
        /// This overload calculates the difference between files.  THe number of rows and columns should be the same.
        /// </summary>
        /// <param name="SourceFile1">String filename of one grid to compare</param>
        /// <param name="SourceFile2">String filename of another grid to compare</param>
        /// <param name="DestFile">String filename of the output difference file</param>
        /// <param name="Overwrite">Boolean, true if you wish to overwrite an existing output
        /// file and delete the associated .bmp file.  False raises a messagebox if the files exist.</param>
        /// <param name="ICallBack">A MapWinGIS.ICallBack for status messages</param>
        public static void Difference(string SourceFile1, string SourceFile2, string DestFile, bool Overwrite, MapWinGIS.ICallback ICallBack)
        {
            MapWinGIS.Grid Source1 = new MapWinGIS.Grid();
            MapWinGIS.Grid Source2 = new MapWinGIS.Grid();
            MapWinGIS.Grid Dest    = new MapWinGIS.Grid();
            bool           res;

            // Open the source grids
            if (ICallBack != null)
            {
                ICallBack.Progress("Status", 0, "Opening Files...");
            }
            res = Source1.Open(SourceFile1, MapWinGIS.GridDataType.UnknownDataType, true, MapWinGIS.GridFileType.UseExtension, ICallBack);
            if (res == false)
            {
                MapWinUtility.Logger.Dbg("Argument Exception: " + Source1.get_ErrorMsg(Source1.LastErrorCode));
                throw new ArgumentException(Source1.get_ErrorMsg(Source1.LastErrorCode));
            }
            res = Source2.Open(SourceFile2, MapWinGIS.GridDataType.UnknownDataType, true, MapWinGIS.GridFileType.UseExtension, ICallBack);
            if (res == false)
            {
                throw new ArgumentException(Source2.get_ErrorMsg(Source2.LastErrorCode));
            }

            // Delete any existing files for our output grid
            if (System.IO.File.Exists(DestFile))
            {
                string bmp   = System.IO.Path.ChangeExtension(DestFile, "bmp");
                string bpw   = System.IO.Path.ChangeExtension(DestFile, "bpw");
                string prj   = System.IO.Path.ChangeExtension(DestFile, "prj");
                string mwleg = System.IO.Path.ChangeExtension(DestFile, "mwleg");
                if (Overwrite == false)
                {
                    if (System.IO.File.Exists(bmp) || System.IO.File.Exists(bpw) ||
                        System.IO.File.Exists(prj) || System.IO.File.Exists(mwleg))
                    {
                        if (MapWinUtility.Logger.Message("The output file exists, or associated files of the same name exist.  Do you wish to delete the existing files?\n", "Output Files Exist", System.Windows.Forms.MessageBoxButtons.YesNo, System.Windows.Forms.MessageBoxIcon.Warning, System.Windows.Forms.DialogResult.No) == System.Windows.Forms.DialogResult.No)
                        {
                            return;
                        }
                        // This ensures mapwindow will recognize the new image as a new file.
                        if (System.IO.File.Exists(bmp))
                        {
                            System.IO.File.Delete(bmp);
                        }
                        if (System.IO.File.Exists(bpw))
                        {
                            System.IO.File.Delete(bpw);
                        }
                        if (System.IO.File.Exists(prj))
                        {
                            System.IO.File.Delete(prj);
                        }
                        if (System.IO.File.Exists(mwleg))
                        {
                            System.IO.File.Delete(mwleg);
                        }
                    }
                    else
                    {
                        if (MapWinUtility.Logger.Message("The output file already exists.  Do you wish to delete it?", "Destination File Already Exists",
                                                         System.Windows.Forms.MessageBoxButtons.YesNo, System.Windows.Forms.MessageBoxIcon.Warning, System.Windows.Forms.DialogResult.No)
                            == System.Windows.Forms.DialogResult.No)
                        {
                            return;
                        }
                    }
                }
                else
                {
                    if (System.IO.File.Exists(bmp))
                    {
                        System.IO.File.Delete(bmp);
                    }
                    if (System.IO.File.Exists(bpw))
                    {
                        System.IO.File.Delete(bpw);
                    }
                    if (System.IO.File.Exists(prj))
                    {
                        System.IO.File.Delete(prj);
                    }
                    if (System.IO.File.Exists(mwleg))
                    {
                        System.IO.File.Delete(mwleg);
                    }
                }
                System.IO.File.Delete(DestFile);
            }

            // Create a new output grid
            MapWinGIS.GridHeader newHeader = new MapWinGIS.GridHeader();
            newHeader.CopyFrom(Source1.Header);
            if (ICallBack != null)
            {
                MapWinUtility.Logger.Dbg("Creating Output File...");
                ICallBack.Progress("Status", 0, "Creating Output File...");
            }
            res = Dest.CreateNew(DestFile, newHeader, Source1.DataType, 0, true, MapWinGIS.GridFileType.UseExtension, ICallBack);
            if (res == false)
            {
                MapWinUtility.Logger.Dbg("Argument Exception: " + Dest.get_ErrorMsg(Dest.LastErrorCode));
                throw new ArgumentException(Dest.get_ErrorMsg(Dest.LastErrorCode));
            }

            // Calculate the differences
            Difference(Source1, Source2, Dest, ICallBack);

            // Close Source grids
            Source1.Close();
            Source2.Close();

            // Save and close the output grid
            res = Dest.Save(DestFile, MapWinGIS.GridFileType.UseExtension, ICallBack);
            if (res == false)
            {
                MapWinUtility.Logger.Dbg("Application Exception: " + Dest.get_ErrorMsg(Dest.LastErrorCode));
                throw new ArgumentException(Dest.get_ErrorMsg(Dest.LastErrorCode));
            }
            Dest.Close();
            MapWinUtility.Logger.Dbg("Finished Difference");
        }
Exemplo n.º 17
0
 public override bool CreateNew(string Filename, MapWinGIS.GridHeader Header, MapWinGIS.GridDataType DataType, object InitialValue, bool InRam = true, MapWinGIS.GridFileType FileType = MapWinGIS.GridFileType.UseExtension, MapWinGIS.ICallback cBack = null)
 {
     return(base.CreateNew(Filename, Header, DataType, InitialValue, InRam, FileType, cBack));
 }
Exemplo n.º 18
0
        public bool GetGridInformation()
        {
            //now show the grid form
            bool result = false;
            frmGrid gridForm = new frmGrid(m_MapWin, m_ShpFileName);

            if (gridForm.ShowDialog() == DialogResult.OK)
            {
                m_GridHeader = gridForm.GridHeader;
                m_GridDataType = gridForm.GridDataType;
                m_GridFileName = gridForm.GridFileName;
                m_GridFileType = gridForm.GridFileType;
                result = true;
            }
            else
            {
                //the user clicked the BACK button - go back to 'select shapefile' dialog
                result = GetShapeInformation();
            }
            return result;
        }