mirror of
https://github.com/qgis/QGIS.git
synced 2025-10-09 00:08:52 -04:00
Proj < 6 updates
This commit is contained in:
parent
59a2cf1424
commit
e64a6acd38
@ -45,6 +45,9 @@
|
|||||||
#include <proj_api.h>
|
#include <proj_api.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "qgsogrutils.h"
|
||||||
|
#include <ogr_srs_api.h>
|
||||||
|
|
||||||
QgsCustomProjectionDialog::QgsCustomProjectionDialog( QWidget *parent, Qt::WindowFlags fl )
|
QgsCustomProjectionDialog::QgsCustomProjectionDialog( QWidget *parent, Qt::WindowFlags fl )
|
||||||
: QDialog( parent, fl )
|
: QDialog( parent, fl )
|
||||||
{
|
{
|
||||||
@ -615,6 +618,31 @@ void QgsCustomProjectionDialog::validateCurrent()
|
|||||||
proj_context_destroy( context );
|
proj_context_destroy( context );
|
||||||
context = nullptr;
|
context = nullptr;
|
||||||
#else
|
#else
|
||||||
|
switch ( static_cast< Format >( mFormatComboBox->currentData().toInt() ) )
|
||||||
|
{
|
||||||
|
case Format::Wkt:
|
||||||
|
{
|
||||||
|
QByteArray ba = projDef.toLatin1();
|
||||||
|
const char *pWkt = ba.data();
|
||||||
|
OGRSpatialReferenceH crs = OSRNewSpatialReference( nullptr );
|
||||||
|
|
||||||
|
OGRErr myInputResult = OSRImportFromWkt( crs, const_cast< char ** >( & pWkt ) );
|
||||||
|
if ( myInputResult == OGRERR_NONE )
|
||||||
|
{
|
||||||
|
QMessageBox::information( this, tr( "Custom Coordinate Reference System" ),
|
||||||
|
tr( "This WKT projection definition is valid." ) );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
QMessageBox::warning( this, tr( "Custom Coordinate Reference System" ),
|
||||||
|
tr( "This WKT projection definition is not valid." ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
OSRDestroySpatialReference( crs );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case Format::Proj:
|
||||||
|
{
|
||||||
projCtx pContext = pj_ctx_alloc();
|
projCtx pContext = pj_ctx_alloc();
|
||||||
projPJ proj = pj_init_plus_ctx( pContext, projDef.toLocal8Bit().data() );
|
projPJ proj = pj_init_plus_ctx( pContext, projDef.toLocal8Bit().data() );
|
||||||
|
|
||||||
@ -628,9 +656,12 @@ void QgsCustomProjectionDialog::validateCurrent()
|
|||||||
QMessageBox::warning( this, tr( "Custom Coordinate Reference System" ),
|
QMessageBox::warning( this, tr( "Custom Coordinate Reference System" ),
|
||||||
tr( "This proj projection definition is not valid" ) );
|
tr( "This proj projection definition is not valid" ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
pj_free( proj );
|
pj_free( proj );
|
||||||
pj_ctx_free( pContext );
|
pj_ctx_free( pContext );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -668,6 +699,14 @@ void QgsCustomProjectionDialog::pbnCalculate_clicked()
|
|||||||
QString projDef = teParameters->toPlainText();
|
QString projDef = teParameters->toPlainText();
|
||||||
QgsDebugMsgLevel( QStringLiteral( "Proj: %1" ).arg( projDef ), 3 );
|
QgsDebugMsgLevel( QStringLiteral( "Proj: %1" ).arg( projDef ), 3 );
|
||||||
#else
|
#else
|
||||||
|
if ( static_cast< Format >( mFormatComboBox->currentData().toInt() ) == Format::Wkt )
|
||||||
|
{
|
||||||
|
// it's not trivial to implement, and we've gotta draw the line somewhere...
|
||||||
|
QMessageBox::warning( this, tr( "Custom Coordinate Reference System" ),
|
||||||
|
tr( "Testing WKT based CRS definitions requires Proj version 6 or later." ) );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
projCtx pContext = pj_ctx_alloc();
|
projCtx pContext = pj_ctx_alloc();
|
||||||
projPJ proj = pj_init_plus_ctx( pContext, teParameters->toPlainText().toLocal8Bit().data() );
|
projPJ proj = pj_init_plus_ctx( pContext, teParameters->toPlainText().toLocal8Bit().data() );
|
||||||
QgsDebugMsgLevel( QStringLiteral( "Proj: %1" ).arg( teParameters->toPlainText() ), 3 );
|
QgsDebugMsgLevel( QStringLiteral( "Proj: %1" ).arg( teParameters->toPlainText() ), 3 );
|
||||||
|
Loading…
x
Reference in New Issue
Block a user