This project has moved and is read-only. For the latest updates, please go here.

[v2] create shape file

Topics: SharpMap v2.0
Nov 11, 2013 at 5:27 PM
Hi list,
I want to create shape file by sharpmap v2. I followed test code on sharpmapv2-read-only\SharpMap.Data.Providers\ShapeFileProvider\Tests\ShapeFileTests.cs. This is my code:
 ICoordinateSequenceFactory<BufferedCoordinate> sequenceFactory = new BufferedCoordinateSequenceFactory();
            IGeometryFactory<BufferedCoordinate> geoFactory = new GeometryFactory<BufferedCoordinate>(sequenceFactory);

            FeatureDataTable<UInt32> schema = new FeatureDataTable<UInt32>("OID", geoFactory);
            schema.Columns.AddRange(new DataColumn[]
                new DataColumn("Name", typeof (String)),
                new DataColumn("DateCreated", typeof (DateTime)),
                new DataColumn("Visits", typeof (Int64)),
                new DataColumn("Weight", typeof (Single))
            ShapeFileProvider shapeFile = ShapeFileProvider.Create("C:\\Test", "DataSet2", ShapeType.Point, schema, geoFactory);

            FeatureDataRow<UInt32> feature = schema.NewRow(100);
            feature["Name"] = "ABCD";
            feature["DateCreated"] = DateTime.Now;
            feature["Visits"] = 1000;
            feature["Weight"] = 100.0f;
            feature.Geometry = geoFactory.CreatePoint2D(1, 1);

i had use BufferedCoordinate and BufferedCoordinateSequenceFactory instead of BufferedCoordinate2D and BufferedCoordinate2DSequenceFactory because i don't know where is BufferedCoordinate2D and BufferedCoordinate2DSequenceFactory.
when i run this code, i get error:
System.NullReferenceException: Object reference not set to an instance of an object. On _writer.BeginWrite(); line 240, sharpmapv2-read-only\SharpMap.Data.Providers\ShapeFileProvider\DbaseFile.cs:240
When i debug, the variable: _writer always null in DbaseFile.cs

Is there anyone know about this error. Pls help me. Thanks