Beispiel #1
0
 public static ShapeType SetLayerInfo(Layer p_Layer, string p_FileName, string p_LayerNid)
 {
     ShapeInfo _ShapeInfo;
     System.IO.FileStream _IO = new System.IO.FileStream(p_FileName, FileMode.Open);
        // XmlSerializer _SRZFrmt = new XmlSerializer();
     XmlSerializer _SRZFrmt = new XmlSerializer(typeof(ShapeInfo));
     _ShapeInfo = (ShapeInfo)_SRZFrmt.Deserialize(_IO);
     _IO.Flush();
     _IO.Close();
     {
         if (p_LayerNid.Length > 0)
             p_Layer.ID = p_LayerNid;
         p_Layer.SourceType = _ShapeInfo.m_SourceType;
         p_Layer.Extent = _ShapeInfo.m_Extent;
         p_Layer.RecordCount = _ShapeInfo.m_RecordCount;
         //.LayerType = _ShapeInfo.m_ShapeType
         p_Layer.Records = _ShapeInfo.m_Records;
     }
     return _ShapeInfo.m_ShapeType;
 }
Beispiel #2
0
        public Layer[] this[DateTime p_Date]
        {
            get
            {
                Layer[] _Layers = null;

                foreach (Layer _layer in List)
                {
                    switch (_layer.LayerType)
                    {
                        case ShapeType.PointCustom:
                        case ShapeType.PolygonCustom:
                        case ShapeType.PolygonBuffer:
                        case ShapeType.PolyLineCustom:
                            break;
                        //Nothing to add
                        default:
                            if (_layer.StartDate <= p_Date && _layer.EndDate >= p_Date)
                            {
                                if ((_Layers == null))
                                {
                                    _Layers = new Layer[1];
                                }
                                else
                                {
                                    Layer[] _LayersTemp = new Layer[_Layers.Length + 1]; // ReDimStatement Not supported in C#, so _Layers[] are copied into Temp Array, then Temp array elements are copied back into original Array.
                                    Array.Copy(_Layers, _LayersTemp, _Layers.Length);
                                    _Layers = _LayersTemp;     //_Temp Aarray elememts are copied back into _layers[]
                                }
                                _Layers[_Layers.Length - 1] = _layer;
                            }

                            break;
                    }
                }
                return _Layers;
            }
        }
Beispiel #3
0
        private void ApplyDIBLayerSetting(Layer dibLayer, DIBSettings DIBSettingsObject)
        {
            try
            {
                if (dibLayer != null && DIBSettingsObject != null)
                {
                    DIBLayerSetting setting = DIBSettingsObject.GetDIBLayerSetting(dibLayer.LayerName);

                    if (setting != null)
                    {
                        dibLayer.FillColor = setting.FillColor;
                        dibLayer.FillStyle = setting.FillStyle;
                        dibLayer.BorderColor = setting.BorderColor;
                        dibLayer.BorderStyle = setting.BorderStyle;
                        dibLayer.BorderSize = setting.BorderWidth;
                    }
                }
            }
            catch
            {
            }
        }
