Example #1
0
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            IWindowsFormsEditorService edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));

            if (edSvc != null)
            {
                OpenFileDialog dlg = new OpenFileDialog();
                dlg.Filter = "ESRI Prj File(*.prj)|*.prj";
                if (dlg.ShowDialog() == DialogResult.OK)
                {
                    ISpatialReference sf = SpatialReferenceFactory.GetSpatialReferenceByPrjFile(dlg.FileName);
                    if (sf == null)
                    {
                        MsgBox.ShowInfo("文件\"" + dlg.FileName + "\"不是标准的OGC WKT空间参考描述格式。");
                        return(value);
                    }
                    if (sf.ProjectionCoordSystem == null)
                    {
                        MsgBox.ShowInfo("您只能选择投影坐标系统。");
                        return(value);
                    }
                    MsgBox.ShowInfo("空间参考设置成功。\n要想生效请先保存地图配置文件(*.mcd),然后重新打开。");
                    return(sf);
                }
            }
            return(value);
        }
Example #2
0
        protected override void Init()
        {
            if (_reader == null)
            {
                BeginRead();
            }
            string prjFile = Path.Combine(Path.GetDirectoryName(_fileUrl),
                                          Path.GetFileNameWithoutExtension(_fileUrl) + ".prj");

            try
            {
                _spatialRef = SpatialReferenceFactory.GetSpatialReferenceByPrjFile(prjFile);
            }
            catch (Exception ex)
            {
                Log.WriterException(ex);
            }
            _fullEnvelope = _reader.Envelope.Clone() as Envelope;
            AdjustZeroWidthEnvelope(_fullEnvelope);
            _shapeType          = _reader.ShapeType;
            _coordType          = _spatialRef != null && _spatialRef.ProjectionCoordSystem != null ? enumCoordinateType.Projection : enumCoordinateType.Geographic;
            _gridStateIndicator = new GridStateIndicator(_fullEnvelope.Clone() as Envelope, _gridDefinition);
            _fullGridCount      = _gridStateIndicator.Width * _gridStateIndicator.Height;
            _fields             = _reader.Fields;
            _isInited           = true;
        }
 private void ParseProjectionInfo(string prjFile)
 {
     try
     {
         _spatialReference = SpatialReferenceFactory.GetSpatialReferenceByPrjFile(prjFile);
     }
     catch (Exception ex)
     {
         Log.WriterException("ShapeFileReader", "ParseProjectionInfo", ex);
     }
 }