Skip to content
Permalink
Browse files

ifdef 0 single source/destination transforms

  • Loading branch information
3nids authored and nyalldawson committed Dec 15, 2017
1 parent 080bea1 commit e303f746e105585fcb453bc0d00368ecf3b28aa6
@@ -61,91 +61,7 @@ class QgsCoordinateTransformContext
Clears all stored transform information from the context.
%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;
%Docstring
@@ -40,8 +40,11 @@ int QgsDatumTransformTableModel::rowCount( const QModelIndex &parent ) const
{
Q_UNUSED( parent );
return mTransformContext.sourceDestinationDatumTransforms().count()
#ifdef singlesourcedest
+ mTransformContext.sourceDatumTransforms().count()
+ mTransformContext.destinationDatumTransforms().count();
+ mTransformContext.destinationDatumTransforms().count()
#endif
;
}

int QgsDatumTransformTableModel::columnCount( const QModelIndex &parent ) const
@@ -57,15 +60,19 @@ QVariant QgsDatumTransformTableModel::data( const QModelIndex &index, int role )
int sourceTransform = -1;
int destinationTransform = -1;

#ifdef singlesourcedest
if ( index.row() < mTransformContext.sourceDestinationDatumTransforms().count() )
{
#endif
QPair< QString, QString> crses = mTransformContext.sourceDestinationDatumTransforms().keys().at( index.row() );
sourceCrs = crses.first;
destinationCrs = crses.second;
QPair< int, int> transforms = mTransformContext.sourceDestinationDatumTransforms().value( crses );
sourceTransform = transforms.first;
destinationTransform = transforms.second;
#ifdef singlesourcedest
}
#endif

switch ( role )
{
@@ -42,6 +42,7 @@ void QgsCoordinateTransformContext::clear()
d->mLock.unlock();
}

#ifdef singlesourcedest
QMap<QString, int> QgsCoordinateTransformContext::sourceDatumTransforms() const
{
d->mLock.lockForRead();
@@ -95,6 +96,8 @@ void QgsCoordinateTransformContext::removeDestinationDatumTransform( const QgsCo
d->mDestDatumTransforms.remove( crs.authid() );
}

#endif

QMap<QPair<QString, QString>, QPair<int, int> > QgsCoordinateTransformContext::sourceDestinationDatumTransforms() const
{
d->mLock.lockForRead();
@@ -129,17 +132,16 @@ QPair<int, int> QgsCoordinateTransformContext::calculateDatumTransforms( const Q
d->mLock.lockForRead();
// highest priority is exact match for source/dest pair
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
int srcTransform = d->mSourceDatumTransforms.value( srcKey, -1 );
int destTransform = d->mDestDatumTransforms.value( destKey, -1 );
d->mLock.unlock();
return qMakePair( srcTransform, destTransform );
#endif
}

void QgsCoordinateTransformContext::readXml( const QDomElement &element, const QDomDocument &, const QgsReadWriteContext & )
@@ -78,6 +78,10 @@ class CORE_EXPORT QgsCoordinateTransformContext
*/
void clear();


#if 0
//singlesourcedest

/**
* Returns the stored mapping for source CRS to associated datum transform to use.
* The map keys will be QgsCoordinateReferenceSystems::authid()s.
@@ -160,6 +164,8 @@ class CORE_EXPORT QgsCoordinateTransformContext
*/
void removeDestinationDatumTransform( const QgsCoordinateReferenceSystem &crs );

#endif

/**
* Returns the stored mapping for source to destination CRS pairs to associated datum transforms to use.
* The map keys will be QgsCoordinateReferenceSystems::authid()s.
@@ -183,6 +183,7 @@ void TestQgsCoordinateTransform::isShortCircuited()

void TestQgsCoordinateTransform::contextShared()
{
#ifdef singlesourcedest
//test implicit sharing of QgsCoordinateTransformContext
QgsCoordinateTransformContext original;
original.addDestinationDatumTransform( QgsCoordinateReferenceSystem( 3111 ), 1 );
@@ -211,6 +212,7 @@ void TestQgsCoordinateTransform::contextShared()
QCOMPARE( original.destinationDatumTransforms(), expected );
expected.insert( "EPSG:3111", 3 );
QCOMPARE( copy2.destinationDatumTransforms(), expected );
#endif
}


0 comments on commit e303f74

Please sign in to comment.
You can’t perform that action at this time.