mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-15 00:04:00 -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,8 +4187,8 @@ 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() ) );
|
||||
|
||||
@ -5224,7 +5224,7 @@ void QgisApp::activateDeactivateLayerRelatedActions( QgsMapLayer* layer )
|
||||
|
||||
//NOTE: This check does not really add any protection, as it is called on load not on layer select/activate
|
||||
//If you load a layer with a provider and idenitfy ability then load another without, the tool would be disabled for both
|
||||
|
||||
|
||||
//Enable the Identify tool ( GDAL datasets draw without a provider )
|
||||
//but turn off if data provider exists and has no Identify capabilities
|
||||
mActionIdentify->setEnabled( true );
|
||||
|
@ -297,8 +297,8 @@ void QgsGraduatedSymbolDialog::adjustClassification()
|
||||
|
||||
if ( provider )
|
||||
{
|
||||
if ( modeComboBox->currentText() == tr( "Equal Interval" ) ||
|
||||
modeComboBox->currentText() == tr( "Quantiles" ) )
|
||||
if ( modeComboBox->currentText() == tr( "Equal Interval" ) ||
|
||||
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;
|
||||
|
@ -180,8 +180,8 @@ bool QgsCoordinateReferenceSystem::createFromEpsg( long id )
|
||||
|
||||
bool QgsCoordinateReferenceSystem::createFromSrsId( long id )
|
||||
{
|
||||
return loadFromDb( id < 100000 ? QgsApplication::srsDbFilePath() :
|
||||
QgsApplication::qgisUserDbFilePath(), "srs_id", id );
|
||||
return loadFromDb( id < 100000 ? QgsApplication::srsDbFilePath() :
|
||||
QgsApplication::qgisUserDbFilePath(), "srs_id", id );
|
||||
}
|
||||
|
||||
bool QgsCoordinateReferenceSystem::loadFromDb( QString db, QString field, long id )
|
||||
|
@ -242,41 +242,41 @@ class CORE_EXPORT QgsCoordinateReferenceSystem
|
||||
* @return long theSrsId The internal sqlite3 srs.db primary key for this srs
|
||||
*/
|
||||
long srsid() const;
|
||||
|
||||
|
||||
/*! Get the postgis srid for this srs
|
||||
* @return long theSRID the Postgis spatial_ref_sys identifier for this srs (defaults to 0)
|
||||
*/
|
||||
long postgisSrid() const;
|
||||
|
||||
|
||||
/*! Get the EpsgCrsId identifier for this srs
|
||||
* @return long theEpsg the ESPG identifier for this srs (defaults to 0)
|
||||
*/
|
||||
long epsg() const;
|
||||
|
||||
|
||||
/*! Get the Description
|
||||
* @return QString the Description A textual description of the srs.
|
||||
* @note A zero length string will be returned if the description is uninitialised
|
||||
*/
|
||||
QString description() const;
|
||||
|
||||
|
||||
/*! Get the Projection Acronym
|
||||
* @return QString theProjectionAcronym The official proj4 acronym for the projection family
|
||||
* @note A zero length string will be returned if the projectionAcronym is uninitialised
|
||||
*/
|
||||
QString projectionAcronym() const;
|
||||
|
||||
|
||||
/*! Get the Ellipsoid Acronym
|
||||
* @return QString theEllipsoidAcronym The official proj4 acronym for the ellipoid
|
||||
* @note A zero length string will be returned if the ellipsoidAcronym is uninitialised
|
||||
*/
|
||||
QString ellipsoidAcronym() const;
|
||||
|
||||
|
||||
/*! A helper to get an wkt representation of this srs
|
||||
* @return string containing Wkt of the srs
|
||||
*/
|
||||
QString toWkt() const;
|
||||
|
||||
/** Get the Proj Proj4 string representation of this srs.
|
||||
/** Get the Proj Proj4 string representation of this srs.
|
||||
* If proj and ellps keys are found in the parameters,
|
||||
* they will be stripped out and the Projection and ellipsoid acronyms will be
|
||||
* overridden with these.
|
||||
@ -284,12 +284,12 @@ class CORE_EXPORT QgsCoordinateReferenceSystem
|
||||
* @note A zero length string will be returned if the toProj4 is uninitialised
|
||||
*/
|
||||
QString toProj4() const;
|
||||
|
||||
|
||||
/*! Get this Geographic? flag
|
||||
* @return bool theGeoFlag Whether this is a geographic or projected coordinate system
|
||||
*/
|
||||
bool geographicFlag() const;
|
||||
|
||||
|
||||
/*! Get the units that the projection is in
|
||||
* @return QGis::UnitType that gives the units for the coordinate system
|
||||
*/
|
||||
@ -305,7 +305,7 @@ class CORE_EXPORT QgsCoordinateReferenceSystem
|
||||
*/
|
||||
QString validationHint();
|
||||
// Mutators -----------------------------------
|
||||
// We dont want to expose these to the public api since they wont create
|
||||
// We dont want to expose these to the public api since they wont create
|
||||
// a fully valid crs. Programmers should use the createFrom* methods rather
|
||||
private:
|
||||
/** A static helper function to find out the proj4 string for a srsid
|
||||
|
@ -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];
|
||||
|
@ -245,10 +245,10 @@ class CORE_EXPORT QgsGeometry
|
||||
@param topological true if topological editing is enabled
|
||||
@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 );
|
||||
int splitGeometry( const QList<QgsPoint>& splitLine,
|
||||
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,15 +1918,15 @@ 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 )
|
||||
{
|
||||
|
@ -77,7 +77,7 @@ QgsGraduatedSymbolRenderer::~QgsGraduatedSymbolRenderer()
|
||||
QgsGraduatedSymbolRenderer::Mode QgsGraduatedSymbolRenderer::mode() const
|
||||
{
|
||||
//mode is only really used to be able to reinstate
|
||||
//the graduated dialog properties properly, so we
|
||||
//the graduated dialog properties properly, so we
|
||||
//dont do anything else besides accessors and mutators in
|
||||
//this class
|
||||
return mMode;
|
||||
@ -86,7 +86,7 @@ QgsGraduatedSymbolRenderer::Mode QgsGraduatedSymbolRenderer::mode() const
|
||||
void QgsGraduatedSymbolRenderer::setMode( QgsGraduatedSymbolRenderer::Mode theMode )
|
||||
{
|
||||
//mode is only really used to be able to reinstate
|
||||
//the graduated dialog properties properly, so we
|
||||
//the graduated dialog properties properly, so we
|
||||
//dont do anything else besides accessors and mutators in
|
||||
//this class
|
||||
mMode = theMode;
|
||||
@ -183,7 +183,7 @@ void QgsGraduatedSymbolRenderer::renderFeature( QPainter * p, QgsFeature & f, QI
|
||||
brush.setColor( mSelectionColor );
|
||||
p->setBrush( brush );
|
||||
}
|
||||
else //dont draw outlines in selection colour for polys otherwise they appear merged
|
||||
else //dont draw outlines in selection colour for polys otherwise they appear merged
|
||||
{
|
||||
pen.setColor( mSelectionColor );
|
||||
}
|
||||
@ -310,12 +310,12 @@ 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 )
|
||||
else if ( QgsGraduatedSymbolRenderer::Quantile )
|
||||
{
|
||||
modeValue = "Quantile";
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ class QgsVectorLayer;
|
||||
class CORE_EXPORT QgsGraduatedSymbolRenderer: public QgsRenderer
|
||||
{
|
||||
public:
|
||||
enum Mode
|
||||
enum Mode
|
||||
{
|
||||
EqualInterval,
|
||||
Quantile,
|
||||
@ -37,85 +37,85 @@ class CORE_EXPORT QgsGraduatedSymbolRenderer: public QgsRenderer
|
||||
QgsGraduatedSymbolRenderer( const QgsGraduatedSymbolRenderer& other );
|
||||
QgsGraduatedSymbolRenderer& operator=( const QgsGraduatedSymbolRenderer& other );
|
||||
virtual ~QgsGraduatedSymbolRenderer();
|
||||
|
||||
|
||||
/** Get the mode - which is only really used to be able to reinstate
|
||||
* the graduated dialog properties properly, so we
|
||||
* the graduated dialog properties properly, so we
|
||||
* dont do anything else besides accessors and mutators in
|
||||
* this class.
|
||||
*/
|
||||
Mode mode() const;
|
||||
|
||||
/** Set the mode - which is only really used to be able to reinstate
|
||||
* the graduated dialog properties properly, so we
|
||||
* the graduated dialog properties properly, so we
|
||||
* dont do anything else besides accessors and mutators in
|
||||
* this class.
|
||||
*/
|
||||
void setMode( Mode theMode );
|
||||
|
||||
|
||||
/**Adds a new item
|
||||
\param sy a pointer to the QgsSymbol to be inserted. It has to be created using the new operator and is automatically destroyed when 'removeItems' is called or when this object is destroyed*/
|
||||
void addSymbol( QgsSymbol* sy );
|
||||
|
||||
|
||||
/**Returns the indes of the classification field*/
|
||||
int classificationField() const;
|
||||
|
||||
|
||||
/**Removes all symbols*/
|
||||
void removeSymbols();
|
||||
|
||||
|
||||
/** Determines if a feature will be rendered or not
|
||||
@param f a pointer to the feature to determine if rendering will happen*/
|
||||
virtual bool willRenderFeature( QgsFeature *f );
|
||||
|
||||
|
||||
/**Renders an OGRFeature
|
||||
\param p a painter (usually the one from the current map canvas)
|
||||
\param f a pointer to a feature to render
|
||||
\param t the transform object containing the information how to transform the map coordinates to screen coordinates*/
|
||||
void renderFeature( QPainter* p, QgsFeature& f, QImage* img, bool selected, double widthScale = 1.0, double rasterScaleFactor = 1.0 );
|
||||
|
||||
|
||||
/**Sets the classicifation field by index
|
||||
\param field the number of the field to classify*/
|
||||
void setClassificationField( int );
|
||||
|
||||
|
||||
/**Reads the renderer configuration from an XML file
|
||||
@param rnode the Dom node to read
|
||||
@param vl the vector layer which will be associated with the renderer
|
||||
@return 0 in case of success, 1 if vector layer has no renderer, 2 if classification field not found
|
||||
*/
|
||||
virtual int readXML( const QDomNode& rnode, QgsVectorLayer& vl );
|
||||
|
||||
|
||||
/**Writes the contents of the renderer to a configuration file
|
||||
@ return true in case of success*/
|
||||
virtual bool writeXML( QDomNode & layer_node, QDomDocument & document, const QgsVectorLayer& vl ) const;
|
||||
|
||||
|
||||
/** Returns true*/
|
||||
bool needsAttributes() const;
|
||||
|
||||
|
||||
/**Returns a list of all needed attributes*/
|
||||
QgsAttributeList classificationAttributes() const;
|
||||
|
||||
|
||||
void updateSymbolAttributes();
|
||||
|
||||
|
||||
/**Returns the renderers name*/
|
||||
QString name() const;
|
||||
|
||||
|
||||
/**Returns the symbols of the items*/
|
||||
const QList<QgsSymbol*> symbols() const;
|
||||
|
||||
|
||||
/**Returns a copy of the renderer (a deep copy on the heap)*/
|
||||
QgsRenderer* clone() const;
|
||||
|
||||
protected:
|
||||
/** The graduation mode */
|
||||
Mode mMode;
|
||||
|
||||
|
||||
/**Index of the classification field (it must be a numerical field)*/
|
||||
int mClassificationField;
|
||||
|
||||
|
||||
/**List holding the symbols for the individual classes*/
|
||||
QList<QgsSymbol*> mSymbols;
|
||||
|
||||
|
||||
QgsSymbol *symbolForFeature( const QgsFeature* f );
|
||||
|
||||
|
||||
/**Cached copy of all underlying symbols required attribute fields*/
|
||||
QgsAttributeList mSymbolAttributes;
|
||||
|
||||
|
@ -106,7 +106,7 @@ QImage QgsMarkerCatalogue::imageMarker( QString fullName, double size, QPen pen,
|
||||
{
|
||||
size = 4;
|
||||
}
|
||||
|
||||
|
||||
QImage myImage;
|
||||
if ( fullName.left( 5 ) == "hard:" )
|
||||
{
|
||||
@ -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;
|
||||
|
@ -54,7 +54,7 @@ void QgsMapCanvasSnapper::setMapCanvas( QgsMapCanvas* canvas )
|
||||
mSnapper = new QgsSnapper( canvas->mapRenderer() );
|
||||
}
|
||||
else
|
||||
{
|
||||
{
|
||||
mSnapper = 0;
|
||||
}
|
||||
}
|
||||
|
@ -120,7 +120,7 @@ class CoordinateCapture: public QObject, public QgisPlugin
|
||||
//!epsg id for showin in geoedit box
|
||||
long mEpsgId;
|
||||
//!proj4 string for coordinate translation
|
||||
QString mProj4Str;
|
||||
QString mProj4Str;
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
|
@ -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,17 +46,17 @@
|
||||
*/
|
||||
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*/
|
||||
void diacriticalTest();
|
||||
|
||||
|
||||
private:
|
||||
QString mEncoding;
|
||||
QgsVectorFileWriter::WriterError mError;
|
||||
@ -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"
|
||||
|
||||
|
||||
|
@ -35,9 +35,9 @@
|
||||
#include <qgsapplication.h> //search path for srs.db
|
||||
#include <qgsfield.h>
|
||||
#include <qgis.h> //defines GEOWkt
|
||||
#include <qgsmaprenderer.h>
|
||||
#include <qgsmaplayer.h>
|
||||
#include <qgsvectorlayer.h>
|
||||
#include <qgsmaprenderer.h>
|
||||
#include <qgsmaplayer.h>
|
||||
#include <qgsvectorlayer.h>
|
||||
#include <qgsapplication.h>
|
||||
#include <qgsproviderregistry.h>
|
||||
#include <qgsmaplayerregistry.h>
|
||||
@ -52,16 +52,16 @@
|
||||
*/
|
||||
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();
|
||||
|
||||
|
||||
private:
|
||||
QString mEncoding;
|
||||
QgsVectorFileWriter::WriterError mError;
|
||||
@ -78,101 +78,101 @@ 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: ");
|
||||
|
||||
QgsVectorFileWriter myWriter (myFileName,
|
||||
mEncoding,
|
||||
mFields,
|
||||
QGis::WKBPolygon,
|
||||
&mCRS);
|
||||
double myInterval=0.5;
|
||||
for (double i=-180.0;i<=180.0;i+=myInterval)
|
||||
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 )
|
||||
{
|
||||
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;
|
||||
//polygon: first item of the list is outer ring,
|
||||
// inner rings (if any) start from second item
|
||||
//polygon: first item of the list is outer ring,
|
||||
// inner rings (if any) start from second item
|
||||
//
|
||||
// NOTE: dont delete this pointer again -
|
||||
// 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,34 +180,34 @@ 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 );
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
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"
|
||||
|
||||
|
||||
|
@ -38,27 +38,27 @@
|
||||
* QVariant::String
|
||||
* QVariant::Int
|
||||
* QVariant::Double
|
||||
*
|
||||
*
|
||||
* Allowed ogr prvider typeNames:
|
||||
* Integer
|
||||
* Real
|
||||
* String
|
||||
*
|
||||
*
|
||||
* Constructor for QgsField:
|
||||
* QgsField::QgsField(QString name,
|
||||
* QVariant::Type type,
|
||||
* QString typeName,
|
||||
* int len,
|
||||
* int prec,
|
||||
* QgsField::QgsField(QString name,
|
||||
* QVariant::Type type,
|
||||
* QString typeName,
|
||||
* int len,
|
||||
* int prec,
|
||||
* QString comment)
|
||||
*/
|
||||
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();
|
||||
@ -70,10 +70,10 @@ class TestQgsVectorFileWriter: public QObject
|
||||
void polygonGridTest();
|
||||
/** As above but using a projected CRS*/
|
||||
void projectedPlygonGridTest();
|
||||
|
||||
|
||||
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 );
|
||||
}
|
||||
|
||||
|
||||
@ -114,43 +114,43 @@ void TestQgsVectorFileWriter::createPoint()
|
||||
// Remove old copies that may be lying around
|
||||
//
|
||||
QString myFileName = "/testpt.shp";
|
||||
myFileName = QDir::tempPath() + myFileName;
|
||||
QVERIFY(QgsVectorFileWriter::deleteShapeFile(myFileName));
|
||||
QgsVectorFileWriter myWriter (myFileName,
|
||||
mEncoding,
|
||||
mFields,
|
||||
QGis::WKBPoint,
|
||||
&mCRS);
|
||||
myFileName = QDir::tempPath() + myFileName;
|
||||
QVERIFY( QgsVectorFileWriter::deleteShapeFile( myFileName ) );
|
||||
QgsVectorFileWriter myWriter( myFileName,
|
||||
mEncoding,
|
||||
mFields,
|
||||
QGis::WKBPoint,
|
||||
&mCRS );
|
||||
//
|
||||
// Create a feature
|
||||
//
|
||||
//
|
||||
// NOTE: dont delete this pointer again -
|
||||
// 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()
|
||||
@ -159,46 +159,46 @@ void TestQgsVectorFileWriter::createLine()
|
||||
// Remove old copies that may be lying around
|
||||
//
|
||||
QString myFileName = "/testln.shp";
|
||||
myFileName = QDir::tempPath() + myFileName;
|
||||
QVERIFY(QgsVectorFileWriter::deleteShapeFile(myFileName));
|
||||
QgsVectorFileWriter myWriter (myFileName,
|
||||
mEncoding,
|
||||
mFields,
|
||||
QGis::WKBLineString,
|
||||
&mCRS);
|
||||
myFileName = QDir::tempPath() + myFileName;
|
||||
QVERIFY( QgsVectorFileWriter::deleteShapeFile( myFileName ) );
|
||||
QgsVectorFileWriter myWriter( myFileName,
|
||||
mEncoding,
|
||||
mFields,
|
||||
QGis::WKBLineString,
|
||||
&mCRS );
|
||||
//
|
||||
// Create a feature
|
||||
//
|
||||
QgsPolyline myPolyline;
|
||||
myPolyline << mPoint1 << mPoint2 << mPoint3;
|
||||
//
|
||||
// NOTE: dont delete this pointer again -
|
||||
// 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()
|
||||
@ -208,13 +208,13 @@ void TestQgsVectorFileWriter::createPolygon()
|
||||
// Remove old copies that may be lying around
|
||||
//
|
||||
QString myFileName = "/testply.shp";
|
||||
myFileName = QDir::tempPath() + myFileName;
|
||||
QVERIFY(QgsVectorFileWriter::deleteShapeFile(myFileName));
|
||||
QgsVectorFileWriter myWriter (myFileName,
|
||||
mEncoding,
|
||||
mFields,
|
||||
QGis::WKBPolygon,
|
||||
&mCRS);
|
||||
myFileName = QDir::tempPath() + myFileName;
|
||||
QVERIFY( QgsVectorFileWriter::deleteShapeFile( myFileName ) );
|
||||
QgsVectorFileWriter myWriter( myFileName,
|
||||
mEncoding,
|
||||
mFields,
|
||||
QGis::WKBPolygon,
|
||||
&mCRS );
|
||||
//
|
||||
// Create a polygon feature
|
||||
//
|
||||
@ -222,36 +222,36 @@ void TestQgsVectorFileWriter::createPolygon()
|
||||
myPolyline << mPoint1 << mPoint2 << mPoint3 << mPoint1;
|
||||
QgsPolygon myPolygon;
|
||||
myPolygon << myPolyline;
|
||||
//polygon: first item of the list is outer ring,
|
||||
// inner rings (if any) start from second item
|
||||
//polygon: first item of the list is outer ring,
|
||||
// inner rings (if any) start from second item
|
||||
//
|
||||
// NOTE: dont delete this pointer again -
|
||||
// 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()
|
||||
{
|
||||
@ -259,59 +259,59 @@ void TestQgsVectorFileWriter::polygonGridTest()
|
||||
// Remove old copies that may be lying around
|
||||
//
|
||||
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)
|
||||
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 )
|
||||
{
|
||||
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;
|
||||
//polygon: first item of the list is outer ring,
|
||||
// inner rings (if any) start from second item
|
||||
//polygon: first item of the list is outer ring,
|
||||
// inner rings (if any) start from second item
|
||||
//
|
||||
// NOTE: dont delete this pointer again -
|
||||
// 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 );
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -322,73 +322,73 @@ void TestQgsVectorFileWriter::projectedPlygonGridTest()
|
||||
// Remove old copies that may be lying around
|
||||
//
|
||||
QString myFileName = "/testprjgrid.shp";
|
||||
myFileName = QDir::tempPath() + myFileName;
|
||||
QVERIFY(QgsVectorFileWriter::deleteShapeFile(myFileName));
|
||||
myFileName = QDir::tempPath() + myFileName;
|
||||
QVERIFY( QgsVectorFileWriter::deleteShapeFile( myFileName ) );
|
||||
//
|
||||
// We are testing projected coordinate
|
||||
// We are testing projected coordinate
|
||||
// system vector writing to lets use something fun...
|
||||
// Jamaica National Grid
|
||||
// QGIS CRSID: 1286
|
||||
// PostGIS SRID: 24200
|
||||
// +proj=lcc +lat_1=18 +lat_0=18 +lon_0=-77 +k_0=1 +x_0=250000
|
||||
// +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;
|
||||
//polygon: first item of the list is outer ring,
|
||||
// inner rings (if any) start from second item
|
||||
//polygon: first item of the list is outer ring,
|
||||
// inner rings (if any) start from second item
|
||||
//
|
||||
// NOTE: dont delete this pointer again -
|
||||
// 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