Skip to content
Permalink
Browse files

Merge pull request #6370 from nyalldawson/afs

ArcGIS feature server: implement provider test suite and fix issues
  • Loading branch information
nyalldawson committed Feb 20, 2018
2 parents e3fbb4c + 7980f30 commit 64369f8099844061b29d08c03fe1c58581963130
@@ -755,14 +755,48 @@ were found.
.. versionadded:: 3.0
%End

bool intersects( const QgsRectangle &r ) const;
bool intersects( const QgsRectangle &rectangle ) const;
%Docstring
Tests for intersection with a rectangle (uses GEOS)
Returns true if this geometry exactly intersects with a ``rectangle``. This test is exact
and can be slow for complex geometries.

The GEOS library is used to perform the intersection test. Geometries which are not
valid may return incorrect results.

.. seealso:: :py:func:`boundingBoxIntersects`
%End

bool intersects( const QgsGeometry &geometry ) const;
%Docstring
Tests for intersection with a geometry (uses GEOS)
Returns true if this geometry exactly intersects with another ``geometry``. This test is exact
and can be slow for complex geometries.

The GEOS library is used to perform the intersection test. Geometries which are not
valid may return incorrect results.

.. seealso:: :py:func:`boundingBoxIntersects`
%End

bool boundingBoxIntersects( const QgsRectangle &rectangle ) const;
%Docstring
Returns true if the bounding box of this geometry intersects with a ``rectangle``. Since this
test only considers the bounding box of the geometry, is is very fast to calculate and handles invalid
geometries.

.. seealso:: :py:func:`intersects`

.. versionadded:: 3.0
%End

bool boundingBoxIntersects( const QgsGeometry &geometry ) const;
%Docstring
Returns true if the bounding box of this geometry intersects with the bounding box of another ``geometry``. Since this
test only considers the bounding box of the geometries, is is very fast to calculate and handles invalid
geometries.

.. seealso:: :py:func:`intersects`

.. versionadded:: 3.0
%End

bool contains( const QgsPointXY *p ) const;
@@ -1106,6 +1106,26 @@ bool QgsGeometry::intersects( const QgsGeometry &geometry ) const
return geos.intersects( geometry.d->geometry.get(), &mLastError );
}

bool QgsGeometry::boundingBoxIntersects( const QgsRectangle &rectangle ) const
{
if ( !d->geometry )
{
return false;
}

return d->geometry->boundingBox().intersects( rectangle );
}

bool QgsGeometry::boundingBoxIntersects( const QgsGeometry &geometry ) const
{
if ( !d->geometry || geometry.isNull() )
{
return false;
}

return d->geometry->boundingBox().intersects( geometry.constGet()->boundingBox() );
}