Beispiel #4
0
        public string GetLabel(Layer _Layer, ref Shape _Shape, ref Theme _Theme, CustomLabel _CustomLabel, ref Legend _Legend)
        {
            int i;
            int j;
            string Label = "";
            //*** BugFix 06 Feb 2006 No label field selected
            string Delimiter = " ";
            int IndentSpace = 3;
            char[] Fields;
            bool Indented;

            if ((_Theme == null))
            {
                //*** Custom and Feature Layers
                if (_CustomLabel == null)
                {
                    if (_Layer.LabelMultirow == true)
                        Delimiter = "\r\n";  //initially it was: ControlChars.CrLf (line feed)
                    Fields = _Layer.LabelField.Replace(",", "").ToCharArray();
                }
                else
                {
                    if (_CustomLabel.MultiRow == true)
                        Delimiter = "\r\n";  //initially it was: ControlChars.CrLf (line feed)
                    Fields = _CustomLabel.LabelField.Replace(",", "").ToCharArray();
                }

                if (Array.IndexOf(Fields, "0"[0]) > -1)
                    Label = _Shape.AreaId + Delimiter;
                if (Array.IndexOf(Fields, char.Parse("1")) > -1)
                {
                    if (_Layer.LabelMultirow == true)
                    {
                        if (Label == "")
                        {
                            Label += _Shape.AreaName;
                        }
                        else
                        {
                            if (_Layer.LabelIndented == true)
                                Label += new string(' ', IndentSpace);
                            Label += _Shape.AreaName;
                        }
                    }
                    else
                    {
                        Label += _Shape.AreaName;
                    }
                }
            }
            else
            {
                //*** Base Layers
                if (_CustomLabel == null)
                {
                    if (_Legend == null)
                    {
                        if (_Layer.LabelMultirow == true)
                            Delimiter = "\r\n";  //initially it was: ControlChars.CrLf (line feed)
                        Fields = _Layer.LabelField.Replace(",", "").ToCharArray();
                        Indented = _Layer.LabelIndented;
                    }
                    else
                    {
                        if (_Legend.LabelMultiRow == true)
                            Delimiter = "\r\n";  //initially it was: ControlChars.CrLf (line feed)
                        Fields = _Legend.LabelField.Replace(",", "").ToCharArray();
                        Indented = _Legend.LabelIndented;
                    }
                }
                else
                {
                    if (_CustomLabel.MultiRow == true)
                        Delimiter = "\r\n";  //initially it was: ControlChars.CrLf (line feed)
                    Fields = _CustomLabel.LabelField.Replace(",", "").ToCharArray();
                    Indented = _CustomLabel.Indent;
                }
                if (_Theme.AreaIndexes.ContainsKey(_Shape.AreaId))
                {
                    j = 0;
                    for (i = 0; i <= Fields.Length - 1; i++)
                    {
                        switch (Fields[i])
                        {
                            case '0':
                                Label += _Shape.AreaId + Delimiter;
                                j = j + 1;
                                break;
                            case '1':
                                if (Indented == true)
                                    Label += new string(' ', j * IndentSpace);

                                Label += ((AreaInfo)_Theme.AreaIndexes[_Shape.AreaId]).AreaName + Delimiter;
                                j = j + 1;
                                break;
                            case '2':
                                if (Indented == true)
                                    Label += new string(' ', j * IndentSpace);

                                //Label += ((AreaInfo)_Theme.AreaIndexes[_Shape.AreaId]).DataValue + Delimiter;
                                //Textual dataValue is also displayed on Map Label, so property AreaInfo.DisplayInfo is used.
                                Label += ((AreaInfo)_Theme.AreaIndexes[_Shape.AreaId]).DisplayInfo + Delimiter;
                                j = j + 1;
                                break;
                            case '3':
                                if (Indented == true)
                                    Label += new string(' ', j * IndentSpace);

                                Label += _Theme.UnitName + Delimiter;
                                j = j + 1;
                                break;
                            case '4':
                                if (Indented == true)
                                    Label += new string(' ', j * IndentSpace);

                                //Label += _Theme.SubgroupName(0) & Delimiter
                                //*** BugFix 21 Sep 2006 Subgroup label error
                                Label += ((AreaInfo)_Theme.AreaIndexes[_Shape.AreaId]).Subgroup + Delimiter;
                                j = j + 1;
                                break;
                            case '5':
                                if (Indented == true)
                                    Label += new string(' ', j * IndentSpace);

                                Label += ((AreaInfo)_Theme.AreaIndexes[_Shape.AreaId]).Time + Delimiter;
                                break;
                        }
                    }
                    Label = Label.Trim(Delimiter.ToCharArray());
                }
                else
                {
                    if (this._ShowLabelWhereDataExists)
                    {
                        //- If label is not required for Areas NOT having Data,
                        // then set blank label.
                        Label = string.Empty;
                    }
                    else
                    {
                        Hashtable AreaNames = _Layer.AreaNames;
                        string AreaName;
                        if (Array.IndexOf(Fields, "0"[0]) > -1)
                            Label = _Shape.AreaId + Delimiter;
                        if (Array.IndexOf(Fields, char.Parse("1")) > -1)
                        {
                            if (AreaNames.ContainsKey(_Shape.AreaId))
                            {
                                //Get language specific AreaName from Database if it exists
                                AreaName = (string)AreaNames[_Shape.AreaId];
                            }
                            else
                            {
                                //Get Shapefile Area Name
                                AreaName = _Shape.AreaName;
                            }
                            if (_Layer.LabelMultirow == true)
                            {
                                if (Label == "")
                                {
                                    Label += AreaName;
                                }
                                else
                                {
                                    if (_Layer.LabelIndented == true)
                                        Label += new string(' ', IndentSpace);
                                    Label += AreaName;
                                }
                            }
                            else
                            {
                                Label += AreaName;
                            }
                        }
                    }
                }
            }
            return Label;
        }
