Ejemplo n.º 1
0
        /// <summary>
        /// Opens a shapefile
        /// </summary>
        /// <param name="fileName">The string fileName of the point shapefile to load</param>
        /// <param name="progressHandler">Any valid implementation of the DotSpatial.Data.IProgressHandler</param>
        public void Open(string fileName, IProgressHandler progressHandler)
        {
            //JK - handle case when filename doesn't exist
            if (!File.Exists(fileName))
            {
                Attributes = new AttributeTable();
                Header = new ShapefileHeader { FileLength = 100, ShapeType = ShapeType.Point };
                FeatureType = FeatureType.Point;
                return;
            }

            IndexMode = true;
            Filename = fileName;

            Header = new ShapefileHeader(fileName);
            CoordinateType = CoordinateType.Regular;
            if (Header.ShapeType == ShapeType.PointM)
            {
                CoordinateType = CoordinateType.M;
            }
            if (Header.ShapeType == ShapeType.PointZ)
            {
                CoordinateType = CoordinateType.Z;
            }
            MyExtent = Header.ToExtent();
            Name = Path.GetFileNameWithoutExtension(fileName);
            Attributes.Open(fileName);
            FillPoints(fileName, progressHandler);
            ReadProjection();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Opens a shapefile
        /// </summary>
        /// <param name="fileName">The string fileName of the line shapefile to load</param>
        /// <param name="progressHandler">Any valid implementation of the DotSpatial.Data.IProgressHandler</param>
        public void Open(string fileName, IProgressHandler progressHandler)
        {
            if (!File.Exists(fileName))
            {
                Attributes = new AttributeTable();
                Header = new ShapefileHeader { FileLength = 100, ShapeType = ShapeType.PolyLine };
                FeatureType = FeatureType.Line;
                return;
            }

            Filename = fileName;
            FeatureType = FeatureType.Line;
            Header = new ShapefileHeader(fileName);
            CoordinateType = CoordinateType.Regular;
            IndexMode = true;
            if (Header.ShapeType == ShapeType.PolyLineM)
            {
                CoordinateType = CoordinateType.M;
            }
            if (Header.ShapeType == ShapeType.PolyLineZ)
            {
                CoordinateType = CoordinateType.Z;
            }
            MyExtent = Header.ToExtent();
            Name = Path.GetFileNameWithoutExtension(fileName);
            Attributes.Open(fileName);
            FillLines(fileName, progressHandler);
            ReadProjection();
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Creates a new instance of a shapefile based on a fileName
 /// </summary>
 /// <param name="fileName">File name</param>
 /// <param name="featureType">Feature type</param>
 protected Shapefile(string fileName, FeatureType featureType)
     : base(featureType)
 {
     Attributes = new AttributeTable();
     Header = new ShapefileHeader();
     
     Open(fileName, null);
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Creates a new instance of a PolygonShapefile for in-ram handling only.
 /// </summary>
 public PolygonShapefile()
     : base(FeatureType.Polygon)
 {
     Attributes = new AttributeTable();
     Header = new ShapefileHeader();
     Header.FileLength = 100;
     Header.ShapeType = ShapeType.Polygon;
     FeatureType = FeatureType.Polygon;
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Creates a new ShapefileReader tailored to read a particular file.
 /// </summary>
 /// <param name="filename"></param>
 /// <returns></returns>
 public ShapefileReader(string filename)
 {
     Filename = filename;
     _attributeTable = new AttributeTable(filename);
     ShapefileHeader header = new ShapefileHeader(filename);
     //if (header.ShapeType == ShapeType.Polygon ||
     //    header.ShapeType == ShapeType.PolygonM ||
     //    header.ShapeType == ShapeType.PolygonZ)
     //{
     //    _shapeSource = new PolygonShapefileShapeSource(filename);
     //}
     // To Do: Implement alternate shape sources here.
     _fieldCount = -1;
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Creates a new instance of a LineShapefile for in-ram handling only.
 /// </summary>
 public LineShapefile()
     : base(FeatureType.Line)
 {
     Attributes = new AttributeTable();
     Header = new ShapefileHeader { FileLength = 100, ShapeType = ShapeType.PolyLine };
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Creates a new instance of a MultiPointShapefile for in-ram handling only.
 /// </summary>
 public MultiPointShapefile()
     : base(FeatureType.MultiPoint)
 {
     Attributes = new AttributeTable();
     Header = new ShapefileHeader { FileLength = 100, ShapeType = ShapeType.MultiPoint };
 }
Ejemplo n.º 8
0
 private void Configure()
 {
     Attributes = new AttributeTable();
     _header = new ShapefileHeader();
     IndexMode = true;
 }
Ejemplo n.º 9
0
 /// <summary>
 /// Creates a new instance of a PolygonShapefile for in-ram handling only.
 /// </summary>
 public PolygonShapefile()
     : base(FeatureType.Polygon)
 {
     Attributes = new AttributeTable();
     Header = new ShapefileHeader { FileLength = 100, ShapeType = ShapeType.Polygon };
 }
Ejemplo n.º 10
0
 private AttributeTable GetAttributeTable(string fileName)
 {
     var at = new AttributeTable();
     at.Open(fileName, _deletedRows);
     if (_trackDeletedRows)
         _deletedRows = at.DeletedRows;
     return at;
 }