[gdal-dev] Output MapInfo File with CoordSys Information
Reinaldo Escada Chohfi
reinaldo at geodesign.com.br
Wed Mar 24 13:01:31 EDT 2010
Hello Frank and List,
We waited for the release of GDAL 1.7.0 to see if we could output MapInfo
Fiels (.tab or .mif/mid) with SRS information.
We still can not output .tab or .mif/mid files with SRS information.
Could you please check the test code below to see what's missing or wrong?
Thanks in advance.
Regards,
Reinaldo
*******************************
#include "gdal.h"
#include "ogr_spatialref.h"
#include "ogrsf_frmts.h"
#include "stdio.h"
double Lat[3], Lon[3];
int n=0; char *pszWKT = NULL;
void main()
{
OGRSpatialReference oSRS;
// oSRS.SetWellKnownGeogCS( "EPSG:4326" );
oSRS.importFromMICoordSys( "CoordSys Earth Projection 1, 104" );
const char *pszDriverName = "MapInfo File" ;
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( "c:/test01.mif", NULL );
// poDS = poDriver->CreateDataSource( "c:/test01.tab", NULL );
if( poDS == NULL )
{
printf( "Creation of output file failed.\n" );
exit( 1 );
}
OGRLayer *poLayer;
poLayer = poDS->CreateLayer( "test01", NULL, wkbPoint, NULL );
if( poLayer == NULL )
{
printf( "Layer creation failed.\n" );
exit( 1 );
}
OGRFieldDefn oField0( "NAME1", OFTString );
OGRFieldDefn oField1( "NAME2", OFTString );
oField0.SetWidth(32);
oField1.SetWidth(32);
if( poLayer->CreateField( &oField0 ) != OGRERR_NONE )
{
printf( "Creating Name field failed.\n" );
exit( 1 );
}
if( poLayer->CreateField( &oField1 ) != OGRERR_NONE )
{
printf( "Creating Name field failed.\n" );
exit( 1 );
}
*******************************
.mif output w/ou SRS:
Version 300
Charset "Neutral"
Delimiter ","
Columns 2
NAME1 Char(32)
NAME2 Char(32)
Data
Point -45.13975272 -22.69426671
Symbol (35,0,12)
Point -45.86066928 -23.21117775
Symbol (35,0,12)
Point -44.33023872 -22.68505859375
Symbol (35,0,12)
************************************
.mid output:
"TEST01","TEST02"
"TEST01","TEST02"
"TEST01","TEST02"
More information about the gdal-dev
mailing list