Beispiel #5
0
 public string GetLabel(Layer _Layer, ref Shape _Shape, ref Theme _Theme, CustomLabel _CustomLabel)
 {
     Legend _Legend = null;
     return GetLabel(_Layer, ref _Shape, ref _Theme, _CustomLabel, ref _Legend);
 }
Beispiel #6
0
        public void DrawMap(Graphics g, string areaIDToHightlight)
        {
            this.AreaIDToHighlight = areaIDToHightlight;
            Layers PreservedLayeres = this.m_Layers;

            if (this.m_Layers != null)
            {
                try
                {
                    this.m_Layers = new Layers();

                    if (this.PreviousLayerHighlighted != null)
                    {
                        this.m_Layers.Add(PreviousLayerHighlighted);
                    }

                    //- get Layer for given AreaID
                    foreach (Layer Lyr in PreservedLayeres)
                    {
                        Shape _Shape = null;
                        Hashtable ht = Lyr.GetRecords(Lyr.LayerPath + "\\" + Lyr.ID);
                        IDictionaryEnumerator dicEnumerator = ht.GetEnumerator();
                        if (Lyr.LayerType == ShapeType.Polygon)
                        {
                            while (dicEnumerator.MoveNext())
                            {
                                //Traverse Shapes
                                _Shape = (Shape)dicEnumerator.Value;

                                if (_Shape.AreaId == areaIDToHightlight)
                                {
                                    if (this.m_Layers.LayerIndex(Lyr.ID) < 0)
                                    {
                                        this.m_Layers.Add(Lyr);

                                        //- Set Layer as previous Highlighted Area Layer.
                                        this.PreviousLayerHighlighted = Lyr;
                                    }
                                    break;
                                }
                            }
                        }
                    }

                    // Re-draw Map only for selected Layer associated with AreaID
                    this.DrawMap("", g);
                }
                catch
                { }
            }

            this.AreaIDToHighlight = string.Empty;
            this.m_Layers = PreservedLayeres;

            try
            {
                //*** Draw Label
                DrawLabel(ref g, this.GetTransMatrix(), this.GetCurrentExtent());
            }
            catch
            { }
        }
