Exemplo n.º 1
0
        protected override void OnMouseDown(GeoMouseArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                _isEnabled    = false;
                _currentPoint = e.Location;
                int x = _currentPoint.X;
                int y = _currentPoint.Y;
                System.Drawing.Point point = new System.Drawing.Point(x, y);
                _points           = point;
                _coordinatePoints = this._map.PixelToProj(new System.Drawing.Point(_points.X, _points.Y));

                IMapPointLayer pointLayer = GetPointLayer();
                _point = new NetTopologySuite.Geometries.Point(_coordinatePoints);
                pointLayer.DataSet.AddFeature(_point as IGeometry);

                _map.Refresh();
                _isEnabled = true;
            }
            else if (e.Button == MouseButtons.Right)
            {
                this.Enabled = false;
                string bufferType  = "PointBuffer";
                Buffer pointBuffer = new Buffer(bufferType);
                pointBuffer.ShowDialog();
                _map.FunctionMode = FunctionMode.Pan;
            }

            base.OnMouseDown(e);
        }
Exemplo n.º 2
0
        private void CategorizeCitiesByAlgorithm(IMapPointLayer alayer)
        {
            /*
             * There are a large number of settings that can be controlled directly using the PointScheme.
             * In this illustration the classification type is quantities, but this can also be
             * UniqueValues or custom.
             * The categories can always be edited programmatically after they are created, but this
             * simply controls what will happen when the CreateCategories method is ultimately called.
             * The interval snap methods include none, rounding, significant figures, and snapping to the
             * nearest value. These can help the appearance of the categories in the legend,
             * but it can also cause trouble. With Significant figures, the IntervalRoundingDigits controls the
             * number of significant figures instead.
             * One property is deceptive in its power.
             * The TemplateSymbolizer property allows you to control the basic appearance of the categories for
             * any property that is not being controlled by either the size or color ramping.
             * For example, if we wanted to add black borders to the stars above, we would simply add that
             * to the template symbolizer. In this case we chose to make them appear as stars and controlled
             * them to have equal sizes since UseSizeRange defaults to false, but UseColorRange defaults to true.
             */
            PointScheme lScheme = new PointScheme();

            lScheme.Categories.Clear();
            lScheme.EditorSettings.ClassificationType     = ClassificationType.Quantities;
            lScheme.EditorSettings.IntervalMethod         = IntervalMethod.EqualInterval;
            lScheme.EditorSettings.IntervalSnapMethod     = IntervalSnapMethod.Rounding;
            lScheme.EditorSettings.IntervalRoundingDigits = 5;
            lScheme.EditorSettings.TemplateSymbolizer     = new PointSymbolizer(Color.Yellow, DotSpatial.Symbology.PointShape.Star, 16);
            lScheme.EditorSettings.FieldName = "Area";
            lScheme.CreateCategories(alayer.DataSet.DataTable);
            alayer.Symbology = lScheme;
        }
 public SnapPourPoint(IMapPointLayer InputPoint, IRaster InputAccumulation, IRaster InputSurface, double InputRadius, string InputSave, IRaster InputResult, IRaster InputLabel, IMap InputMap)
 {
     pointLayer   = InputPoint;
     Accumulation = InputAccumulation;
     Surface      = InputSurface;
     Radius       = InputRadius;
     savePath     = InputSave;
     Result       = InputResult;
     Label        = InputLabel;
     MainMap      = InputMap;
 }
