89 changes: 45 additions & 44 deletions doc/TRANSLATORS

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion doc/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</td>
<td valign="center">
<span class="header">Quantum GIS Documentation</span><br>
<span class="subheader">Version 1.7.0 <i>Wrocław</i></span><br>
<span class="subheader">Use Help inside functions or:</span><br>
<span class="warning">You can find a <a href="http://www.qgis.org/en/documentation/manuals.html">PDF manual of the current version</a> on the QGIS website.</span>
</td>
</tr>
Expand Down
6,713 changes: 3,922 additions & 2,791 deletions i18n/qgis_de.ts

Large diffs are not rendered by default.

49,349 changes: 49,349 additions & 0 deletions i18n/qgis_en.ts

Large diffs are not rendered by default.

38,416 changes: 18,638 additions & 19,778 deletions i18n/qgis_km.ts

Large diffs are not rendered by default.

455 changes: 215 additions & 240 deletions i18n/qgis_lt.ts

Large diffs are not rendered by default.

5,541 changes: 2,730 additions & 2,811 deletions i18n/qgis_ml_IN.ts

Large diffs are not rendered by default.

Binary file added images/flags/km.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions images/images.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@
<file>themes/default/symbologyUp.png</file>
<file>themes/default/tracking.png</file>
<file>themes/default/transformed.png</file>
<file>themes/default/transp-background_8x8.png</file>
<file>themes/default/user.png</file>
<file>themes/default/mActionAddHtml.png</file>
<file>themes/gis/mActionAddArrow.png</file>
Expand Down Expand Up @@ -331,6 +332,7 @@
<file>themes/gis/mActionFilePrint.png</file>
<file>themes/gis/mActionFileSaveAs.png</file>
<file>themes/gis/mActionFileSave.png</file>
<file>themes/gis/mActionFilter.svg</file>
<file>themes/gis/mActionFolder.png</file>
<file>themes/gis/mActionFormAnnotation.png</file>
<file>themes/gis/mActionGroupItems.png</file>
Expand Down Expand Up @@ -427,6 +429,7 @@
<file>themes/gis/plugins/dxf2shp_converter.png</file>
<file>themes/gis/plugins/gps_importer/create_gpx.png</file>
<file>themes/gis/plugins/gps_importer/import_gpx.png</file>
<file>themes/gis/plugins/gps_importer.png</file>
<file>themes/gis/plugins/interpolation.png</file>
<file>themes/gis/plugins/mapserver_export.png</file>
<file>themes/gis/plugins/mGeorefRun.png</file>
Expand Down Expand Up @@ -535,6 +538,13 @@
<file>flags/sw.png</file>
<file>flags/eu_ES.png</file>
<file>flags/ml_IN.png</file>
<file>flags/km.png</file>
<file>themes/gis/mIconExpressionFilter.svg</file>
<file>themes/gis/mIconExpressionPreview.svg</file>
<file>themes/gis/mIconExpressionSelect.svg</file>
<file>themes/gis/mIconSelectAdd.svg</file>
<file>themes/gis/mIconSelectIntersect.svg</file>
<file>themes/gis/mIconSelectRemove.svg</file>
</qresource>
<qresource prefix="/images/tips">
<file alias="symbol_levels.png">qgis_tips/symbol_levels.png</file>
Expand Down
Binary file added images/themes/default/transp-background_8x8.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
927 changes: 927 additions & 0 deletions images/themes/gis/mActionFilter.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
952 changes: 952 additions & 0 deletions images/themes/gis/mIconExpressionFilter.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
974 changes: 974 additions & 0 deletions images/themes/gis/mIconExpressionPreview.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
935 changes: 935 additions & 0 deletions images/themes/gis/mIconExpressionSelect.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
947 changes: 947 additions & 0 deletions images/themes/gis/mIconSelectAdd.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
938 changes: 938 additions & 0 deletions images/themes/gis/mIconSelectIntersect.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
948 changes: 948 additions & 0 deletions images/themes/gis/mIconSelectRemove.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 8 additions & 5 deletions python/core/composer/qgscomposeritem.sip
Original file line number Diff line number Diff line change
Expand Up @@ -292,16 +292,19 @@ class QgsComposerItem: QObject, QGraphicsRectItem
/**Updates item, with the possibility to do custom update for subclasses*/
virtual void updateItem();

/**Get item identification name
/**Get item's id (which is not necessarly unique)
@note this method was added in version 1.7*/
QString id() const;

/**Set item identification name
@note this method was added in version 1.7
This method was moved from qgscomposerlabel so that every object can have a
id (NathanW)*/
/**Set item's id (which is not necessarly unique)
@note this method was added in version 1.7*/
void setId( const QString& id );

/**Get item identification name
@note this method was added in version 2.0
@note there is not setter since one can't manually set the id*/
QString uuid() const;

public slots:
virtual void setRotation( double r );
void repaint();
Expand Down
32 changes: 9 additions & 23 deletions python/core/composer/qgscomposerlegend.sip
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ class QgsComposerLegend : QgsComposerItem
{
%TypeHeaderCode
#include <qgscomposerlegend.h>
#include <qgscomposerlegendstyle.h>
%End

public:
Expand All @@ -30,33 +31,18 @@ class QgsComposerLegend : QgsComposerItem
void setTitle( const QString& t );
QString title() const;

QFont titleFont() const;
void setTitleFont( const QFont& f );

QFont groupFont() const;
void setGroupFont( const QFont& f );

QFont layerFont() const;
void setLayerFont( const QFont& f );

QFont itemFont() const;
void setItemFont( const QFont& f );
/*
QgsComposerLegendStyle style(QgsComposerLegendStyle::Style s) const;
void setStyle(QgsComposerLegendStyle::Style s, const QgsComposerLegendStyle style);
QFont styleFont( QgsComposerLegendStyle::Style s ) const;
void setStyleFont( QgsComposerLegendStyle::Style s, const QFont& f );
void setStyleMargin( QgsComposerLegendStyle::Style s, double margin );
void setStyleMargin( QgsComposerLegendStyle::Style s, QgsComposerLegendStyle::Side side, double margin );
*/

double boxSpace() const;
void setBoxSpace( double s );

double groupSpace() const;
void setGroupSpace( double s );

double layerSpace() const;
void setLayerSpace( double s );

double symbolSpace() const;
void setSymbolSpace( double s );

double iconLabelSpace() const;
void setIconLabelSpace( double s );

double symbolWidth() const;
void setSymbolWidth( double w );

Expand Down
12 changes: 12 additions & 0 deletions python/core/composer/qgscomposition.sip
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,25 @@ class QgsComposition : QGraphicsScene
const QgsComposerHtml* getComposerHtmlByItem( QgsComposerItem *item ) const;

/**Returns a composer item given its text identifier.
Ids are not necessarely unique, but this function returns only one element.
@note added in 2.0
@param theId - A QString representing the identifier of the item to
retrieve.
@return QgsComposerItem pointer or 0 pointer if no such item exists.
**/
const QgsComposerItem* getComposerItemById( QString theId ) const;


/**Returns a composer item given its unique identifier.
Warning : ids are not necessarely unique, but this function returns only one element.
@note added in 2.0
@param theId - A QString representing the UUID of the item to retrieve.
@param inAllComposers - Whether the search should be done in all composers of the project
@return QgsComposerItem pointer or 0 pointer if no such item exists.
**/
//const QgsComposerItem* getComposerItemByUuid( QString theUuid, bool inAllComposers = false ) const;
const QgsComposerItem* getComposerItemByUuid( QString theUuid ) const;

int printResolution() const;
void setPrintResolution( int dpi );

Expand Down
1 change: 1 addition & 0 deletions python/core/core.sip
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
%Include qgsvectordataprovider.sip
%Include qgsvectorfilewriter.sip
%Include qgsvectorlayer.sip
%Include qgsvectorlayercache.sip
%Include qgsvectorlayereditbuffer.sip
%Include qgsvectorlayerimport.sip
%Include qgsvectorlayerjoinbuffer.sip
Expand Down
108 changes: 50 additions & 58 deletions python/core/qgsexpression.sip
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ class QgsExpression
//! Returns parser error
QString parserErrorString() const;

//! Returns root node of the expression. Root node is null is parsing has failed
const QgsExpression::Node* rootNode() const;

//! Get the expression ready for evaluation - find out column indexes.
bool prepare( const QgsFields &fields );

Expand Down Expand Up @@ -118,9 +121,6 @@ class QgsExpression
// static const char* BinaryOperatorText[];
// static const char* UnaryOperatorText[];

// static const char* BinaryOgcOperatorText[];
// static const char* UnaryOgcOperatorText[];

class Function
{
public:
Expand Down Expand Up @@ -167,10 +167,22 @@ class QgsExpression

//////

enum NodeType
{
ntUnaryOperator,
ntBinaryOperator,
ntInOperator,
ntFunction,
ntLiteral,
ntColumnRef,
ntCondition
};

class Node
{
public:
virtual ~Node();
virtual QgsExpression::NodeType nodeType() const = 0;
// abstract virtual eval function
// errors are reported to the parent
virtual QVariant eval( QgsExpression* parent, QgsFeature* f ) = 0;
Expand All @@ -181,14 +193,11 @@ class QgsExpression

virtual QString dump() const = 0;

virtual void toOgcFilter( QDomDocument &doc, QDomElement &element ) const;
static QgsExpression::Node* createFromOgcFilter( QDomElement &element, QString &errorMessage ) /Factory/;

virtual QStringList referencedColumns() const = 0;
virtual bool needsGeometry() const = 0;

// support for visitor pattern
virtual void accept( QgsExpression::Visitor& v ) = 0;
virtual void accept( QgsExpression::Visitor& v ) const = 0;
};

class NodeList
Expand All @@ -201,7 +210,6 @@ class QgsExpression
QList<QgsExpression::Node*> list();

virtual QString dump() const;
virtual void toOgcFilter( QDomDocument &doc, QDomElement &element ) const;
};

class Interval
Expand Down Expand Up @@ -229,19 +237,17 @@ class QgsExpression
NodeUnaryOperator( QgsExpression::UnaryOperator op, QgsExpression::Node* operand );
~NodeUnaryOperator();

QgsExpression::UnaryOperator op();
QgsExpression::Node* operand();
QgsExpression::UnaryOperator op() const;
QgsExpression::Node* operand() const;

virtual QgsExpression::NodeType nodeType() const;
virtual bool prepare( QgsExpression* parent, const QgsFields &fields );
virtual QVariant eval( QgsExpression* parent, QgsFeature* f );
virtual QString dump() const;

virtual void toOgcFilter( QDomDocument &doc, QDomElement &element ) const;
static QgsExpression::Node* createFromOgcFilter( QDomElement &element, QString &errorMessage ) /Factory/;

virtual QStringList referencedColumns() const;
virtual bool needsGeometry() const;
virtual void accept( QgsExpression::Visitor& v );
virtual void accept( QgsExpression::Visitor& v ) const;
};

class NodeBinaryOperator : QgsExpression::Node
Expand All @@ -250,20 +256,18 @@ class QgsExpression
NodeBinaryOperator( QgsExpression::BinaryOperator op, QgsExpression::Node* opLeft, QgsExpression::Node* opRight );
~NodeBinaryOperator();

QgsExpression::BinaryOperator op();
QgsExpression::Node* opLeft();
QgsExpression::Node* opRight();
QgsExpression::BinaryOperator op() const;
QgsExpression::Node* opLeft() const;
QgsExpression::Node* opRight() const;

