[Gdal-dev] Compiling with MS Visual C++ 6
Eisen Co. Ltd.
wzhang at eisen.de
Tue Jan 4 10:04:27 EST 2005
Dear experts,
I've got problem to execute the following source from the tutorial with MS
Visual C++ 6. Could you please give me a step for step instruction how to
setup the compiling environment?
Regards, Wei.
----------------------------------------------------------------------------
------------------------------------------------
#include "ogrsf_frmts.h"
int main()
{
const char *pszDriverName = "ESRI Shapefile";
OGRSFDriver *poDriver;
OGRRegisterAll();
poDriver = OGRSFDriverRegistrar::GetRegistrar()->GetDriverByName(
pszDriverName );
if( poDriver == NULL )
{
printf( "%s driver not available.\n", pszDriverName );
exit( 1 );
}
OGRDataSource *poDS;
poDS = poDriver->CreateDataSource( "point_out.shp", NULL );
if( poDS == NULL )
{
printf( "Creation of output file failed.\n" );
exit( 1 );
}
OGRLayer *poLayer;
poLayer = poDS->CreateLayer( "point_out", NULL, wkbPoint, NULL );
if( poLayer == NULL )
{
printf( "Layer creation failed.\n" );
exit( 1 );
}
OGRFieldDefn oField( "Name", OFTString );
oField.SetWidth(32);
if( poLayer->CreateField( &oField ) != OGRERR_NONE )
{
printf( "Creating Name field failed.\n" );
exit( 1 );
}
double x, y;
char szName[33];
while( !feof(stdin)
&& fscanf( stdin, "%lf,%lf,%32s", &x, &y, szName ) == 3 )
{
OGRFeature *poFeature;
poFeature = new OGRFeature( poLayer->GetLayerDefn() );
poFeature->SetField( "Name", szName );
OGRPoint *poPoint = new OGRPoint();
poPoint->setX( x );
poPoint->setY( y );
poFeature->SetGeometryDirectly( poPoint );
if( poLayer->CreateFeature( poFeature ) != OGRERR_NONE )
{
printf( "Failed to create feature in shapefile.\n" );
exit( 1 );
}
delete poFeature;
}
OGRDataSource::DestroyDataSource( poDS );
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/gdal-dev/attachments/20050104/c20d6e67/attachment.html
More information about the Gdal-dev
mailing list