bool QgsGeometry::contains( const QgsPointXY *p ) const
{
if ( !d->geometry || !p )
@@ -798,12 +798,50 @@ class CORE_EXPORT QgsGeometry
*/
bool removeDuplicateNodes( double epsilon = 4 * DBL_EPSILON, bool useZValues = false );

//! Tests for intersection with a rectangle (uses GEOS)
bool intersects( const QgsRectangle &r ) const;
/**
* Returns true if this geometry exactly intersects with a \a rectangle. This test is exact
* and can be slow for complex geometries.
*
* The GEOS library is used to perform the intersection test. Geometries which are not
* valid may return incorrect results.
*
* \see boundingBoxIntersects()
*/
bool intersects( const QgsRectangle &rectangle ) const;

//! Tests for intersection with a geometry (uses GEOS)
/**
* Returns true if this geometry exactly intersects with another \a geometry. This test is exact
* and can be slow for complex geometries.
*
* The GEOS library is used to perform the intersection test. Geometries which are not
* valid may return incorrect results.
*
* \see boundingBoxIntersects()
*/
bool intersects( const QgsGeometry &geometry ) const;

/**
* Returns true if the bounding box of this geometry intersects with a \a rectangle. Since this
* test only considers the bounding box of the geometry, is is very fast to calculate and handles invalid
* geometries.
*
* \see intersects()
*
* \since QGIS 3.0
*/
bool boundingBoxIntersects( const QgsRectangle &rectangle ) const;

/**
* Returns true if the bounding box of this geometry intersects with the bounding box of another \a geometry. Since this
* test only considers the bounding box of the geometries, is is very fast to calculate and handles invalid
* geometries.
*
* \see intersects()
*
* \since QGIS 3.0
*/
bool boundingBoxIntersects( const QgsGeometry &geometry ) const;

//! Tests for containment of a point (uses GEOS)
bool contains( const QgsPointXY *p ) const;

@@ -483,18 +483,19 @@ void QgsVectorDataProvider::fillMinMaxCache() const
{
if ( flds.at( i ).type() == QVariant::Int )
{
mCacheMinValues[i] = QVariant( INT_MAX );
mCacheMaxValues[i] = QVariant( INT_MIN );
mCacheMinValues[i] = QVariant( std::numeric_limits<int>::max() );
mCacheMaxValues[i] = QVariant( std::numeric_limits<int>::lowest() );
}
else if ( flds.at( i ).type() == QVariant::LongLong )
{
mCacheMinValues[i] = QVariant( std::numeric_limits<qlonglong>::max() );
mCacheMaxValues[i] = QVariant( std::numeric_limits<qlonglong>::min() );
mCacheMaxValues[i] = QVariant( std::numeric_limits<qlonglong>::lowest() );
}
else if ( flds.at( i ).type() == QVariant::Double )
{
mCacheMinValues[i] = QVariant( DBL_MAX );
mCacheMaxValues[i] = QVariant( -DBL_MAX );
mCacheMinValues[i] = QVariant( std::numeric_limits<double>::max() );
mCacheMaxValues[i] = QVariant( std::numeric_limits<double>::lowest() );

}
else
{
@@ -504,54 +505,61 @@ void QgsVectorDataProvider::fillMinMaxCache() const
}

QgsFeature f;
QgsAttributeList keys = mCacheMinValues.keys();
const QgsAttributeList keys = mCacheMinValues.keys();
QgsFeatureIterator fi = getFeatures( QgsFeatureRequest().setSubsetOfAttributes( keys )
.setFlags( QgsFeatureRequest::NoGeometry ) );

while ( fi.nextFeature( f ) )
{
QgsAttributes attrs = f.attributes();
for ( QgsAttributeList::const_iterator it = keys.constBegin(); it != keys.constEnd(); ++it )
for ( int attributeIndex : keys )
{
const QVariant &varValue = attrs.at( *it );
const QVariant &varValue = attrs.at( attributeIndex );

if ( varValue.isNull() )
continue;

if ( flds.at( *it ).type() == QVariant::Int )
{
int value = varValue.toInt();
if ( value < mCacheMinValues[*it].toInt() )
mCacheMinValues[*it] = value;
if ( value > mCacheMaxValues[*it].toInt() )
mCacheMaxValues[*it] = value;
}
else if ( flds.at( *it ).type() == QVariant::LongLong )
switch ( flds.at( attributeIndex ).type() )
{
qlonglong value = varValue.toLongLong();
if ( value < mCacheMinValues[*it].toLongLong() )
mCacheMinValues[*it] = value;
if ( value > mCacheMaxValues[*it].toLongLong() )
mCacheMaxValues[*it] = value;
}
else if ( flds.at( *it ).type() == QVariant::Double )
{
double value = varValue.toDouble();
if ( value < mCacheMinValues[*it].toDouble() )
mCacheMinValues[*it] = value;
if ( value > mCacheMaxValues[*it].toDouble() )
mCacheMaxValues[*it] = value;
}
else
{
QString value = varValue.toString();
if ( mCacheMinValues[*it].isNull() || value < mCacheMinValues[*it].toString() )
case QVariant::Int:
{
int value = varValue.toInt();
if ( value < mCacheMinValues[ attributeIndex ].toInt() )
mCacheMinValues[ attributeIndex ] = value;
if ( value > mCacheMaxValues[ attributeIndex ].toInt() )
mCacheMaxValues[ attributeIndex ] = value;
break;
}
case QVariant::LongLong:
{
qlonglong value = varValue.toLongLong();
if ( value < mCacheMinValues[ attributeIndex ].toLongLong() )
mCacheMinValues[ attributeIndex ] = value;
if ( value > mCacheMaxValues[ attributeIndex ].toLongLong() )
mCacheMaxValues[ attributeIndex ] = value;
break;
}
case QVariant::Double:
{
mCacheMinValues[*it] = value;
double value = varValue.toDouble();
if ( value < mCacheMinValues[ attributeIndex ].toDouble() )
mCacheMinValues[attributeIndex ] = value;
if ( value > mCacheMaxValues[ attributeIndex ].toDouble() )
mCacheMaxValues[ attributeIndex ] = value;
break;
}
if ( mCacheMaxValues[*it].isNull() || value > mCacheMaxValues[*it].toString() )
default:
{
mCacheMaxValues[*it] = value;
QString value = varValue.toString();
if ( mCacheMinValues[ attributeIndex ].isNull() || value < mCacheMinValues[attributeIndex ].toString() )
{
mCacheMinValues[attributeIndex] = value;
}
if ( mCacheMaxValues[attributeIndex].isNull() || value > mCacheMaxValues[attributeIndex].toString() )
{
mCacheMaxValues[attributeIndex] = value;
}
break;
}
}
}
@@ -531,6 +531,7 @@ void QgsMetadataWidget::setPropertiesFromLayer()

// Links
const QList<QgsLayerMetadata::Link> &links = mMetadata.links();
mLinksModel->setRowCount( 0 );
for ( const QgsLayerMetadata::Link &link : links )
{
int row = mLinksModel->rowCount();

0 comments on commit 64369f8

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