virtual QgsExpression::NodeType nodeType() const;
virtual bool prepare( QgsExpression* parent, const QgsFields &fields );
virtual QVariant eval( QgsExpression* parent, QgsFeature* f );
virtual QString dump() const;

virtual void toOgcFilter( QDomDocument &doc, QDomElement &element ) const;
static QgsExpression::Node* createFromOgcFilter( QDomElement &element, QString &errorMessage ) /Factory/;

virtual QStringList referencedColumns() const;
virtual bool needsGeometry() const;
virtual void accept( QgsExpression::Visitor& v );
virtual void accept( QgsExpression::Visitor& v ) const;
};

class NodeInOperator : QgsExpression::Node
Expand All @@ -272,19 +276,18 @@ class QgsExpression
NodeInOperator( QgsExpression::Node* node, QgsExpression::NodeList* list, bool notin = false );
~NodeInOperator();

QgsExpression::Node* node();
bool isNotIn();
QgsExpression::NodeList* list();
QgsExpression::Node* node() const;
bool isNotIn() const;
QgsExpression::NodeList* list() const;

virtual QgsExpression::NodeType nodeType() const;
virtual bool prepare( QgsExpression* parent, const QgsFields &fields );
virtual QVariant eval( QgsExpression* parent, QgsFeature* f );
virtual QString dump() const;

virtual void toOgcFilter( QDomDocument &doc, QDomElement &element ) const;

virtual QStringList referencedColumns() const;
virtual bool needsGeometry() const;
virtual void accept( QgsExpression::Visitor& v );
virtual void accept( QgsExpression::Visitor& v ) const;
};

class NodeFunction : QgsExpression::Node
Expand All @@ -294,57 +297,51 @@ class QgsExpression
//NodeFunction( QString name, QgsExpression::NodeList* args );
~NodeFunction();

int fnIndex();
QgsExpression::NodeList* args();
int fnIndex() const;
QgsExpression::NodeList* args() const;

virtual QgsExpression::NodeType nodeType() const;
virtual bool prepare( QgsExpression* parent, const QgsFields &fields );
virtual QVariant eval( QgsExpression* parent, QgsFeature* f );
virtual QString dump() const;

virtual void toOgcFilter( QDomDocument &doc, QDomElement &element ) const;
static QgsExpression::Node* createFromOgcFilter( QDomElement &element, QString &errorMessage ) /Factory/;

virtual QStringList referencedColumns() const;
virtual bool needsGeometry() const;
virtual void accept( QgsExpression::Visitor& v );
virtual void accept( QgsExpression::Visitor& v ) const;
};

class NodeLiteral : QgsExpression::Node
{
public:
NodeLiteral( QVariant value );

QVariant value();
QVariant value() const;

virtual QgsExpression::NodeType nodeType() const;
virtual bool prepare( QgsExpression* parent, const QgsFields &fields );
virtual QVariant eval( QgsExpression* parent, QgsFeature* f );
virtual QString dump() const;

virtual void toOgcFilter( QDomDocument &doc, QDomElement &element ) const;
static QgsExpression::Node* createFromOgcFilter( QDomElement &element, QString &errorMessage ) /Factory/;

virtual QStringList referencedColumns() const;
virtual bool needsGeometry() const;
virtual void accept( QgsExpression::Visitor& v );
virtual void accept( QgsExpression::Visitor& v ) const;
};

class NodeColumnRef : QgsExpression::Node
{
public:
NodeColumnRef( QString name );

QString name();
QString name() const;

virtual QgsExpression::NodeType nodeType() const;
virtual bool prepare( QgsExpression* parent, const QgsFields &fields );
virtual QVariant eval( QgsExpression* parent, QgsFeature* f );
virtual QString dump() const;

virtual void toOgcFilter( QDomDocument &doc, QDomElement &element ) const;
static QgsExpression::Node* createFromOgcFilter( QDomElement &element, QString &errorMessage ) /Factory/;

virtual QStringList referencedColumns() const;
virtual bool needsGeometry() const;
virtual void accept( QgsExpression::Visitor& v );
virtual void accept( QgsExpression::Visitor& v ) const;
};

class WhenThen
Expand All @@ -365,15 +362,14 @@ class QgsExpression
NodeCondition( QgsExpression::WhenThenList* conditions, QgsExpression::Node* elseExp = NULL );
~NodeCondition();

virtual QgsExpression::NodeType nodeType() const;
virtual QVariant eval( QgsExpression* parent, QgsFeature* f );
virtual bool prepare( QgsExpression* parent, const QgsFields &fields );
virtual QString dump() const;

virtual void toOgcFilter( QDomDocument &doc, QDomElement &element ) const;

virtual QStringList referencedColumns() const;
virtual bool needsGeometry() const;
virtual void accept( QgsExpression::Visitor& v );
virtual void accept( QgsExpression::Visitor& v ) const;
};

//////
Expand All @@ -384,21 +380,17 @@ class QgsExpression
{
public:
virtual ~Visitor();
virtual void visit( QgsExpression::NodeUnaryOperator* n ) = 0;
virtual void visit( QgsExpression::NodeBinaryOperator* n ) = 0;
virtual void visit( QgsExpression::NodeInOperator* n ) = 0;
virtual void visit( QgsExpression::NodeFunction* n ) = 0;
virtual void visit( QgsExpression::NodeLiteral* n ) = 0;
virtual void visit( QgsExpression::NodeColumnRef* n ) = 0;
virtual void visit( QgsExpression::NodeCondition* n ) = 0;
virtual void visit( const QgsExpression::NodeUnaryOperator& n ) = 0;
virtual void visit( const QgsExpression::NodeBinaryOperator& n ) = 0;
virtual void visit( const QgsExpression::NodeInOperator& n ) = 0;
virtual void visit( const QgsExpression::NodeFunction& n ) = 0;
virtual void visit( const QgsExpression::NodeLiteral& n ) = 0;
virtual void visit( const QgsExpression::NodeColumnRef& n ) = 0;
virtual void visit( const QgsExpression::NodeCondition& n ) = 0;
};

/** entry function for the visitor pattern */
void acceptVisitor( QgsExpression::Visitor& v );

// convert from/to OGC Filter
void toOgcFilter( QDomDocument &doc, QDomElement &element ) const;
static QgsExpression* createFromOgcFilter( QDomElement &element ) /Factory/;
void acceptVisitor( QgsExpression::Visitor& v ) const;

protected:
void initGeomCalculator();
Expand Down
4 changes: 4 additions & 0 deletions python/core/qgsfeaturerequest.sip
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ class QgsFeatureRequest

//! construct a default request: for all features get attributes and geometries
QgsFeatureRequest();
//! construct a request with feature ID filter
explicit QgsFeatureRequest( QgsFeatureId fid );
//! construct a request with rectangle filter
explicit QgsFeatureRequest( const QgsRectangle& rect );

FilterType filterType() const;

