示例#1
0
        /// <summary>
        /// Initializes the categories tab
        /// </summary>
        private void InitCategoriesTab()
        {
            icbCategories.ComboStyle   = ImageComboStyle.ColorSchemeGraduated;
            icbCategories.ColorSchemes = Globals.LayerColors;
            if (icbCategories.Items.Count > 0)
            {
                icbCategories.SelectedIndex = 0;
            }

            // layer settings

            chkSetGradient.Checked     = _settings.CategoriesUseGradient;
            chkRandomColors.Checked    = _settings.CategoriesRandomColors;
            udNumCategories.Value      = _settings.CategoriesCount;
            chkUniqueValues.Checked    = (_settings.CategoriesClassification == tkClassificationType.ctUniqueValues);
            chkUseVariableSize.Checked = _settings.CategoriesVariableSize;

            // fills in the list of fields
            FillFieldList(_settings.CategoriesFieldName);

            // setting the color scheme that is in use
            for (int i = 0; i < icbCategories.Items.Count; i++)
            {
                //if (m_plugin.LayerColors.List[i] == _settings.CategoriesColorScheme)
                //{
                //    icbCategories.SelectedIndex = i;
                //    break;
                //}
            }

            MapWinGIS.ShpfileType type = Globals.ShapefileType2D(_shapefile.ShapefileType);
            groupVariableSize.Visible = (type == ShpfileType.SHP_POINT || type == ShpfileType.SHP_POLYLINE);

            if (type == ShpfileType.SHP_POINT)
            {
                udMinSize.SetValue(_shapefile.DefaultDrawingOptions.PointSize);
            }
            else if (type == ShpfileType.SHP_POLYLINE)
            {
                udMinSize.SetValue(_shapefile.DefaultDrawingOptions.LineWidth);
            }
            udMaxSize.SetValue((double)udMinSize.Value + _settings.CategoriesSizeRange);

            RefreshCategoriesList();

            if (dgvCategories.Rows.Count > 0 && dgvCategories.Columns.Count > 0)
            {
                dgvCategories[0, 0].Selected = true;
            }
        }
        private void initGategoiresTab()
        {
            //默认为渐变
            icbCategories.ComboStyle = ImageComboStyle.ColorSchemeGraduated;
            //颜色资源获取
            icbCategories.ColorSchemes = Globals.LayerColors;
            if (icbCategories.Items.Count > 0)
            {
                icbCategories.SelectedIndex = 0;
            }


            // 从图层设置中读取图层信息,初始化控件
            chkSetGradient.Checked     = _settings.CategoriesUseGradient;
            chkRandomColors.Checked    = _settings.CategoriesRandomColors;
            udNumCategories.Value      = _settings.CategoriesCount;
            chkUniqueValues.Checked    = (_settings.CategoriesClassification == tkClassificationType.ctUniqueValues);
            chkUseVariableSize.Checked = _settings.CategoriesVariableSize;
            //读取字段信息
            FillFieldList(_settings.CategoriesFieldName);
            //设置可见性
            MapWinGIS.ShpfileType type = Globals.ShapefileType2D(_shapefile.ShapefileType);
            groupVariableSize.Visible = (type == ShpfileType.SHP_POINT || type == ShpfileType.SHP_POLYLINE);
            //设置分类最大最小值
            if (type == ShpfileType.SHP_POINT)
            {
                udMinSize.SetValue(_shapefile.DefaultDrawingOptions.PointSize);
            }
            else if (type == ShpfileType.SHP_POLYLINE)
            {
                udMinSize.SetValue(_shapefile.DefaultDrawingOptions.LineWidth);
            }
            udMaxSize.SetValue((double)udMinSize.Value + _settings.CategoriesSizeRange);



            RefreshCategoriesList();

            if (dgvCategories.Rows.Count > 0 && dgvCategories.Columns.Count > 0)
            {
                dgvCategories[0, 0].Selected = true;
            }

            //初始化事件
            initEvent();
        }
 public static ShpfileType ShapefileType2D(MapWinGIS.ShpfileType shpType)
 {
     if (shpType == ShpfileType.SHP_POLYGON || shpType == ShpfileType.SHP_POLYGONM || shpType == ShpfileType.SHP_POLYGONZ)
     {
         return(ShpfileType.SHP_POLYGON);
     }
     else if (shpType == ShpfileType.SHP_POLYLINE || shpType == ShpfileType.SHP_POLYLINEM || shpType == ShpfileType.SHP_POLYLINEZ)
     {
         return(ShpfileType.SHP_POLYLINE);
     }
     else if (shpType == ShpfileType.SHP_POINT || shpType == ShpfileType.SHP_POINTM || shpType == ShpfileType.SHP_POINTZ ||
              shpType == ShpfileType.SHP_MULTIPOINT || shpType == ShpfileType.SHP_MULTIPOINTM || shpType == ShpfileType.SHP_MULTIPOINTZ)
     {
         return(ShpfileType.SHP_POINT);
     }
     else
     {
         return(ShpfileType.SHP_NULLSHAPE);
     }
 }
