diff --git a/src/app/nodetool/qgsmaptoolnodetool.cpp b/src/app/nodetool/qgsmaptoolnodetool.cpp index a333c27e891f..7917c47e1e76 100644 --- a/src/app/nodetool/qgsmaptoolnodetool.cpp +++ b/src/app/nodetool/qgsmaptoolnodetool.cpp @@ -711,7 +711,7 @@ void QgsMapToolNodeTool::keyReleaseEvent( QKeyEvent* e ) return; } - if ( mSelectedFeature && e->key() == Qt::Key_Backspace ) + if ( mSelectedFeature && ( e->key() == Qt::Key_Backspace || e->key() == Qt::Key_Delete ) ) { mSelectedFeature->deleteSelectedVertexes(); mCanvas->refresh(); diff --git a/src/app/qgisapp.cpp b/src/app/qgisapp.cpp index c17042f3d917..36660b72fd2b 100644 --- a/src/app/qgisapp.cpp +++ b/src/app/qgisapp.cpp @@ -4859,6 +4859,10 @@ void QgisApp::deleteSelected( QgsMapLayer *layer, QWidget* parent, bool promptCo tr( "A problem occured during deletion of features" ), QgsMessageBar::WARNING ); } + else + { + showStatusMessage( tr( "%n feature(s) deleted.", "number of features deleted", numberOfDeletedFeatures ) ); + } vlayer->endEditCommand(); } @@ -6505,6 +6509,8 @@ void QgisApp::removeLayer( bool promptConfirmation ) mMapLegend->removeSelectedLayers(); + showStatusMessage( tr( "%n layer(s) removed.", "number of layers removed", numberOfRemovedLayers ) ); + mMapCanvas->refresh(); } @@ -9056,11 +9062,6 @@ void QgisApp::keyPressEvent( QKeyEvent * e ) { stopRendering(); } - //remove selected layers - else if ( e->key() == Qt::Key_D ) - { - removeLayer( true ); - } #if defined(Q_OS_WIN)&& defined(QGISDEBUG) else if ( e->key() == Qt::Key_Backslash && e->modifiers() & Qt::ControlModifier ) { diff --git a/src/app/qgisapp.h b/src/app/qgisapp.h index 3b441b49f183..1c0c6e341163 100644 --- a/src/app/qgisapp.h +++ b/src/app/qgisapp.h @@ -686,7 +686,7 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow //! Slot to handle user center input; void userCenter(); //! Remove a layer from the map and legend - void removeLayer( bool promptConfirmation = false ); + void removeLayer( bool promptConfirmation = true ); /** Duplicate map layer(s) in legend * @note added in 1.9 */ void duplicateLayers( const QList lyrList = QList() ); diff --git a/src/app/qgsmaptoolselect.cpp b/src/app/qgsmaptoolselect.cpp index 613f041d50e2..e9f1db81cd10 100644 --- a/src/app/qgsmaptoolselect.cpp +++ b/src/app/qgsmaptoolselect.cpp @@ -13,7 +13,7 @@ * * ***************************************************************************/ - +#include "qgisapp.h" #include "qgsmaptoolselect.h" #include "qgsmaptoolselectutils.h" #include "qgsrubberband.h" @@ -50,3 +50,11 @@ void QgsMapToolSelect::canvasReleaseEvent( QMouseEvent * e ) delete selectGeom; rubberBand.reset( QGis::Polygon ); } + +void QgsMapToolSelect::keyPressEvent( QKeyEvent* e ) +{ + if ( e->key() == Qt::Key_Backspace || e->key() == Qt::Key_Delete ) + { + QgisApp::instance()->deleteSelected( ); + } +} diff --git a/src/app/qgsmaptoolselect.h b/src/app/qgsmaptoolselect.h index dc882fc8ddab..6c2b3e0f9ef7 100644 --- a/src/app/qgsmaptoolselect.h +++ b/src/app/qgsmaptoolselect.h @@ -30,6 +30,9 @@ class APP_EXPORT QgsMapToolSelect : public QgsMapTool //! Overridden mouse release event virtual void canvasReleaseEvent( QMouseEvent * e ); + //! Overridden key press event + virtual void keyPressEvent( QKeyEvent* e ); + private: }; diff --git a/src/app/qgsmaptoolselectfreehand.cpp b/src/app/qgsmaptoolselectfreehand.cpp index 38d6bc9c1177..f22da4970126 100644 --- a/src/app/qgsmaptoolselectfreehand.cpp +++ b/src/app/qgsmaptoolselectfreehand.cpp @@ -13,6 +13,7 @@ email : jpalmer at linz dot govt dot nz * * ***************************************************************************/ +#include "qgisapp.h" #include "qgsmaptoolselectfreehand.h" #include "qgsmaptoolselectutils.h" #include "qgsgeometry.h" @@ -77,3 +78,11 @@ void QgsMapToolSelectFreehand::canvasReleaseEvent( QMouseEvent * e ) mRubberBand = 0; mDragging = false; } + +void QgsMapToolSelectFreehand::keyPressEvent( QKeyEvent* e ) +{ + if ( e->key() == Qt::Key_Backspace || e->key() == Qt::Key_Delete ) + { + QgisApp::instance()->deleteSelected( ); + } +} diff --git a/src/app/qgsmaptoolselectfreehand.h b/src/app/qgsmaptoolselectfreehand.h index 5f2b86151483..1d26c8fc86b0 100644 --- a/src/app/qgsmaptoolselectfreehand.h +++ b/src/app/qgsmaptoolselectfreehand.h @@ -39,6 +39,9 @@ class APP_EXPORT QgsMapToolSelectFreehand : public QgsMapTool //! Overridden mouse release event virtual void canvasReleaseEvent( QMouseEvent * e ); + //! Overridden key press event + virtual void keyPressEvent( QKeyEvent* e ); + private: //! used for storing all of the maps point for the freehand sketch diff --git a/src/app/qgsmaptoolselectpolygon.cpp b/src/app/qgsmaptoolselectpolygon.cpp index 5e58314b31ad..9fd07935b2ef 100644 --- a/src/app/qgsmaptoolselectpolygon.cpp +++ b/src/app/qgsmaptoolselectpolygon.cpp @@ -13,6 +13,7 @@ email : jpalmer at linz dot govt dot nz * * ***************************************************************************/ +#include "qgisapp.h" #include "qgsmaptoolselectpolygon.h" #include "qgsmaptoolselectutils.h" #include "qgsgeometry.h" @@ -72,3 +73,10 @@ void QgsMapToolSelectPolygon::canvasMoveEvent( QMouseEvent * e ) } } +void QgsMapToolSelectPolygon::keyPressEvent( QKeyEvent* e ) +{ + if ( e->key() == Qt::Key_Backspace || e->key() == Qt::Key_Delete ) + { + QgisApp::instance()->deleteSelected( ); + } +} diff --git a/src/app/qgsmaptoolselectpolygon.h b/src/app/qgsmaptoolselectpolygon.h index e3aeb57be3c7..67953aa294db 100644 --- a/src/app/qgsmaptoolselectpolygon.h +++ b/src/app/qgsmaptoolselectpolygon.h @@ -36,6 +36,9 @@ class APP_EXPORT QgsMapToolSelectPolygon : public QgsMapTool //! Overridden mouse press event virtual void canvasPressEvent( QMouseEvent * e ); + //! Overridden key press event + virtual void keyPressEvent( QKeyEvent* e ); + private: //! used for storing all of the maps point for the polygon diff --git a/src/app/qgsmaptoolselectradius.cpp b/src/app/qgsmaptoolselectradius.cpp index 1c4c70b3407e..18e54c051a06 100644 --- a/src/app/qgsmaptoolselectradius.cpp +++ b/src/app/qgsmaptoolselectradius.cpp @@ -13,6 +13,7 @@ email : jpalmer at linz dot govt dot nz * * ***************************************************************************/ +#include "qgisapp.h" #include "qgsmaptoolselectradius.h" #include "qgsmaptoolselectutils.h" #include "qgsgeometry.h" @@ -109,3 +110,11 @@ void QgsMapToolSelectRadius::setRadiusRubberBand( QgsPoint & radiusEdge ) mRubberBand->addPoint( radiusPoint ); } } + +void QgsMapToolSelectRadius::keyPressEvent( QKeyEvent* e ) +{ + if ( e->key() == Qt::Key_Backspace || e->key() == Qt::Key_Delete ) + { + QgisApp::instance()->deleteSelected( ); + } +} diff --git a/src/app/qgsmaptoolselectradius.h b/src/app/qgsmaptoolselectradius.h index b83387c058a5..453258c50009 100644 --- a/src/app/qgsmaptoolselectradius.h +++ b/src/app/qgsmaptoolselectradius.h @@ -41,6 +41,9 @@ class APP_EXPORT QgsMapToolSelectRadius : public QgsMapTool //! Overridden mouse release event virtual void canvasReleaseEvent( QMouseEvent * e ); + //! Overridden key press event + virtual void keyPressEvent( QKeyEvent* e ); + private: //! sets the rubber band to a circle approximated using 40 segments. diff --git a/src/app/qgsmaptoolselectrectangle.cpp b/src/app/qgsmaptoolselectrectangle.cpp index 74b788b659d3..2fe8d1b8ef07 100644 --- a/src/app/qgsmaptoolselectrectangle.cpp +++ b/src/app/qgsmaptoolselectrectangle.cpp @@ -14,6 +14,7 @@ * * ***************************************************************************/ +#include "qgisapp.h" #include "qgsmaptoolselectrectangle.h" #include "qgsmaptoolselectutils.h" #include "qgsrubberband.h" @@ -111,3 +112,11 @@ void QgsMapToolSelectRectangle::canvasReleaseEvent( QMouseEvent *e ) mDragging = false; } + +void QgsMapToolSelectRectangle::keyPressEvent( QKeyEvent* e ) +{ + if ( e->key() == Qt::Key_Backspace || e->key() == Qt::Key_Delete ) + { + QgisApp::instance()->deleteSelected( ); + } +} diff --git a/src/app/qgsmaptoolselectrectangle.h b/src/app/qgsmaptoolselectrectangle.h index 24fc4dc29248..297053e6ee06 100644 --- a/src/app/qgsmaptoolselectrectangle.h +++ b/src/app/qgsmaptoolselectrectangle.h @@ -43,6 +43,9 @@ class APP_EXPORT QgsMapToolSelectRectangle : public QgsMapTool //! Overridden mouse release event virtual void canvasReleaseEvent( QMouseEvent * e ); + //! Overridden key press event + virtual void keyPressEvent( QKeyEvent* e ); + private: //! Flag to indicate a map canvas drag operation is taking place diff --git a/src/providers/ogr/Copia de Copia de qgsogrfeatureiterator.cpp b/src/providers/ogr/Copia de Copia de qgsogrfeatureiterator.cpp new file mode 100644 index 000000000000..38ab5fa38e99 --- /dev/null +++ b/src/providers/ogr/Copia de Copia de qgsogrfeatureiterator.cpp @@ -0,0 +1,456 @@ +/*************************************************************************** + qgsogrfeatureiterator.cpp + --------------------- + begin : Juli 2012 + copyright : (C) 2012 by Martin Dobias + email : wonder dot sk at gmail dot com + *************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ +#include "qgsogrfeatureiterator.h" + +#include "qgsogrprovider.h" + +#include "qgsapplication.h" +#include "qgsgeometry.h" +#include "qgslogger.h" +#include "qgsmessagelog.h" + +#include +#include + +#include // for setting gdal options + +// using from provider: +// - setRelevantFields(), mRelevantFieldsForNextFeature +// - ogrLayer +// - mFetchFeaturesWithoutGeom +// - mAttributeFields +// - mEncoding + + +QgsOgrFeatureIterator::QgsOgrFeatureIterator( QgsOgrProvider* p, const QgsFeatureRequest& request ) + : QgsAbstractFeatureIterator( request ) + , P( p ) + , ogrDataSource( 0 ) + , ogrLayer( 0 ) + , mSubsetStringSet( false ) +{ + mFeatureFetched = false; + + //CPLSetConfigOption( "VSI_CACHE", "TRUE" ); + + ogrDataSource = OGROpen( TO8F( P->filePath() ), false, NULL ); + + if ( P->layerName().isNull() ) + { + ogrLayer = OGR_DS_GetLayer( ogrDataSource, P->layerIndex() ); + } + else + { + ogrLayer = OGR_DS_GetLayerByName( ogrDataSource, TO8( p->layerName() ) ); + } + + if ( !P->subsetString().isEmpty() ) + { + ogrLayer = P->setSubsetString( ogrLayer, ogrDataSource ); + mSubsetStringSet = true; + } + + ensureRelevantFields(); + + // spatial query to select features + if ( mRequest.filterType() == QgsFeatureRequest::FilterRect ) + { + OGRGeometryH filter = 0; + QString wktExtent = QString( "POLYGON((%1))" ).arg( mRequest.filterRect().asPolygon() ); + QByteArray ba = wktExtent.toAscii(); + const char *wktText = ba; + + OGR_G_CreateFromWkt(( char ** )&wktText, NULL, &filter ); + QgsDebugMsg( "Setting spatial filter using " + wktExtent ); + OGR_L_SetSpatialFilter( ogrLayer, filter ); + OGR_G_DestroyGeometry( filter ); + } + else + { + OGR_L_SetSpatialFilter( ogrLayer, 0 ); + } + + //start with first feature + rewind(); +} + +QgsOgrFeatureIterator::~QgsOgrFeatureIterator() +{ + close(); +} + +void QgsOgrFeatureIterator::ensureRelevantFields() +{ + mFetchGeometry = ( mRequest.filterType() == QgsFeatureRequest::FilterRect ) || !( mRequest.flags() & QgsFeatureRequest::NoGeometry ); + QgsAttributeList attrs = ( mRequest.flags() & QgsFeatureRequest::SubsetOfAttributes ) ? mRequest.subsetOfAttributes() : P->attributeIndexes(); + P->setRelevantFields( ogrLayer, mFetchGeometry, attrs ); + P->mRelevantFieldsForNextFeature = true; +} + + +bool QgsOgrFeatureIterator::fetchFeature( QgsFeature& feature ) +{ + feature.setValid( false ); + + if ( mClosed ) + return false; + + if ( !P->mRelevantFieldsForNextFeature ) + ensureRelevantFields(); + + if ( mRequest.filterType() == QgsFeatureRequest::FilterFid ) + { + OGRFeatureH fet = OGR_L_GetFeature( ogrLayer, FID_TO_NUMBER( mRequest.filterFid() ) ); + if ( !fet ) + { + close(); + return false; + } + + if ( readFeature( fet, feature ) ) + OGR_F_Destroy( fet ); + + feature.setValid( true ); + close(); // the feature has been read: we have finished here + return true; + } + + OGRFeatureH fet; + + while (( fet = OGR_L_GetNextFeature( ogrLayer ) ) ) + { + if ( !readFeature( fet, feature ) ) + continue; + + // we have a feature, end this cycle + feature.setValid( true ); + OGR_F_Destroy( fet ); + return true; + + } // while + + QgsDebugMsg( "Feature is null" ); + + close(); + return false; +} + + +bool QgsOgrFeatureIterator::rewind() +{ + if ( mClosed ) + return false; + + OGR_L_ResetReading( ogrLayer ); + + return true; +} + + +bool QgsOgrFeatureIterator::close() +{ + if ( mClosed ) + return false; + + P->mActiveIterators.remove( this ); + + if ( mSubsetStringSet ) + { + OGR_DS_ReleaseResultSet( ogrDataSource, ogrLayer ); + } + + OGR_DS_Destroy( ogrDataSource ); + + mClosed = true; + ogrDataSource = 0; + return true; +} + + +void QgsOgrFeatureIterator::getFeatureAttribute( OGRFeatureH ogrFet, QgsFeature & f, int attindex ) +{ + OGRFieldDefnH fldDef = OGR_F_GetFieldDefnRef( ogrFet, attindex ); + + if ( ! fldDef ) + { + QgsDebugMsg( "ogrFet->GetFieldDefnRef(attindex) returns NULL" ); + return; + } + + QVariant value; + + if ( OGR_F_IsFieldSet( ogrFet, attindex ) ) + { + switch ( P->mAttributeFields[attindex].type() ) + { + case QVariant::String: value = QVariant( P->mEncoding->toUnicode( OGR_F_GetFieldAsString( ogrFet, attindex ) ) ); break; + case QVariant::Int: value = QVariant( OGR_F_GetFieldAsInteger( ogrFet, attindex ) ); break; + case QVariant::Double: value = QVariant( OGR_F_GetFieldAsDouble( ogrFet, attindex ) ); break; + case QVariant::Date: + case QVariant::DateTime: + { + int year, month, day, hour, minute, second, tzf; + + OGR_F_GetFieldAsDateTime( ogrFet, attindex, &year, &month, &day, &hour, &minute, &second, &tzf ); + if ( P->mAttributeFields[attindex].type() == QVariant::Date ) + value = QDate( year, month, day ); + else + value = QDateTime( QDate( year, month, day ), QTime( hour, minute, second ) ); + } + break; + default: + assert( 0 && "unsupported field type" ); + } + } + else + { + value = QVariant( QString::null ); + } + + f.setAttribute( attindex, value ); +} + + +bool QgsOgrFeatureIterator::readFeature( OGRFeatureH fet, QgsFeature& feature ) +{ + feature.setFeatureId( OGR_F_GetFID( fet ) ); + feature.initAttributes( P->fields().count() ); + feature.setFields( &P->mAttributeFields ); // allow name-based attribute lookups + + bool useIntersect = mRequest.flags() & QgsFeatureRequest::ExactIntersect; + bool geometryTypeFilter = P->mOgrGeometryTypeFilter != wkbUnknown; + if ( mFetchGeometry || useIntersect || geometryTypeFilter ) + { + OGRGeometryH geom = OGR_F_GetGeometryRef( fet ); + + if ( geom ) + { + notifyReadedFeature( fet, geom, feature ); + + // get the wkb representation + int memorySize = OGR_G_WkbSize( geom ); + unsigned char *wkb = new unsigned char[memorySize]; + OGR_G_ExportToWkb( geom, ( OGRwkbByteOrder ) QgsApplication::endian(), wkb ); + + QgsGeometry* geometry = feature.geometry(); + if ( !geometry ) feature.setGeometryAndOwnership( wkb, memorySize ); else geometry->fromWkb( wkb, memorySize ); + + notifyLoadedFeature( fet, feature ); + } + if (( useIntersect && ( !feature.geometry() || !feature.geometry()->intersects( mRequest.filterRect() ) ) ) + || ( geometryTypeFilter && ( !feature.geometry() || QgsOgrProvider::ogrWkbSingleFlatten(( OGRwkbGeometryType )feature.geometry()->wkbType() ) != P->mOgrGeometryTypeFilter ) ) ) + { + OGR_F_Destroy( fet ); + return false; + } + } + + if ( !mFetchGeometry ) + { + feature.setGeometry( 0 ); + } + + // fetch attributes + if ( mRequest.flags() & QgsFeatureRequest::SubsetOfAttributes ) + { + const QgsAttributeList& attrs = mRequest.subsetOfAttributes(); + for ( QgsAttributeList::const_iterator it = attrs.begin(); it != attrs.end(); ++it ) + { + getFeatureAttribute( fet, feature, *it ); + } + } + else + { + // all attributes + for ( int idx = 0; idx < P->mAttributeFields.count(); ++idx ) + { + getFeatureAttribute( fet, feature, idx ); + } + } + + return true; +} + +//! notify the OGRFeatureH was readed of the data provider +void QgsOgrFeatureIterator::notifyReadedFeature( OGRFeatureH fet, OGRGeometryH geom, QgsFeature& feature ) +{ +} +//! notify the OGRFeatureH was loaded to the QgsFeature object +void QgsOgrFeatureIterator::notifyLoadedFeature( OGRFeatureH fet, QgsFeature& feature ) +{ +} + +/*************************************************************************** + MapToPixel simplification classes + ---------------------- + begin : October 2013 + copyright : (C) 2013 by Alvaro Huarte + email : http://wiki.osgeo.org/wiki/Alvaro_Huarte + + *************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include + +//! Provides a specialized FeatureIterator for enable map2pixel simplification of the geometries +QgsOgrSimplifiedFeatureIterator::QgsOgrSimplifiedFeatureIterator( QgsOgrProvider* p, const QgsFeatureRequest& request ) : QgsOgrFeatureIterator( p, request ) +{ + mPointBufferCount = 512; + mPointBufferPtr = (OGRRawPoint*)OGRMalloc( mPointBufferCount * sizeof(OGRRawPoint) ); +} +QgsOgrSimplifiedFeatureIterator::~QgsOgrSimplifiedFeatureIterator( ) +{ + if ( mPointBufferPtr ) + { + OGRFree( mPointBufferPtr ); + mPointBufferPtr = NULL; + } +} + +//! Returns a point buffer of the specified size +OGRRawPoint* QgsOgrSimplifiedFeatureIterator::mallocPoints( int numPoints ) +{ + if ( mPointBufferPtr && mPointBufferCount < numPoints ) + { + OGRFree( mPointBufferPtr ); + mPointBufferPtr = NULL; + } + if ( mPointBufferPtr==NULL ) + { + mPointBufferCount = numPoints; + mPointBufferPtr = (OGRRawPoint*)OGRMalloc( mPointBufferCount * sizeof(OGRRawPoint) ); + } + return mPointBufferPtr; +} + +//! Simplify the OGR-geometry using the specified tolerance +bool QgsOgrSimplifiedFeatureIterator::simplifyOgrGeometry( const QgsFeatureRequest& request, OGRGeometry* geometry, bool isaLinearRing ) +{ + OGRwkbGeometryType wkbGeometryType = wkbFlatten( geometry->getGeometryType() ); + + // Simplify the geometry rewriting temporally its WKB-stream for saving calloc's. + if ( wkbGeometryType == wkbLineString ) + { + OGRLineString* lineString = (OGRLineString*)geometry; + + int numPoints = lineString->getNumPoints(); + if ( (isaLinearRing && numPoints<=5) || (!isaLinearRing && numPoints<=2) ) return false; + + OGREnvelope env; + geometry->getEnvelope( &env ); + QgsRectangle envelope( env.MinX, env.MinY, env.MaxX, env.MaxY ); + + // Can replace the geometry by its BBOX ? + if ( request.flags() & QgsFeatureRequest::SimplifyEnvelope && request.canbeGeneralizedByMapBoundingBox( envelope ) ) + { + OGRRawPoint* points = NULL; + int numPoints = 0; + + double x1 = envelope.xMinimum(); + double y1 = envelope.yMinimum(); + double x2 = envelope.xMaximum(); + double y2 = envelope.yMaximum(); + + if ( isaLinearRing ) + { + numPoints = 5; + points = mallocPoints( numPoints ); + points[0].x = x1; points[0].y = y1; + points[1].x = x2; points[1].y = y1; + points[2].x = x2; points[2].y = y2; + points[3].x = x1; points[3].y = y2; + points[4].x = x1; points[4].y = y1; + } + else + { + numPoints = 2; + points = mallocPoints( numPoints ); + points[0].x = x1; points[0].y = y1; + points[1].x = x2; points[1].y = y2; + } + lineString->setPoints( numPoints, points ); + lineString->flattenTo2D(); + return true; + } + else + if ( request.flags() & QgsFeatureRequest::SimplifyGeometry ) + { + QGis::GeometryType geometryType = isaLinearRing ? QGis::Polygon : QGis::Line; + int numSimplifiedPoints = 0; + + OGRRawPoint* points = mallocPoints( numPoints ); + double* xptr = (double*)points; + double* yptr = xptr+1; + lineString->getPoints( points ); + + if ( request.simplifyGeometry( request.flags(), geometryType, envelope, xptr, 16, yptr, 16, numPoints, numSimplifiedPoints ) ) + { + lineString->setPoints( numSimplifiedPoints, points ); + lineString->flattenTo2D(); + } + return numSimplifiedPoints!=numPoints; + } + } + else + if ( wkbGeometryType == wkbPolygon ) + { + OGRPolygon* polygon = (OGRPolygon*)geometry; + bool result = simplifyOgrGeometry( request, polygon->getExteriorRing(), true ); + + for ( int i = 0, numInteriorRings = polygon->getNumInteriorRings(); i < numInteriorRings; ++i ) + { + result |= simplifyOgrGeometry( request, polygon->getInteriorRing(i), true ); + } + if ( result ) polygon->flattenTo2D(); + return result; + } + else + if ( wkbGeometryType == wkbMultiLineString || wkbGeometryType == wkbMultiPolygon ) + { + OGRGeometryCollection* collection = (OGRGeometryCollection*)geometry; + bool result = false; + + for ( int i = 0, numGeometries = collection->getNumGeometries(); i < numGeometries; ++i ) + { + result |= simplifyOgrGeometry( request, collection->getGeometryRef(i), wkbGeometryType==wkbMultiPolygon ); + } + if ( result ) collection->flattenTo2D(); + return result; + } + return false; +} + +//! notify the OGRFeatureH was readed of the data provider +void QgsOgrSimplifiedFeatureIterator::notifyReadedFeature( OGRFeatureH fet, OGRGeometryH geom, QgsFeature& feature ) +{ + if ( mRequest.flags() & ( QgsFeatureRequest::SimplifyGeometry | QgsFeatureRequest::SimplifyEnvelope ) ) + { + OGRwkbGeometryType wkbType = QgsOgrProvider::ogrWkbSingleFlatten( OGR_G_GetGeometryType(geom) ); + + if ( wkbType == wkbLineString || wkbType == wkbPolygon ) + { + simplifyOgrGeometry( mRequest, (OGRGeometry*)geom, wkbType==wkbPolygon ); + } + } + QgsOgrFeatureIterator::notifyReadedFeature( fet, geom, feature ); +} + +/***************************************************************************/ diff --git a/src/ui/qgisapp.ui b/src/ui/qgisapp.ui index e2dbf8a8408e..aa8177a53f1a 100644 --- a/src/ui/qgisapp.ui +++ b/src/ui/qgisapp.ui @@ -710,9 +710,6 @@ Delete Selected - - Delete -