示例#1
0
        public bool QueryInter(string srcLayerName, string tgtLayerName, IMap iMap, esriSpatialRelationEnum spatialRel)
        {
            DataOperator   dataOperator = new DataOperator(iMap);
            IFeatureLayer  iSrcLayer    = (IFeatureLayer)dataOperator.GetLayerByName(srcLayerName);
            IFeatureLayer  iTgtLayer    = (IFeatureLayer)dataOperator.GetLayerByName(tgtLayerName);
            IGeometry      geom;
            IFeature       feature;
            IFeatureCursor featureCursor;
            IFeatureClass  srcFeatClass;
            IQueryFilter   queryFilter = new QueryFilter();

            queryFilter.WhereClause = "CONTINENT='Asia'";
            featureCursor           = iTgtLayer.FeatureClass.Search(queryFilter, false);
            feature      = featureCursor.NextFeature();
            geom         = feature.Shape;
            srcFeatClass = iSrcLayer.FeatureClass;
            ISpatialFilter spatialFilter = new SpatialFilter();

            spatialFilter.Geometry    = geom;
            spatialFilter.WhereClause = "POPULATION=1060000";
            spatialFilter.SpatialRel  = (esriSpatialRelEnum)spatialRel;
            IFeatureSelection featureSelect = (IFeatureSelection)iSrcLayer;

            featureSelect.SelectFeatures(spatialFilter, esriSelectionResultEnum.esriSelectionResultNew, false);
            return(true);
        }
示例#2
0
        private void miAccessData_Click(object sender, EventArgs e)
        {
            DataOperator dataOperator = new DataOperator(axMapControl1.Map);
            DataBoard    dataBoard    = new DataBoard("", dataOperator.GetContinentsNames());

            dataBoard.Show();
        }
示例#3
0
        public string Statistic(string layerName, string fieldName, IMap iMap)
        {
            DataOperator    dataOperator   = new DataOperator(iMap);
            IFeatureLayer   featLayer      = (IFeatureLayer)dataOperator.GetLayerByName(layerName);
            IFeatureClass   featClass      = featLayer.FeatureClass;
            IDataStatistics dataStatistics = new DataStatistics();
            IFeatureCursor  featCursor;

            featCursor = featClass.Search(null, false);
            ICursor cursor = (ICursor)featCursor;

            dataStatistics.Cursor = cursor;
            dataStatistics.Field  = fieldName;
            IStatisticsResults statResult;

            statResult = dataStatistics.Statistics;
            // double dMax;
            // double dMin;
            // double dMean;
            string sResult = "最大面积为:" + statResult.Maximum.ToString()
                             + "\n最小面积为:" + statResult.Minimum.ToString()
                             + "\n平均面积为:" + statResult.Mean.ToString();

            return(sResult);
        }
示例#4
0
        public bool Buffer(string layerName, string sWhere, int iSize, IMap iMap)
        {
            IFeatureClass      featClass;
            IFeature           feature;
            IGeometry          iGeom;
            DataOperator       dataOperator      = new DataOperator(iMap);
            IFeatureLayer      featLayer         = (IFeatureLayer)dataOperator.GetLayerByName(layerName);
            IGraphicsContainer graphicsContainer = (IGraphicsContainer)iMap;

            graphicsContainer.DeleteAllElements();
            featClass = featLayer.FeatureClass;
            IQueryFilter queryFilter = new QueryFilter();

            queryFilter.WhereClause = sWhere;
            IFeatureCursor featCursor;

            featCursor = (IFeatureCursor)featClass.Search(queryFilter, false);
            int count = featClass.FeatureCount(queryFilter);

            feature = featCursor.NextFeature();
            iGeom   = feature.Shape;
            IElement             element = new PolygonElementClass();
            ITopologicalOperator ipTO    = (ITopologicalOperator)iGeom;

            element.Geometry = ipTO.Buffer(iSize);
            graphicsContainer.AddElement(element, 0);
            return(true);
        }
示例#5
0
        private void miGetRenderInfo_Click(object sender, EventArgs e)
        {
            miRenderSimply.Enabled = true;
            DataOperator dataOperator = new DataOperator(axMapControl1.Map);
            ILayer       layer        = dataOperator.GetLayerByName("cities");

            MessageBox.Show(MapComposer.GetRendererTypeByLayer(layer));
        }
示例#6
0
 private void axMapControl1_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e)
 {
     if (miAddFeature.Checked == true)
     {
         IPoint point = new PointClass();
         point.PutCoords(e.mapX, e.mapY);
         DataOperator dataOperator = new DataOperator(axMapControl1.Map);
         dataOperator.AddFeatureToLayer("Observation Stations", "观测站", point);
     }
     return;
 }
示例#7
0
        private void miCreatShapefile_Click(object sender, EventArgs e)
        {
            DataOperator  dataOperator = new DataOperator(axMapControl1.Map);
            IFeatureClass featureClass = dataOperator.CreateShapefile("F:\\ProjectFiles\\GIS\\MapControlApplication111", "ShapefileWorkSpace", "ShapefileSample");

            if (featureClass == null)
            {
                MessageBox.Show("创建Shape文件失败");
                return;
            }
            bool bRes = dataOperator.AddFeatureClassToMap(featureClass, "Observation Stations");

            if (bRes)
            {
                miCreateShapefile.Enabled = false;
                miAddFeature.Enabled      = true;
                return;
            }
            else
            {
                MessageBox.Show("将新建的Shape文件加入地图失败");
            }
        }
示例#8
0
        private void miRenderSimply_Click(object sender, EventArgs e)
        {
            DataOperator dataOperator = new DataOperator(axMapControl1.Map);
            ILayer       layer        = dataOperator.GetLayerByName("cities");
            IRgbColor    rgbColor     = new RgbColorClass();

            rgbColor.Red   = 240;
            rgbColor.Green = 0;
            rgbColor.Blue  = 86;

            IColor color = rgbColor as IColor;
            bool   bRes  = MapComposer.RenderSimply(layer, color);

            if (bRes)
            {
                axTOCControl1.ActiveView.ContentsChanged();
                axMapControl1.ActiveView.Refresh();
                miRenderSimply.Enabled = false;
            }
            else
            {
                MessageBox.Show("简单图层渲染");
            }
        }