示例#4
0
 public DrawingOptions(ShapeDrawingOptions options, ShpfileType type)
 {
     Options = options;
     Type    = type;
 }
示例#5
0
        /// <summary>
        /// 'Copyright (C) 2008  Enrico Antonio Chiaradia, UNIMI
        ///'This program is free software; you can redistribute it and/or
        ///'modify it under the terms of the GNU General Public License 
        ///'version 2, 1991 as published by the Free Software Foundation.
        ///'This program is distributed in the hope that it will be useful,
        ///'but WITHOUT ANY WARRANTY; without even the implied warranty of
        ///'MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
        ///'GNU General Public License for more details.
        ///'A copy of the full GNU General Public License is available at:
        ///'http://www.gnu.org/copyleft/gpl.html
        ///'or from:
        ///'The Free Software Foundation, Inc., 59 Temple Place - Suite 330, 
        ///'Boston, MA  02111-1307, USA.
        ///'If you wish to use or incorporate this program (or parts of it) into 
        ///'other software that does not meet the GNU General Public License 
        ///'conditions contact the author to request permission.
        ///'If you have any question or suggestion, please contact the author.
        ///'Enrico A. Chiaradia
        ///'University of Milan
        ///'Ist. di Idraulica Agraria
        ///'via Celoria 2
        ///'20133, Milan, Italy
        ///'email:  [email protected]
        /// </summary>
        /// <param name="sfPath">the name of the shapefile</param>
        /// <param name="resultGridPath">the name of the new grid</param>
        /// <param name="gridFileType">file type of the new grid</param>
        /// <param name="gridDataType">data format of the new grid</param>
        /// <param name="sfValueField">the name of the field that contains data</param>
        /// <param name="resultGridHeader">contains information about dimension of the new grid</param>
        /// <param name="callback">(optional) reports progress and error messages</param>
        /// <returns></returns>
        public bool ShapefileToGrid2(string SfNm, string GrdName,
            MapWinGIS.GridFileType GrdFileType, MapWinGIS.GridDataType GrdDataType,
            string Fldname, MapWinGIS.GridHeader GrdHd,
            MapWinGIS.ICallback cback)
        {
            int i;
            bool flg;
            string projStr;

            //open the shapefile
            MapWinGIS.Shapefile MySf = new MapWinGIS.Shapefile();
            flg = MySf.Open(SfNm, cback);
            if (flg == false)
            {
                reportError("ERROR in opening shapefile: " + SfNm, cback);
                MySf.Close();
                return false;
            }

            //get the handle for the field
            MapWinGIS.Field field;
            int FldId = -1;
            int LayFldNum = MySf.NumFields;

            i = 0;
            for (i = 0; i < LayFldNum; ++i)
            {
                field = MySf.get_Field(i);
                if (field.Name.ToLower() == Fldname.ToLower())
                {
                    FldId = i;
                    break;
                }
            }
            if (FldId < 0)
            {
                reportError("The shapefile " + SfNm + " doesn't have a field " + Fldname, cback);
                MySf.Close();
                return false;
            }

            //copy shapefile projection
            projStr = MySf.Projection;
            if (!MapWinUtility.Strings.IsEmpty(projStr))
            {
                GrdHd.Projection = projStr;
            }

            //create a new grid and a new gridheader
            MapWinGIS.Grid NewGrd = new MapWinGIS.Grid();
            flg = NewGrd.CreateNew(GrdName, GrdHd, GrdDataType, GrdHd.NodataValue, false, GrdFileType, cback);
            if (flg == false)
            {
                reportError("ERROR in grid initialization: " + GrdName, cback);
                NewGrd.Close();
                MySf.Close();
            }

            //verify the type of shapefile and call rasterization function
            MapWinGIS.ShpfileType SfType = new MapWinGIS.ShpfileType();
            SfType = MySf.ShapefileType;
            switch (SfType)
            {
                case ShpfileType.SHP_POLYGON:
                case ShpfileType.SHP_POLYGONM:
                case ShpfileType.SHP_POLYGONZ:
                    flg = Poly2Grid(MySf, FldId, NewGrd, GrdHd, GrdDataType, cback);
                    break;
                case ShpfileType.SHP_POLYLINE:
                case ShpfileType.SHP_POLYLINEM:
                case ShpfileType.SHP_POLYLINEZ:
                    flg = Line2Grid(MySf, FldId, NewGrd, GrdHd, GrdDataType, cback);
                    break;
                case ShpfileType.SHP_POINT:
                case ShpfileType.SHP_POINTM:
                case ShpfileType.SHP_POINTZ:
                    flg = Point2Grid(MySf, FldId, NewGrd, GrdHd, GrdDataType, cback);
                    break;
                case ShpfileType.SHP_MULTIPOINT:
                case ShpfileType.SHP_MULTIPOINTM:
                case ShpfileType.SHP_MULTIPOINTZ:
                    flg = Multipoint2Grid(MySf, FldId, NewGrd, GrdHd, GrdDataType, cback);
                    break;
                default:
                    reportError("The shapefile type " + SfType.ToString() + "is not supported.", cback);
                    NewGrd.Close();
                    MySf.Close();
                    flg = false;
                    break;
            }

            //save and close the grid, close shapefile
            NewGrd.Save(GrdName, GrdFileType, cback);
            NewGrd.Close();
            MySf.Close();
            return flg;
        }