Expand Down
4 changes: 2 additions & 2 deletions python/core/qgsgml.sip
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
class QgsGml: QObject
class QgsGml: QObject
{

%TypeHeaderCode
#include <qgsgml.h>
%End

public:

QgsGml(
const QString& typeName,
const QString& geometryAttribute,
Expand Down
20 changes: 20 additions & 0 deletions python/core/qgsogcutils.sip
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,25 @@ public:
@return QDomElement
*/
static QDomElement geometryToGML( QgsGeometry* geometry, QDomDocument& doc, QString Format );

/** Exports the rectangle to GML2 Box
@return QDomElement
*/
static QDomElement rectangleToGMLBox( QgsRectangle* box, QDomDocument& doc );

/** Exports the rectangle to GML2 Envelope
@return QDomElement
*/
static QDomElement rectangleToGMLEnvelope( QgsRectangle* env, QDomDocument& doc );


/** Parse XML with OGC filter into QGIS expression */
static QgsExpression* expressionFromOgcFilter( const QDomElement& element ) /Factory/;

/** Creates OGC filter XML element. Supports minimum standard filter according to the OGC filter specs (=,!=,<,>,<=,>=,AND,OR,NOT)
@return valid <Filter> QDomElement on success, otherwise null QDomElement
*/
static QDomElement expressionToOgcFilter( const QgsExpression& exp, QDomDocument& doc, QString* errorMessage /Out/ );

};

65 changes: 21 additions & 44 deletions python/core/qgsvectorlayer.sip
Original file line number Diff line number Diff line change
Expand Up @@ -89,23 +89,6 @@ class QgsVectorLayer : QgsMapLayer

public:

QgsVectorLayer* __iter__();
%MethodCode
sipRes = sipCpp;
%End

SIP_PYOBJECT __next__();
%MethodCode
QgsFeature* f = new QgsFeature;
if (sipCpp->nextFeature(*f))
sipRes = sipConvertFromInstance(f, sipClass_QgsFeature, Py_None);
else
{
delete f;
PyErr_SetString(PyExc_StopIteration,"");
}
%End

enum EditorLayout
{
GeneratedLayout,
Expand Down Expand Up @@ -382,34 +365,11 @@ class QgsVectorLayer : QgsMapLayer
*/
virtual QString subsetString();

/**
* Select features with or without attributes in a given window.
* @param fetchAttributes indizes of attributes to fetch
* @param rect window (QgsRectangle() for all)
* @param fetchGeometry fetch features with geometry
* @param useIntersect fetch only features that actually intersect the window (not just the bounding box)
*/
void select( QList<int> fetchAttributes,
QgsRectangle rect = QgsRectangle(),
bool fetchGeometry = true,
bool useIntersect = false ) /Deprecated/;

/**
* Query the provider for features specified in request.
*/
QgsFeatureIterator getFeatures( const QgsFeatureRequest& request = QgsFeatureRequest() );

/**
* fetch a feature (after select)
* @param feature buffer to read the feature into
* @return true, if a feature was fetched, false, if there are no more features
*/
bool nextFeature( QgsFeature& feature ) /Deprecated/;

/**Gets the feature at the given feature id. Considers the changed, added, deleted and permanent features
@return true in case of success*/
bool featureAtId( QgsFeatureId featureId, QgsFeature &f, bool fetchGeometries = true, bool fetchAttributes = true ) /Deprecated/;

/** Adds a feature
@param f feature to add
@param alsoUpdateExtent If True, will also go to the effort of e.g. updating the extents.
Expand Down Expand Up @@ -659,8 +619,10 @@ class QgsVectorLayer : QgsMapLayer
bool commitChanges();
const QStringList &commitErrors();

/** Stop editing and discard the edits */
bool rollBack();
/** Stop editing and discard the edits
* @param deleteBuffer whether to delete editing buffer (added in 1.9)
*/
bool rollBack( bool deleteBuffer = true );

/**get edit type*/
EditType editType( int idx );
Expand Down Expand Up @@ -712,10 +674,25 @@ class QgsVectorLayer : QgsMapLayer
**/
ValueRelationData &valueRelation( int idx );

/**access date format
* @note added in 1.9
*/
QString &dateFormat( int idx );

/**is edit widget editable
* @note added in 1.9
**/
bool fieldEditable( int idx );

/**set edit widget editable
* @note added in 1.9
**/
void setFieldEditable( int idx, bool editable );

/**Adds a new overlay to this class. QgsVectorLayer takes ownership of the object
@note this method was added in version 1.1
*/
void addOverlay( QgsVectorOverlay* overlay /Transfer/);
void addOverlay( QgsVectorOverlay* overlay /Transfer/ );

/**Removes all overlays of a given type
@note this method was added in version 1.1
Expand All @@ -725,7 +702,7 @@ class QgsVectorLayer : QgsMapLayer
/**Returns pointers to the overlays of this layer
@note this method was added in version 1.1
*/
void vectorOverlays( QList<QgsVectorOverlay*>& overlayList /Out/);
void vectorOverlays( QList<QgsVectorOverlay*>& overlayList /Out/ );

/**Returns the (first) overlay of a type, e.g. diagram or label
@note this method was added in version 1.1
Expand Down
31 changes: 31 additions & 0 deletions python/core/qgsvectorlayercache.sip
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/**
* This class caches features of a given QgsVectorLayer.
* The features are automatically updated and/or invalidated, whenever a change happens to the feature.
*
* It is the callers responsibility to make sure, that he specifies all required fields in every select operation.
* There is no guarantee, that a cached feature will contain a field not specified in a previous select operation.
*
* Performance:
* Depending on the usage scenario, it can be a good idea to prepopulate the cache by calling select, nextFeature and
* and removeCachedFeature. This is especially interesting, whenever requesting a single feature from the dataProvider
* takes much longer than querying in bunches (e.g. network latency, slow views in the database...)
*/

class QgsVectorLayerCache : QObject
{
%TypeHeaderCode
#include "qgsvectorlayercache.h"
%End

public:
QgsVectorLayerCache( QgsVectorLayer* layer, int cacheSize, QObject* parent = NULL );

/**
* Sets the maximum number of features to keep in the cache. Some features will be removed from
* the cache if the number is smaller than the previous size of the cache.
*
* @param cacheSize indicates the maximum number of features to keep in the cache
*/
void setCacheSize( int cacheSize );
};

164 changes: 0 additions & 164 deletions python/gui/attributetable/qgsattributetablemodel.sip

This file was deleted.

11 changes: 7 additions & 4 deletions python/gui/attributetable/qgsattributetableview.sip
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,15 @@ class QgsAttributeTableView : QTableView
virtual ~QgsAttributeTableView();

/**
* Sets the layer
* @param canvas canvas pointer
* @param layer layer pointer
* Autocreates the models
* @param layerCache The {@link QgsVectorLayerCache} to use ( as backend )
* @param canvas The {@link QgsMapCanvas} to use ( for the currently visible features filter )
*
* @deprecated
*/
void setCanvasAndLayer( QgsMapCanvas *canvas, QgsVectorLayer *layer );
void setCanvasAndLayerCache( QgsMapCanvas *canvas, QgsVectorLayerCache *layerCache );

protected:
/**
* Saves geometry to the settings on close
* @param event not used
Expand Down
2 changes: 1 addition & 1 deletion python/gui/gui.sip
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
%Include qgsattributeeditor.sip
%Include qgscollapsiblegroupbox.sip
%Include qgscolorbutton.sip
%Include qgscolordialog.sip
%Include qgscomposerview.sip
%Include qgscredentialdialog.sip
%Include qgsdetaileditemdata.sip
Expand Down Expand Up @@ -63,7 +64,6 @@
%Include qgstextannotationitem.sip
%Include qgsvertexmarker.sip

%Include attributetable/qgsattributetablemodel.sip
%Include attributetable/qgsattributetableview.sip

%Include raster/qgsmultibandcolorrendererwidget.sip
Expand Down
99 changes: 84 additions & 15 deletions python/gui/qgscolorbutton.sip
Original file line number Diff line number Diff line change
@@ -1,34 +1,103 @@

/** \ingroup gui
* \class QgsColorButton
* A cross platform button subclass for selecting colors. Will open a color chooser dialog when clicked.
* Offers live updates to button from color chooser dialog
* @note inherited base class moved from QToolButton to QPushButton in QGIS 1.9
*/

class QgsColorButton : QToolButton
class QgsColorButton: QPushButton
{
%TypeHeaderCode
#include <qgscolorbutton.h>
%End

public:
QgsColorButton( QWidget *parent = 0 );
/**
* Construct a new color button.
*
* @param parent The parent QWidget for the dialog
* @param cdt The title to show in the color chooser dialog
* @param cdo Options for the color chooser dialog
* @note changed in 1.9
*/
QgsColorButton( QWidget *parent = 0, QString cdt = "", QColorDialog::ColorDialogOptions cdo = 0 );
~QgsColorButton();

/**
* Specify the current color. Will emit a colorChanged signal if the color is different to the previous.
*
* @param color the new color
* @note added in 1.9
*/
void setColor( const QColor &color );
/**
* Return the currently selected color.
*
* @return the currently selected color
* @note added in 1.9
*/
QColor color() const;

protected:
void paintEvent( QPaintEvent *e );
/**
* Specify the options for the color chooser dialog (e.g. alpha).
*
* @param cdo Options for the color chooser dialog
* @note added in 1.9
*/
void setColorDialogOptions( QColorDialog::ColorDialogOptions cdo );

};
/**
* Returns the options for the color chooser dialog.
*
* @return Options for the color chooser dialog
* @note added in 1.9
*/
QColorDialog::ColorDialogOptions colorDialogOptions();

/**
* Set the title, which the color chooser dialog will show.
*
* @param cdt Title for the color chooser dialog
* @note added in 1.9
*/
void setColorDialogTitle( QString cdt );

class QgsColorButtonV2 : QPushButton
{
%TypeHeaderCode
#include <qgscolorbutton.h>
%End
/**
* Returns the title, which the color chooser dialog shows.
*
* @return Title for the color chooser dialog
* @note added in 1.9
*/
QString colorDialogTitle();

public:
QgsColorButtonV2( QWidget* parent = 0 );
QgsColorButtonV2( QString text, QWidget* parent = 0 );
/**
* Whether the button accepts live updates from QColorDialog.
*
* @note added in 1.9
*/
bool acceptLiveUpdates();

void setColor( const QColor &color );
QColor color() const;
/**
* Sets whether the button accepts live updates from QColorDialog.
* Live updates may cause changes that are not undoable on QColorDialog cancel.
*
* @note added in 1.9
*/
void setAcceptLiveUpdates( bool accept );

signals:
/**
* Is emitted, whenever a new color is accepted. The color is always valid.
* In case the new color is the same, no signal is emitted, to avoid infinite loops.
*
* @param color New color
* @note added in 1.9
*/
void colorChanged( const QColor &color );

protected:
void changeEvent( QEvent* e );
void paintEvent( QPaintEvent* e );
static const QPixmap& transpBkgrd();
};
29 changes: 29 additions & 0 deletions python/gui/qgscolordialog.sip
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@

/** \ingroup gui
* \class QgsColorDialog
* A dialog for selecting a color
*/

class QgsColorDialog : QObject
{
%TypeHeaderCode
#include <qgscolordialog.h>
%End
public:
QgsColorDialog();
~QgsColorDialog();

/** Return a color selection from a QColorDialog, with live updating of interim selections.
* @param initialColor The initial color of the selection dialog.
* @param updateObject The receiver object of the live updating.
* @param updateSlot The receiver object's slot for live updating (e.g. SLOT( setValidColor( const QColor& ) ) ).
* @param parent Parent widget. Usually 0 is best for native system color dialogs.
* @param title The title of the QColorDialog.
* @param options ColorDialogOptions passed to QColorDialog.
* @return Selected color on accepted() or initialColor on rejected().
*/
static QColor getLiveColor( const QColor& initialColor, QObject* updateObject, const char* updateSlot,
QWidget* parent = 0,
const QString& title = "",
QColorDialog::ColorDialogOptions options = 0 );
};
2 changes: 1 addition & 1 deletion python/gui/symbology-ng/qgsrulebasedrendererv2widget.sip
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class QgsRendererRulePropsDialog : QDialog
%End

public:
QgsRendererRulePropsDialog( QgsRuleBasedRendererV2::Rule* rule, QgsVectorLayer* layer, QgsStyleV2* style );
QgsRendererRulePropsDialog( QgsRuleBasedRendererV2::Rule* rule, QgsVectorLayer* layer, QgsStyleV2* style, QWidget* parent = 0 );
~QgsRendererRulePropsDialog();

QgsRuleBasedRendererV2::Rule* rule();
Expand Down
18 changes: 9 additions & 9 deletions python/gui/symbology-ng/qgssymbollayerv2widget.sip
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class QgsSimpleLineSymbolLayerV2Widget : QgsSymbolLayerV2Widget

public slots:
void penWidthChanged();
void colorChanged();
void colorChanged( const QColor& color );
void penStyleChanged();
void offsetChanged();
void on_mCustomCheckBox_stateChanged( int state );
Expand Down Expand Up @@ -65,8 +65,8 @@ class QgsSimpleMarkerSymbolLayerV2Widget : QgsSymbolLayerV2Widget

public slots:
void setName();
void setColorBorder();
void setColorFill();
void setColorBorder( const QColor& color );
void setColorFill( const QColor& color );
void setSize();
void setAngle();
void setOffset();
Expand All @@ -90,8 +90,8 @@ class QgsSimpleFillSymbolLayerV2Widget : QgsSymbolLayerV2Widget
virtual QgsSymbolLayerV2* symbolLayer();

public slots:
void setColor();
void setBorderColor();
void setColor( const QColor& color );
void setBorderColor( const QColor& color );
void setBrushStyle();
void borderWidthChanged();
void borderStyleChanged();
Expand Down Expand Up @@ -150,8 +150,8 @@ class QgsSvgMarkerSymbolLayerV2Widget : QgsSymbolLayerV2Widget
void setOffset();
void on_mFileToolButton_clicked();
void on_mFileLineEdit_textEdited( const QString& text );
void on_mChangeColorButton_clicked();
void on_mChangeBorderColorButton_clicked();
void on_mChangeColorButton_colorChanged( const QColor& color );
void on_mChangeBorderColorButton_colorChanged( const QColor& color );
void on_mBorderWidthSpinBox_valueChanged( double d );

protected:
Expand Down Expand Up @@ -180,7 +180,7 @@ class QgsLineDecorationSymbolLayerV2Widget : QgsSymbolLayerV2Widget
virtual QgsSymbolLayerV2* symbolLayer();

public slots:
void colorChanged();
void colorChanged( const QColor& color );
void penWidthChanged();
};

Expand Down Expand Up @@ -252,7 +252,7 @@ class QgsFontMarkerSymbolLayerV2Widget : QgsSymbolLayerV2Widget

public slots:
void setFontFamily( const QFont& font );
void setColor();
void setColor( const QColor& color );
void setSize( double size );
void setAngle( double angle );
void setCharacter( const QChar& chr );
Expand Down
2 changes: 1 addition & 1 deletion python/gui/symbology-ng/qgssymbolslistwidget.sip
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class QgsSymbolsListWidget : QWidget

public slots:
void setSymbolFromStyle( const QModelIndex & index );
void setSymbolColor();
void setSymbolColor( const QColor& color );
void setMarkerAngle( double angle );
void setMarkerSize( double size );
void setLineWidth( double width );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ class QgsVectorGradientColorRampV2Dialog : QDialog
QgsVectorGradientColorRampV2Dialog( QgsVectorGradientColorRampV2* ramp, QWidget* parent = NULL );

public slots:
void setColor1();
void setColor2();
void setColor1( const QColor& color );
void setColor2( const QColor& color );

void toggledStops( bool on );
void addStop();
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/GdalTools/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ PYQT4_ADD_RESOURCES(PYRC_FILES resources.qrc)
SET(INSTALLER_FILES ${INSTALLER_FILES} ${PYUI_FILES} ${PYRC_FILES})

#INSTALL(FILES ${INSTALLER_FILES} DESTINATION ${QGIS_DATA_DIR}/python/plugins/GdalTools)
PLUGIN_INSTALL(GdalTools . ${INSTALLER_FILES} __init__.py)
PLUGIN_INSTALL(GdalTools . ${INSTALLER_FILES} __init__.py metadata.txt)

ADD_SUBDIRECTORY(tools)
ADD_SUBDIRECTORY(icons)
12 changes: 0 additions & 12 deletions python/plugins/GdalTools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,6 @@
***************************************************************************/
This script initializes the plugin, making it known to QGIS.
"""
def name():
return "GdalTools"
def description():
return "Integrate gdal tools into qgis"
def category():
return "Raster"
def version():
return "Version 1.2.29"
def qgisMinimumVersion():
return "1.0"
def icon():
return "icons/raster-info.png"
def classFactory(iface):
# load GdalTools class from file GdalTools
from GdalTools import GdalTools
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/db_manager/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ FILE(GLOB UI_FILES ui/*.ui)
PYQT4_WRAP_UI(PYUI_FILES ${UI_FILES})
PYQT4_ADD_RESOURCES(PYRC_FILES resources.qrc)

PLUGIN_INSTALL(db_manager . ${OTHER_FILES} ${PY_FILES} ${PYRC_FILES})
PLUGIN_INSTALL(db_manager . ${OTHER_FILES} ${PY_FILES} ${PYRC_FILES} metadata.txt)
PLUGIN_INSTALL(db_manager ui ${PYUI_FILES} ui/__init__.py)
18 changes: 0 additions & 18 deletions python/plugins/db_manager/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,6 @@
***************************************************************************/
"""

def name():
return "DB Manager"

def description():
return "Manage your databases within QGis"

def version():
return "0.1.20"

def qgisMinimumVersion():
return "1.5.0"

def icon():
return "icons/dbmanager.png"

def authorName():
return "Giuseppe Sucameli"

def classFactory(iface):
from .db_manager_plugin import DBManagerPlugin
return DBManagerPlugin(iface)
2 changes: 1 addition & 1 deletion python/plugins/fTools/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ PYQT4_ADD_RESOURCES(PYRC_FILES resources.qrc)

SET(INSTALLER_FILES ${INSTALLER_FILES} ${PYUI_FILES} ${PYRC_FILES})

PLUGIN_INSTALL(fTools . ${INSTALLER_FILES} __init__.py)
PLUGIN_INSTALL(fTools . ${INSTALLER_FILES} __init__.py metadata.txt)

ADD_SUBDIRECTORY(tools)
ADD_SUBDIRECTORY(icons)
Expand Down
21 changes: 0 additions & 21 deletions python/plugins/fTools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,27 +28,6 @@
#
#---------------------------------------------------------------------

def name():
return "fTools"

def description():
return "Tools for vector data analysis and management"

def category():
return "Vector"

def version():
return "0.6.2"

def qgisMinimumVersion():
return "1.4"

def icon():
return "icons/logo_small.png"

def authorName():
return "Carson J. Q. Farmer"

def classFactory( iface ):
from .fTools import fToolsPlugin
return fToolsPlugin( iface )
1 change: 1 addition & 0 deletions python/plugins/mapserver_export/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
SET(INSTALLER_FILES
metadata.txt
mapserver_export.png
__init__.py
mapserverexportdialog.py
Expand Down
14 changes: 0 additions & 14 deletions python/plugins/mapserver_export/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,6 @@
This script initializes the plugin, making it known to QGIS.
"""

def name():
return "MapServer Export"
def description():
return "Export a saved QGIS project file to a MapServer map file"
def category():
return "Web"
def version():
return "Version 0.4.4"
def qgisMinimumVersion():
return "1.0"
def icon():
return "mapserver_export.png"
def authorName():
return "Gary E. Sherman"
def classFactory(iface):
# load MapServerExport class from file mapserverexport.py
from mapserverexport import MapServerExport
Expand Down
1 change: 1 addition & 0 deletions python/plugins/plugin_installer/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
SET(INSTALLER_FILES
metadata.txt
__init__.py
installer_data.py
installer_gui.py
Expand Down
24 changes: 0 additions & 24 deletions python/plugins/plugin_installer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,30 +11,6 @@
* *
***************************************************************************/
"""
def name():
return "Plugin Installer"

def version():
return "Version 1.2.1"

def description():
return "Downloads and installs QGIS python plugins"

def category():
return "Plugins"

def qgisMinimumVersion():
return "1.0"

def icon():
import resources_rc
return ":/plugins/installer/plugin_installer.png"

def authorName():
return "Matthew Perry, Borys Jurgiel"

def homepage():
return "http://bwj.aster.net.pl/qgis/"

def classFactory(iface):
from installer_plugin import InstallerPlugin
Expand Down
3 changes: 1 addition & 2 deletions python/plugins/sextante/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,12 @@ ADD_SUBDIRECTORY(modeler)
ADD_SUBDIRECTORY(otb)
ADD_SUBDIRECTORY(outputs)
ADD_SUBDIRECTORY(parameters)
#ADD_SUBDIRECTORY(pymorph)
ADD_SUBDIRECTORY(r)
ADD_SUBDIRECTORY(saga)
ADD_SUBDIRECTORY(script)
ADD_SUBDIRECTORY(taudem)
ADD_SUBDIRECTORY(tools)
#ADD_SUBDIRECTORY(tests)
ADD_SUBDIRECTORY(tests)

FILE(GLOB UI_FILES ui/*.ui)
PYQT4_WRAP_UI(PYUI_FILES ${UI_FILES})
Expand Down
9 changes: 2 additions & 7 deletions python/plugins/sextante/SextantePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
* *
***************************************************************************
"""
import shutil

__author__ = 'Victor Olaya'
__date__ = 'August 2012'
Expand Down Expand Up @@ -100,13 +101,7 @@ def unload(self):
#delete temporary output files
folder = SextanteUtils.tempFolder()
if QDir(folder).exists():
for f in os.listdir(folder):
path = os.path.join(folder, f)
try:
os.unlink(path)
except:
#leave files that could not be deleted
pass
shutil.rmtree(folder, True)

def openToolbox(self):
if self.toolbox.isVisible():
Expand Down
2 changes: 2 additions & 0 deletions python/plugins/sextante/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
from sextante.core.Sextante import runalg, runandload, alghelp, alglist, algoptions, load, \
extent, getObjectFromName, getObjectFromUri, getobject, getfeatures

from sextante.tests.TestData import loadTestData

__author__ = 'Victor Olaya'
__date__ = 'August 2012'
__copyright__ = '(C) 2012, Victor Olaya'
Expand Down
10 changes: 5 additions & 5 deletions python/plugins/sextante/algs/AutoincrementalField.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def processAlgorithm(self, progress):
vlayer = QGisLayers.getObjectFromUri(self.getParameterValue(self.INPUT))
vprovider = vlayer.dataProvider()
fields = vprovider.fields()
fields[len(fields)] = QgsField("AUTO", QVariant.Int)
fields.append(QgsField("AUTO", QVariant.Int))
writer = output.getVectorWriter(fields, vprovider.geometryType(), vlayer.crs() )
inFeat = QgsFeature()
outFeat = QgsFeature()
Expand All @@ -58,10 +58,10 @@ def processAlgorithm(self, progress):
nElement += 1
inGeom = inFeat.geometry()
outFeat.setGeometry( inGeom )
atMap = inFeat.attributeMap()
atMap.append(QVariant(nElement))
outFeat.setAttributeMap( atMap )
writer.addFeature( outFeat )
attrs = inFeat.attributes()
attrs.append(QVariant(nElement))
outFeat.setAttributes(attrs)
writer.addFeature(outFeat)
del writer

def defineCharacteristics(self):
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/sextante/algs/Explode.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def processAlgorithm(self, progress):
outFeat = QgsFeature()
inGeom = QgsGeometry()
nElement = 0
features = QGisLayers.features(layer)
features = QGisLayers.features(vlayer)
nFeat = len(features)
for feature in features:
nElement += 1
Expand Down
6 changes: 3 additions & 3 deletions python/plugins/sextante/algs/FieldsCalculator.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ def processAlgorithm(self, progress):
nElement += 1
inGeom = inFeat.geometry()
outFeat.setGeometry(inGeom)
atMap = inFeat.attributeMap()
atMap.append(QVariant(result))
outFeat.setAttributeMap(atMap)
attrs = inFeat.attributes()
attrs.append(QVariant(result))
outFeat.setAttributes(attrs)
writer.addFeature(outFeat)
del writer

Expand Down
64 changes: 38 additions & 26 deletions python/plugins/sextante/algs/QGISAlgorithmProvider.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

"""
***************************************************************************
SextanteAlgorithmProvider.py
QGISAlgorithmProvider.py
---------------------
Date : August 2012
Date : December 2012
Copyright : (C) 2012 by Victor Olaya
Email : volayaf at gmail dot com
***************************************************************************
Expand All @@ -16,21 +16,17 @@
* *
***************************************************************************
"""
#from sextante.algs.MeanAndStdDevPlot import MeanAndStdDevPlot
#from sextante.algs.BarPlot import BarPlot
#from sextante.algs.PolarPlot import PolarPlot
from sextante.algs.RasterLayerStatistics import RasterLayerStatistics

__author__ = 'Victor Olaya'
__date__ = 'August 2012'
__date__ = 'December 2012'
__copyright__ = '(C) 2012, Victor Olaya'
# This will get replaced with a git SHA1 when you do a git archive
__revision__ = '$Format:%H$'

import os
from PyQt4 import QtGui
#from sextante.algs.RasterLayerHistogram import RasterLayerHistogram
from sextante.algs.StatisticsByCategories import StatisticsByCategories
from PyQt4.QtGui import *

from sextante.core.AlgorithmProvider import AlgorithmProvider

from sextante.algs.ftools.PointsInPolygon import PointsInPolygon
from sextante.algs.ftools.PointsInPolygonUnique import PointsInPolygonUnique
from sextante.algs.ftools.PointsInPolygonWeighted import PointsInPolygonWeighted
Expand Down Expand Up @@ -67,17 +63,18 @@
from sextante.algs.ftools.SelectByLocation import SelectByLocation
from sextante.algs.ftools.Union import Union
from sextante.algs.ftools.DensifyGeometriesInterval import DensifyGeometriesInterval

from sextante.algs.mmqgisx.MMQGISXAlgorithms import (mmqgisx_delete_columns_algorithm,
mmqgisx_delete_duplicate_geometries_algorithm,
mmqgisx_geometry_convert_algorithm,
mmqgisx_grid_algorithm, mmqgisx_gridify_algorithm,
mmqgisx_hub_distance_algorithm, mmqgisx_hub_lines_algorithm,
mmqgisx_merge_algorithm, mmqgisx_select_algorithm,
mmqgisx_text_to_float_algorithm)

from sextante.algs.RasterLayerStatistics import RasterLayerStatistics
from sextante.algs.StatisticsByCategories import StatisticsByCategories
from sextante.algs.EquivalentNumField import EquivalentNumField
#from sextante.algs.VectorLayerHistogram import VectorLayerHistogram
#from sextante.algs.VectorLayerScatterplot import VectorLayerScatterplot
from sextante.core.AlgorithmProvider import AlgorithmProvider
from sextante.algs.AddTableField import AddTableField
from sextante.algs.FieldsCalculator import FieldsCalculator
from sextante.algs.SaveSelectedFeatures import SaveSelectedFeatures
Expand All @@ -88,25 +85,38 @@
from sextante.algs.CreateConstantRaster import CreateConstantRaster
from sextante.algs.PointsLayerFromTable import PointsLayerFromTable

#from sextante.algs.VectorLayerHistogram import VectorLayerHistogram
#from sextante.algs.VectorLayerScatterplot import VectorLayerScatterplot
#from sextante.algs.MeanAndStdDevPlot import MeanAndStdDevPlot
#from sextante.algs.BarPlot import BarPlot
#from sextante.algs.PolarPlot import PolarPlot
#from sextante.algs.RasterLayerHistogram import RasterLayerHistogram

import sextante.resources_rc

class QGISAlgorithmProvider(AlgorithmProvider):

def __init__(self):
AlgorithmProvider.__init__(self)
self.alglist = [AddTableField(), FieldsCalculator(), SaveSelectedFeatures(), JoinAttributes(),
AutoincrementalField(), Explode(), FieldsPyculator(), EquivalentNumField(),
SumLines(), PointsInPolygon(), PointsInPolygonWeighted(), PointsInPolygonUnique(),
BasicStatisticsStrings(), BasicStatisticsNumbers(), NearestNeighbourAnalysis(),
MeanCoords(), LinesIntersection(), UniqueValues(), PointDistance(), PointsLayerFromTable(),
StatisticsByCategories(),ReprojectLayer(),
self.alglist = [# ------ fTools ------
SumLines(), PointsInPolygon(), PointsInPolygonWeighted(),
PointsInPolygonUnique(), BasicStatisticsStrings(),
BasicStatisticsNumbers(), NearestNeighbourAnalysis(),
MeanCoords(), LinesIntersection(), UniqueValues(), PointDistance(),
# data management
ReprojectLayer(),
# geometry
ExportGeometryInfo(), Centroids(), Delaunay(), VoronoiPolygons(),
SimplifyGeometries(), DensifyGeometries(), DensifyGeometriesInterval(),
MultipartToSingleparts(), SinglePartsToMultiparts(), PolygonsToLines(),
LinesToPolygons(), ExtractNodes(),
# geoprocessing
ConvexHull(), FixedDistanceBuffer(), VariableDistanceBuffer(),
Dissolve(), Difference(), Intersection(), Union(), Clip(),
# research
ExtentFromLayer(), RandomSelection(), RandomSelectionWithinSubsets(),
SelectByLocation(),
#MMQGISX
# ------ mmqgisx ------
mmqgisx_delete_columns_algorithm(),
mmqgisx_delete_duplicate_geometries_algorithm(),
mmqgisx_geometry_convert_algorithm(),
Expand All @@ -117,29 +127,31 @@ def __init__(self):
mmqgisx_merge_algorithm(),
mmqgisx_select_algorithm(),
mmqgisx_text_to_float_algorithm(),
#raster
# ------ native algs ------
AddTableField(), FieldsCalculator(), SaveSelectedFeatures(), JoinAttributes(),
AutoincrementalField(), Explode(), FieldsPyculator(), EquivalentNumField(),
PointsLayerFromTable(), StatisticsByCategories(),
# ------ raster ------
CreateConstantRaster(), RasterLayerStatistics()
#graphics
# ------ graphics ------
#VectorLayerHistogram(), VectorLayerScatterplot(), RasterLayerHistogram(),
#MeanAndStdDevPlot(), BarPlot(), PolarPlot()
]

def initializeSettings(self):
AlgorithmProvider.initializeSettings(self)


def unload(self):
AlgorithmProvider.unload(self)


def getName(self):
return "qgis"

def getDescription(self):
return "QGIS geoalgorithms"

def getIcon(self):
return QtGui.QIcon(os.path.dirname(__file__) + "/../images/qgis.png")
return QIcon(":/sextante/images/qgis.png")

def _loadAlgorithms(self):
self.algs = self.alglist
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,17 @@
__revision__ = '$Format:%H$'

import math

from PyQt4.QtCore import *

from qgis.core import *

from sextante.core.GeoAlgorithm import GeoAlgorithm
from sextante.core.QGisLayers import QGisLayers

from sextante.parameters.ParameterVector import ParameterVector
from sextante.parameters.ParameterTableField import ParameterTableField

from sextante.outputs.OutputHTML import OutputHTML
from sextante.outputs.OutputNumber import OutputNumber

Expand Down Expand Up @@ -86,7 +91,6 @@ def processAlgorithm(self, progress):
outputFile = self.getOutputValue(self.OUTPUT_HTML_FILE)

index = layer.fieldNameIndex(fieldName)
#layer.select([index], QgsRectangle(), False)

cvValue = 0
minValue = 0
Expand Down
8 changes: 5 additions & 3 deletions python/plugins/sextante/algs/ftools/BasicStatisticsStrings.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
# This will get replaced with a git SHA1 when you do a git archive
__revision__ = '$Format:%H$'

import codecs

from PyQt4 import QtGui
from PyQt4.QtCore import *

from qgis.core import *
Expand Down Expand Up @@ -84,7 +84,6 @@ def processAlgorithm(self, progress):
outputFile = self.getOutputValue(self.OUTPUT_HTML_FILE)

index = layer.fieldNameIndex(fieldName)
layer.select([index], QgsRectangle(), False)

sumValue = 0
minValue = 0
Expand Down Expand Up @@ -150,7 +149,10 @@ def processAlgorithm(self, progress):
self.setOutputValue(self.UNIQUE, uniqueValues)

def createHTML(self, outputFile, algData):
f = open(outputFile, "w")
f = codecs.open(outputFile, "w", encoding="utf-8")
f.write('<html><head>')
f.write('<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /></head><body>')
for s in algData:
f.write("<p>" + str(s) + "</p>")
f.write("</body></html>")
f.close()
16 changes: 8 additions & 8 deletions python/plugins/sextante/algs/ftools/Buffer.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,25 @@
* *
***************************************************************************
"""
from sextante.core.QGisLayers import QGisLayers

__author__ = 'Victor Olaya'
__date__ = 'August 2012'
__copyright__ = '(C) 2012, Victor Olaya'
# This will get replaced with a git SHA1 when you do a git archive
__revision__ = '$Format:%H$'


from PyQt4.QtCore import *

from qgis.core import *

from sextante.core.QGisLayers import QGisLayers
from sextante.core.SextanteLog import SextanteLog

def buffering(progress, writer, distance, field, useField, layer, dissolve, segments):
GEOS_EXCEPT = True
FEATURE_EXCEPT = True

layer.select(layer.pendingAllAttributesList())

if useField:
field = layer.fieldNameIndex(field)

Expand All @@ -52,9 +51,9 @@ def buffering(progress, writer, distance, field, useField, layer, dissolve, segm
if dissolve:
first = True
for inFeat in features:
atMap = inFeat.attributes()
attrs = inFeat.attributes()
if useField:
value = atMap[field].toDouble()[0]
value = attrs[field].toDouble()[0]
else:
value = distance

Expand All @@ -78,15 +77,16 @@ def buffering(progress, writer, distance, field, useField, layer, dissolve, segm
progress.setPercentage(int(current * total))
try:
outFeat.setGeometry(tempGeom)
outFeat.setAttributes(attrs)
writer.addFeature(outFeat)
except:
FEATURE_EXCEPT = False
# without dissolve
else:
for inFeat in features:
atMap = inFeat.attributes()
attrs = inFeat.attributes()
if useField:
value = atMap[field].toDouble()[0]
value = attrs[field].toDouble()[0]
else:
value = distance

Expand All @@ -95,7 +95,7 @@ def buffering(progress, writer, distance, field, useField, layer, dissolve, segm
outGeom = inGeom.buffer(float(value), segments)
try:
outFeat.setGeometry(outGeom)
outFeat.setAttributes(atMap)
outFeat.setAttributes(attrs)
writer.addFeature(outFeat)
except:
FEATURE_EXCEPT = False
Expand Down
4 changes: 1 addition & 3 deletions python/plugins/sextante/algs/ftools/Centroids.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,9 @@ def defineCharacteristics(self):
def processAlgorithm(self, progress):
layer = QGisLayers.getObjectFromUri(self.getParameterValue(self.INPUT_LAYER))

writer = self.getOutputFromName(self.OUTPUT_LAYER).getVectorWriter(layer.pendingFields(),
writer = self.getOutputFromName(self.OUTPUT_LAYER).getVectorWriter(layer.pendingFields().toList(),
QGis.WKBPoint, layer.crs())

#layer.select(layer.pendingAllAttributesList())

outFeat = QgsFeature()

features = QGisLayers.features(layer)
Expand Down
147 changes: 71 additions & 76 deletions python/plugins/sextante/algs/ftools/Clip.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,113 +23,108 @@
# This will get replaced with a git SHA1 when you do a git archive
__revision__ = '$Format:%H$'

from sextante.core.GeoAlgorithm import GeoAlgorithm
from PyQt4.QtCore import *
from PyQt4.QtGui import *

from qgis.core import *
from sextante.parameters.ParameterVector import ParameterVector

from sextante.core.GeoAlgorithm import GeoAlgorithm
from sextante.core.QGisLayers import QGisLayers
from sextante.core.SextanteLog import SextanteLog

from sextante.parameters.ParameterVector import ParameterVector

from sextante.outputs.OutputVector import OutputVector

from sextante.algs.ftools import FToolsUtils as utils
from sextante.core.SextanteLog import SextanteLog

class Clip(GeoAlgorithm):

INPUT = "INPUT"
INPUT2 = "INPUT2"
OVERLAY = "OVERLAY"
OUTPUT = "OUTPUT"

#===========================================================================
# def getIcon(self):
# return QtGui.QIcon(os.path.dirname(__file__) + "/icons/clip.png")
#===========================================================================

def defineCharacteristics(self):
self.name = "Clip"
self.group = "Vector overlay tools"
self.addParameter(ParameterVector(Clip.INPUT, "Input layer", ParameterVector.VECTOR_TYPE_ANY))
self.addParameter(ParameterVector(Clip.OVERLAY, "Clip layer", ParameterVector.VECTOR_TYPE_ANY))
self.addOutput(OutputVector(Clip.OUTPUT, "Clipped"))

def processAlgorithm(self, progress):
settings = QSettings()
systemEncoding = settings.value( "/UI/encoding", "System" ).toString()
output = self.getOutputValue(Clip.OUTPUT)
vlayerA = QGisLayers.getObjectFromUri(self.getParameterValue(Clip.INPUT))
vlayerB = QGisLayers.getObjectFromUri(self.getParameterValue(Clip.INPUT2))
layerA = QGisLayers.getObjectFromUri(self.getParameterValue(Clip.INPUT))
layerB = QGisLayers.getObjectFromUri(self.getParameterValue(Clip.OVERLAY))

GEOS_EXCEPT = True
FEATURE_EXCEPT = True
vproviderA = vlayerA.dataProvider()
#allAttrsA = vproviderA.attributeIndexes()
#vproviderA.select( allAttrsA )
vproviderB = vlayerB.dataProvider()
#allAttrsB = vproviderB.attributeIndexes()
#vproviderB.select( allAttrsB )

# check for crs compatibility
crsA = vproviderA.crs()
crsB = vproviderB.crs()
if not crsA.isValid() or not crsB.isValid():
SextanteLog.addToLog(SextanteLog.LOG_WARNING, "Intersection. Invalid CRS. Results might be unexpected")
else:
if crsA != crsB:
SextanteLog.addToLog(SextanteLog.LOG_WARNING, "Intersection. Non-matching CRSs. Results might be unexpected")
fields = vproviderA.fields()
writer = QgsVectorFileWriter( output, systemEncoding,fields, vproviderA.geometryType(), vproviderA.crs() )

writer = self.getOutputFromName(self.OUTPUT).getVectorWriter(layerA.pendingFields(),
layerA.dataProvider().geometryType(), layerA.dataProvider().crs())

inFeatA = QgsFeature()
inFeatB = QgsFeature()
outFeat = QgsFeature()
index = utils.createSpatialIndex(vlayerB)
#vproviderA.rewind()
nElement = 0
selectionA = QGisLayers.features(vlayerA)
nFeat = len(selectionA)

index = utils.createSpatialIndex(layerB)

selectionA = QGisLayers.features(layerA)

current = 0
total = 100.0 / float(len(selectionA))

for inFeatA in selectionA:
nElement += 1
progress.setPercentage(nElement/float(nFeat) * 100)
geom = QgsGeometry( inFeatA.geometry() )
int_geom = QgsGeometry( geom )
atMap = inFeatA.attributes()
intersects = index.intersects(geom.boundingBox())
found = False
geom = QgsGeometry(inFeatA.geometry())
attrs = inFeatA.attributes()
intersections = index.intersects(geom.boundingBox())
first = True
for id in intersects:
vlayerB.featureAtId(int(id), inFeatB)
tmpGeom = QgsGeometry(inFeatB.geometry())
if tmpGeom.intersects(geom):
found = True
if first:
outFeat.setGeometry(QgsGeometry(tmpGeom))
first = False
else:
found = False
if len(intersections) > 0:
for i in intersections:
request = QgsFeatureRequest().setFilterFid(i)
inFeatB = layerB.getFeatures(request).next()
tmpGeom = QgsGeometry(inFeatB.geometry())
if tmpGeom.intersects(geom):
found = True
if first:
outFeat.setGeometry(QgsGeometry(tmpGeom))
first = False
else:
try:
cur_geom = QgsGeometry(outFeat.geometry())
new_geom = QgsGeometry(cur_geom.combine(tmpGeom))
outFeat.setGeometry(QgsGeometry(new_geom))
except:
GEOS_EXCEPT = False
break
if found:
try:
cur_geom = QgsGeometry(outFeat.geometry())
new_geom = QgsGeometry(geom.intersection(cur_geom))
if new_geom.wkbType() == QGis.WKBNoGeometry :
int_com = QgsGeometry(geom.combine(cur_geom))
int_sym = QgsGeometry(geom.symDifference(cur_geom))
new_geom = QgsGeometry(int_com.difference(int_sym))
try:
cur_geom = QgsGeometry( outFeat.geometry() )
new_geom = QgsGeometry( cur_geom.combine( tmpGeom ) )
outFeat.setGeometry( QgsGeometry( new_geom ) )
outFeat.setGeometry(new_geom)
outFeat.setAttributes(attrs)
writer.addFeature(outFeat)
except:
GEOS_EXCEPT = False
break
if found:
try:
cur_geom = QgsGeometry( outFeat.geometry() )
new_geom = QgsGeometry( geom.intersection( cur_geom ) )
if new_geom.wkbType() == 7:
int_com = QgsGeometry( geom.combine( cur_geom ) )
int_sym = QgsGeometry( geom.symDifference( cur_geom ) )
new_geom = QgsGeometry( int_com.difference( int_sym ) )
try:
outFeat.setGeometry( new_geom )
outFeat.setAttributes( atMap )
writer.addFeature( outFeat )
FEAT_EXCEPT = False
continue
except:
FEATURE_EXCEPT = False
GEOS_EXCEPT = False
continue
except:
GEOS_EXCEPT = False
continue

current += 1
progress.setPercentage(int(current * total))

del writer

if not GEOS_EXCEPT:
SextanteLog.addToLog(SextanteLog.LOG_WARNING, "Geometry exception while computing clip")
if not FEATURE_EXCEPT:
SextanteLog.addToLog(SextanteLog.LOG_WARNING, "Feature exception while computing clip")

def defineCharacteristics(self):
self.name = "Clip"
self.group = "Vector overlay tools"
self.addParameter(ParameterVector(Clip.INPUT, "Input layer", ParameterVector.VECTOR_TYPE_ANY))
self.addParameter(ParameterVector(Clip.INPUT2, "Clip layer", ParameterVector.VECTOR_TYPE_ANY))
self.addOutput(OutputVector(Clip.OUTPUT, "Clipped"))
205 changes: 106 additions & 99 deletions python/plugins/sextante/algs/ftools/ConvexHull.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,144 +23,151 @@
# This will get replaced with a git SHA1 when you do a git archive
__revision__ = '$Format:%H$'

from sextante.core.GeoAlgorithm import GeoAlgorithm
from PyQt4.QtCore import *
from PyQt4.QtGui import *

from qgis.core import *
from sextante.parameters.ParameterVector import ParameterVector

from sextante.core.GeoAlgorithm import GeoAlgorithm
from sextante.core.QGisLayers import QGisLayers
from sextante.outputs.OutputVector import OutputVector
from sextante.algs.ftools import FToolsUtils as utils
from sextante.core.SextanteLog import SextanteLog

from sextante.parameters.ParameterVector import ParameterVector
from sextante.parameters.ParameterTableField import ParameterTableField
from sextante.parameters.ParameterSelection import ParameterSelection

from sextante.outputs.OutputVector import OutputVector

from sextante.algs.ftools import FToolsUtils as utils

class ConvexHull(GeoAlgorithm):

INPUT = "INPUT"
OUTPUT = "OUTPUT"
FIELD = "FIELD"
METHOD = "METHOD"
METHODS = ["Create single minimum convex hull", "Create convex hulls based on field"]
METHODS = ["Create single minimum convex hull",
"Create convex hulls based on field"
]

#===========================================================================
# def getIcon(self):
# return QtGui.QIcon(os.path.dirname(__file__) + "/icons/convex_hull.png")
#===========================================================================

def defineCharacteristics(self):
self.name = "Convex hull"
self.group = "Vector geometry tools"
self.addParameter(ParameterVector(ConvexHull.INPUT, "Input layer", ParameterVector.VECTOR_TYPE_ANY))
self.addParameter(ParameterTableField(ConvexHull.FIELD, "Field", ConvexHull.INPUT))
self.addParameter(ParameterSelection(ConvexHull.METHOD, "Method", ConvexHull.METHODS))
self.addOutput(OutputVector(ConvexHull.OUTPUT, "Convex hull"))

def processAlgorithm(self, progress):
useField = (self.getParameterValue(ConvexHull.METHOD) == 1)
field = self.getParameterValue(ConvexHull.FIELD)
vlayerA = QGisLayers.getObjectFromUri(self.getParameterValue(ConvexHull.INPUT))
fieldName = self.getParameterValue(ConvexHull.FIELD)
layer = QGisLayers.getObjectFromUri(self.getParameterValue(ConvexHull.INPUT))

GEOS_EXCEPT = True
FEATURE_EXCEPT = True
vproviderA = vlayerA.dataProvider()
#allAttrsA = vproviderA.attributeIndexes()
#vproviderA.select(allAttrsA)
fields = [QgsField("ID", QVariant.Int),
QgsField("Area", QVariant.Double),
QgsField("Perim", QVariant.Double)]
writer = self.getOutputFromName(ConvexHull.OUTPUT).getVectorWriter(fields, QGis.WKBPolygon, vproviderA.crs())
inFeat = QgsFeature()

index = layer.fieldNameIndex(fieldName)
fType = layer.pendingFields()[index].type()
f = QgsField("value")
f.setType(QVariant.String)
f.setLength(255)
if useField:
if fType == QVariant.Int:
f.setType(QVariant.Int)
f.setLength(20)
elif fType == QVariant.Double:
f.setType(QVariant.Double)
f.setLength(20)
f.setPrecision(6)
else:
f.setType(QVariant.String)
f.setLength(255)

fields = [QgsField("id", QVariant.Int, "", 20),
f,
QgsField("area", QVariant.Double, "", 20, 6),
QgsField("perim", QVariant.Double, "", 20, 6)
]

writer = self.getOutputFromName(ConvexHull.OUTPUT).getVectorWriter(fields, QGis.WKBPolygon, layer.dataProvider().crs())

outFeat = QgsFeature()
inGeom = QgsGeometry()
outGeom = QgsGeometry()
nElement = 0
index = vproviderA.fieldNameIndex(field)

features = QGisLayers.features(vlayerA)
nFeat = len(features)
current = 0

fid = 0
val = ""
if useField:
unique = utils.getUniqueValues(vproviderA, index)
nFeat = nFeat * len(unique)
for i in unique:
hull = []
first = True
outID = 0
#vproviderA.select(allAttrsA)
features = QGisLayers.features(vlayerA)
for inFeat in features:
atMap = inFeat.attributes()
idVar = atMap[ index ]
if idVar.toString().trimmed() == i.toString().trimmed():
if first:
outID = idVar
first = False
inGeom = QgsGeometry(inFeat.geometry())
points = utils.extractPoints(inGeom)
hull.extend(points)
nElement += 1
progress.setPercentage(int(nElement / nFeat * 100))
if len(hull) >= 3:
tmpGeom = QgsGeometry(outGeom.fromMultiPoint(hull))
try:
outGeom = tmpGeom.convexHull()
outFeat.setGeometry(outGeom)
(area, perim) = self.simpleMeasure(outGeom)
outFeat.addAttribute(0, QVariant(outID))
outFeat.addAttribute(1, QVariant(area))
outFeat.addAttribute(2, QVariant(perim))
writer.addFeature(outFeat)
except:
GEOS_EXCEPT = False
continue
unique = layer.uniqueValues(index)
total = 100.0 / float(layer.featureCount() * len (unique))

for i in unique:
hull = []
first = True
features = QGisLayers.features(layer)
for f in features:
idVar = f[fieldName]
if idVar.toString().trimmed() == i.toString().trimmed():
if first:
val = idVar
first = False
inGeom = QgsGeometry(f.geometry())
points = utils.extractPoints(inGeom)
hull.extend(points)
current += 1
progress.setPercentage(int(current * total))

if len(hull) >= 3:
tmpGeom = QgsGeometry(outGeom.fromMultiPoint(hull))
try:
outGeom = tmpGeom.convexHull()
(area, perim) = utils.simpleMeasure(outGeom)
outFeat.setGeometry(outGeom)
outFeat.setAttributes([QVariant(fid),
QVariant(val),
QVariant(area),
QVariant(perim)
])
writer.addFeature(outFeat)
except:
GEOS_EXCEPT = False
continue
fid += 1
else:
hull = []
#vproviderA.select(allAttrsA)
features = QGisLayers.features(vlayerA)
for inFeat in features:
inGeom = QgsGeometry(inFeat.geometry())
points = utils.extractPoints(inGeom)
hull.extend(points)
nElement += 1
progress.setPercentage(int(nElement / nFeat * 100))
total = 100.0 / float(layer.featureCount())
features = QGisLayers.features(layer)
for f in features:
inGeom = QgsGeometry(f.geometry())
points = utils.extractPoints(inGeom)
hull.extend(points)
current += 1
progress.setPercentage(int(current * total))

tmpGeom = QgsGeometry(outGeom.fromMultiPoint(hull))
try:
outGeom = tmpGeom.convexHull()
outFeat.setGeometry(outGeom)
(area, perim) = self.simpleMeasure(outGeom)
#outFeat.addAttribute(0, QVariant("1"))
#outFeat.addAttribute(1, QVariant(area))
#outFeat.addAttribute(2, QVariant(perim))
writer.addFeature(outFeat)
outGeom = tmpGeom.convexHull()
(area, perim) = utils.simpleMeasure(outGeom)
outFeat.setGeometry(outGeom)
outFeat.setAttributes([QVariant(0),
QVariant("all"),
QVariant(area),
QVariant(perim)
])
writer.addFeature(outFeat)
except:
GEOS_EXCEPT = False
GEOS_EXCEPT = False

del writer

if not GEOS_EXCEPT:
SextanteLog.addToLog(SextanteLog.LOG_WARNING, "Geometry exception while computing convex hull")
if not FEATURE_EXCEPT:
SextanteLog.addToLog(SextanteLog.LOG_WARNING, "Feature exception while computing convex hull")

def simpleMeasure(self, inGeom):
measure = QgsDistanceArea()
attr1 = measure.measure(inGeom)
if inGeom.type() == QGis.Polygon:
attr2 = self.perimMeasure(inGeom, measure)
else:
attr2 = attr1
return (attr1, attr2)

def perimMeasure(self, inGeom, measure):
value = 0.00
if inGeom.isMultipart():
poly = inGeom.asMultiPolygon()
for k in poly:
for j in k:
value = value + measure.measureLine(j)
else:
poly = inGeom.asPolygon()
for k in poly:
value = value + measure.measureLine(k)
return value

def defineCharacteristics(self):
self.name = "Convex hull"
self.group = "Vector geometry tools"
self.addParameter(ParameterVector(ConvexHull.INPUT, "Input layer", ParameterVector.VECTOR_TYPE_ANY))
self.addParameter(ParameterTableField(ConvexHull.FIELD, "Field", ConvexHull.INPUT))
self.addParameter(ParameterSelection(ConvexHull.METHOD, "Method", ConvexHull.METHODS))
self.addOutput(OutputVector(ConvexHull.OUTPUT, "Convex hull"))
#=========================================================
24 changes: 15 additions & 9 deletions python/plugins/sextante/algs/ftools/Delaunay.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,22 @@
# This will get replaced with a git SHA1 when you do a git archive
__revision__ = '$Format:%H$'

from sets import Set

from PyQt4.QtCore import *

from qgis.core import *
from sets import Set
from sextante.algs.ftools import voronoi

from sextante.core.GeoAlgorithm import GeoAlgorithm
from sextante.core.GeoAlgorithmExecutionException import \
GeoAlgorithmExecutionException
from sextante.core.GeoAlgorithmExecutionException import GeoAlgorithmExecutionException
from sextante.core.QGisLayers import QGisLayers
from sextante.outputs.OutputVector import OutputVector

from sextante.parameters.ParameterVector import ParameterVector

from sextante.outputs.OutputVector import OutputVector

from sextante.algs.ftools import voronoi


class Delaunay(GeoAlgorithm):

Expand All @@ -57,9 +62,9 @@ def processAlgorithm(self, progress):
layer = QGisLayers.getObjectFromUri(self.getParameterValue(self.INPUT))


fields = [ QgsField("POINTA", QVariant.Double, "", 24, 15),
QgsField("POINTB", QVariant.Double, "", 24, 15),
QgsField("POINTC", QVariant.Double, "", 24, 15)
fields = [QgsField("POINTA", QVariant.Double, "", 24, 15),
QgsField("POINTB", QVariant.Double, "", 24, 15),
QgsField("POINTC", QVariant.Double, "", 24, 15)
]

writer = self.getOutputFromName(self.OUTPUT).getVectorWriter(fields,
Expand Down Expand Up @@ -100,7 +105,8 @@ def processAlgorithm(self, progress):
attrs = []
step = 0
for index in indicies:
layer.featureAtId(ptDict[ids[index]], inFeat, True)
request = QgsFeatureRequest().setFilterFid(ptDict[ids[index]])
inFeat = layer.getFeatures(request).next()
geom = QgsGeometry(inFeat.geometry())
point = QgsPoint(geom.asPoint())
polygon.append(point)
Expand Down
10 changes: 3 additions & 7 deletions python/plugins/sextante/algs/ftools/DensifyGeometries.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
# This will get replaced with a git SHA1 when you do a git archive
__revision__ = '$Format:%H$'


from PyQt4.QtCore import *

from qgis.core import *
Expand All @@ -42,9 +41,6 @@ class DensifyGeometries(GeoAlgorithm):
VERTICES = "VERTICES"
OUTPUT = "OUTPUT"

#def getIcon(self):
# return QtGui.QIcon(os.path.dirname(__file__) + "/icons/de.png")

def defineCharacteristics(self):
self.name = "Densify geometries"
self.group = "Vector geometry tools"
Expand All @@ -60,19 +56,19 @@ def processAlgorithm(self, progress):

isPolygon = layer.geometryType() == QGis.Polygon

writer = self.getOutputFromName(self.OUTPUT).getVectorWriter(layer.pendingFields(),
writer = self.getOutputFromName(self.OUTPUT).getVectorWriter(layer.pendingFields().toList(),
layer.wkbType(), layer.crs())

features = QGisLayers.features(layer)
total = 100.0 / float(len(features))
current = 0
for f in features:
featGeometry = QgsGeometry(f.geometry())
attrMap = f.attributes()
attrs = f.attributes()
newGeometry = self.densifyGeometry(featGeometry, int(vertices), isPolygon)
feature = QgsFeature()
feature.setGeometry(newGeometry)
feature.setAttributes(attrMap)
feature.setAttributes(attrs)
writer.addFeature(feature)
current += 1
progress.setPercentage(int(current * total))
Expand Down
10 changes: 4 additions & 6 deletions python/plugins/sextante/algs/ftools/DensifyGeometriesInterval.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
"""
***************************************************************************
DensifyGeometriesInterval.py by Anita Graser, Dec 2012
based on
DensifyGeometries.py
based on DensifyGeometries.py
---------------------
Date : October 2012
Copyright : (C) 2012 by Victor Olaya
Expand Down Expand Up @@ -58,20 +57,19 @@ def processAlgorithm(self, progress):

isPolygon = layer.geometryType() == QGis.Polygon

writer = self.getOutputFromName(self.OUTPUT).getVectorWriter(layer.pendingFields(),
writer = self.getOutputFromName(self.OUTPUT).getVectorWriter(layer.pendingFields().toList(),
layer.wkbType(), layer.crs())


features = QGisLayers.features(layer)
total = 100.0 / float(len(features))
current = 0
for f in features:
featGeometry = QgsGeometry(f.geometry())
attrMap = f.attributes()
attrs = f.attributes()
newGeometry = self.densifyGeometry(featGeometry, interval, isPolygon)
feature = QgsFeature()
feature.setGeometry(newGeometry)
feature.setAttributes(attrMap)
feature.setAttributes(attrs)
writer.addFeature(feature)

current += 1
Expand Down
93 changes: 48 additions & 45 deletions python/plugins/sextante/algs/ftools/Difference.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,90 +22,93 @@
# This will get replaced with a git SHA1 when you do a git archive
__revision__ = '$Format:%H$'


from PyQt4.QtCore import *
from PyQt4.QtGui import *

from qgis.core import *
from sextante.parameters.ParameterVector import ParameterVector

from sextante.core.QGisLayers import QGisLayers
from sextante.outputs.OutputVector import OutputVector
from sextante.algs.ftools import FToolsUtils as utils
from sextante.core.SextanteLog import SextanteLog
from sextante.core.GeoAlgorithm import GeoAlgorithm

from sextante.parameters.ParameterVector import ParameterVector

from sextante.outputs.OutputVector import OutputVector

from sextante.algs.ftools import FToolsUtils as utils

class Difference(GeoAlgorithm):

INPUT = "INPUT"
INPUT2 = "INPUT2"
OVERLAY = "OVERLAY"
OUTPUT = "OUTPUT"

#===========================================================================
# def getIcon(self):
# return QtGui.QIcon(os.path.dirname(__file__) + "/icons/difference.png")
#===========================================================================

def defineCharacteristics(self):
self.name = "Difference"
self.group = "Vector overlay tools"
self.addParameter(ParameterVector(Difference.INPUT, "Input layer", ParameterVector.VECTOR_TYPE_ANY))
self.addParameter(ParameterVector(Difference.OVERLAY, "Difference layer", ParameterVector.VECTOR_TYPE_ANY))
self.addOutput(OutputVector(Difference.OUTPUT, "Difference"))

def processAlgorithm(self, progress):
vlayerA = QGisLayers.getObjectFromUri(self.getParameterValue(Difference.INPUT))
vlayerB = QGisLayers.getObjectFromUri(self.getParameterValue(Difference.INPUT2))
layerA = QGisLayers.getObjectFromUri(self.getParameterValue(Difference.INPUT))
layerB = QGisLayers.getObjectFromUri(self.getParameterValue(Difference.OVERLAY))

GEOS_EXCEPT = True

FEATURE_EXCEPT = True
vproviderA = vlayerA.dataProvider()
vproviderB = vlayerB.dataProvider()
fields = vproviderA.fields()
# check for crs compatibility
crsA = vproviderA.crs()
crsB = vproviderB.crs()
if not crsA.isValid() or not crsB.isValid():
SextanteLog.addToLog(SextanteLog.LOG_WARNING, "Difference. Invalid CRS. Results might be unexpected")
else:
if crsA != crsB:
SextanteLog.addToLog(SextanteLog.LOG_WARNING, "Difference. Non-matching CRSs. Results might be unexpected")
writer = self.getOutputFromName(Difference.OUTPUT).getVectorWriter(fields, vproviderA.geometryType(), vproviderA.crs() )

writer = self.getOutputFromName(Difference.OUTPUT).getVectorWriter(layerA.pendingFields(),
layerA.dataProvider().geometryType(), layerA.dataProvider().crs())

inFeatA = QgsFeature()
inFeatB = QgsFeature()
outFeat = QgsFeature()
index = utils.createSpatialIndex(vlayerB)
nElement = 0
selectionA = QGisLayers.features(vlayerA)
nFeat = len(selectionA)

index = utils.createSpatialIndex(layerB)

selectionA = QGisLayers.features(layerA)

current = 0
total = 100.0 / float(len(selectionA))

for inFeatA in selectionA:
nElement += 1
progress.setPercentage(nElement/float(nFeat) * 100)
add = True
geom = QgsGeometry( inFeatA.geometry() )
diff_geom = QgsGeometry( geom )
atMap = inFeatA.attributes()
intersects = index.intersects( geom.boundingBox() )
for id in intersects:
vlayerB.featureAtId( int( id ), inFeatB , True)
tmpGeom = QgsGeometry( inFeatB.geometry() )
geom = QgsGeometry(inFeatA.geometry())
diff_geom = QgsGeometry(geom)
attrs = inFeatA.attributes()
intersections = index.intersects(geom.boundingBox())
for i in intersections:
request = QgsFeatureRequest().setFilterFid(i)
inFeatB = layerB.getFeatures(request).next()
tmpGeom = QgsGeometry(inFeatB.geometry())
try:
if diff_geom.intersects( tmpGeom ):
diff_geom = QgsGeometry( diff_geom.difference( tmpGeom ) )
if diff_geom.intersects(tmpGeom):
diff_geom = QgsGeometry(diff_geom.difference(tmpGeom))
except:
GEOS_EXCEPT = False
add = False
break

if add:
try:
outFeat.setGeometry( diff_geom )
outFeat.setAttributes( atMap )
writer.addFeature( outFeat )
outFeat.setGeometry(diff_geom)
outFeat.setAttributes(attrs)
writer.addFeature(outFeat)
except:
FEATURE_EXCEPT = False
continue

current += 1
progress.setPercentage(int(current * total))

del writer

if not GEOS_EXCEPT:
SextanteLog.addToLog(SextanteLog.LOG_WARNING, "Geometry exception while computing difference")
if not FEATURE_EXCEPT:
SextanteLog.addToLog(SextanteLog.LOG_WARNING, "Feature exception while computing difference")

def defineCharacteristics(self):
self.name = "Difference"
self.group = "Vector overlay tools"
self.addParameter(ParameterVector(Difference.INPUT, "Input layer", ParameterVector.VECTOR_TYPE_ANY))
self.addParameter(ParameterVector(Difference.INPUT2, "Difference layer", ParameterVector.VECTOR_TYPE_ANY))
self.addOutput(OutputVector(Difference.OUTPUT, "Difference"))
1 change: 0 additions & 1 deletion python/plugins/sextante/algs/ftools/Dissolve.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ def processAlgorithm(self, progress):
vproviderA = vlayerA.dataProvider()
fields = vproviderA.fields()
writer = self.getOutputFromName(Dissolve.OUTPUT).getVectorWriter(fields, vproviderA.geometryType(), vproviderA.crs() )
#inFeat = QgsFeature()
outFeat = QgsFeature()
nElement = 0
nFeat = vproviderA.featureCount()
Expand Down
89 changes: 30 additions & 59 deletions python/plugins/sextante/algs/ftools/ExportGeometryInfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,19 @@
__revision__ = '$Format:%H$'

from PyQt4.QtCore import *

from qgis.core import *

from sextante.core.GeoAlgorithm import GeoAlgorithm
from sextante.core.QGisLayers import QGisLayers

from sextante.parameters.ParameterVector import ParameterVector
from sextante.parameters.ParameterSelection import ParameterSelection

from sextante.outputs.OutputVector import OutputVector

from sextante.algs.ftools import FToolsUtils as utils

class ExportGeometryInfo(GeoAlgorithm):

INPUT = "INPUT"
Expand All @@ -56,29 +62,30 @@ def defineCharacteristics(self):

self.addOutput(OutputVector(self.OUTPUT, "Output layer"))


def processAlgorithm(self, progress):
layer = QGisLayers.getObjectFromUri(self.getParameterValue(self.INPUT))
method = self.getParameterValue(self.METHOD)

provider = layer.dataProvider()
geometryType = layer.geometryType()

layer.select(layer.pendingAllAttributesList())

fields = provider.fields()
idx1 = -1
idx2 = -1
fields = layer.pendingFields()

if geometryType == QGis.Polygon:
fields.append(QgsField(QString("area"), QVariant.Double))
fields.append(QgsField(QString("perimeter"), QVariant.Double))
idx1, fields = utils.findOrCreateField(layer, fields, "area", 21, 6)
idx2, fields = utils.findOrCreateField(layer, fields, "perimeter", 21, 6)
elif geometryType == QGis.Line:
fields.append(QgsField(QString("length"), QVariant.Double))
idx1, fields = utils.findOrCreateField(layer, fields, "length", 21, 6)
idx2 = idx1
else:
fields.append(QgsField(QString("xcoords"), QVariant.Double))
fields.append(QgsField(QString("ycoords"), QVariant.Double))
idx1, fields = utils.findOrCreateField(layer, fields, "xcoord", 21, 6)
idx2, fields = utils.findOrCreateField(layer, fields, "ycoord", 21, 6)

writer = self.getOutputFromName(self.OUTPUT).getVectorWriter(fields,
provider.geometryType(), layer.crs())
writer = self.getOutputFromName(self.OUTPUT).getVectorWriter(fields.toList(),
layer.dataProvider().geometryType(), layer.crs())

print idx1, idx2

ellips = None
crs = None
Expand All @@ -90,7 +97,7 @@ def processAlgorithm(self, progress):
# 2 - ellipsoidal
if method == 2:
settings = QSettings()
ellips = settings.value("/qgis/measure/ellipsoid", "WGS84").toString()
ellips = QgsProject.instance().readEntry("Measure", "/Ellipsoid", GEO_NONE)[0]
crs = layer.crs().srsid()
elif method == 1:
mapCRS = QGisLayers.iface.mapCanvas().mapRenderer().destinationCrs()
Expand All @@ -100,65 +107,29 @@ def processAlgorithm(self, progress):
outFeat = QgsFeature()
inGeom = QgsGeometry()

outFeat.initAttributes(len(fields))
outFeat.setFields(fields)

current = 0
features = QGisLayers.features(layer)
total = 100.0 / float(len(features))
for inFeat in features:
inGeom = inFeat.geometry()
for f in features:
inGeom = f.geometry()

if method == 1:
inGeom.transform(coordTransform)

(attr1, attr2) = self.simpleMeasure(inGeom, method, ellips, crs)
(attr1, attr2) = utils.simpleMeasure(inGeom, method, ellips, crs)

outFeat.setGeometry(inGeom)
atMap = inFeat.attributes()
atMap.append(QVariant(attr1))
attrs = f.attributes()
attrs.insert(idx1, QVariant(attr1))
if attr2 is not None:
atMap.append(QVariant(attr2))
outFeat.setAttributes(atMap)
attrs.insert(idx2, QVariant(attr2))
outFeat.setAttributes(attrs)
writer.addFeature(outFeat)

current += 1
progress.setPercentage(int(current * total))

del writer

def simpleMeasure(self, geom, method, ellips, crs):
if geom.wkbType() in [QGis.WKBPoint, QGis.WKBPoint25D]:
pt = geom.asPoint()
attr1 = pt.x()
attr2 = pt.y()
elif geom.wkbType() in [QGis.WKBMultiPoint, QGis.WKBMultiPoint25D]:
pt = inGeom.asMultiPoint()
attr1 = pt[0].x()
attr2 = pt[0].y()
else:
measure = QgsDistanceArea()

if method == 2:
measure.setSourceCrs(crs)
measure.setEllipsoid(ellips)
measure.setEllipsoidalMode(True)

attr1 = measure.measure(geom)
if geom.type() == QGis.Polygon:
attr2 = self.perimMeasure(geom, measure)
else:
attr2 = None

return (attr1, attr2)

def perimMeasure(self, geom, measure):
value = 0.0
if geom.isMultipart():
polygons = geom.asMultiPolygon()
for p in polygons:
for line in p:
value += measure.measureLine(line)
else:
poly = geom.asPolygon()
for r in poly:
value += measure.measureLine(r)

return value
51 changes: 27 additions & 24 deletions python/plugins/sextante/algs/ftools/ExtentFromLayer.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,16 @@
# This will get replaced with a git SHA1 when you do a git archive
__revision__ = '$Format:%H$'


from PyQt4.QtCore import *

from qgis.core import *

from sextante.core.GeoAlgorithm import GeoAlgorithm
from sextante.core.QGisLayers import QGisLayers

from sextante.parameters.ParameterVector import ParameterVector
from sextante.parameters.ParameterBoolean import ParameterBoolean

from sextante.outputs.OutputVector import OutputVector

class ExtentFromLayer(GeoAlgorithm):
Expand Down Expand Up @@ -102,27 +105,26 @@ def layerExtent(self, layer, writer, progress):
feat = QgsFeature()
feat.setGeometry(geometry)
attrs = [QVariant(minx),
QVariant(miny),
QVariant(maxx),
QVariant(maxy),
QVariant(cntx),
QVariant(cnty),
QVariant(area),
QVariant(perim),
QVariant(height),
QVariant(width) ]
QVariant(miny),
QVariant(maxx),
QVariant(maxy),
QVariant(cntx),
QVariant(cnty),
QVariant(area),
QVariant(perim),
QVariant(height),
QVariant(width)
]
feat.setAttributes(attrs)
writer.addFeature(feat)

def featureExtent(self, layer, writer, progress):
current = 0
feat = QgsFeature()

provider = layer.dataProvider()
features = QGisLayers.features(layer)
total = 100.0 / float(len(features))
for inFeat in features:
rect = inFeat.geometry().boundingBox()
feat = QgsFeature()
for f in features:
rect = f.geometry().boundingBox()
minx = rect.xMinimum()
miny = rect.yMinimum()
maxx = rect.xMaximum()
Expand All @@ -143,15 +145,16 @@ def featureExtent(self, layer, writer, progress):
geometry = QgsGeometry().fromPolygon([rect])
feat.setGeometry(geometry)
attrs = [QVariant(minx),
QVariant(miny),
QVariant(maxx),
QVariant(maxy),
QVariant(cntx),
QVariant(cnty),
QVariant(area),
QVariant(perim),
QVariant(height),
QVariant(width) ]
QVariant(miny),
QVariant(maxx),
QVariant(maxy),
QVariant(cntx),
QVariant(cnty),
QVariant(area),
QVariant(perim),
QVariant(height),
QVariant(width)
]
feat.setAttributes(attrs)

writer.addFeature(feat)
Expand Down
15 changes: 7 additions & 8 deletions python/plugins/sextante/algs/ftools/ExtractNodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,14 @@
# This will get replaced with a git SHA1 when you do a git archive
__revision__ = '$Format:%H$'


from PyQt4.QtCore import *
from qgis.core import *

from sextante.core.GeoAlgorithm import GeoAlgorithm
from sextante.core.QGisLayers import QGisLayers
from sextante.parameters.ParameterVector import ParameterVector
from sextante.outputs.OutputVector import OutputVector

from sextante.algs.ftools import FToolsUtils as utils

class ExtractNodes(GeoAlgorithm):
Expand All @@ -53,9 +54,7 @@ def defineCharacteristics(self):
def processAlgorithm(self, progress):
layer = QGisLayers.getObjectFromUri(self.getParameterValue(self.INPUT))

provider = layer.dataProvider()

writer = self.getOutputFromName(self.OUTPUT).getVectorWriter(layer.pendingFields(),
writer = self.getOutputFromName(self.OUTPUT).getVectorWriter(layer.pendingFields().toList(),
QGis.WKBPoint, layer.crs())

outFeat = QgsFeature()
Expand All @@ -65,12 +64,12 @@ def processAlgorithm(self, progress):
current = 0
features = QGisLayers.features(layer)
total = 100.0 / float(len(features))
for inFeat in features:
inGeom = inFeat.geometry()
atMap = inFeat.attributes()
for f in features:
inGeom = f.geometry()
attrs = f.attributes()

points = utils.extractPoints(inGeom)
outFeat.setAttributes(atMap)
outFeat.setAttributes(attrs)

for i in points:
outFeat.setGeometry(outGeom.fromPoint(i))
Expand Down
115 changes: 0 additions & 115 deletions python/plugins/sextante/algs/ftools/FToolsAlgorithmProvider.py

This file was deleted.

Loading