[gdal-dev] Output MapInfo File with CoordSys Information

Reinaldo escada Chohfi reinaldo at geodesign.com.br
Wed Oct 7 12:33:34 EDT 2009




Hi Frank & List



I tested the program below but it does not out put the .tab or
.mif/.mid with the coordinate system.  It is always non-earth. 
Could you please check it against your gdal/ogr installation to see
if something went  wrong during my compilation of gdal 1.6.2?



Thanks a lot,



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:



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"



>> Reinaldo escada Chohfi wrote: 

> 

>>> Hello List, 

> 

>>> 

> 

>>> I am still trying to get a x,y (lon/Lat) point file in
MapInfo 

> format 

> 

>>> with 

> 

>>> coordinate information. 

> 

>>> 

> 

>>> I get the correct MapInfo files out (.tab or .mif) with the
x,y 

> points 

> 

>>> and 

> 

>>> attributes, but without the CoordSys information. 

> 

>>> The output file is always Non-Earth. 

> 

>>> 

> 

>>> I've tried everything: 

> 

>>> 

> 

>>> OGRSpatialReference oSRS; 

> 

>>> oSRS.SetWellKnownGeogCS("EPSG:4326"); 

> 

>>> oSRS.importFromMICoordSys( "CoordSys Earth Projection 1,


> 104" ); 

> 

>>> 

> 

>>> 

> 

>>> Could someone PLEASE let me know what to do? 

> 

>> 

> 

>> Reinaldo, 

> 

>> 

> 

>> I just tried: 

> 

>> 

> 

>> ogr2ogr -skipfailures -f "MapInfo File" out.mif 

> GB4X0000.000 TUNNEL 

> 

>> 

> 

>> and this produced a mapinfo mid/mif fileset with "CoordSys
Earth 

> 

> 

>> Projection 1, 104" as the coord sys line. I also tested a
small 

> 

> 

>> program: 

> 

>> 

> 

>> 

> 

>> #include "gdal.h" 

> 

>> #include "ogr_spatialref.h" 

> 

>> 

> 

>> int main() 

> 

>> 

> 

>> { 

> 

>> OGRSpatialReference oSRS; 

> 

>> 

> 

>> oSRS.importFromMICoordSys( "CoordSys Earth Projection 1, 

> 104" ); 

> 

>> } 

> 

>> 

> 

>> and it appeared to correctly parse the Coordsys into a WGS84 srs.


> 

>> 

> 

>> I even tried: 

> 

>> 

> 

>> ogr2ogr -a_srs wgs84.wkt -skipfailures -f "MapInfo
File" 

> out.mif 

> 

>> data/s57/GB4X0000.000 TUNNEL 

> 

>> 

> 

>> with wgs84.wkt holding: 

> 

>> 

> 

>> 

>
GEOGCS["unnamed",DATUM["WGS_1984",SPHEROID["WGS


> 

> 

>> 

>
84",6378137,298.257223563],TOWGS84[0,0,0,-0,-0,-0,0]],PRIMEM["Greenwich",0],UNIT["degree",0.0174532925199433]]


> 

> 

>> 

> 

>> and things seemed to work. 

> 

>> 

> 

>> Can you provide a more complete example that is failing for you?


> 

>> 

> 

>> Best regards, 

> 

>> -- 

> 

>> 

>
---------------------------------------+--------------------------------------


> 

> 

>> I set the clouds in motion - turn up | Frank Warmerdam, 

> 

>> warmerdam at pobox.com 

> 

>> light and sound - activate the windows |
http://pobox.com/~warmerdam 

> 

> 

>> and watch the world go round - Rush | Geospatial Programmer for
Rent 

> 

> 

>> 

> 

>> 

> 

>   

> 

 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/gdal-dev/attachments/20091007/9f18740e/attachment.html


More information about the gdal-dev mailing list