[Shapelib] Adding new shape to shapefile

thecrashteam didier.romain at gmail.com
Fri May 30 04:06:39 EDT 2008


hi,

I post my new code. It doesn't function but there is no error. My shapeFile
and its dbf file are not created. Someone could say to me why it doesn't
work please ?

Thank you for your help

Romain




IntPtr ptrCreateSHP = shpFile.SHPCreate(@"\SD-MMCard\TestParcelle\test.shp",
ShapeFile.ShapeFile.ShapeType.Point);
shpFile.SHPClose(ptrCreateSHP);

IntPtr ptrCreateDBF =
shpFile.DBFCreate(@"\SD-MMCard\TestParcelle\test.dbf");
shpFile.DBFClose(ptrCreateDBF);

IntPtr ptrOpenDBF = shpFile.DBFOpen(@"\SD-MMCard\TestParcelle\test.dbf",
"rb+");

IntPtr ptrOpenSHP = shpFile.SHPOpen(@"\SD-MMCard\TestParcelle\test.shp",
"rb+");

double[] x = new double[1];
double[] y = new double[1];
double[] z = new double[1];
x[0] = 803606;
y[0] = 803606;
z[0] = 0;

IntPtr psObject =
shpFile.SHPCreateSimpleObject(ShapeFile.ShapeFile.ShapeType.Point, 1, x, y,
z);

shpFile.SHPWriteObject(ptrOpenSHP, -1, psObject);
shpFile.SHPDestroyObject(psObject);

shpFile.DBFWriteDoubleAttribute(ptrOpenDBF, -1, 0, 0d);
shpFile.DBFWriteStringAttribute(ptrOpenDBF, -1, 1, "toto");
shpFile.DBFWriteStringAttribute(ptrOpenDBF, -1, 2, "aime");
shpFile.DBFWriteStringAttribute(ptrOpenDBF, -1, 3, "les");
shpFile.DBFWriteStringAttribute(ptrOpenDBF, -1, 4, "fraises");

shpFile.DBFClose(ptrOpenDBF);

-- 
View this message in context: http://www.nabble.com/Adding-new-shape-to-shapefile-tp17536792p17553659.html
Sent from the ShapeLib mailing list archive at Nabble.com.



More information about the Shapelib mailing list