Exemplo n.º 4
0
        /// <summary>
        /// Populate the variables available from the selected site
        /// layer, the polygon layer, and the selected polygons in
        /// the map within this layer.
        /// </summary>
        private void populateVariables()
        {
            polygonData.Clear();

            foreach (IFeature polygon in polygons.Features)
            {
                PolygonData data = new PolygonData();
                data.polygon = polygon;

                IMapPointLayer pointLayer = ((KeyValuePair <IMapPointLayer, string>)SiteList.SelectedItem).Key;
                var            features   = pointLayer.DataSet.Features;

                foreach (IFeature point in features)
                {
                    if (point.Intersects(polygon))
                    {
                        SiteData siteData = new SiteData();
                        siteData.site = point;

                        foreach (var fld in point.ParentFeatureSet.GetColumns())
                        {
                            var getColumnValue = (Func <string, string>)(column => (point.DataRow[column].ToString()));
                            var strValue       = getColumnValue(fld.ColumnName);

                            switch (fld.ColumnName)
                            {
                            case "SiteCode":
                                siteData.siteCode = strValue;
                                break;

                            case "VarCode":
                                siteData.variableCode = strValue;
                                break;

                            case "VarName":
                                siteData.variableName = strValue;
                                break;
                            }
                        }

                        data.sites.Add(siteData);
                        variables.Add(siteData.variableName);
                    }
                }

                polygonData.Add(data);
            }

            if (variables.Count > 0)
            {
                VariableList.DataSource = new BindingSource(variables, null);
            }
        }