Beispiel #7
0
        public Layer CreateBufferLayer(PointF[] moBufferPts, float BufferRadius, BufferStyle eBufferStyle, string BufferName)
        {
            int i;

            //*** BugFix 11 Feb 2006 Error on Double clicking on same point
            if (moBufferPts.Length > 1)
            {
                if (moBufferPts[moBufferPts.Length - 1].Equals(moBufferPts[moBufferPts.Length - 2]))
                {
                    // ERROR: Not supported in C#: ReDimStatement
                }
            }

            //*** BugFix 02 Feb 2006 If user double click on first point itself for line buffer then create point buffer
            if (eBufferStyle == BufferStyle.Line & moBufferPts.Length == 1)
                eBufferStyle = BufferStyle.Point;

            //*** Transform Buffer Points to Latitude and Longitude
            for (i = 0; i <= moBufferPts.Length - 1; i++)
            {
                moBufferPts[i] = PointToClient(moBufferPts[i]);
            }

            //*** Create buffer
            Shape TempShp = new Shape();
            Layer BufferLayer = new Layer();
            GraphicsPath TempGp = new GraphicsPath();

            PointF[] PolyPts;
            if (eBufferStyle == BufferStyle.Point)
            {
                //*** Point Buffer
                GraphicsPath LyrGp = new GraphicsPath();
                for (i = 0; i <= moBufferPts.Length - 1; i++)
                {
                    TempShp = new Shape();
                    TempShp.AreaId = BufferName + "_" + i + 1;
                    TempShp.AreaName = BufferName + "_" + i + 1;
                    TempShp.Centroid = moBufferPts[i];
                    PolyPts = GetPointBuffer(moBufferPts[i], BufferRadius);
                    TempShp.Parts.Add(PolyPts);
                    TempGp.Reset();
                    TempGp.AddPolygon(PolyPts);
                    TempShp.Extent = TempGp.GetBounds();
                    BufferLayer.Records.Add(TempShp.AreaId, TempShp);
                    LyrGp.AddPolygon(PolyPts);
                }
                BufferLayer.Extent = LyrGp.GetBounds();
                LyrGp.Dispose();
            }
            else
            {
                //*** Line Buffer
                TempShp.AreaId = BufferName;
                TempShp.AreaName = BufferName;
                TempShp.Centroid = moBufferPts[(int)moBufferPts.Length / 2];
                PolyPts = GetLineBuffer(moBufferPts, BufferRadius);
                TempShp.Parts.Add(PolyPts);
                TempGp.AddPolygon(PolyPts);
                TempShp.Extent = TempGp.GetBounds();
                BufferLayer.Extent = TempGp.GetBounds();
                BufferLayer.Records.Add(TempShp.AreaId, TempShp);
            }

            TempGp.Dispose();
            TempShp = null;

            BufferLayer.LayerType = ShapeType.PolygonBuffer;
            BufferLayer.FillColor = Color.FromArgb(40, 255, 0, 0);
            BufferLayer.BorderColor = Color.Transparent;

            return BufferLayer;
        }
Beispiel #8
0
        public Layer CreateBufferLayer(Layer SrcLayer, float BufferRadius)
        {
            int i;
            Layer BufferLayer = new Layer();
            Shape SrcShape;
            IDictionaryEnumerator dicEnumerator = SrcLayer.GetRecords(SrcLayer.LayerPath + "\\" + SrcLayer.ID).GetEnumerator();
            switch (SrcLayer.LayerType)
            {
                case ShapeType.Point:
                case ShapeType.PointCustom:
                case ShapeType.PointFeature:
                    GraphicsPath TempGp = new GraphicsPath();
                    PointF Pt;
                    while (dicEnumerator.MoveNext())
                    {
                        Shape TempShp = new Shape();
                        SrcShape = (Shape)dicEnumerator.Value;
                        Pt = (PointF)SrcShape.Parts[0];
                        TempShp.AreaId = SrcShape.AreaId;
                        TempShp.AreaName = SrcShape.AreaName;
                        TempShp.Centroid = Pt;
                        PointF[] Pts = GetPointBuffer(Pt, BufferRadius);

                        TempGp.Reset();
                        TempGp.AddPolygon(Pts);
                        TempShp.Extent = TempGp.GetBounds();

                        TempShp.Parts.Add(Pts);
                        BufferLayer.Records.Add(TempShp.AreaId, TempShp);

                        if (BufferLayer.Extent.IsEmpty)
                        {
                            BufferLayer.Extent = TempShp.Extent;
                        }
                        else
                        {
                            BufferLayer.Extent = RectangleF.Union(BufferLayer.Extent, TempShp.Extent);
                        }

                        TempShp = null;
                    }

                    TempGp.Dispose();
                    break;

                case ShapeType.PolyLine:
                case ShapeType.PolyLineCustom:
                case ShapeType.PolyLineFeature:
                    TempGp = new GraphicsPath();
                    while (dicEnumerator.MoveNext())
                    {
                        Shape TempShp = new Shape();
                        SrcShape = (Shape)dicEnumerator.Value;
                        TempShp.AreaId = SrcShape.AreaId;
                        TempShp.AreaName = SrcShape.AreaName;
                        //TempShp.Centroid = SrcShape.Parts(j)
                        for (i = 0; i <= SrcShape.Parts.Count - 1; i++)
                        {
                            PointF[] Pts = (PointF[])SrcShape.Parts[i];
                            PointF[] PolyPts = GetLineBuffer(Pts, BufferRadius);
                            TempShp.Centroid = Pts[(int)Pts.Length / 2];
                            TempShp.Parts.Add(PolyPts);

                            TempGp.Reset();
                            TempGp.AddPolygon(PolyPts);

                            if (TempShp.Extent.IsEmpty)
                            {
                                TempShp.Extent = TempGp.GetBounds();
                            }
                            else
                            {
                                TempShp.Extent = RectangleF.Union(TempShp.Extent, TempGp.GetBounds());
                            }

                            Pts = null;
                        }

                        BufferLayer.Records.Add(TempShp.AreaId, TempShp);

                        if (BufferLayer.Extent.IsEmpty)
                        {
                            BufferLayer.Extent = TempShp.Extent;
                        }
                        else
                        {
                            BufferLayer.Extent = RectangleF.Union(BufferLayer.Extent, TempShp.Extent);
                        }

                        TempShp = null;
                    }

                    TempGp.Dispose();
                    break;
            }
            BufferLayer.LayerType = ShapeType.PolygonBuffer;
            BufferLayer.FillColor = Color.FromArgb(40, 255, 0, 0);
            BufferLayer.BorderColor = Color.Transparent;
            return BufferLayer;
        }
