Skip to content
Permalink
Browse files

[ftools] Fix "Join attributes by location"

  • Loading branch information
m-kuhn committed Jun 15, 2013
1 parent 54956db commit b6770be7291f7d41ba145b9c153287b01ca63457
@@ -146,6 +146,7 @@ public:
int fieldOriginIndex( int fieldIdx ) const;

int indexFromName( const QString& name ) const;
void extend( const QgsFields& other );


QgsField& operator[](int i);
@@ -149,7 +149,7 @@ def compute(self, inName, joinName, outName, summary, sumList, keep, progressBar
# check for correct field names
print fieldList1
longNames = ftools_utils.checkFieldNameLength( fieldList1.values() )
if not longNames.isEmpty():
if len( longNames ) > 0:
QMessageBox.warning( self, self.tr( 'Incorrect field names' ),
self.tr( 'No output will be created.\nFollowing field names are longer than 10 characters:\n%s' ) % ( "\n".join(longNames) ) )
return False
@@ -202,8 +202,7 @@ def compute(self, inName, joinName, outName, summary, sumList, keep, progressBar
for i in joinList:
#tempGeom = i.geometry()
provider2.getFeatures( QgsFeatureRequest().setFilterFid( int(i) ) ).nextFeature( inFeatB )
tmpGeom = QgsGeometry( inFeatB.geometry() )
if inGeom.intersects(tmpGeom):
if inGeom.intersects(inFeatB.geometry()):
count = count + 1
none = False
atMap2 = inFeatB.attributes()
@@ -185,8 +185,8 @@ def createUniqueFieldName( field ):
def checkFieldNameLength( fieldList ):
longNames = []
for field in fieldList:
if field.name().size() > 10:
longNames.append(unicode( field.name() ))
if len ( field.name() ) > 10:
longNames.append( field.name() )
return longNames

# Return list of names of all layers in QgsMapLayerRegistry
@@ -195,15 +195,15 @@ def getLayerNames( vTypes ):
layerlist = []
if vTypes == "all":
for name, layer in layermap.iteritems():
layerlist.append( unicode( layer.name() ) )
layerlist.append( layer.name() )
else:
for name, layer in layermap.iteritems():
if layer.type() == QgsMapLayer.VectorLayer:
if layer.geometryType() in vTypes:
layerlist.append( unicode( layer.name() ) )
layerlist.append( layer.name() )
elif layer.type() == QgsMapLayer.RasterLayer:
if "Raster" in vTypes:
layerlist.append( unicode( layer.name() ) )
layerlist.append( layer.name() )
return sorted( layerlist, cmp=locale.strcoll )

# Return list of names of all fields from input QgsVectorLayer
@@ -212,7 +212,7 @@ def getFieldNames( vlayer ):
fieldlist = []
for field in fieldmap:
if not field.name() in fieldlist:
fieldlist.append( unicode( field.name() ) )
fieldlist.append( field.name() )
return sorted( fieldlist, cmp=locale.strcoll )

# Return QgsVectorLayer from a layer name ( as string )
@@ -186,6 +186,14 @@ class CORE_EXPORT QgsFields
inline bool isEmpty() const { return mFields.isEmpty(); }
inline int count() const { return mFields.count(); }
inline int size() const { return mFields.count(); } // TODO[MD]: delete?
void extend( const QgsFields& other )
{
for ( int i = 0; i < other.count(); ++i )
{
if ( other.fieldOrigin( i ) != OriginJoin )
append( other.at( i ), other.fieldOrigin( i ), other.fieldOriginIndex( i ) );
}
}
inline const QgsField& operator[]( int i ) const { return mFields[i].field; }
inline QgsField& operator[]( int i ) { return mFields[i].field; }
const QgsField& at( int i ) const { return mFields[i].field; }

0 comments on commit b6770be

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