示例#6
0
        /// <summary>
        /// 'Copyright (C) 2008  Enrico Antonio Chiaradia, UNIMI
        ///'This program is free software; you can redistribute it and/or
        ///'modify it under the terms of the GNU General Public License
        ///'version 2, 1991 as published by the Free Software Foundation.

        ///'This program is distributed in the hope that it will be useful,
        ///'but WITHOUT ANY WARRANTY; without even the implied warranty of
        ///'MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
        ///'GNU General Public License for more details.

        ///'A copy of the full GNU General Public License is available at:
        ///'http://www.gnu.org/copyleft/gpl.html
        ///'or from:
        ///'The Free Software Foundation, Inc., 59 Temple Place - Suite 330,
        ///'Boston, MA  02111-1307, USA.

        ///'If you wish to use or incorporate this program (or parts of it) into
        ///'other software that does not meet the GNU General Public License
        ///'conditions contact the author to request permission.

        ///'If you have any question or suggestion, please contact the author.

        ///'Enrico A. Chiaradia
        ///'University of Milan
        ///'Ist. di Idraulica Agraria
        ///'via Celoria 2
        ///'20133, Milan, Italy
        ///'email:  [email protected]
        /// </summary>
        /// <param name="sfPath">the name of the shapefile</param>
        /// <param name="resultGridPath">the name of the new grid</param>
        /// <param name="gridFileType">file type of the new grid</param>
        /// <param name="gridDataType">data format of the new grid</param>
        /// <param name="sfValueField">the name of the field that contains data</param>
        /// <param name="resultGridHeader">contains information about dimension of the new grid</param>
        /// <param name="callback">(optional) reports progress and error messages</param>
        /// <returns></returns>
        public bool ShapefileToGrid2(string SfNm, string GrdName,
                                     MapWinGIS.GridFileType GrdFileType, MapWinGIS.GridDataType GrdDataType,
                                     string Fldname, MapWinGIS.GridHeader GrdHd,
                                     MapWinGIS.ICallback cback)
        {
            int    i;
            bool   flg;
            string projStr;

            //open the shapefile
            MapWinGIS.Shapefile MySf = new MapWinGIS.Shapefile();
            flg = MySf.Open(SfNm, cback);
            if (flg == false)
            {
                reportError("ERROR in opening shapefile: " + SfNm, cback);
                MySf.Close();
                return(false);
            }

            //get the handle for the field
            MapWinGIS.Field field;
            int             FldId     = -1;
            int             LayFldNum = MySf.NumFields;

            i = 0;
            for (i = 0; i < LayFldNum; ++i)
            {
                field = MySf.get_Field(i);
                if (field.Name.ToLower() == Fldname.ToLower())
                {
                    FldId = i;
                    break;
                }
            }
            if (FldId < 0)
            {
                reportError("The shapefile " + SfNm + " doesn't have a field " + Fldname, cback);
                MySf.Close();
                return(false);
            }

            //copy shapefile projection
            projStr = MySf.Projection;
            if (!MapWinUtility.Strings.IsEmpty(projStr))
            {
                GrdHd.Projection = projStr;
            }

            //create a new grid and a new gridheader
            MapWinGIS.Grid NewGrd = new MapWinGIS.Grid();
            flg = NewGrd.CreateNew(GrdName, GrdHd, GrdDataType, GrdHd.NodataValue, false, GrdFileType, cback);
            if (flg == false)
            {
                reportError("ERROR in grid initialization: " + GrdName, cback);
                NewGrd.Close();
                MySf.Close();
            }

            //verify the type of shapefile and call rasterization function
            MapWinGIS.ShpfileType SfType = new MapWinGIS.ShpfileType();
            SfType = MySf.ShapefileType;
            switch (SfType)
            {
            case ShpfileType.SHP_POLYGON:
            case ShpfileType.SHP_POLYGONM:
            case ShpfileType.SHP_POLYGONZ:
                flg = Poly2Grid(MySf, FldId, NewGrd, GrdHd, GrdDataType, cback);
                break;

            case ShpfileType.SHP_POLYLINE:
            case ShpfileType.SHP_POLYLINEM:
            case ShpfileType.SHP_POLYLINEZ:
                flg = Line2Grid(MySf, FldId, NewGrd, GrdHd, GrdDataType, cback);
                break;

            case ShpfileType.SHP_POINT:
            case ShpfileType.SHP_POINTM:
            case ShpfileType.SHP_POINTZ:
                flg = Point2Grid(MySf, FldId, NewGrd, GrdHd, GrdDataType, cback);
                break;

            case ShpfileType.SHP_MULTIPOINT:
            case ShpfileType.SHP_MULTIPOINTM:
            case ShpfileType.SHP_MULTIPOINTZ:
                flg = Multipoint2Grid(MySf, FldId, NewGrd, GrdHd, GrdDataType, cback);
                break;

            default:
                reportError("The shapefile type " + SfType.ToString() + "is not supported.", cback);
                NewGrd.Close();
                MySf.Close();
                flg = false;
                break;
            }

            //save and close the grid, close shapefile
            NewGrd.Save(GrdName, GrdFileType, cback);
            NewGrd.Close();
            MySf.Close();
            return(flg);
        }