mirror of
https://github.com/qgis/QGIS.git
synced 2025-10-07 00:15:48 -04:00
Handle polar CRS with NE axis order
This commit is contained in:
parent
9e127a8358
commit
4b9e1d665e
@ -113,6 +113,7 @@ bool QgsProjUtils::usesAngularUnit( const QString &projDef )
|
|||||||
bool QgsProjUtils::axisOrderIsSwapped( const PJ *crs )
|
bool QgsProjUtils::axisOrderIsSwapped( const PJ *crs )
|
||||||
{
|
{
|
||||||
//ported from https://github.com/pramsey/postgis/blob/7ecf6839c57a838e2c8540001a3cd35b78a730db/liblwgeom/lwgeom_transform.c#L299
|
//ported from https://github.com/pramsey/postgis/blob/7ecf6839c57a838e2c8540001a3cd35b78a730db/liblwgeom/lwgeom_transform.c#L299
|
||||||
|
//and GDAL OGRSpatialReference::isNorthEastAxisOrder https://github.com/OSGeo/gdal/blob/release/3.10/ogr/ogrspatialreference.cpp#L419
|
||||||
if ( !crs )
|
if ( !crs )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@ -129,19 +130,46 @@ bool QgsProjUtils::axisOrderIsSwapped( const PJ *crs )
|
|||||||
const int axisCount = proj_cs_get_axis_count( context, pjCs.get() );
|
const int axisCount = proj_cs_get_axis_count( context, pjCs.get() );
|
||||||
if ( axisCount > 0 )
|
if ( axisCount > 0 )
|
||||||
{
|
{
|
||||||
const char *outDirection = nullptr;
|
const char *outDirection0 = nullptr;
|
||||||
// Read only first axis, see if it is degrees / north
|
const char *outDirection1 = nullptr;
|
||||||
|
const char *outName0 = nullptr;
|
||||||
|
const char *outName1 = nullptr;
|
||||||
|
|
||||||
proj_cs_get_axis_info( context, pjCs.get(), 0,
|
proj_cs_get_axis_info( context, pjCs.get(), 0,
|
||||||
|
&outName0,
|
||||||
nullptr,
|
nullptr,
|
||||||
nullptr,
|
&outDirection0,
|
||||||
&outDirection,
|
|
||||||
nullptr,
|
nullptr,
|
||||||
nullptr,
|
nullptr,
|
||||||
nullptr,
|
nullptr,
|
||||||
nullptr
|
nullptr
|
||||||
);
|
);
|
||||||
return QString( outDirection ).compare( QLatin1String( "north" ), Qt::CaseInsensitive ) == 0;
|
|
||||||
|
proj_cs_get_axis_info( context, pjCs.get(), 1,
|
||||||
|
&outName1,
|
||||||
|
nullptr,
|
||||||
|
&outDirection1,
|
||||||
|
nullptr,
|
||||||
|
nullptr,
|
||||||
|
nullptr,
|
||||||
|
nullptr
|
||||||
|
);
|
||||||
|
|
||||||
|
if ( QString( outDirection0 ).compare( QLatin1String( "north" ), Qt::CaseInsensitive ) == 0 &&
|
||||||
|
QString( outDirection1 ).compare( QLatin1String( "east" ), Qt::CaseInsensitive ) == 0 )
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Handle polar projections with NE-order
|
||||||
|
if ( ( QString( outDirection0 ).compare( QLatin1String( "north" ), Qt::CaseInsensitive ) == 0 &&
|
||||||
|
QString( outDirection1 ).compare( QLatin1String( "north" ), Qt::CaseInsensitive ) == 0 ) ||
|
||||||
|
( QString( outDirection0 ).compare( QLatin1String( "south" ), Qt::CaseInsensitive ) == 0 &&
|
||||||
|
QString( outDirection1 ).compare( QLatin1String( "south" ), Qt::CaseInsensitive ) == 0 ) )
|
||||||
|
{
|
||||||
|
return QString( outName0 ).startsWith( QLatin1String( "northing" ), Qt::CaseInsensitive ) &&
|
||||||
|
QString( outName1 ).startsWith( QLatin1String( "easting" ), Qt::CaseInsensitive ) ;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -95,6 +95,12 @@ void TestQgsProjUtils::axisOrderIsSwapped()
|
|||||||
QVERIFY( QgsProjUtils::axisOrderIsSwapped( crs.get() ) );
|
QVERIFY( QgsProjUtils::axisOrderIsSwapped( crs.get() ) );
|
||||||
crs.reset( proj_create( context, "urn:ogc:def:crs:EPSG::3903" ) );
|
crs.reset( proj_create( context, "urn:ogc:def:crs:EPSG::3903" ) );
|
||||||
QVERIFY( QgsProjUtils::axisOrderIsSwapped( crs.get() ) );
|
QVERIFY( QgsProjUtils::axisOrderIsSwapped( crs.get() ) );
|
||||||
|
crs.reset( proj_create( context, "urn:ogc:def:crs:EPSG::32761" ) );
|
||||||
|
QVERIFY( QgsProjUtils::axisOrderIsSwapped( crs.get() ) );
|
||||||
|
crs.reset( proj_create( context, "urn:ogc:def:crs:EPSG::5482" ) );
|
||||||
|
QVERIFY( QgsProjUtils::axisOrderIsSwapped( crs.get() ) );
|
||||||
|
crs.reset( proj_create( context, "urn:ogc:def:crs:EPSG::32661" ) );
|
||||||
|
QVERIFY( QgsProjUtils::axisOrderIsSwapped( crs.get() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestQgsProjUtils::searchPath()
|
void TestQgsProjUtils::searchPath()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user