mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-15 00:04:00 -04:00
ifdef 0 single source/destination transforms
This commit is contained in:
parent
080bea1989
commit
e303f746e1
@ -61,91 +61,7 @@ class QgsCoordinateTransformContext
|
|||||||
Clears all stored transform information from the context.
|
Clears all stored transform information from the context.
|
||||||
%End
|
%End
|
||||||
|
|
||||||
QMap<QString, int> sourceDatumTransforms() const;
|
|
||||||
%Docstring
|
|
||||||
Returns the stored mapping for source CRS to associated datum transform to use.
|
|
||||||
The map keys will be QgsCoordinateReferenceSystems.authid()s.
|
|
||||||
|
|
||||||
A datum transform of -1 indicates that no datum transform is required for the
|
|
||||||
source CRS.
|
|
||||||
|
|
||||||
\warning This method should not be used to calculate the corresponding datum transforms
|
|
||||||
to use for a coordinate transform. Instead, always use calculateDatumTransforms()
|
|
||||||
to determine this.
|
|
||||||
|
|
||||||
.. seealso:: addSourceDatumTransform()
|
|
||||||
.. seealso:: destinationDatumTransforms()
|
|
||||||
:rtype: QMap<str, int>
|
|
||||||
%End
|
|
||||||
|
|
||||||
bool addSourceDatumTransform( const QgsCoordinateReferenceSystem &crs, int transform );
|
|
||||||
%Docstring
|
|
||||||
Adds a new ``transform`` to use when projecting coordinates from the specified source
|
|
||||||
``crs``.
|
|
||||||
|
|
||||||
A datum ``transform`` of -1 indicates that no datum transform is required for the
|
|
||||||
source CRS.
|
|
||||||
|
|
||||||
Returns true if the new transform was added successfully.
|
|
||||||
|
|
||||||
\warning Transforms set using this method may be overridden by specific source/destination
|
|
||||||
transforms set by addSourceDestinationDatumTransform().
|
|
||||||
|
|
||||||
.. seealso:: sourceDatumTransforms()
|
|
||||||
.. seealso:: addDestinationDatumTransform()
|
|
||||||
.. seealso:: removeSourceDatumTransform()
|
|
||||||
:rtype: bool
|
|
||||||
%End
|
|
||||||
|
|
||||||
void removeSourceDatumTransform( const QgsCoordinateReferenceSystem &crs );
|
|
||||||
%Docstring
|
|
||||||
Removes the source datum transform for the specified ``crs``.
|
|
||||||
.. seealso:: addSourceDatumTransform()
|
|
||||||
.. seealso:: removeDestinationDatumTransform()
|
|
||||||
%End
|
|
||||||
|
|
||||||
QMap< QString, int > destinationDatumTransforms() const;
|
|
||||||
%Docstring
|
|
||||||
Returns the stored mapping for destination CRS to associated datum transform to use.
|
|
||||||
The map keys will be QgsCoordinateReferenceSystems.authid()s.
|
|
||||||
|
|
||||||
A datum transform of -1 indicates that no datum transform is required for the
|
|
||||||
destination CRS.
|
|
||||||
|
|
||||||
\warning This method should not be used to calculate the corresponding datum transforms
|
|
||||||
to use for a coordinate transform. Instead, always use calculateDatumTransforms()
|
|
||||||
to determine this.
|
|
||||||
|
|
||||||
.. seealso:: addDestinationDatumTransform()
|
|
||||||
.. seealso:: sourceDatumTransforms()
|
|
||||||
:rtype: QMap< str, int >
|
|
||||||
%End
|
|
||||||
|
|
||||||
bool addDestinationDatumTransform( const QgsCoordinateReferenceSystem &crs, int transform );
|
|
||||||
%Docstring
|
|
||||||
Adds a new ``transform`` to use when projecting coordinates to the specified destination
|
|
||||||
``crs``.
|
|
||||||
|
|
||||||
A datum ``transform`` of -1 indicates that no datum transform is required for the
|
|
||||||
destination CRS.
|
|
||||||
|
|
||||||
Returns true if the new transform was added successfully.
|
|
||||||
|
|
||||||
\warning Transforms set using this method may be overridden by specific source/destination
|
|
||||||
transforms set by addSourceDestinationDatumTransform().
|
|
||||||
|
|
||||||
.. seealso:: destinationDatumTransforms()
|
|
||||||
.. seealso:: addSourceDatumTransform()
|
|
||||||
.. seealso:: removeDestinationDatumTransform()
|
|
||||||
:rtype: bool
|
|
||||||
%End
|
|
||||||
|
|
||||||
void removeDestinationDatumTransform( const QgsCoordinateReferenceSystem &crs );
|
|
||||||
%Docstring
|
|
||||||
Removes the destination datum transform for the specified ``crs``.
|
|
||||||
.. seealso:: addDestinationDatumTransform()
|
|
||||||
.. seealso:: removeSourceDatumTransform()
|
|
||||||
%End
|
|
||||||
|
|
||||||
QMap< QPair< QString, QString>, QPair< int, int > > sourceDestinationDatumTransforms() const;
|
QMap< QPair< QString, QString>, QPair< int, int > > sourceDestinationDatumTransforms() const;
|
||||||
%Docstring
|
%Docstring
|
||||||
|
@ -40,8 +40,11 @@ int QgsDatumTransformTableModel::rowCount( const QModelIndex &parent ) const
|
|||||||
{
|
{
|
||||||
Q_UNUSED( parent );
|
Q_UNUSED( parent );
|
||||||
return mTransformContext.sourceDestinationDatumTransforms().count()
|
return mTransformContext.sourceDestinationDatumTransforms().count()
|
||||||
|
#ifdef singlesourcedest
|
||||||
+ mTransformContext.sourceDatumTransforms().count()
|
+ mTransformContext.sourceDatumTransforms().count()
|
||||||
+ mTransformContext.destinationDatumTransforms().count();
|
+ mTransformContext.destinationDatumTransforms().count()
|
||||||
|
#endif
|
||||||
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
int QgsDatumTransformTableModel::columnCount( const QModelIndex &parent ) const
|
int QgsDatumTransformTableModel::columnCount( const QModelIndex &parent ) const
|
||||||
@ -57,15 +60,19 @@ QVariant QgsDatumTransformTableModel::data( const QModelIndex &index, int role )
|
|||||||
int sourceTransform = -1;
|
int sourceTransform = -1;
|
||||||
int destinationTransform = -1;
|
int destinationTransform = -1;
|
||||||
|
|
||||||
|
#ifdef singlesourcedest
|
||||||
if ( index.row() < mTransformContext.sourceDestinationDatumTransforms().count() )
|
if ( index.row() < mTransformContext.sourceDestinationDatumTransforms().count() )
|
||||||
{
|
{
|
||||||
|
#endif
|
||||||
QPair< QString, QString> crses = mTransformContext.sourceDestinationDatumTransforms().keys().at( index.row() );
|
QPair< QString, QString> crses = mTransformContext.sourceDestinationDatumTransforms().keys().at( index.row() );
|
||||||
sourceCrs = crses.first;
|
sourceCrs = crses.first;
|
||||||
destinationCrs = crses.second;
|
destinationCrs = crses.second;
|
||||||
QPair< int, int> transforms = mTransformContext.sourceDestinationDatumTransforms().value( crses );
|
QPair< int, int> transforms = mTransformContext.sourceDestinationDatumTransforms().value( crses );
|
||||||
sourceTransform = transforms.first;
|
sourceTransform = transforms.first;
|
||||||
destinationTransform = transforms.second;
|
destinationTransform = transforms.second;
|
||||||
|
#ifdef singlesourcedest
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
switch ( role )
|
switch ( role )
|
||||||
{
|
{
|
||||||
|
@ -42,6 +42,7 @@ void QgsCoordinateTransformContext::clear()
|
|||||||
d->mLock.unlock();
|
d->mLock.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef singlesourcedest
|
||||||
QMap<QString, int> QgsCoordinateTransformContext::sourceDatumTransforms() const
|
QMap<QString, int> QgsCoordinateTransformContext::sourceDatumTransforms() const
|
||||||
{
|
{
|
||||||
d->mLock.lockForRead();
|
d->mLock.lockForRead();
|
||||||
@ -95,6 +96,8 @@ void QgsCoordinateTransformContext::removeDestinationDatumTransform( const QgsCo
|
|||||||
d->mDestDatumTransforms.remove( crs.authid() );
|
d->mDestDatumTransforms.remove( crs.authid() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
QMap<QPair<QString, QString>, QPair<int, int> > QgsCoordinateTransformContext::sourceDestinationDatumTransforms() const
|
QMap<QPair<QString, QString>, QPair<int, int> > QgsCoordinateTransformContext::sourceDestinationDatumTransforms() const
|
||||||
{
|
{
|
||||||
d->mLock.lockForRead();
|
d->mLock.lockForRead();
|
||||||
@ -129,17 +132,16 @@ QPair<int, int> QgsCoordinateTransformContext::calculateDatumTransforms( const Q
|
|||||||
d->mLock.lockForRead();
|
d->mLock.lockForRead();
|
||||||
// highest priority is exact match for source/dest pair
|
// highest priority is exact match for source/dest pair
|
||||||
QPair< int, int > res = d->mSourceDestDatumTransforms.value( qMakePair( srcKey, destKey ), qMakePair( -1, -1 ) );
|
QPair< int, int > res = d->mSourceDestDatumTransforms.value( qMakePair( srcKey, destKey ), qMakePair( -1, -1 ) );
|
||||||
if ( res.first != -1 && res.second != -1 )
|
d->mLock.unlock();
|
||||||
{
|
return res;
|
||||||
d->mLock.unlock();
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
#ifdef singlesourcedest
|
||||||
// fallback to checking src and dest separately
|
// fallback to checking src and dest separately
|
||||||
int srcTransform = d->mSourceDatumTransforms.value( srcKey, -1 );
|
int srcTransform = d->mSourceDatumTransforms.value( srcKey, -1 );
|
||||||
int destTransform = d->mDestDatumTransforms.value( destKey, -1 );
|
int destTransform = d->mDestDatumTransforms.value( destKey, -1 );
|
||||||
d->mLock.unlock();
|
d->mLock.unlock();
|
||||||
return qMakePair( srcTransform, destTransform );
|
return qMakePair( srcTransform, destTransform );
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void QgsCoordinateTransformContext::readXml( const QDomElement &element, const QDomDocument &, const QgsReadWriteContext & )
|
void QgsCoordinateTransformContext::readXml( const QDomElement &element, const QDomDocument &, const QgsReadWriteContext & )
|
||||||
|
@ -78,6 +78,10 @@ class CORE_EXPORT QgsCoordinateTransformContext
|
|||||||
*/
|
*/
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
//singlesourcedest
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the stored mapping for source CRS to associated datum transform to use.
|
* Returns the stored mapping for source CRS to associated datum transform to use.
|
||||||
* The map keys will be QgsCoordinateReferenceSystems::authid()s.
|
* The map keys will be QgsCoordinateReferenceSystems::authid()s.
|
||||||
@ -160,6 +164,8 @@ class CORE_EXPORT QgsCoordinateTransformContext
|
|||||||
*/
|
*/
|
||||||
void removeDestinationDatumTransform( const QgsCoordinateReferenceSystem &crs );
|
void removeDestinationDatumTransform( const QgsCoordinateReferenceSystem &crs );
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the stored mapping for source to destination CRS pairs to associated datum transforms to use.
|
* Returns the stored mapping for source to destination CRS pairs to associated datum transforms to use.
|
||||||
* The map keys will be QgsCoordinateReferenceSystems::authid()s.
|
* The map keys will be QgsCoordinateReferenceSystems::authid()s.
|
||||||
|
@ -183,6 +183,7 @@ void TestQgsCoordinateTransform::isShortCircuited()
|
|||||||
|
|
||||||
void TestQgsCoordinateTransform::contextShared()
|
void TestQgsCoordinateTransform::contextShared()
|
||||||
{
|
{
|
||||||
|
#ifdef singlesourcedest
|
||||||
//test implicit sharing of QgsCoordinateTransformContext
|
//test implicit sharing of QgsCoordinateTransformContext
|
||||||
QgsCoordinateTransformContext original;
|
QgsCoordinateTransformContext original;
|
||||||
original.addDestinationDatumTransform( QgsCoordinateReferenceSystem( 3111 ), 1 );
|
original.addDestinationDatumTransform( QgsCoordinateReferenceSystem( 3111 ), 1 );
|
||||||
@ -211,6 +212,7 @@ void TestQgsCoordinateTransform::contextShared()
|
|||||||
QCOMPARE( original.destinationDatumTransforms(), expected );
|
QCOMPARE( original.destinationDatumTransforms(), expected );
|
||||||
expected.insert( "EPSG:3111", 3 );
|
expected.insert( "EPSG:3111", 3 );
|
||||||
QCOMPARE( copy2.destinationDatumTransforms(), expected );
|
QCOMPARE( copy2.destinationDatumTransforms(), expected );
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user