Exemplo n.º 5
0
        private void comboBox1_SelectedValueChanged(object sender, EventArgs e)
        {
            string         cv         = comboBox1.Text;
            IMapPointLayer pointlayer = null;
            List <string>  column     = new List <string>();

            if (flag == true)
            {
                pointlayer = file_layer[cv];
            }
            if (pointlayer == null)
            {
                foreach (IMapPointLayer l in ipl)
                {
                    if (l.LegendText == cv)
                    {
                        pointlayer = l;
                    }
                }
            }
            if (pointlayer != null)
            {
                /*FeatureSet fs = new FeatureSet(FeatureType.Point);
                 * fs = layer as FeatureSet;
                 * for(int i = 0; i < fs.DataTable.Columns.Count; i++)
                 * {
                 *  column.Add(fs.DataTable.Columns[i].ColumnName.ToString());
                 * }*///为空,错误

                IFeatureLayer fl = pointlayer as IFeatureLayer;
                //fl.ShowAttributes();
                //column = fl.DataSet.GetColumnNames;
                //IFeatureSet featureSet = new FeatureSet();
                ifeatureset = pointlayer.DataSet;
                DataTable dt = pointlayer.DataSet.DataTable;
                for (int i = 0; i < dt.Columns.Count; i++)
                {
                    column.Add(dt.Columns[i].ColumnName.ToString());
                }
            }
            //Console.WriteLine("column_count:"+column.Count);
            //comboBox2.Items.Add("xxxx");
            foreach (string s in column)
            {
                comboBox2.Items.Add(s);
            }
            //comboBox2.Items.Add("adasdad");
            if (comboBox2.Items.Count > 0)
            {
                comboBox2.SelectedIndex = 0;
            }
        }
        //Convert point to pixel
        private RcIndex Point_to_Raster(IMapPointLayer point, IRaster ExecuteRaster)
        {
            IFeatureSet featureSet = point.DataSet;

            if (featureSet.Features.Count > 1 || featureSet.Features.Count <= 0)
            {
                //只能有一个点,不能没有点
                MessageBox.Show("The point is invalid!", "Admin", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return(new RcIndex(-9999, -9999));
            }
            Coordinate coor = featureSet.Features[0].Geometry.Coordinates[0]; //获取点要素的坐标
            RcIndex    rc   = ExecuteRaster.Bounds.ProjToCell(coor);          //获取点要素对应的栅格坐标

            return(rc);
        }
Exemplo n.º 7
0
 private void pointBuffer()
 {
     foreach (ILayer item in _map.MapFrame.DrawingLayers)
     {
         if (item.LegendText == "Point")
         {
             IMapPointLayer pointLayer = item as IMapPointLayer;
             ILayer         layer      = bufferLayer();
             for (int i = 0; i < pointLayer.DataSet.Features.Count; i++)
             {
                 (layer as IMapPolygonLayer).DataSet.AddFeature(pointLayer.DataSet.Features[i].Geometry.Buffer(_distance));
             }
             _map.Refresh();
             break;
         }
     }
 }
Exemplo n.º 8
0
        private void MakeComplexSymbol(IMapPointLayer alayer)
        {   //Objective: Yellow stars in a Blue Circle
            /*
             * Complex symbols can be created, simply by adding symbols to the Symbolizer.Symbols list.
             * There are three basic kinds of symbols, Simple, Character and Image based.
             * These have some common characteristics, like the Angle, Offset and Size,
             * which are stored on the base class.
             * In the derived classes, the characteristics that are specific to the sub‐class control
             * those aspects of symbology.
             * For creating new symbols, the Subclass can be used.
             * For working with individual symbols in the collection, you may need to test what type of
             * symbol you are working with before you will be able to control its properties.
             */
            PointSymbolizer lPS = new PointSymbolizer(Color.Blue, DotSpatial.Symbology.PointShape.Ellipse, 16);

            lPS.Symbols.Add(new SimpleSymbol(Color.Yellow, DotSpatial.Symbology.PointShape.Star, 10));
            alayer.Symbolizer = lPS;
        }
Exemplo n.º 9
0
        private void CategorizeCities(IMapPointLayer alayer)
        {
            PointScheme lScheme = new PointScheme();

            lScheme.Categories.Clear();
            PointCategory smallSize = new PointCategory(Color.Blue, DotSpatial.Symbology.PointShape.Rectangle, 4);

            smallSize.FilterExpression = "[Area] < 1e+08";
            smallSize.LegendText       = "Small Cities";
            lScheme.AddCategory(smallSize);

            PointCategory largeSize = new PointCategory(Color.Yellow, DotSpatial.Symbology.PointShape.Star, 16);

            largeSize.FilterExpression = "[Area] >= 1e+08";
            largeSize.LegendText       = "Large Cities";
            lScheme.AddCategory(largeSize);

            alayer.Symbology = lScheme;
        }
Exemplo n.º 10
0
        //public bool PointCanIn
        //{
        //    get;
        //    set;
        //}

        #endregion

        #region Method

        protected IMapPointLayer GetPointLayer()
        {
            IMapPointLayer pointLayer = null;

            foreach (ILayer item in this._map.MapFrame.DrawingLayers)
            {
                if (item.LegendText == "Point")
                {
                    pointLayer = item as IMapPointLayer;
                    break;
                }
            }
            if (pointLayer == null)
            {
                pointLayer            = new MapPointLayer();
                pointLayer.LegendText = "Point";
                pointLayer.Symbolizer = GIS.FrameWork.ROIConfigure.pointSymbolizer;
                this._map.MapFrame.DrawingLayers.Add(pointLayer);
            }
            return(pointLayer);
        }
Exemplo n.º 11
0
        private void comboBox1_SelectedValueChanged(object sender, EventArgs e)
        {
            string         cv         = comboBox1.Text;
            IMapPointLayer pointlayer = null;

            //List<string> column = new List<string>();
            if (flag == true)
            {
                pointlayer = file_layer[cv];
            }
            if (pointlayer == null)
            {
                foreach (IMapPointLayer l in ipl)
                {
                    if (l.LegendText == cv)
                    {
                        pointlayer = l;
                    }
                }
            }
            if (pointlayer != null && flag == false)
            {
                ifeatureset = pointlayer.DataSet;

                /*IFeatureLayer fl = pointlayer as IFeatureLayer;
                 * //fl.ShowAttributes();
                 * //column = fl.DataSet.GetColumnNames;
                 * //IFeatureSet featureSet = new FeatureSet();
                 * ifeatureset = pointlayer.DataSet;
                 * DataTable dt = pointlayer.DataSet.DataTable;
                 * for (int i = 0; i < dt.Columns.Count; i++)
                 * {
                 *  column.Add(dt.Columns[i].ColumnName.ToString());
                 * }*/
                comboBox6.Items.Add("已选定。");
                comboBox5.Items.Add("已选定。");
                comboBox6.SelectedIndex = 0;
                comboBox5.SelectedIndex = 0;
            }
        }