[Shapelib] Shapelib Digest, Vol 73, Issue 1
Juan Antonio Pastor
juanpastjim at gmail.com
Thu Jun 2 00:47:59 PDT 2011
Hi.
You must write data in the DBF.
Use DBFAddField and: DBFWriteStringAttribute, DBFWriteIntegerAttribute... to
write values into fields.
For example you can write the x and y values (double values):
DBFAddField(hDBF, "X", FTDouble, 15, 15);
DBFAddField(hDBF, "Y", FTDouble, 15, 15);
for(int i=0;i<3;i++) {
DBFWriteDoubleAttribute(hDBF, i, 0,X[i]);
DBFWriteDoubleAttribute(hDBF, i, 1,Y[i]);
}
Good luck!
2011/5/31 <shapelib-request at lists.maptools.org>
> Send Shapelib mailing list submissions to
> shapelib at lists.maptools.org
>
> To subscribe or unsubscribe via the World Wide Web, visit
> http://lists.maptools.org/mailman/listinfo/shapelib
> or, via email, send a message with subject or body 'help' to
> shapelib-request at lists.maptools.org
>
> You can reach the person managing the list at
> shapelib-owner at lists.maptools.org
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of Shapelib digest..."
>
>
> Today's Topics:
>
> 1. Point shp file is created with empty dbf. (Rakib Solaimani)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Tue, 31 May 2011 01:03:30 +0600
> From: Rakib Solaimani <rakib114 at gmail.com>
> Subject: [Shapelib] Point shp file is created with empty dbf.
> To: shapelib at lists.maptools.org
> Message-ID: <BANLkTinzpKCdF3jNrzPOS4r39Wu6OUuZ7g at mail.gmail.com>
> Content-Type: text/plain; charset="iso-8859-1"
>
> Hi,
>
> I am new to shapelib. I want to create a simple shp file. I want to draw
> point on specific latitude and longitude. I tried to execute the following
> code which I found by google research.
> I successfully create the shp file and viewed it by ShapeViewer but I found
> my dbf file empty. I am wondering if data in dbf file is created while
> creating new shp file or should it be created
> manually? If so how can I link shp and dbf file. Basically I want to apply
> some rule on dbf file. Can anyone help me please. Here I attach my sample
> code.
>
>
> #include "stdafx.h"
> #include <iostream
> #include <cstdlib
> #include "shapefil.h"
> #include <string
>
> using namespace std;
>
> int _tmain(int argc, _TCHAR* argv[])
> {
> SHPHandle hSHP;
> DBFHandle hDBF;
> int nShapeType, Vertices;
> string shape_name, Col1;
> SHPObject *psObject;
>
> double X[3], Y[3];
>
> X[0] = -130;
> Y[0]= 54;
>
> X[1] = -120;
> Y[1]= 30;
>
> X[2] = -100;
> Y[2]= 10;
>
> nShapeType = MultiPoint;
> Vertices = 3;
>
>
> hSHP = SHPCreate( "T:\\shapefolder\\test.shp",
> nShapeType);
>
> hDBF = DBFCreate(T:\\shapefolder\\test.dbf);
>
> psObject = SHPCreateSimpleObject( nShapeType, Vertices, X, Y, NULL);
> SHPWriteObject( hSHP, -1, psObject );
>
>
> DBFClose( hDBF );
> SHPClose( hSHP );
>
>
>
> return 0;
> }
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL:
> http://lists.maptools.org/pipermail/shapelib/attachments/20110531/669da739/attachment-0001.htm
>
> ------------------------------
>
> _______________________________________________
> Shapelib mailing list
> Shapelib at lists.maptools.org
> http://lists.maptools.org/mailman/listinfo/shapelib
>
>
> End of Shapelib Digest, Vol 73, Issue 1
> ***************************************
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/shapelib/attachments/20110602/2031c35c/attachment.html>
More information about the Shapelib
mailing list