I've attached a patch that enables ogr2gui to build on Linux and run
successfully.
I'm not sure about the 'a_wx_string.mb_str(wxConvUTF8)' stuff that may not
work on Windows but that is necessary on Linux to get an UTF8 string instead
of a multi-byte unicode string. That unicode stuff in wxWidget is really a
nightmare.
But there's also a very important fix that must be applied for all platforms.
The OGRGetDriver ( an_integer ) call must be absolutely avoided ! It depends
on the drivers that are build in the gdal library. That may change for each
user (it didn't work with my GDAL build). Use OGRGetDriverByName
( "the_name_of_the_driver") instead. Another thing, when opening an OGR
dataset, you don't need to provide the driver. This is an output of the
OGROpen call in fact, and you can pass NULL if you're not interested by
knowing which source driver it is.
Best regards
Even
--- src/Gui.cpp.ori 2008-08-23 21:39:40.000000000 +0200
+++ src/Gui.cpp 2008-08-23 22:58:01.000000000 +0200
@@ -373,34 +373,8 @@
wxString ext = sourceName.substr( sourceName.size() - 3, 3 );
- if( ext == wxT( "shp" ) )
- {
- sourceDriver = OGRGetDriver( 0 );
- }
- else if( ext == wxT( "tab" ) )
- {
- sourceDriver = OGRGetDriver( 1 );
- }
- else if( ext == wxT( "csv" ) )
- {
- sourceDriver = OGRGetDriver( 11 );
- }
- else if( ext == wxT( "gml" ) )
- {
- sourceDriver = OGRGetDriver( 12 );
- }
- else if( ext == wxT( "kml" ) )
- {
- sourceDriver = OGRGetDriver( 14 );
- }
- else
- {
- txtOutput->AppendText( wxT( "\xA\xA> unable to find driver ! \xA" ) );
-
- return source = false;
- }
// opening source data
- sourceData = OGROpen( sourceName.c_str(), 0, &sourceDriver );
+ sourceData = OGROpen( sourceName.mb_str(wxConvUTF8), 0, NULL );
if( sourceData != NULL )
{
@@ -411,7 +385,7 @@
{
sourceLayerDefn = OGR_L_GetLayerDefn( sourceLayer );
- sourceLayerName = OGR_FD_GetName( sourceLayerDefn );
+ sourceLayerName = wxString::FromAscii(OGR_FD_GetName( sourceLayerDefn ));
sourceLayerGeom = OGR_FD_GetGeomType( sourceLayerDefn );
@@ -424,13 +398,13 @@
{
if( ! Error( OSRAutoIdentifyEPSG( sourceSRS ), erroText ) )
{
- const char *epsg = OSRGetAttrValue( sourceSRS, wxT( "AUTHORITY" ), 1 );
+ const char *epsg = OSRGetAttrValue( sourceSRS, "AUTHORITY", 1 );
for( int i = 0; i < cntProject; i ++ )
{
- if( arrProject[ i ][ 0 ] == epsg )
+ if( arrProject[ i ][ 0 ] == wxString::FromAscii(epsg) )
{
- txtSrcProj->SetValue( arrProject[ i ][ 0 ] + " : " + arrProject[ i ][ 1 ] );
+ txtSrcProj->SetValue( arrProject[ i ][ 0 ] + wxT(" : ") + arrProject[ i ][ 1 ] );
break;
}
}
@@ -482,31 +456,31 @@
{
case 1 : // ESRI Shapefile
{
- formatDriver = OGRGetDriver( 0 );
+ formatDriver = OGRGetDriverByName( "ESRI Shapefile" );
}
break;
case 2 : // Mapinfo File
{
- formatDriver = OGRGetDriver( 1 );
+ formatDriver = OGRGetDriverByName( "MapInfo File" );
}
break;
case 3 : // CSV
{
- formatDriver = OGRGetDriver( 11 );
+ formatDriver = OGRGetDriverByName( "CSV" );
}
break;
case 4 : // GML
{
- formatDriver = OGRGetDriver( 12 );
+ formatDriver = OGRGetDriverByName( "GML" );
}
break;
case 5 : // KML
{
- formatDriver = OGRGetDriver( 14 );
+ formatDriver = OGRGetDriverByName( "KML" );
}
break;
}
@@ -551,7 +525,7 @@
targetSRS = OSRNewSpatialReference( NULL );
- if( Error( OSRImportFromEPSG( targetSRS, atoi( epsgCode ) ), erroText ) )
+ if( Error( OSRImportFromEPSG( targetSRS, atoi( epsgCode.mb_str(wxConvUTF8) ) ), erroText ) )
{
txtOutput->AppendText( wxT( "\xA\xA> unable to create spatial reference : " ) + erroText );
}
@@ -559,9 +533,9 @@
if( append || update )
{ // opening target data
- if( stat( targetName.c_str(), &fleInfo ) == 0 )
+ if( stat( targetName.mb_str(wxConvUTF8), &fleInfo ) == 0 )
{
- targetData = OGR_Dr_Open( formatDriver, targetName.c_str(), 1 );
+ targetData = OGR_Dr_Open( formatDriver, targetName.mb_str(wxConvUTF8), 1 );
}
else
{
@@ -572,16 +546,16 @@
}
else if( ovrwrt )
{
- if( stat( targetName.c_str(), &fleInfo ) == 0 )
+ if( stat( targetName.mb_str(wxConvUTF8), &fleInfo ) == 0 )
{ //delete data source
- if( remove( targetName.c_str() ) != 0 )
+ if( remove( targetName.mb_str(wxConvUTF8) ) != 0 )
{
txtOutput->AppendText( wxT( "\xA\xA unable to delete data source !" ) );
}
}
// creating target data
- targetData = OGR_Dr_CreateDataSource( formatDriver, targetName.c_str(), NULL );
+ targetData = OGR_Dr_CreateDataSource( formatDriver, targetName.mb_str(wxConvUTF8), NULL );
}
if( targetData != NULL )
@@ -597,11 +571,11 @@
{
if( targetSRS != NULL )
{ // creating target layer with target spatial reference
- targetLayer = OGR_DS_CreateLayer( targetData, sourceLayerName, targetSRS, sourceLayerGeom, NULL );
+ targetLayer = OGR_DS_CreateLayer( targetData, sourceLayerName.mb_str(wxConvUTF8), targetSRS, sourceLayerGeom, NULL );
}
else
{ // creating target layer with source spatial reference
- targetLayer = OGR_DS_CreateLayer( targetData, sourceLayerName, sourceSRS, sourceLayerGeom, NULL );
+ targetLayer = OGR_DS_CreateLayer( targetData, sourceLayerName.mb_str(wxConvUTF8), sourceSRS, sourceLayerGeom, NULL );
}
}
}
@@ -667,7 +641,7 @@
if( sQuery )
{
- squeryLayer = OGR_DS_ExecuteSQL( sourceData, txtSQuery->GetValue().c_str(), NULL, "" );
+ squeryLayer = OGR_DS_ExecuteSQL( sourceData, txtSQuery->GetValue().mb_str(wxConvUTF8), NULL, "" );
if( squeryLayer != NULL )
{
@@ -892,7 +866,7 @@
{
//sourceSRS->exportToPrettyWkt( &sourceWKT );
- wxMessageBox( sourceWKT, wxT( "Source SRS Wkt" ) );
+ wxMessageBox( wxString::FromAscii(sourceWKT), wxT( "Source SRS Wkt" ) );
}
void Gui::_txtSQuery( wxCommandEvent &event )
@@ -910,7 +884,7 @@
wxString tgt = txtSource->GetValue().substr( 0, txtSource->GetValue().size() - 3 ) + arrFormat[ cmbFormat->GetSelection() ][ 1 ];
if( txtSource->GetValue() == tgt )
- tgt.insert( tgt.find_last_of( "." ), wxT( "(2)" ) );
+ tgt.insert( tgt.find_last_of( wxT(".") ), wxT( "(2)" ) );
txtTarget->SetValue( tgt );
_______________________________________________
gdal-dev mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/gdal-dev