mirror of
https://github.com/qgis/QGIS.git
synced 2025-10-07 00:15:48 -04:00
automatic indentation update (r9447-r9517)
git-svn-id: http://svn.osgeo.org/qgis/trunk@9518 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
parent
0b9b2d3c61
commit
5a68ac12b0
@ -4187,7 +4187,7 @@ void QgisApp::loadPythonSupport()
|
||||
|
||||
if ( mPythonUtils && mPythonUtils->isEnabled() )
|
||||
{
|
||||
QgsPluginRegistry::instance()->setPythonUtils(mPythonUtils);
|
||||
QgsPluginRegistry::instance()->setPythonUtils( mPythonUtils );
|
||||
|
||||
mActionShowPythonDialog = new QAction( tr( "Python Console" ), this );
|
||||
connect( mActionShowPythonDialog, SIGNAL( triggered() ), this, SLOT( showPythonDialog() ) );
|
||||
|
@ -298,7 +298,7 @@ void QgsGraduatedSymbolDialog::adjustClassification()
|
||||
if ( provider )
|
||||
{
|
||||
if ( modeComboBox->currentText() == tr( "Equal Interval" ) ||
|
||||
modeComboBox->currentText() == tr( "Quantiles" ) )
|
||||
modeComboBox->currentText() == tr( "Quantiles" ) )
|
||||
{
|
||||
minimum = provider->minimumValue( field ).toDouble();
|
||||
maximum = provider->maximumValue( field ).toDouble();
|
||||
@ -590,11 +590,11 @@ void QgsGraduatedSymbolDialog::updateEntryIcon( QgsSymbol * thepSymbol,
|
||||
switch ( myType )
|
||||
{
|
||||
case QGis::Point:
|
||||
{
|
||||
int myWidthScale = 4; //magick no to try to make vector props dialog preview look same as legend
|
||||
thepItem->setIcon( QIcon( QPixmap::fromImage( thepSymbol->getPointSymbolAsImage( myWidthScale ) ) ) );
|
||||
}
|
||||
break;
|
||||
{
|
||||
int myWidthScale = 4; //magick no to try to make vector props dialog preview look same as legend
|
||||
thepItem->setIcon( QIcon( QPixmap::fromImage( thepSymbol->getPointSymbolAsImage( myWidthScale ) ) ) );
|
||||
}
|
||||
break;
|
||||
case QGis::Line:
|
||||
thepItem->setIcon( QIcon( QPixmap::fromImage( thepSymbol->getLineSymbolAsImage() ) ) );
|
||||
break;
|
||||
|
@ -95,9 +95,9 @@ void QgsMapToolAddVertex::canvasReleaseEvent( QMouseEvent * e )
|
||||
//add segment points in case of topological editing
|
||||
int topologicalEditing = QgsProject::instance()->readNumEntry( "Digitizing", "/TopologicalEditing", 0 );
|
||||
if ( topologicalEditing )
|
||||
{
|
||||
insertSegmentVerticesForSnap( snapResults, vlayer );
|
||||
}
|
||||
{
|
||||
insertSegmentVerticesForSnap( snapResults, vlayer );
|
||||
}
|
||||
|
||||
snappedPointMapCoord = snapPointFromResults( snapResults, e->pos() );
|
||||
snappedPointLayerCoord = toLayerCoordinates( vlayer, snappedPointMapCoord );
|
||||
|
@ -80,10 +80,10 @@ void QgsMapToolSplitFeatures::canvasReleaseEvent( QMouseEvent * e )
|
||||
//bring up dialog if a split was not possible (polygon) or only done once (line)
|
||||
int topologicalEditing = QgsProject::instance()->readNumEntry( "Digitizing", "/TopologicalEditing", 0 );
|
||||
int returnCode = vlayer->splitFeatures( mCaptureList, topologicalEditing );
|
||||
if(returnCode == 4)
|
||||
{
|
||||
QMessageBox::warning(0, tr("No feature split done"), tr("If there are selected features, the split tool only applies to the selected ones. If you like to split all features under the split line, clear the selection"));
|
||||
}
|
||||
if ( returnCode == 4 )
|
||||
{
|
||||
QMessageBox::warning( 0, tr( "No feature split done" ), tr( "If there are selected features, the split tool only applies to the selected ones. If you like to split all features under the split line, clear the selection" ) );
|
||||
}
|
||||
else if ( returnCode != 0 )
|
||||
{
|
||||
//several intersections but only one split (most likely line)
|
||||
|
@ -34,12 +34,12 @@ QgsPluginRegistry *QgsPluginRegistry::instance()
|
||||
}
|
||||
|
||||
QgsPluginRegistry::QgsPluginRegistry()
|
||||
: mPythonUtils(NULL)
|
||||
: mPythonUtils( NULL )
|
||||
{
|
||||
// constructor does nothing
|
||||
}
|
||||
|
||||
void QgsPluginRegistry::setPythonUtils(QgsPythonUtils* pythonUtils)
|
||||
void QgsPluginRegistry::setPythonUtils( QgsPythonUtils* pythonUtils )
|
||||
{
|
||||
mPythonUtils = pythonUtils;
|
||||
}
|
||||
@ -102,19 +102,19 @@ void QgsPluginRegistry::unloadAll()
|
||||
it != plugins.end();
|
||||
it++ )
|
||||
{
|
||||
if (isPythonPlugin(it->second->name()))
|
||||
if ( isPythonPlugin( it->second->name() ) )
|
||||
{
|
||||
if (mPythonUtils)
|
||||
mPythonUtils->unloadPlugin(it->second->library());
|
||||
if ( mPythonUtils )
|
||||
mPythonUtils->unloadPlugin( it->second->library() );
|
||||
else
|
||||
QgsDebugMsg("warning: python utils is NULL");
|
||||
QgsDebugMsg( "warning: python utils is NULL" );
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( it->second->plugin() )
|
||||
it->second->plugin()->unload();
|
||||
else
|
||||
QgsDebugMsg("warning: plugin is NULL:" + it->second->name());
|
||||
QgsDebugMsg( "warning: plugin is NULL:" + it->second->name() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ class QgsPluginRegistry
|
||||
//! Unload plugins
|
||||
void unloadAll();
|
||||
//! Save pointer for python utils (needed for unloading python plugins)
|
||||
void setPythonUtils(QgsPythonUtils* pythonUtils);
|
||||
void setPythonUtils( QgsPythonUtils* pythonUtils );
|
||||
protected:
|
||||
//! protected constructor
|
||||
QgsPluginRegistry();
|
||||
|
@ -438,11 +438,11 @@ void QgsUniqueValueDialog::updateEntryIcon( QgsSymbol * thepSymbol,
|
||||
switch ( myType )
|
||||
{
|
||||
case QGis::Point:
|
||||
{
|
||||
int myWidthScale = 4; //magick no to try to make vector props dialog preview look same as legend
|
||||
thepItem->setIcon( QIcon( QPixmap::fromImage( thepSymbol->getPointSymbolAsImage( myWidthScale ) ) ) );
|
||||
}
|
||||
break;
|
||||
{
|
||||
int myWidthScale = 4; //magick no to try to make vector props dialog preview look same as legend
|
||||
thepItem->setIcon( QIcon( QPixmap::fromImage( thepSymbol->getPointSymbolAsImage( myWidthScale ) ) ) );
|
||||
}
|
||||
break;
|
||||
case QGis::Line:
|
||||
thepItem->setIcon( QIcon( QPixmap::fromImage( thepSymbol->getLineSymbolAsImage() ) ) );
|
||||
break;
|
||||
|
@ -181,7 +181,7 @@ bool QgsCoordinateReferenceSystem::createFromEpsg( long id )
|
||||
bool QgsCoordinateReferenceSystem::createFromSrsId( long id )
|
||||
{
|
||||
return loadFromDb( id < 100000 ? QgsApplication::srsDbFilePath() :
|
||||
QgsApplication::qgisUserDbFilePath(), "srs_id", id );
|
||||
QgsApplication::qgisUserDbFilePath(), "srs_id", id );
|
||||
}
|
||||
|
||||
bool QgsCoordinateReferenceSystem::loadFromDb( QString db, QString field, long id )
|
||||
|
@ -4883,24 +4883,24 @@ int QgsGeometry::splitPolygonGeometry( GEOSGeometry* splitLine, QList<QgsGeometr
|
||||
}
|
||||
|
||||
bool splitDone = true;
|
||||
int nGeometriesThis = GEOSGetNumGeometries(mGeos); //original number of geometries
|
||||
if(testedGeometries.size() == nGeometriesThis)
|
||||
{
|
||||
splitDone = false;
|
||||
}
|
||||
int nGeometriesThis = GEOSGetNumGeometries( mGeos ); //original number of geometries
|
||||
if ( testedGeometries.size() == nGeometriesThis )
|
||||
{
|
||||
splitDone = false;
|
||||
}
|
||||
|
||||
mergeGeometriesMultiTypeSplit( testedGeometries );
|
||||
|
||||
//no split done, preserve original geometry
|
||||
if(!splitDone)
|
||||
if ( !splitDone )
|
||||
{
|
||||
for ( int i = 0; i < testedGeometries.size(); ++i )
|
||||
{
|
||||
for(int i = 0; i < testedGeometries.size(); ++i)
|
||||
{
|
||||
GEOSGeom_destroy(testedGeometries[i]);
|
||||
}
|
||||
return 1;
|
||||
GEOSGeom_destroy( testedGeometries[i] );
|
||||
}
|
||||
else if(testedGeometries.size() > 0) //split successfull
|
||||
return 1;
|
||||
}
|
||||
else if ( testedGeometries.size() > 0 ) //split successfull
|
||||
{
|
||||
GEOSGeom_destroy( mGeos );
|
||||
mGeos = testedGeometries[0];
|
||||
|
@ -246,9 +246,9 @@ class CORE_EXPORT QgsGeometry
|
||||
@topologyTestPoints OUT: points that need to be tested for topological completeness in the dataset
|
||||
@return 0 in case of success, 1 if geometry has not been split, error else*/
|
||||
int splitGeometry( const QList<QgsPoint>& splitLine,
|
||||
QList<QgsGeometry*>&newGeometries,
|
||||
bool topological,
|
||||
QList<QgsPoint>& topologyTestPoints );
|
||||
QList<QgsGeometry*>&newGeometries,
|
||||
bool topological,
|
||||
QList<QgsPoint>& topologyTestPoints );
|
||||
|
||||
/**Changes this geometry such that it does not intersect the other geometry
|
||||
@param other geometry that should not be intersect
|
||||
|
@ -1758,12 +1758,12 @@ int QgsVectorLayer::splitFeatures( const QList<QgsPoint>& splitLine, bool topolo
|
||||
}
|
||||
}
|
||||
|
||||
if(numberOfSplitedFeatures == 0 && selectedIds.size() > 0)
|
||||
{
|
||||
//There is a selection but no feature has been split.
|
||||
//Maybe user forgot that only the selected features are split
|
||||
returnCode = 4;
|
||||
}
|
||||
if ( numberOfSplitedFeatures == 0 && selectedIds.size() > 0 )
|
||||
{
|
||||
//There is a selection but no feature has been split.
|
||||
//Maybe user forgot that only the selected features are split
|
||||
returnCode = 4;
|
||||
}
|
||||
|
||||
|
||||
//now add the new features to this vectorlayer
|
||||
@ -1918,14 +1918,14 @@ int QgsVectorLayer::addTopologicalPoints( const QgsPoint& p )
|
||||
|
||||
//work with a tolerance because coordinate projection may introduce some rounding
|
||||
double threshold = 0.0000001;
|
||||
if(mCRS && mCRS->mapUnits() == QGis::Meters)
|
||||
{
|
||||
threshold = 0.001;
|
||||
}
|
||||
else if(mCRS && mCRS->mapUnits() == QGis::Feet)
|
||||
{
|
||||
threshold = 0.0001;
|
||||
}
|
||||
if ( mCRS && mCRS->mapUnits() == QGis::Meters )
|
||||
{
|
||||
threshold = 0.001;
|
||||
}
|
||||
else if ( mCRS && mCRS->mapUnits() == QGis::Feet )
|
||||
{
|
||||
threshold = 0.0001;
|
||||
}
|
||||
|
||||
|
||||
if ( snapWithContext( p, threshold, snapResults, QgsSnapper::SNAP_TO_SEGMENT ) != 0 )
|
||||
|
@ -310,10 +310,10 @@ bool QgsGraduatedSymbolRenderer::writeXML( QDomNode & layer_node, QDomDocument &
|
||||
// Mode field first ...
|
||||
//
|
||||
|
||||
QString modeValue="";
|
||||
QString modeValue = "";
|
||||
if ( mMode == QgsGraduatedSymbolRenderer::Empty )
|
||||
{
|
||||
modeValue == "Empty";
|
||||
modeValue == "Empty";
|
||||
}
|
||||
else if ( QgsGraduatedSymbolRenderer::Quantile )
|
||||
{
|
||||
|
@ -225,7 +225,7 @@ void QgsMarkerCatalogue::hardMarker( QPainter * thepPainter, QString name, doubl
|
||||
QgsDebugMsg( QString( "Hard marker radius %1" ).arg( r ) );
|
||||
|
||||
// If radius is 0, draw a circle, so it wont disappear.
|
||||
if ( name == "circle" || r < 1)
|
||||
if ( name == "circle" || r < 1 )
|
||||
{
|
||||
// "A stroked ellipse has a size of rectangle.size() plus the pen width."
|
||||
// (from Qt doc)
|
||||
|
@ -349,16 +349,16 @@ QImage QgsSymbol::getPointSymbolAsImage( double widthScale, bool selected, QColo
|
||||
pen.setColor( selectionColor );
|
||||
QBrush brush = mBrush;
|
||||
preRotateImage = QgsMarkerCatalogue::instance()->imageMarker(
|
||||
mPointSymbolName, ( float )( mPointSize * scale * widthScale *
|
||||
rasterScaleFactor ),
|
||||
pen, mBrush );
|
||||
mPointSymbolName, ( float )( mPointSize * scale * widthScale *
|
||||
rasterScaleFactor ),
|
||||
pen, mBrush );
|
||||
}
|
||||
else
|
||||
{
|
||||
preRotateImage = QgsMarkerCatalogue::instance()->imageMarker(
|
||||
mPointSymbolName, ( float )( mPointSize * scale * widthScale *
|
||||
rasterScaleFactor ),
|
||||
pen, mBrush );
|
||||
mPointSymbolName, ( float )( mPointSize * scale * widthScale *
|
||||
rasterScaleFactor ),
|
||||
pen, mBrush );
|
||||
}
|
||||
|
||||
QMatrix rotationMatrix;
|
||||
|
@ -70,10 +70,10 @@ void MapCoordsDialog::on_buttonCancel_clicked()
|
||||
reject();
|
||||
}
|
||||
|
||||
void MapCoordsDialog::maybeSetXY( QgsPoint & xy, Qt::MouseButton button)
|
||||
void MapCoordsDialog::maybeSetXY( QgsPoint & xy, Qt::MouseButton button )
|
||||
{
|
||||
// Only LeftButton should set point
|
||||
if( Qt::LeftButton == button )
|
||||
if ( Qt::LeftButton == button )
|
||||
{
|
||||
leXCoord->clear();
|
||||
leYCoord->clear();
|
||||
|
@ -51,12 +51,12 @@ class QgsGeorefTool : public QgsMapTool
|
||||
// Only add point on Qt:LeftButton
|
||||
if ( Qt::LeftButton == e->button() )
|
||||
{
|
||||
QgsPoint pnt = toMapCoordinates( e->pos() );
|
||||
QgsPoint pnt = toMapCoordinates( e->pos() );
|
||||
|
||||
if ( mAddPoint )
|
||||
mDlg->showCoordDialog( pnt );
|
||||
else
|
||||
mDlg->deleteDataPoint( pnt );
|
||||
if ( mAddPoint )
|
||||
mDlg->showCoordDialog( pnt );
|
||||
else
|
||||
mDlg->deleteDataPoint( pnt );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -91,7 +91,7 @@ int QgsWFSData::getWFSData()
|
||||
}
|
||||
|
||||
//mHttp.get( mUri );
|
||||
mHttp.get(requestUrl.path() + "?" + QString(requestUrl.encodedQuery()));
|
||||
mHttp.get( requestUrl.path() + "?" + QString( requestUrl.encodedQuery() ) );
|
||||
|
||||
|
||||
//loop to read the data
|
||||
|
@ -72,7 +72,7 @@ QgsWmsProvider::QgsWmsProvider( QString const & uri )
|
||||
// 2) http://xxx.xxx.xx/yyy/yyy?
|
||||
// 3) http://xxx.xxx.xx/yyy/yyy?zzz=www
|
||||
|
||||
baseUrl = prepareUri(httpuri);
|
||||
baseUrl = prepareUri( httpuri );
|
||||
|
||||
QgsDebugMsg( "baseUrl = " + baseUrl );
|
||||
|
||||
@ -98,7 +98,7 @@ QgsWmsProvider::QgsWmsProvider( QString const & uri )
|
||||
QgsDebugMsg( "QgsWmsProvider: exiting constructor." );
|
||||
}
|
||||
|
||||
QString QgsWmsProvider::prepareUri(QString uri)
|
||||
QString QgsWmsProvider::prepareUri( QString uri )
|
||||
{
|
||||
if ( !( uri.contains( "?" ) ) )
|
||||
{
|
||||
@ -379,7 +379,7 @@ QImage* QgsWmsProvider::draw( QgsRect const & viewExtent, int pixelWidth, int p
|
||||
crsKey = "CRS";
|
||||
}
|
||||
|
||||
QString url = prepareUri(mCapabilities.capability.request.getMap.dcpType.front().http.get.onlineResource.xlinkHref);
|
||||
QString url = prepareUri( mCapabilities.capability.request.getMap.dcpType.front().http.get.onlineResource.xlinkHref );
|
||||
|
||||
url += "SERVICE=WMS";
|
||||
url += "&";
|
||||
|
@ -689,7 +689,7 @@ class QgsWmsProvider : public QgsRasterDataProvider
|
||||
* \param uri uri to prepare
|
||||
* \retval prepared uri
|
||||
*/
|
||||
QString prepareUri(QString uri);
|
||||
QString prepareUri( QString uri );
|
||||
|
||||
//! Data source URI of the WMS for this layer
|
||||
QString httpuri;
|
||||
|
@ -46,12 +46,12 @@
|
||||
*/
|
||||
class Regression1141: public QObject
|
||||
{
|
||||
Q_OBJECT;
|
||||
Q_OBJECT;
|
||||
private slots:
|
||||
void initTestCase();// will be called before the first testfunction is executed.
|
||||
void cleanupTestCase();// will be called after the last testfunction was executed.
|
||||
void init(){};// will be called before each testfunction is executed.
|
||||
void cleanup(){};// will be called after every testfunction.
|
||||
void init() {};// will be called before each testfunction is executed.
|
||||
void cleanup() {};// will be called after every testfunction.
|
||||
|
||||
/** This method tests that we can create a shpfile with diacriticals in its name
|
||||
* and with fields that have diacriticals in their names*/
|
||||
@ -71,11 +71,11 @@ void Regression1141::initTestCase()
|
||||
// Runs once before any tests are run
|
||||
//
|
||||
// init QGIS's paths - true means that all path will be inited from prefix
|
||||
QString qgisPath = QCoreApplication::applicationDirPath ();
|
||||
QgsApplication::setPrefixPath(INSTALL_PREFIX, true);
|
||||
QString qgisPath = QCoreApplication::applicationDirPath();
|
||||
QgsApplication::setPrefixPath( INSTALL_PREFIX, true );
|
||||
QgsApplication::showSettings();
|
||||
// Instantiate the plugin directory so that providers are loaded
|
||||
QgsProviderRegistry::instance(QgsApplication::pluginPath());
|
||||
QgsProviderRegistry::instance( QgsApplication::pluginPath() );
|
||||
// compute our test file name:
|
||||
QString myTmpDir = QDir::tempPath() + QDir::separator() ;
|
||||
mFileName = myTmpDir + "ąęćń.shp";
|
||||
@ -143,13 +143,13 @@ void Regression1141::diacriticalTest()
|
||||
|
||||
QVERIFY( mError == QgsVectorFileWriter::NoError );
|
||||
// Now check we can delete it again ok
|
||||
QVERIFY(QgsVectorFileWriter::deleteShapeFile(mFileName));
|
||||
QVERIFY( QgsVectorFileWriter::deleteShapeFile( mFileName ) );
|
||||
|
||||
} //file exists
|
||||
}
|
||||
|
||||
|
||||
QTEST_MAIN(Regression1141)
|
||||
QTEST_MAIN( Regression1141 )
|
||||
|
||||
#include "moc_regression1141.cxx"
|
||||
|
||||
|
@ -52,12 +52,12 @@
|
||||
*/
|
||||
class TestQgsMapRenderer: public QObject
|
||||
{
|
||||
Q_OBJECT;
|
||||
Q_OBJECT;
|
||||
private slots:
|
||||
void initTestCase();// will be called before the first testfunction is executed.
|
||||
void cleanupTestCase();// will be called after the last testfunction was executed.
|
||||
void init(){};// will be called before each testfunction is executed.
|
||||
void cleanup(){};// will be called after every testfunction.
|
||||
void init() {};// will be called before each testfunction is executed.
|
||||
void cleanup() {};// will be called after every testfunction.
|
||||
|
||||
/** This method tests render perfomance */
|
||||
void performanceTest();
|
||||
@ -78,52 +78,52 @@ void TestQgsMapRenderer::initTestCase()
|
||||
// Runs once before any tests are run
|
||||
//
|
||||
// init QGIS's paths - true means that all path will be inited from prefix
|
||||
QString qgisPath = QCoreApplication::applicationDirPath ();
|
||||
QgsApplication::setPrefixPath(INSTALL_PREFIX, true);
|
||||
QString qgisPath = QCoreApplication::applicationDirPath();
|
||||
QgsApplication::setPrefixPath( INSTALL_PREFIX, true );
|
||||
QgsApplication::showSettings();
|
||||
// Instantiate the plugin directory so that providers are loaded
|
||||
QgsProviderRegistry::instance(QgsApplication::pluginPath());
|
||||
QgsProviderRegistry::instance( QgsApplication::pluginPath() );
|
||||
|
||||
|
||||
//create some objects that will be used in all tests...
|
||||
mEncoding = "UTF-8";
|
||||
QgsField myField1("Value",QVariant::Int,"int",10,0,"Value on lon");
|
||||
mFields.insert(0, myField1);
|
||||
mCRS = QgsCoordinateReferenceSystem(GEOWkt);
|
||||
QgsField myField1( "Value", QVariant::Int, "int", 10, 0, "Value on lon" );
|
||||
mFields.insert( 0, myField1 );
|
||||
mCRS = QgsCoordinateReferenceSystem( GEOWkt );
|
||||
//
|
||||
// Create the test dataset if it doesnt exist
|
||||
//
|
||||
QString myDataDir (TEST_DATA_DIR); //defined in CmakeLists.txt
|
||||
QString myDataDir( TEST_DATA_DIR ); //defined in CmakeLists.txt
|
||||
QString myTestDataDir = myDataDir + QDir::separator();
|
||||
QString myTmpDir = QDir::tempPath() + QDir::separator() ;
|
||||
QString myFileName = myTmpDir + "maprender_testdata.shp";
|
||||
//copy over the default qml for our generated layer
|
||||
QString myQmlFileName = myTestDataDir + "maprender_testdata.qml";
|
||||
QFile::copy(myQmlFileName, myTmpDir + "maprender_testdata.qml");
|
||||
qDebug ( "Checking test dataset exists...");
|
||||
qDebug ( myFileName.toLocal8Bit() );
|
||||
if (!QFile::exists(myFileName))
|
||||
QFile::copy( myQmlFileName, myTmpDir + "maprender_testdata.qml" );
|
||||
qDebug( "Checking test dataset exists..." );
|
||||
qDebug( myFileName.toLocal8Bit() );
|
||||
if ( !QFile::exists( myFileName ) )
|
||||
{
|
||||
qDebug ( "Creating test dataset: ");
|
||||
qDebug( "Creating test dataset: " );
|
||||
|
||||
QgsVectorFileWriter myWriter (myFileName,
|
||||
mEncoding,
|
||||
mFields,
|
||||
QGis::WKBPolygon,
|
||||
&mCRS);
|
||||
double myInterval=0.5;
|
||||
for (double i=-180.0;i<=180.0;i+=myInterval)
|
||||
QgsVectorFileWriter myWriter( myFileName,
|
||||
mEncoding,
|
||||
mFields,
|
||||
QGis::WKBPolygon,
|
||||
&mCRS );
|
||||
double myInterval = 0.5;
|
||||
for ( double i = -180.0;i <= 180.0;i += myInterval )
|
||||
{
|
||||
for (double j=-90.0;j<=90.0;j+=myInterval)
|
||||
for ( double j = -90.0;j <= 90.0;j += myInterval )
|
||||
{
|
||||
//
|
||||
// Create a polygon feature
|
||||
//
|
||||
QgsPolyline myPolyline;
|
||||
QgsPoint myPoint1 = QgsPoint(i,j);
|
||||
QgsPoint myPoint2 = QgsPoint(i+myInterval,j);
|
||||
QgsPoint myPoint3 = QgsPoint(i+myInterval,j+myInterval);
|
||||
QgsPoint myPoint4 = QgsPoint(i,j+myInterval);
|
||||
QgsPoint myPoint1 = QgsPoint( i, j );
|
||||
QgsPoint myPoint2 = QgsPoint( i + myInterval, j );
|
||||
QgsPoint myPoint3 = QgsPoint( i + myInterval, j + myInterval );
|
||||
QgsPoint myPoint4 = QgsPoint( i, j + myInterval );
|
||||
myPolyline << myPoint1 << myPoint2 << myPoint3 << myPoint4 << myPoint1;
|
||||
QgsPolygon myPolygon;
|
||||
myPolygon << myPolyline;
|
||||
@ -133,46 +133,46 @@ void TestQgsMapRenderer::initTestCase()
|
||||
// NOTE: dont delete this pointer again -
|
||||
// ownership is passed to the feature which will
|
||||
// delete it in its dtor!
|
||||
QgsGeometry * mypPolygonGeometry = QgsGeometry::fromPolygon(myPolygon);
|
||||
QgsGeometry * mypPolygonGeometry = QgsGeometry::fromPolygon( myPolygon );
|
||||
QgsFeature myFeature;
|
||||
myFeature.setTypeName("WKBPolygon");
|
||||
myFeature.setGeometry(mypPolygonGeometry);
|
||||
myFeature.addAttribute(0,i);
|
||||
myFeature.setTypeName( "WKBPolygon" );
|
||||
myFeature.setGeometry( mypPolygonGeometry );
|
||||
myFeature.addAttribute( 0, i );
|
||||
//
|
||||
// Write the feature to the filewriter
|
||||
// and check for errors
|
||||
//
|
||||
QVERIFY(myWriter.addFeature(myFeature));
|
||||
QVERIFY( myWriter.addFeature( myFeature ) );
|
||||
mError = myWriter.hasError();
|
||||
if(mError==QgsVectorFileWriter::ErrDriverNotFound)
|
||||
if ( mError == QgsVectorFileWriter::ErrDriverNotFound )
|
||||
{
|
||||
std::cout << "Driver not found error" << std::endl;
|
||||
}
|
||||
else if (mError==QgsVectorFileWriter::ErrCreateDataSource)
|
||||
else if ( mError == QgsVectorFileWriter::ErrCreateDataSource )
|
||||
{
|
||||
std::cout << "Create data source error" << std::endl;
|
||||
}
|
||||
else if (mError==QgsVectorFileWriter::ErrCreateLayer)
|
||||
else if ( mError == QgsVectorFileWriter::ErrCreateLayer )
|
||||
{
|
||||
std::cout << "Create layer error" << std::endl;
|
||||
}
|
||||
QVERIFY(mError==QgsVectorFileWriter::NoError);
|
||||
QVERIFY( mError == QgsVectorFileWriter::NoError );
|
||||
}
|
||||
}
|
||||
} //file exists
|
||||
//
|
||||
//create a poly layer that will be used in all tests...
|
||||
//
|
||||
QFileInfo myPolyFileInfo ( myFileName );
|
||||
mpPolysLayer = new QgsVectorLayer ( myPolyFileInfo.filePath(),
|
||||
myPolyFileInfo.completeBaseName(), "ogr" );
|
||||
QFileInfo myPolyFileInfo( myFileName );
|
||||
mpPolysLayer = new QgsVectorLayer( myPolyFileInfo.filePath(),
|
||||
myPolyFileInfo.completeBaseName(), "ogr" );
|
||||
// Register the layer with the registry
|
||||
QgsMapLayerRegistry::instance()->addMapLayer(mpPolysLayer);
|
||||
QgsMapLayerRegistry::instance()->addMapLayer( mpPolysLayer );
|
||||
// add the test layer to the maprender
|
||||
mpMapRenderer = new QgsMapRenderer();
|
||||
QStringList myLayers;
|
||||
myLayers << mpPolysLayer->getLayerID();
|
||||
mpMapRenderer->setLayerSet(myLayers);
|
||||
mpMapRenderer->setLayerSet( myLayers );
|
||||
mReport += "<h1>Map Render Tests</h1>\n";
|
||||
}
|
||||
|
||||
@ -180,13 +180,13 @@ void TestQgsMapRenderer::initTestCase()
|
||||
void TestQgsMapRenderer::cleanupTestCase()
|
||||
{
|
||||
QString myReportFile = QDir::tempPath() + QDir::separator() + "maprendertest.html";
|
||||
QFile myFile ( myReportFile);
|
||||
if ( myFile.open ( QIODevice::WriteOnly ) )
|
||||
QFile myFile( myReportFile );
|
||||
if ( myFile.open( QIODevice::WriteOnly ) )
|
||||
{
|
||||
QTextStream myQTextStream ( &myFile );
|
||||
QTextStream myQTextStream( &myFile );
|
||||
myQTextStream << mReport;
|
||||
myFile.close();
|
||||
QDesktopServices::openUrl("file://"+myReportFile);
|
||||
QDesktopServices::openUrl( "file://" + myReportFile );
|
||||
}
|
||||
|
||||
}
|
||||
@ -195,19 +195,19 @@ void TestQgsMapRenderer::cleanupTestCase()
|
||||
|
||||
void TestQgsMapRenderer::performanceTest()
|
||||
{
|
||||
mpMapRenderer->setExtent(mpPolysLayer->extent());
|
||||
QString myDataDir (TEST_DATA_DIR); //defined in CmakeLists.txt
|
||||
mpMapRenderer->setExtent( mpPolysLayer->extent() );
|
||||
QString myDataDir( TEST_DATA_DIR ); //defined in CmakeLists.txt
|
||||
QString myTestDataDir = myDataDir + QDir::separator();
|
||||
QgsRenderChecker myChecker;
|
||||
myChecker.setExpectedImage ( myTestDataDir + "expected_maprender.png" );
|
||||
myChecker.setMapRenderer ( mpMapRenderer );
|
||||
bool myResultFlag = myChecker.runTest("maprender");
|
||||
myChecker.setExpectedImage( myTestDataDir + "expected_maprender.png" );
|
||||
myChecker.setMapRenderer( mpMapRenderer );
|
||||
bool myResultFlag = myChecker.runTest( "maprender" );
|
||||
mReport += myChecker.report();
|
||||
QVERIFY(myResultFlag);
|
||||
QVERIFY( myResultFlag );
|
||||
}
|
||||
|
||||
|
||||
QTEST_MAIN(TestQgsMapRenderer)
|
||||
QTEST_MAIN( TestQgsMapRenderer )
|
||||
#include "moc_testqgsmaprenderer.cxx"
|
||||
|
||||
|
||||
|
@ -54,11 +54,11 @@
|
||||
*/
|
||||
class TestQgsVectorFileWriter: public QObject
|
||||
{
|
||||
Q_OBJECT;
|
||||
Q_OBJECT;
|
||||
private slots:
|
||||
void initTestCase();// will be called before the first testfunction is executed.
|
||||
void init(){};// will be called before each testfunction is executed.
|
||||
void cleanup(){};// will be called after every testfunction.
|
||||
void init() {};// will be called before each testfunction is executed.
|
||||
void cleanup() {};// will be called after every testfunction.
|
||||
|
||||
/** This method tests writing a point to a shapefile */
|
||||
void createPoint();
|
||||
@ -73,7 +73,7 @@ class TestQgsVectorFileWriter: public QObject
|
||||
|
||||
private:
|
||||
// a little util fn used by all tests
|
||||
bool cleanupFile(QString theFileBase);
|
||||
bool cleanupFile( QString theFileBase );
|
||||
QString mEncoding;
|
||||
QgsVectorFileWriter::WriterError mError;
|
||||
QgsCoordinateReferenceSystem mCRS;
|
||||
@ -85,25 +85,25 @@ class TestQgsVectorFileWriter: public QObject
|
||||
|
||||
void TestQgsVectorFileWriter::initTestCase()
|
||||
{
|
||||
qDebug("\n\n **************\n"
|
||||
"Note: if you get a message like \n"
|
||||
"ERROR 1: /tmp/testpt.shp is not a directory.\n"
|
||||
"It is caused by the /tmp/testshp.* files already existing\n"
|
||||
"(the ERROR comes from OGR and is not very intuitive)\n"
|
||||
"******************\n");
|
||||
qDebug( "\n\n **************\n"
|
||||
"Note: if you get a message like \n"
|
||||
"ERROR 1: /tmp/testpt.shp is not a directory.\n"
|
||||
"It is caused by the /tmp/testshp.* files already existing\n"
|
||||
"(the ERROR comes from OGR and is not very intuitive)\n"
|
||||
"******************\n" );
|
||||
// init QGIS's paths - true means that all path will be inited from prefix
|
||||
QString qgisPath = QCoreApplication::applicationDirPath ();
|
||||
QgsApplication::setPrefixPath(INSTALL_PREFIX, true);
|
||||
QString qgisPath = QCoreApplication::applicationDirPath();
|
||||
QgsApplication::setPrefixPath( INSTALL_PREFIX, true );
|
||||
QgsApplication::showSettings();
|
||||
//create some objects that will be used in all tests...
|
||||
|
||||
mEncoding = "UTF-8";
|
||||
QgsField myField1("Field1",QVariant::String,"String",10,0,"Field 1 comment");
|
||||
mFields.insert(0, myField1);
|
||||
mCRS = QgsCoordinateReferenceSystem(GEOWkt);
|
||||
mPoint1 = QgsPoint(10.0,10.0);
|
||||
mPoint2 = QgsPoint(15.0,10.0);
|
||||
mPoint3 = QgsPoint(15.0,12.0);
|
||||
QgsField myField1( "Field1", QVariant::String, "String", 10, 0, "Field 1 comment" );
|
||||
mFields.insert( 0, myField1 );
|
||||
mCRS = QgsCoordinateReferenceSystem( GEOWkt );
|
||||
mPoint1 = QgsPoint( 10.0, 10.0 );
|
||||
mPoint2 = QgsPoint( 15.0, 10.0 );
|
||||
mPoint3 = QgsPoint( 15.0, 12.0 );
|
||||
}
|
||||
|
||||
|
||||
@ -115,12 +115,12 @@ void TestQgsVectorFileWriter::createPoint()
|
||||
//
|
||||
QString myFileName = "/testpt.shp";
|
||||
myFileName = QDir::tempPath() + myFileName;
|
||||
QVERIFY(QgsVectorFileWriter::deleteShapeFile(myFileName));
|
||||
QgsVectorFileWriter myWriter (myFileName,
|
||||
mEncoding,
|
||||
mFields,
|
||||
QGis::WKBPoint,
|
||||
&mCRS);
|
||||
QVERIFY( QgsVectorFileWriter::deleteShapeFile( myFileName ) );
|
||||
QgsVectorFileWriter myWriter( myFileName,
|
||||
mEncoding,
|
||||
mFields,
|
||||
QGis::WKBPoint,
|
||||
&mCRS );
|
||||
//
|
||||
// Create a feature
|
||||
//
|
||||
@ -128,29 +128,29 @@ void TestQgsVectorFileWriter::createPoint()
|
||||
// NOTE: dont delete this pointer again -
|
||||
// ownership is passed to the feature which will
|
||||
// delete it in its dtor!
|
||||
QgsGeometry * mypPointGeometry = QgsGeometry::fromPoint(mPoint1);
|
||||
QgsGeometry * mypPointGeometry = QgsGeometry::fromPoint( mPoint1 );
|
||||
QgsFeature myFeature;
|
||||
myFeature.setGeometry(mypPointGeometry);
|
||||
myFeature.addAttribute(0,"HelloWorld");
|
||||
myFeature.setGeometry( mypPointGeometry );
|
||||
myFeature.addAttribute( 0, "HelloWorld" );
|
||||
//
|
||||
// Write the feature to the filewriter
|
||||
// and check for errors
|
||||
//
|
||||
QVERIFY(myWriter.addFeature(myFeature));
|
||||
QVERIFY( myWriter.addFeature( myFeature ) );
|
||||
mError = myWriter.hasError();
|
||||
if(mError==QgsVectorFileWriter::ErrDriverNotFound)
|
||||
if ( mError == QgsVectorFileWriter::ErrDriverNotFound )
|
||||
{
|
||||
std::cout << "Driver not found error" << std::endl;
|
||||
}
|
||||
else if (mError==QgsVectorFileWriter::ErrCreateDataSource)
|
||||
else if ( mError == QgsVectorFileWriter::ErrCreateDataSource )
|
||||
{
|
||||
std::cout << "Create data source error" << std::endl;
|
||||
}
|
||||
else if (mError==QgsVectorFileWriter::ErrCreateLayer)
|
||||
else if ( mError == QgsVectorFileWriter::ErrCreateLayer )
|
||||
{
|
||||
std::cout << "Create layer error" << std::endl;
|
||||
}
|
||||
QVERIFY(mError==QgsVectorFileWriter::NoError);
|
||||
QVERIFY( mError == QgsVectorFileWriter::NoError );
|
||||
}
|
||||
|
||||
void TestQgsVectorFileWriter::createLine()
|
||||
@ -160,12 +160,12 @@ void TestQgsVectorFileWriter::createLine()
|
||||
//
|
||||
QString myFileName = "/testln.shp";
|
||||
myFileName = QDir::tempPath() + myFileName;
|
||||
QVERIFY(QgsVectorFileWriter::deleteShapeFile(myFileName));
|
||||
QgsVectorFileWriter myWriter (myFileName,
|
||||
mEncoding,
|
||||
mFields,
|
||||
QGis::WKBLineString,
|
||||
&mCRS);
|
||||
QVERIFY( QgsVectorFileWriter::deleteShapeFile( myFileName ) );
|
||||
QgsVectorFileWriter myWriter( myFileName,
|
||||
mEncoding,
|
||||
mFields,
|
||||
QGis::WKBLineString,
|
||||
&mCRS );
|
||||
//
|
||||
// Create a feature
|
||||
//
|
||||
@ -175,30 +175,30 @@ void TestQgsVectorFileWriter::createLine()
|
||||
// NOTE: dont delete this pointer again -
|
||||
// ownership is passed to the feature which will
|
||||
// delete it in its dtor!
|
||||
QgsGeometry * mypLineGeometry = QgsGeometry::fromPolyline(myPolyline);
|
||||
QgsGeometry * mypLineGeometry = QgsGeometry::fromPolyline( myPolyline );
|
||||
QgsFeature myFeature;
|
||||
myFeature.setTypeName("WKBLineString");
|
||||
myFeature.setGeometry(mypLineGeometry);
|
||||
myFeature.addAttribute(0,"HelloWorld");
|
||||
myFeature.setTypeName( "WKBLineString" );
|
||||
myFeature.setGeometry( mypLineGeometry );
|
||||
myFeature.addAttribute( 0, "HelloWorld" );
|
||||
//
|
||||
// Write the feature to the filewriter
|
||||
// and check for errors
|
||||
//
|
||||
QVERIFY(myWriter.addFeature(myFeature));
|
||||
QVERIFY( myWriter.addFeature( myFeature ) );
|
||||
mError = myWriter.hasError();
|
||||
if(mError==QgsVectorFileWriter::ErrDriverNotFound)
|
||||
if ( mError == QgsVectorFileWriter::ErrDriverNotFound )
|
||||
{
|
||||
std::cout << "Driver not found error" << std::endl;
|
||||
}
|
||||
else if (mError==QgsVectorFileWriter::ErrCreateDataSource)
|
||||
else if ( mError == QgsVectorFileWriter::ErrCreateDataSource )
|
||||
{
|
||||
std::cout << "Create data source error" << std::endl;
|
||||
}
|
||||
else if (mError==QgsVectorFileWriter::ErrCreateLayer)
|
||||
else if ( mError == QgsVectorFileWriter::ErrCreateLayer )
|
||||
{
|
||||
std::cout << "Create layer error" << std::endl;
|
||||
}
|
||||
QVERIFY(mError==QgsVectorFileWriter::NoError);
|
||||
QVERIFY( mError == QgsVectorFileWriter::NoError );
|
||||
}
|
||||
|
||||
void TestQgsVectorFileWriter::createPolygon()
|
||||
@ -209,12 +209,12 @@ void TestQgsVectorFileWriter::createPolygon()
|
||||
//
|
||||
QString myFileName = "/testply.shp";
|
||||
myFileName = QDir::tempPath() + myFileName;
|
||||
QVERIFY(QgsVectorFileWriter::deleteShapeFile(myFileName));
|
||||
QgsVectorFileWriter myWriter (myFileName,
|
||||
mEncoding,
|
||||
mFields,
|
||||
QGis::WKBPolygon,
|
||||
&mCRS);
|
||||
QVERIFY( QgsVectorFileWriter::deleteShapeFile( myFileName ) );
|
||||
QgsVectorFileWriter myWriter( myFileName,
|
||||
mEncoding,
|
||||
mFields,
|
||||
QGis::WKBPolygon,
|
||||
&mCRS );
|
||||
//
|
||||
// Create a polygon feature
|
||||
//
|
||||
@ -228,30 +228,30 @@ void TestQgsVectorFileWriter::createPolygon()
|
||||
// NOTE: dont delete this pointer again -
|
||||
// ownership is passed to the feature which will
|
||||
// delete it in its dtor!
|
||||
QgsGeometry * mypPolygonGeometry = QgsGeometry::fromPolygon(myPolygon);
|
||||
QgsGeometry * mypPolygonGeometry = QgsGeometry::fromPolygon( myPolygon );
|
||||
QgsFeature myFeature;
|
||||
myFeature.setTypeName("WKBPolygon");
|
||||
myFeature.setGeometry(mypPolygonGeometry);
|
||||
myFeature.addAttribute(0,"HelloWorld");
|
||||
myFeature.setTypeName( "WKBPolygon" );
|
||||
myFeature.setGeometry( mypPolygonGeometry );
|
||||
myFeature.addAttribute( 0, "HelloWorld" );
|
||||
//
|
||||
// Write the feature to the filewriter
|
||||
// and check for errors
|
||||
//
|
||||
QVERIFY(myWriter.addFeature(myFeature));
|
||||
QVERIFY( myWriter.addFeature( myFeature ) );
|
||||
mError = myWriter.hasError();
|
||||
if(mError==QgsVectorFileWriter::ErrDriverNotFound)
|
||||
if ( mError == QgsVectorFileWriter::ErrDriverNotFound )
|
||||
{
|
||||
std::cout << "Driver not found error" << std::endl;
|
||||
}
|
||||
else if (mError==QgsVectorFileWriter::ErrCreateDataSource)
|
||||
else if ( mError == QgsVectorFileWriter::ErrCreateDataSource )
|
||||
{
|
||||
std::cout << "Create data source error" << std::endl;
|
||||
}
|
||||
else if (mError==QgsVectorFileWriter::ErrCreateLayer)
|
||||
else if ( mError == QgsVectorFileWriter::ErrCreateLayer )
|
||||
{
|
||||
std::cout << "Create layer error" << std::endl;
|
||||
}
|
||||
QVERIFY(mError==QgsVectorFileWriter::NoError);
|
||||
QVERIFY( mError == QgsVectorFileWriter::NoError );
|
||||
}
|
||||
void TestQgsVectorFileWriter::polygonGridTest()
|
||||
{
|
||||
@ -260,25 +260,25 @@ void TestQgsVectorFileWriter::polygonGridTest()
|
||||
//
|
||||
QString myFileName = "/testgrid.shp";
|
||||
myFileName = QDir::tempPath() + myFileName;
|
||||
QVERIFY(QgsVectorFileWriter::deleteShapeFile(myFileName));
|
||||
QgsVectorFileWriter myWriter (myFileName,
|
||||
mEncoding,
|
||||
mFields,
|
||||
QGis::WKBPolygon,
|
||||
&mCRS);
|
||||
double myInterval=5.0;
|
||||
for (double i=-180.0;i<=180.0;i+=myInterval)
|
||||
QVERIFY( QgsVectorFileWriter::deleteShapeFile( myFileName ) );
|
||||
QgsVectorFileWriter myWriter( myFileName,
|
||||
mEncoding,
|
||||
mFields,
|
||||
QGis::WKBPolygon,
|
||||
&mCRS );
|
||||
double myInterval = 5.0;
|
||||
for ( double i = -180.0;i <= 180.0;i += myInterval )
|
||||
{
|
||||
for (double j=-90.0;j<=90.0;j+=myInterval)
|
||||
for ( double j = -90.0;j <= 90.0;j += myInterval )
|
||||
{
|
||||
//
|
||||
// Create a polygon feature
|
||||
//
|
||||
QgsPolyline myPolyline;
|
||||
QgsPoint myPoint1 = QgsPoint(i,j);
|
||||
QgsPoint myPoint2 = QgsPoint(i+myInterval,j);
|
||||
QgsPoint myPoint3 = QgsPoint(i+myInterval,j+myInterval);
|
||||
QgsPoint myPoint4 = QgsPoint(i,j+myInterval);
|
||||
QgsPoint myPoint1 = QgsPoint( i, j );
|
||||
QgsPoint myPoint2 = QgsPoint( i + myInterval, j );
|
||||
QgsPoint myPoint3 = QgsPoint( i + myInterval, j + myInterval );
|
||||
QgsPoint myPoint4 = QgsPoint( i, j + myInterval );
|
||||
myPolyline << myPoint1 << myPoint2 << myPoint3 << myPoint4 << myPoint1;
|
||||
QgsPolygon myPolygon;
|
||||
myPolygon << myPolyline;
|
||||
@ -288,30 +288,30 @@ void TestQgsVectorFileWriter::polygonGridTest()
|
||||
// NOTE: dont delete this pointer again -
|
||||
// ownership is passed to the feature which will
|
||||
// delete it in its dtor!
|
||||
QgsGeometry * mypPolygonGeometry = QgsGeometry::fromPolygon(myPolygon);
|
||||
QgsGeometry * mypPolygonGeometry = QgsGeometry::fromPolygon( myPolygon );
|
||||
QgsFeature myFeature;
|
||||
myFeature.setTypeName("WKBPolygon");
|
||||
myFeature.setGeometry(mypPolygonGeometry);
|
||||
myFeature.addAttribute(0,"HelloWorld");
|
||||
myFeature.setTypeName( "WKBPolygon" );
|
||||
myFeature.setGeometry( mypPolygonGeometry );
|
||||
myFeature.addAttribute( 0, "HelloWorld" );
|
||||
//
|
||||
// Write the feature to the filewriter
|
||||
// and check for errors
|
||||
//
|
||||
QVERIFY(myWriter.addFeature(myFeature));
|
||||
QVERIFY( myWriter.addFeature( myFeature ) );
|
||||
mError = myWriter.hasError();
|
||||
if(mError==QgsVectorFileWriter::ErrDriverNotFound)
|
||||
if ( mError == QgsVectorFileWriter::ErrDriverNotFound )
|
||||
{
|
||||
std::cout << "Driver not found error" << std::endl;
|
||||
}
|
||||
else if (mError==QgsVectorFileWriter::ErrCreateDataSource)
|
||||
else if ( mError == QgsVectorFileWriter::ErrCreateDataSource )
|
||||
{
|
||||
std::cout << "Create data source error" << std::endl;
|
||||
}
|
||||
else if (mError==QgsVectorFileWriter::ErrCreateLayer)
|
||||
else if ( mError == QgsVectorFileWriter::ErrCreateLayer )
|
||||
{
|
||||
std::cout << "Create layer error" << std::endl;
|
||||
}
|
||||
QVERIFY(mError==QgsVectorFileWriter::NoError);
|
||||
QVERIFY( mError == QgsVectorFileWriter::NoError );
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -323,7 +323,7 @@ void TestQgsVectorFileWriter::projectedPlygonGridTest()
|
||||
//
|
||||
QString myFileName = "/testprjgrid.shp";
|
||||
myFileName = QDir::tempPath() + myFileName;
|
||||
QVERIFY(QgsVectorFileWriter::deleteShapeFile(myFileName));
|
||||
QVERIFY( QgsVectorFileWriter::deleteShapeFile( myFileName ) );
|
||||
//
|
||||
// We are testing projected coordinate
|
||||
// system vector writing to lets use something fun...
|
||||
@ -333,25 +333,25 @@ void TestQgsVectorFileWriter::projectedPlygonGridTest()
|
||||
// +proj=lcc +lat_1=18 +lat_0=18 +lon_0=-77 +k_0=1 +x_0=250000
|
||||
// +y_0=150000 +ellps=clrk66 +units=m +no_defs
|
||||
//
|
||||
mCRS = QgsCoordinateReferenceSystem(1286,QgsCoordinateReferenceSystem::InternalCrsId);
|
||||
QgsVectorFileWriter myWriter (myFileName,
|
||||
mEncoding,
|
||||
mFields,
|
||||
QGis::WKBPolygon,
|
||||
&mCRS);
|
||||
double myInterval=1000.0; //1km2
|
||||
for (double i=0.0;i<=10000.0;i+=myInterval) //10km
|
||||
mCRS = QgsCoordinateReferenceSystem( 1286, QgsCoordinateReferenceSystem::InternalCrsId );
|
||||
QgsVectorFileWriter myWriter( myFileName,
|
||||
mEncoding,
|
||||
mFields,
|
||||
QGis::WKBPolygon,
|
||||
&mCRS );
|
||||
double myInterval = 1000.0; //1km2
|
||||
for ( double i = 0.0;i <= 10000.0;i += myInterval ) //10km
|
||||
{
|
||||
for (double j=0.0;j<=10000.0;j+=myInterval)//10km
|
||||
for ( double j = 0.0;j <= 10000.0;j += myInterval )//10km
|
||||
{
|
||||
//
|
||||
// Create a polygon feature
|
||||
//
|
||||
QgsPolyline myPolyline;
|
||||
QgsPoint myPoint1 = QgsPoint(i,j);
|
||||
QgsPoint myPoint2 = QgsPoint(i+myInterval,j);
|
||||
QgsPoint myPoint3 = QgsPoint(i+myInterval,j+myInterval);
|
||||
QgsPoint myPoint4 = QgsPoint(i,j+myInterval);
|
||||
QgsPoint myPoint1 = QgsPoint( i, j );
|
||||
QgsPoint myPoint2 = QgsPoint( i + myInterval, j );
|
||||
QgsPoint myPoint3 = QgsPoint( i + myInterval, j + myInterval );
|
||||
QgsPoint myPoint4 = QgsPoint( i, j + myInterval );
|
||||
myPolyline << myPoint1 << myPoint2 << myPoint3 << myPoint4 << myPoint1;
|
||||
QgsPolygon myPolygon;
|
||||
myPolygon << myPolyline;
|
||||
@ -361,34 +361,34 @@ void TestQgsVectorFileWriter::projectedPlygonGridTest()
|
||||
// NOTE: dont delete this pointer again -
|
||||
// ownership is passed to the feature which will
|
||||
// delete it in its dtor!
|
||||
QgsGeometry * mypPolygonGeometry = QgsGeometry::fromPolygon(myPolygon);
|
||||
QgsGeometry * mypPolygonGeometry = QgsGeometry::fromPolygon( myPolygon );
|
||||
QgsFeature myFeature;
|
||||
myFeature.setTypeName("WKBPolygon");
|
||||
myFeature.setGeometry(mypPolygonGeometry);
|
||||
myFeature.addAttribute(0,"HelloWorld");
|
||||
myFeature.setTypeName( "WKBPolygon" );
|
||||
myFeature.setGeometry( mypPolygonGeometry );
|
||||
myFeature.addAttribute( 0, "HelloWorld" );
|
||||
//
|
||||
// Write the feature to the filewriter
|
||||
// and check for errors
|
||||
//
|
||||
QVERIFY(myWriter.addFeature(myFeature));
|
||||
QVERIFY( myWriter.addFeature( myFeature ) );
|
||||
mError = myWriter.hasError();
|
||||
if(mError==QgsVectorFileWriter::ErrDriverNotFound)
|
||||
if ( mError == QgsVectorFileWriter::ErrDriverNotFound )
|
||||
{
|
||||
std::cout << "Driver not found error" << std::endl;
|
||||
}
|
||||
else if (mError==QgsVectorFileWriter::ErrCreateDataSource)
|
||||
else if ( mError == QgsVectorFileWriter::ErrCreateDataSource )
|
||||
{
|
||||
std::cout << "Create data source error" << std::endl;
|
||||
}
|
||||
else if (mError==QgsVectorFileWriter::ErrCreateLayer)
|
||||
else if ( mError == QgsVectorFileWriter::ErrCreateLayer )
|
||||
{
|
||||
std::cout << "Create layer error" << std::endl;
|
||||
}
|
||||
QVERIFY(mError==QgsVectorFileWriter::NoError);
|
||||
QVERIFY( mError == QgsVectorFileWriter::NoError );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QTEST_MAIN(TestQgsVectorFileWriter)
|
||||
QTEST_MAIN( TestQgsVectorFileWriter )
|
||||
#include "moc_testqgsvectorfilewriter.cxx"
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user