Skip to content

Commit

Permalink
Revert "[grass] Use better approach to retrieve CRS information for m…
Browse files Browse the repository at this point in the history
…apsets"

This reverts commit 40e9710.
  • Loading branch information
nyalldawson committed Jul 15, 2024
1 parent ee16c13 commit c1905c2
Show file tree
Hide file tree
Showing 13 changed files with 5 additions and 148 deletions.
27 changes: 2 additions & 25 deletions src/providers/grass/qgis.g.info.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ int main( int argc, char **argv )
info_opt->key = "info";
info_opt->type = TYPE_STRING;
info_opt->description = "info key";
info_opt->options = "proj,wkt,srid,window,size,query,info,colors,stats";
info_opt->options = "proj,window,size,query,info,colors,stats";

rast_opt = G_define_standard_option( G_OPT_R_INPUT );
rast_opt->key = "rast";
Expand Down Expand Up @@ -107,6 +107,7 @@ int main( int argc, char **argv )
if ( strcmp( "proj", info_opt->answer ) == 0 )
{
G_get_window( &window );
/* code from g.proj */
if ( window.proj != PROJECTION_XY )
{
struct Key_Value *projinfo, *projunits;
Expand All @@ -117,30 +118,6 @@ int main( int argc, char **argv )
fprintf( stdout, "%s", wkt );
}
}
else if ( strcmp( "wkt", info_opt->answer ) == 0 )
{
G_get_window( &window );
if ( window.proj != PROJECTION_XY )
{
char *wkt = G_get_projwkt();
if ( wkt )
{
fprintf( stdout, "%s", wkt );
}
}
}
else if ( strcmp( "srid", info_opt->answer ) == 0 )
{
G_get_window( &window );
if ( window.proj != PROJECTION_XY )
{
char *srid = G_get_projsrid();
if ( srid )
{
fprintf( stdout, "%s", srid );
}
}
}
else if ( strcmp( "window", info_opt->answer ) == 0 )
{
if ( rast_opt->answer )
Expand Down
41 changes: 3 additions & 38 deletions src/providers/grass/qgsgrass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2068,48 +2068,13 @@ QgsCoordinateReferenceSystem QgsGrass::crs( const QString &gisdbase, const QStri
QString &error )
{
QgsDebugMsgLevel( QStringLiteral( "gisdbase = %1 location = %2" ).arg( gisdbase, location ), 2 );
QgsCoordinateReferenceSystem crs;

// try getting SRID directly first
try
{
const QString srid = getInfo( QStringLiteral( "srid" ), gisdbase, location );
QgsDebugMsgLevel( QStringLiteral( "srid: %1" ).arg( srid ), 2 );
crs = QgsCoordinateReferenceSystem( srid );
if ( crs.isValid() )
return crs;
}
catch ( QgsGrass::Exception &e )
{
error = tr( "Cannot get SRID" ) + "\n" + e.what();
QgsDebugError( error );
}

// else try WKT
QgsCoordinateReferenceSystem crs = QgsCoordinateReferenceSystem();
try
{
const QString wkt = getInfo( QStringLiteral( "wkt" ), gisdbase, location );
QgsDebugMsgLevel( QStringLiteral( "wkt: %1" ).arg( wkt ), 2 );
QString wkt = getInfo( QStringLiteral( "proj" ), gisdbase, location );
QgsDebugMsgLevel( "wkt: " + wkt, 2 );
crs = QgsCoordinateReferenceSystem::fromWkt( wkt );
QgsDebugMsgLevel( "crs.toWkt: " + crs.toWkt(), 2 );
if ( crs.isValid() )
return crs;
}
catch ( QgsGrass::Exception &e )
{
error = tr( "Cannot get projection" ) + "\n" + e.what();
QgsDebugError( error );
}

//else try lossy old proj properties approach
try
{
const QString wktFromProjString = getInfo( QStringLiteral( "proj" ), gisdbase, location );
QgsDebugMsgLevel( QStringLiteral( "WKT from proj string: %1" ).arg( wktFromProjString ), 2 );
crs = QgsCoordinateReferenceSystem::fromWkt( wktFromProjString );
QgsDebugMsgLevel( "crs.toWkt: " + crs.toWkt(), 2 );
if ( crs.isValid() )
return crs;
}
catch ( QgsGrass::Exception &e )
{
Expand Down
18 changes: 0 additions & 18 deletions tests/testdata/grass/webmerc/PERMANENT/DEFAULT_WIND

This file was deleted.

12 changes: 0 additions & 12 deletions tests/testdata/grass/webmerc/PERMANENT/PROJ_INFO

This file was deleted.

1 change: 0 additions & 1 deletion tests/testdata/grass/webmerc/PERMANENT/PROJ_SRID

This file was deleted.

3 changes: 0 additions & 3 deletions tests/testdata/grass/webmerc/PERMANENT/PROJ_UNITS

This file was deleted.

1 change: 0 additions & 1 deletion tests/testdata/grass/webmerc/PERMANENT/PROJ_WKT

This file was deleted.

18 changes: 0 additions & 18 deletions tests/testdata/grass/webmerc/PERMANENT/WIND

This file was deleted.

18 changes: 0 additions & 18 deletions tests/testdata/grass/webmerc/webmerc/WIND

This file was deleted.

Binary file removed tests/testdata/grass/webmerc/webmerc/vector/ff/coor
Binary file not shown.
Empty file.
10 changes: 0 additions & 10 deletions tests/testdata/grass/webmerc/webmerc/vector/ff/head

This file was deleted.

4 changes: 0 additions & 4 deletions tests/testdata/grass/webmerc/webmerc/vector/ff/hist

This file was deleted.

0 comments on commit c1905c2

Please sign in to comment.