Beispiel #9
0
        public void ApplyDIBLayerSetting(Layer dibLayer, string DIBSettingsFileName)
        {
            try
            {
                if (File.Exists(DIBSettingsFileName))
                {
                    DIBSettings DIBSettingsObject = DIBSettings.LoadDIBSettings(DIBSettingsFileName);

                    this.ApplyDIBLayerSetting(dibLayer, DIBSettingsObject);
                }
            }
            catch
            {
            }
        }
        public static void CreateShapefile(Layer _Layer, string FilePath, string FileName)
        {
            System.Text.Encoding FileEncoding = System.Text.Encoding.Default;

            FileHeader SHPFileHeader = new FileHeader();
            FileStream oShpStream = new FileStream(FilePath + "\\" + FileName + ".shp", FileMode.Create);
            BinaryWriter oShpBinaryWriter = new BinaryWriter(oShpStream);

            FileStream oShxStream = new FileStream(FilePath + "\\" + FileName + ".shx", FileMode.Create);
            BinaryWriter oShxBinaryWriter = new BinaryWriter(oShxStream);

            FileStream oDbfStream = new FileStream(FilePath + "\\" + FileName + ".dbf", FileMode.Create);
            BinaryWriter oDbfBinaryWriter = new BinaryWriter(oDbfStream, FileEncoding);
            SHPFileHeader.FileCode = BigToLittleEndian(9994);
            SHPFileHeader.Version = 1000;
            switch (_Layer.LayerType)
            {

                case DevInfo.Lib.DI_LibBAL.UI.Presentations.Map.ShapeType.Point:
                case DevInfo.Lib.DI_LibBAL.UI.Presentations.Map.ShapeType.PointCustom:
                    SHPFileHeader.ShapeType = (int)ShapeType.Point;
                    break;
                case DevInfo.Lib.DI_LibBAL.UI.Presentations.Map.ShapeType.PolyLine:
                case DevInfo.Lib.DI_LibBAL.UI.Presentations.Map.ShapeType.PolyLineCustom:
                case DevInfo.Lib.DI_LibBAL.UI.Presentations.Map.ShapeType.PolyLineFeature:
                    SHPFileHeader.ShapeType = (int)ShapeType.PolyLine;
                    break;
                case DevInfo.Lib.DI_LibBAL.UI.Presentations.Map.ShapeType.Polygon:
                case DevInfo.Lib.DI_LibBAL.UI.Presentations.Map.ShapeType.PolygonBuffer:
                case DevInfo.Lib.DI_LibBAL.UI.Presentations.Map.ShapeType.PolygonCustom:
                case DevInfo.Lib.DI_LibBAL.UI.Presentations.Map.ShapeType.PolygonFeature:
                    SHPFileHeader.ShapeType = (int)ShapeType.Polygon;
                    break;
            }
            SHPFileHeader.BoundingBoxXMin = _Layer.Extent.X;
            SHPFileHeader.BoundingBoxYMin = _Layer.Extent.Y;
            SHPFileHeader.BoundingBoxXMax = _Layer.Extent.X + _Layer.Extent.Width;
            SHPFileHeader.BoundingBoxYMax = _Layer.Extent.Y + _Layer.Extent.Height;

            ShapeFileHeaderWriter(ref oShpBinaryWriter, SHPFileHeader);
            //*** Write .Shp File Header
            ShapeFileHeaderWriter(ref oShxBinaryWriter, SHPFileHeader);
            //*** Write .Shx File Header
            DbaseFileHeaderWriter(ref oDbfBinaryWriter, _Layer.RecordCount, FileEncoding);
            //*** Write .dbf File Header

            int i;
            Shape _Shape = new Shape();
            PointF[] Pts;
            int Offset = 50;
            int RecordNumber = 0;
            int ContentLength;
            int Points;

            IDictionaryEnumerator dicEnumerator = _Layer.Records.GetEnumerator();
            switch (SHPFileHeader.ShapeType)
            {
                case 1:
                    PointF Pt;
                    ContentLength = 10;
                    while (dicEnumerator.MoveNext())
                    {
                        _Shape = (Shape)dicEnumerator.Value;
                        Pt = (PointF)_Shape.Parts[0];
                        RecordNumber += 1;
                        oShpBinaryWriter.Write(BigToLittleEndian(RecordNumber));
                        oShpBinaryWriter.Write(BigToLittleEndian(ContentLength));
                        oShpBinaryWriter.Write((int)1);
                        //Shape Type
                        oShpBinaryWriter.Write((double)Pt.X);
                        oShpBinaryWriter.Write((double)Pt.Y);
                        IndexRecordWriter(ref oShxBinaryWriter, Offset, ContentLength);
                        //*** Write SHX Record
                        Offset += (4 + ContentLength);
                        //*** Add 4 for record header '*** Set Offset for next SHX record
                        DbaseRecordWriter(ref oDbfBinaryWriter, _Shape.AreaId, _Shape.AreaName);
                        //*** Write DBF Record
                    }

                    break;
                case 3:
                case 5:
                    while (dicEnumerator.MoveNext())
                    {
                        _Shape = (Shape)dicEnumerator.Value;
                        int[] NumPoints = new int[_Shape.Parts.Count];
                        Points = 0;
                        for (i = 0; i <= _Shape.Parts.Count - 1; i++)
                        {
                            Pts = (PointF[])_Shape.Parts[i];
                            NumPoints[i] = Pts.Length;
                            Points += Pts.Length;
                        }
                        ContentLength = ((11 + _Shape.Parts.Count) * 2) + (Points * 8);
                        RecordNumber += 1;
                        PolygonRecordWriter(ref oShpBinaryWriter, RecordNumber, ContentLength, Points, NumPoints, _Shape, SHPFileHeader.ShapeType);
                        IndexRecordWriter(ref oShxBinaryWriter, Offset, ContentLength);
                        //*** Write SHX Record
                        Offset += (4 + ContentLength);
                        //*** Add 4 for record header '*** Set Offset for next SHX record
                        DbaseRecordWriter(ref oDbfBinaryWriter, _Shape.AreaId, _Shape.AreaName);
                        //*** Write DBF Record
                    }

                    break;
            }

            //*** Reset FileLength in Shp File Header
            oShpStream.Position = 24;
            oShpBinaryWriter.Write(BigToLittleEndian((int)oShpStream.Length / 2));

            //*** Reset FileLength in Shx File Header
            oShxStream.Position = 24;
            oShxBinaryWriter.Write(BigToLittleEndian((int)oShxStream.Length / 2));

            //*** Dispose
            oShpBinaryWriter.Close();
            oShxBinaryWriter.Close();
            oDbfBinaryWriter.Close();
            oShpStream.Close();
            oShxStream.Close();
            oDbfStream.Close();
            oShpBinaryWriter = null;
            oShxBinaryWriter = null;
            oDbfBinaryWriter = null;
            oShpStream = null;
            oShxStream = null;
            oDbfStream = null;
            dicEnumerator = null;
        }
