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;
        }
Example #3
0
        public RstReader(string filename)
        {
            _geoImage = IGeoImage.GeoOpen(filename);
            GeoImage g = _geoImage as GeoImage;

            _fullEnvelope      = new Envelope(g.MinX, g.MinY, g.MaxX, g.MaxY);
            _coordType         = g.IsProjected ? enumCoordinateType.Projection : enumCoordinateType.Geographic;
            _sref              = SpatialReferenceFactory.GetSpatialReferenceByWKT(g.ProjectDescription, enumWKTSource.GDAL);
            _byteCountPerPixel = GetBandCount(_geoImage.DataType);
        }
Example #4
0
        public FeatureSplitterByProjection(string spatialRef)
        {
            ISpatialReference spRef = SpatialReferenceFactory.GetSpatialReferenceByWKT(spatialRef, enumWKTSource.EsriPrjFile);

            if (spRef != null)
            {
                _computer    = new SplitRangesComputer(spRef);
                _isNeedSplit = _computer.ComputeValidGeoRange(out _centerLont, out _minLat, out _maxLat, out _minLon, out _maxLon);
            }
        }
 private void ParseProjectionInfo(string prjFile)
 {
     try
     {
         _spatialReference = SpatialReferenceFactory.GetSpatialReferenceByPrjFile(prjFile);
     }
     catch (Exception ex)
     {
         Log.WriterException("ShapeFileReader", "ParseProjectionInfo", ex);
     }
 }
Example #6
0
        public static MapArguments FromXElement(XElement ele)
        {
            if (ele == null)
            {
                return(null);
            }
            MapArguments arg = new MapArguments();

            arg.BackColor = ColorHelper.StringToColor(ele.Attribute("backcolor").Value);
            if (ele.Element("FullExtent") != null)
            {
                arg.FullExtent = XElementToEnvelope(ele.Element("FullExtent"));
            }
            if (ele.Element("Extent") != null)
            {
                arg.Extent = XElementToEnvelope(ele.Element("Extent"));
            }
            if (ele.Attribute("smoothingmode") != null)
            {
                string        sm    = ele.Attribute("smoothingmode").Value;
                SmoothingMode smode = SmoothingMode.Default;
                foreach (SmoothingMode s in Enum.GetValues(typeof(SmoothingMode)))
                {
                    if (s.ToString() == sm)
                    {
                        smode = s;
                        break;
                    }
                }
                arg.SmoothingMode = smode;
            }
            if (ele.Attribute("spatialreference") != null)
            {
                try
                {
                    string sf = ele.Attribute("spatialreference").Value;
                    arg._targetSpatialReference = SpatialReferenceFactory.GetSpatialReferenceByWKT(sf, enumWKTSource.EsriPrjFile);
                }
                catch (Exception ex)
                {
                    Log.WriterException(ex);
                }
            }
            return(arg);
        }