[Shapelib] Adding new shape to shapefile

Christian Kirchhoff ckirchho at directmedia.de
Thu Jun 5 05:18:12 EDT 2008


Hello once more, Romain,

the documentation is here:
http://shapelib.maptools.org/shp_api.html

Best regards,

Christian
*Directmedia Publishing GmbH* · Möckernstraße 68 · 10965 Berlin
www.digitale-bibliothek.de
AG Berlin-Charlottenburg · HR B 58002 · USt.Id. DE173211737
Geschäftsführer: Ralf Szymanski · Erwin Jurschitza


thecrashteam schrieb:
> Thank you for your help Bram, it is very nice !
> So, I did a list of return values of functions used in my code :
> DBFCreate returns 375328,
> SHPCreate = 379776,
> DBFAddField = 0,
> DBFWriteStringAttribute = 1,
> SHPCreateSimpleObject = 410704,
> SHPWriteObject = 0.
>
> I hope you could tell me what these figures mean... And do you know where
> could I find documentation about shapelib ?
>
> Thank you again for your help
>
> Romain.
>
>
>
> Bram de Greve wrote:
>   
>> The extension has nothing to do with it.  At worst, it would create 
>> something like test.shp.shp.
>>
>> As no files AT ALL are created, the problem probably is within DBFCreate 
>> and SHPCreate, as they should create file files straight away, even 
>> without the data being added.  Please, check the return values of 
>> DBFCreate and SHPCreate.   Are they null?  Probably they are, and that 
>> means the creation of the files simply fail.  And thus everything else 
>> fails too.
>>
>> Try a more simple filename like just "test".
>>
>> Are you prepared to step through the code in a debug session.  Maybe you 
>> can figure out what exactly fails ...
>>
>> Good luck =)
>> Bram
>>
>> thecrashteam schreef:
>>     
>>> Hi  Vassilis,
>>>
>>>
>>> I tried what you told me too, but it still not work. No error, but no
>>> files... It's hopeless !! ^^
>>> I think there is something wrong against me with this library !!!
>>>
>>> Thank you for your reply !
>>>
>>> Romain
>>>
>>> My code : 
>>>
>>> //création du dbf
>>> IntPtr ptrDBFCreate = shpFile.DBFCreate(@"\SD-MMCard\TestParcelle\test");
>>>
>>> //création du shapefile
>>> IntPtr ptrSHPCreate = shpFile.SHPCreate(@"\SD-MMCard\TestParcelle\test",
>>> ShapeFile.ShapeFile.ShapeType.Point);
>>>
>>> //nouvelle colonne dans le dbf
>>> shpFile.DBFAddField(ptrDBFCreate, @"\SD-MMCard\TestParcelle\test",
>>> ShapeFile.ShapeFile.DBFFieldType.FTString, 255, 0);
>>>
>>> //écriture de la valeur liée au futur shape
>>> shpFile.DBFWriteStringAttribute(ptrDBFCreate,
>>> shpFile.DBFGetRecordCount(ptrDBFCreate), 0, "to");
>>>
>>> //création du point
>>> 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);
>>>
>>> //écriture du point dans le shape
>>> shpFile.SHPWriteObject(ptrSHPCreate, -1, psObject);
>>>
>>> //fermeture du dbf et du shapefile
>>> shpFile.SHPClose(ptrSHPCreate);
>>> shpFile.DBFClose(ptrDBFCreate);
>>>   
>>>       
>> _______________________________________________
>> Shapelib mailing list
>> Shapelib at lists.maptools.org
>> http://lists.maptools.org/mailman/listinfo/shapelib
>>
>>
>>     
>
>   
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.maptools.org/pipermail/shapelib/attachments/20080605/f6bb05d9/attachment-0001.html


More information about the Shapelib mailing list