Beispiel #11
0
 public void Add(Layer p_Layer)
 {
     List.Add(p_Layer);
 }
Beispiel #12
0
        public Layer AddSpatialLayer(string p_SpatialMapPath, string p_LayerName)
        {
            Layer Lyr = new Layer();
            ShapeInfo _ShapeInfo;
            // ShapeFileReader sfr = new ShapeFileReader();
            //Checking if same Layer already exists in Layers Collection, if yes return the same..
            if (this[p_LayerName] == null)
            {

                _ShapeInfo = ShapeFileReader.GetShapeInfo(p_SpatialMapPath, p_LayerName);
                // sfr = null;
                //*** BugFix 15 May 2006 Problem: Error while reading shape file information simply ignore it.
                if ((_ShapeInfo != null))
                {
                    {
                        Lyr.ID = p_LayerName;
                        Lyr.LayerName = p_LayerName;
                        Lyr.LayerPath = p_SpatialMapPath;
                        Lyr.SourceType = SourceType.Database;
                        Lyr.Extent = _ShapeInfo.Extent;
                        Lyr.RecordCount = _ShapeInfo.RecordCount;
                        Lyr.LayerType = _ShapeInfo.ShapeType;
                        Lyr.Records = _ShapeInfo.Records;
                    }
                    List.Add(Lyr);
                }
                else
                {
                    Lyr = null;
                }
                _ShapeInfo = null;
            }
            else
            {
                Lyr = this[p_LayerName];    //Return same Layer that was already existed in collection
            }
            return Lyr;
        }
