[Shapelib] Adding new shape to shapefile

Vassilis Perantzakis vaspervnp at yahoo.gr
Thu May 29 08:53:24 PDT 2008


If it works like in Delphi, after creating the file you should close it with

shpFile.SHPClose(newShp);

and then reopen it with 

IntPtr newShp = shpFile.SHPOpen(@"\SD-MMCard\TestParcelle\ARRETBUS.shp ",
"rb+") 

to insure appending mode. I believe the same goes for the dbf file.

Let me know if it helped.

-----Original Message-----
From: shapelib-bounces at lists.maptools.org
[mailto:shapelib-bounces at lists.maptools.org] On Behalf Of thecrashteam
Sent: Thursday, May 29, 2008 6:31 PM
To: shapelib at lists.maptools.org
Subject: [Shapelib] Adding new shape to shapefile


Hello,

 

First, sorry for my English, I'll promise you I'll do my best.

 

I'm in a training period in order to prepare my degree and I've in charge of
the development of a PPC application in C# using shapelib.

I read some posts in this forum about adding shapes in shapefile, and I
apply some parts of code in my application but, I have a problem with the
SHPWriteObject function. The application runs correctly but nothing is
written in my shapefile. Someone could help me ? Do I make a mistake in my
code ?

 

Well thank you for your help

 

Romain

 

 

My code : 

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

double[] dblX = new double[1];

dblX[0] = 803606;

double[] dblY = new double[1];

dblY[0] = 800000;

IntPtr newDbf = shpFile.DBFCreate(@"\SD-MMCard\TestParcelle\ARRETBUS.dbf");

IntPtr pso = shpFile.SHPCreateObject(ShapeFile.ShapeFile.ShapeType.Point, 1,
1, null, null, 1, dblX, dblY, null, null);

IntPtr psObject =
shpFile.SHPCreateSimpleObject(ShapeFile.ShapeFile.ShapeType.Point, 1, dblX,
dblY, null);

shpFile.SHPWriteObject(newShp, -1, psObject);

shpFile.SHPWriteObject(newShp, -1, pso);

shpFile.DBFClose(newDbf);

shpFile.SHPClose(newShp);
-- 
View this message in context:
http://www.nabble.com/Adding-new-shape-to-shapefile-tp17536792p17536792.html
Sent from the ShapeLib mailing list archive at Nabble.com.


_______________________________________________
Shapelib mailing list
Shapelib at lists.maptools.org
http://lists.maptools.org/mailman/listinfo/shapelib




More information about the Shapelib mailing list