Exemplo n.º 1
0
        /// <summary>
        /// 暂时保存编辑内容,将正在编辑的要素保存到原有要素,并计算地理坐标
        /// </summary>
        public void TmpSaveEdit()
        {
            if (_IsEditing)
            {
                if (_EditingLayer.GeoType == typeof(PointD))
                {
                    foreach (DataRow sRow in _EditingLayer.EditingRecord)
                    {
                        if (!Convert.IsDBNull(sRow[2]))
                        {
                            sRow[1] = _PrjSystem.ToLngLat((PointD)sRow[2]);
                            sRow[3] = ((PointD)sRow[2]).Clone();
                        }
                        else
                        {
                            sRow[1] = null;
                        }
                    }
                }
                else if (_EditingLayer.GeoType == typeof(MultiPolyLine))
                {
                    foreach (DataRow sRow in _EditingLayer.EditingRecord)
                    {
                        if (!Convert.IsDBNull(sRow[2]))
                        {
                            sRow[1] = _PrjSystem.ToLngLat((MultiPolyLine)sRow[2]);
                            sRow[3] = LayerTools.GetCenterPoint((MultiPolyLine)sRow[2]);
                        }
                        else
                        {
                            sRow[1] = null;
                        }
                    }
                }
                else if (_EditingLayer.GeoType == typeof(MultiPolygon))
                {
                    foreach (DataRow sRow in _EditingLayer.EditingRecord)
                    {
                        if (!Convert.IsDBNull(sRow[2]))
                        {
                            sRow[1] = _PrjSystem.ToLngLat((MultiPolygon)sRow[2]);
                            sRow[3] = LayerTools.GetCenterPoint((MultiPolygon)sRow[2]);
                        }
                        else
                        {
                            sRow[1] = null;
                        }
                    }
                }

                _EditingLayer.EditingRecord.Clear();
            }
        }
Exemplo n.º 2
0
 public void AddGeometry(Layer layer, List <Geometry> gList, Type geoType)
 {
     if (_IsEditing && !layer.ReadOnly)
     {
         if (gList != null && geoType == layer.GeoType)
         {
             foreach (Geometry geo in gList)
             {
                 layer.Records.Rows.Add(null, geo, _PrjSystem.ToProjCo(geo), LayerTools.GetCenterPoint(geo));
             }
         }
     }
 }
Exemplo n.º 3
0
        //投影信息改变了
        private void _PrjSystem_ProjectedSystemChanged(object sender)
        {
            foreach (Layer sLayer in _Layers)
            {
                //计算投影
                bool sRead = sLayer.ReadOnly;
                sLayer.ReadOnly = false;
                if (sLayer.GeoType == typeof(PointD))
                {
                    PointD sPoint;
                    foreach (DataRow mRow in sLayer.Records.Rows)
                    {
                        sPoint = mRow.Field <PointD>(1);
                        if (sPoint != null)
                        {
                            mRow[2] = _PrjSystem.ToProjCo(sPoint);
                        }
                    }
                }
                else if (sLayer.GeoType == typeof(MultiPolyLine))
                {
                    MultiPolyLine sMultiPolyLine;
                    foreach (DataRow mRow in sLayer.Records.Rows)
                    {
                        sMultiPolyLine = mRow.Field <MultiPolyLine>(1);
                        if (sMultiPolyLine != null)
                        {
                            mRow[2] = _PrjSystem.ToProjCo(sMultiPolyLine);
                        }
                    }
                }
                else if (sLayer.GeoType == typeof(MultiPolygon))
                {
                    MultiPolygon sMultiPolygon;
                    foreach (DataRow mRow in sLayer.Records.Rows)
                    {
                        sMultiPolygon = mRow.Field <MultiPolygon>(1);
                        if (sMultiPolygon != null)
                        {
                            mRow[2] = _PrjSystem.ToProjCo(sMultiPolygon);
                        }
                    }
                }

                Geometry sGeo;
                foreach (DataRow mRow in sLayer.Records.Rows)
                {
                    if (!Convert.IsDBNull(mRow[2]))
                    {
                        sGeo    = (Geometry)mRow[2];
                        mRow[3] = LayerTools.GetCenterPoint(sGeo);
                    }
                }

                sLayer.MBR    = LayerTools.GetLayerGeoMBR(sLayer);
                sLayer.PRJMBR = _PrjSystem.ToProjCo(sLayer.MBR);
                sLayer.Records.AcceptChanges();     //保存更改
                sLayer.GenerateIndex();             //计算地理索引
                MapPerformaceChanged?.Invoke(this); //重绘一级地图
                sLayer.ReadOnly = sRead;
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// 添加图层
        /// </summary>
        /// <param name="layer">图层</param>
        public void AddLayer(Layer layer)
        {
            //计算投影
            if (layer.GeoType == typeof(PointD))
            {
                PointD sPoint;
                foreach (DataRow mRow in layer.Records.Rows)
                {
                    sPoint = mRow.Field <PointD>(1);
                    if (sPoint != null)
                    {
                        mRow[2] = _PrjSystem.ToProjCo(sPoint);
                    }
                }
            }
            else if (layer.GeoType == typeof(MultiPolyLine))
            {
                MultiPolyLine sMultiPolyLine;
                foreach (DataRow mRow in layer.Records.Rows)
                {
                    sMultiPolyLine = mRow.Field <MultiPolyLine>(1);
                    if (sMultiPolyLine != null)
                    {
                        mRow[2] = _PrjSystem.ToProjCo(sMultiPolyLine);
                    }
                }
            }
            else if (layer.GeoType == typeof(MultiPolygon))
            {
                MultiPolygon sMultiPolygon;
                foreach (DataRow mRow in layer.Records.Rows)
                {
                    sMultiPolygon = mRow.Field <MultiPolygon>(1);
                    if (sMultiPolygon != null)
                    {
                        mRow[2] = _PrjSystem.ToProjCo(sMultiPolygon);
                    }
                }
            }

            Geometry sGeo;

            foreach (DataRow mRow in layer.Records.Rows)
            {
                if (!Convert.IsDBNull(mRow[2]))
                {
                    sGeo    = (Geometry)mRow[2];
                    mRow[3] = LayerTools.GetCenterPoint(sGeo);
                }
            }
            if (layer.MBR == null)
            {
                layer.MBR = LayerTools.GetLayerGeoMBR(layer);
            }

            layer.PRJMBR = _PrjSystem.ToProjCo(layer.MBR);
            layer.Records.AcceptChanges(); //保存更改
            layer.GenerateIndex();         //计算地理索引

            //将地图数据锁住,不允许修改
            layer.ReadOnly = true;


            layer.VisiblityChanged += Layer_VisiblityChanged;
            layer.SymbolChanged    += Layer_SymbolChanged;
            layer.RecordsChanged   += Layer_RecordsChanged;

            _Layers.Insert(0, layer);
            if (_DataSet.Tables.Contains(layer.Name))
            {
                layer.Name += "_";
            }
            _DataSet.Tables.Add(layer.Records);
            _TreeNode.Nodes.Insert(0, layer.Node);

            LayerAdded?.Invoke(this, layer);    //通知外部已经添加了图层
            MapPerformaceChanged?.Invoke(this); //重绘一级地图
        }