Beispiel #13
0
        public Layer AddShapeFile(string SrcPath, string FileName)
        {
            Layer Lyr = new Layer();
            ShapeInfo _ShapeInfo;
            //ShapeFileReader sfr = new ShapeFileReader();
            try
            {
                _ShapeInfo = ShapeFileReader.GetShapeInfo(SrcPath, FileName);
            }
            catch (Exception ex)
            {
                //*** Invalid Shape file Duplicate Ids / invalid Id field etc
                return null;
            }
            //sfr = null;

            //*** Bugfix 21 Sep 2006 '*** Invalid Shape file Duplicate Ids
            if ((_ShapeInfo == null))
                return null;

            {
                Lyr.ID = FileName;
                Lyr.LayerName = FileName;
                Lyr.LayerPath = SrcPath;
                Lyr.SourceType = SourceType.Shapefile;
                Lyr.Extent = _ShapeInfo.Extent;
                Lyr.RecordCount = _ShapeInfo.RecordCount;
                switch (_ShapeInfo.ShapeType)
                {
                    case ShapeType.Point:
                        Lyr.LayerType = ShapeType.PointCustom;
                        break;
                    case ShapeType.Polygon:
                        Lyr.LayerType = ShapeType.PolygonCustom;
                        break;
                    case ShapeType.PolyLine:
                        Lyr.LayerType = ShapeType.PolyLineCustom;
                        break;
                }
                Lyr.Records = _ShapeInfo.Records;
            }
            List.Add(Lyr);
            return Lyr;
        }
Beispiel #14
0
 public static ShapeType SetLayerInfo(Layer p_Layer, string p_FileName)
 {
     return SetLayerInfo(p_Layer, p_FileName, "");
 }