Re: [Qgis-developer] What's the difference between provider.geometryType() and layer.geometryType()
If we start to talk about inconsistencies I also want to propose to use same approach for retrieving selected features as we use for all features — iterator. Now getFeatures() method returns iterator, while selectedFeatures() returns a list. It will be good to have same approach for both method. This can be done as introducing new method (or updating existing) for getting selected features or, alternatively, by introducing special flag to existing getFeaures() method. 2013/10/19 Matthias Kuhn matthias.k...@gmx.ch: Hi, Currently we have: QgsVectorLayer: * geometryType() returns QGIS geometry type (coarse) * wkbType() returns WKB type (fine) QgsVectorDataProvider: * geometryType() returns WKB type (fine) Unfortunate indeed. To not break existing code, a new method geomType() could be introduced, which returns the QGIS geometry type and the method wkbType() could be implemented for the dataprovider as well. The current methods could be deprecated, but left for a transition period (IMO, there is no need to force people to change working code too fast) Apart from this, a couple of other methods could also be called the same in data provider, vector layer and fields. QgsVectorLayer * int fieldNameIndex( fieldName ) * QgsFields pendingFields() QgsDataProvider * int fieldNameIndex( fieldName ) * QgsFields fields() * QMapQString, int fieldNameMap() QgsFields * int indexFromName( name ) * QgsField field( name ) I would even argue, that QgsVectorLayer should have a common interface (base class) with QgsVectorDataProvider. A lot of code could perfectly be run against any of the two, and with such an interface, this could be done. Just like we don't care if we are working with an iterator from a vector layer or a data provider. Regards, Matthias On Sam 19 Okt 2013 17:33:09 CEST, Martin Dobias wrote: Hi Anita looking into the code... the unintuitive part is that these geometryType() methods return values from different enumerations: - provider's geometryType() returns value from WKBType enumeration - layer's geometryType() returns value from GeometryType enumeration (translated from provider's geometryType()) GeometryType has just coarse differentiation (Point, Line, Polygon, UnknownGeometry, NoGeometry), while WKBType is more fine grained (WKBPoint, WKBPoint2D, WKBMultiPoint, ...) I totally agree that it is confusing... they should be at least called differently (e.g. geometryWkbType vs geometryType). Regards Martin On Sat, Oct 19, 2013 at 9:46 PM, Anita Graser anitagra...@gmx.at wrote: Hi Victor, I've been porting one of my scripts to the new Processing. Everything seems fine but I'm confused about one issue: It seems like almost everything can be accessed via the layer now, e.g. crs(), pendingFields(), etc. However, if I try to use layer.geometryType() in the VectorWriter constructor, I get an error. It only works if I do: writer = VectorWriter(output, None, fields, provider.geometryType(), layer.crs() ) What's the reason for this unintuitive behavior? Thanks and best wishes, Anita ___ Qgis-developer mailing list Qgis-developer@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/qgis-developer ___ Qgis-developer mailing list Qgis-developer@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/qgis-developer ___ Qgis-developer mailing list Qgis-developer@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/qgis-developer -- Alexander Bruy ___ Qgis-developer mailing list Qgis-developer@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/qgis-developer
[Qgis-developer] What's the difference between provider.geometryType() and layer.geometryType()
Hi Victor, I've been porting one of my scripts to the new Processing. Everything seems fine but I'm confused about one issue: It seems like almost everything can be accessed via the layer now, e.g. crs(), pendingFields(), etc. However, if I try to use layer.geometryType() in the VectorWriter constructor, I get an error. It only works if I do: writer = VectorWriter(output, None, fields, provider.geometryType(), layer.crs() ) What's the reason for this unintuitive behavior? Thanks and best wishes, Anita ___ Qgis-developer mailing list Qgis-developer@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/qgis-developer
Re: [Qgis-developer] What's the difference between provider.geometryType() and layer.geometryType()
Hi Anita looking into the code... the unintuitive part is that these geometryType() methods return values from different enumerations: - provider's geometryType() returns value from WKBType enumeration - layer's geometryType() returns value from GeometryType enumeration (translated from provider's geometryType()) GeometryType has just coarse differentiation (Point, Line, Polygon, UnknownGeometry, NoGeometry), while WKBType is more fine grained (WKBPoint, WKBPoint2D, WKBMultiPoint, ...) I totally agree that it is confusing... they should be at least called differently (e.g. geometryWkbType vs geometryType). Regards Martin On Sat, Oct 19, 2013 at 9:46 PM, Anita Graser anitagra...@gmx.at wrote: Hi Victor, I've been porting one of my scripts to the new Processing. Everything seems fine but I'm confused about one issue: It seems like almost everything can be accessed via the layer now, e.g. crs(), pendingFields(), etc. However, if I try to use layer.geometryType() in the VectorWriter constructor, I get an error. It only works if I do: writer = VectorWriter(output, None, fields, provider.geometryType(), layer.crs() ) What's the reason for this unintuitive behavior? Thanks and best wishes, Anita ___ Qgis-developer mailing list Qgis-developer@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/qgis-developer ___ Qgis-developer mailing list Qgis-developer@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/qgis-developer
Re: [Qgis-developer] What's the difference between provider.geometryType() and layer.geometryType()
I wasn't aware of that difference that Martin mentions. I guess that, from the Processing side, the only thing to do is to document clearly which find of enumeration value is expected, and also how to convert it in case you have a value corresponding to the other enumeration. I will try to add that to the Processing documentation thanks for finding this issue 2013/10/19 Martin Dobias wonder...@gmail.com: Hi Anita looking into the code... the unintuitive part is that these geometryType() methods return values from different enumerations: - provider's geometryType() returns value from WKBType enumeration - layer's geometryType() returns value from GeometryType enumeration (translated from provider's geometryType()) GeometryType has just coarse differentiation (Point, Line, Polygon, UnknownGeometry, NoGeometry), while WKBType is more fine grained (WKBPoint, WKBPoint2D, WKBMultiPoint, ...) I totally agree that it is confusing... they should be at least called differently (e.g. geometryWkbType vs geometryType). Regards Martin On Sat, Oct 19, 2013 at 9:46 PM, Anita Graser anitagra...@gmx.at wrote: Hi Victor, I've been porting one of my scripts to the new Processing. Everything seems fine but I'm confused about one issue: It seems like almost everything can be accessed via the layer now, e.g. crs(), pendingFields(), etc. However, if I try to use layer.geometryType() in the VectorWriter constructor, I get an error. It only works if I do: writer = VectorWriter(output, None, fields, provider.geometryType(), layer.crs() ) What's the reason for this unintuitive behavior? Thanks and best wishes, Anita ___ Qgis-developer mailing list Qgis-developer@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/qgis-developer ___ Qgis-developer mailing list Qgis-developer@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/qgis-developer
Re: [Qgis-developer] What's the difference between provider.geometryType() and layer.geometryType()
Hi, Currently we have: QgsVectorLayer: * geometryType() returns QGIS geometry type (coarse) * wkbType() returns WKB type (fine) QgsVectorDataProvider: * geometryType() returns WKB type (fine) Unfortunate indeed. To not break existing code, a new method geomType() could be introduced, which returns the QGIS geometry type and the method wkbType() could be implemented for the dataprovider as well. The current methods could be deprecated, but left for a transition period (IMO, there is no need to force people to change working code too fast) Apart from this, a couple of other methods could also be called the same in data provider, vector layer and fields. QgsVectorLayer * int fieldNameIndex( fieldName ) * QgsFields pendingFields() QgsDataProvider * int fieldNameIndex( fieldName ) * QgsFields fields() * QMapQString, int fieldNameMap() QgsFields * int indexFromName( name ) * QgsField field( name ) I would even argue, that QgsVectorLayer should have a common interface (base class) with QgsVectorDataProvider. A lot of code could perfectly be run against any of the two, and with such an interface, this could be done. Just like we don't care if we are working with an iterator from a vector layer or a data provider. Regards, Matthias On Sam 19 Okt 2013 17:33:09 CEST, Martin Dobias wrote: Hi Anita looking into the code... the unintuitive part is that these geometryType() methods return values from different enumerations: - provider's geometryType() returns value from WKBType enumeration - layer's geometryType() returns value from GeometryType enumeration (translated from provider's geometryType()) GeometryType has just coarse differentiation (Point, Line, Polygon, UnknownGeometry, NoGeometry), while WKBType is more fine grained (WKBPoint, WKBPoint2D, WKBMultiPoint, ...) I totally agree that it is confusing... they should be at least called differently (e.g. geometryWkbType vs geometryType). Regards Martin On Sat, Oct 19, 2013 at 9:46 PM, Anita Graser anitagra...@gmx.at wrote: Hi Victor, I've been porting one of my scripts to the new Processing. Everything seems fine but I'm confused about one issue: It seems like almost everything can be accessed via the layer now, e.g. crs(), pendingFields(), etc. However, if I try to use layer.geometryType() in the VectorWriter constructor, I get an error. It only works if I do: writer = VectorWriter(output, None, fields, provider.geometryType(), layer.crs() ) What's the reason for this unintuitive behavior? Thanks and best wishes, Anita ___ Qgis-developer mailing list Qgis-developer@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/qgis-developer ___ Qgis-developer mailing list Qgis-developer@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/qgis-developer ___ Qgis-developer mailing list Qgis-developer@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/qgis-developer
Re: [Qgis-developer] What's the difference between provider.geometryType() and layer.geometryType()
Thanks for the explanation Martin! I hope here is a way to have consistency again without necessarily breaking working code. @Victor: A few comments in the example scripts explaining the issue would already help a lot I think. Best wishes, Anita Am 19.10.2013, 19:54 Uhr, schrieb Victor Olaya vola...@gmail.com: I wasn't aware of that difference that Martin mentions. I guess that, from the Processing side, the only thing to do is to document clearly which find of enumeration value is expected, and also how to convert it in case you have a value corresponding to the other enumeration. I will try to add that to the Processing documentation thanks for finding this issue 2013/10/19 Martin Dobias wonder...@gmail.com: Hi Anita looking into the code... the unintuitive part is that these geometryType() methods return values from different enumerations: - provider's geometryType() returns value from WKBType enumeration - layer's geometryType() returns value from GeometryType enumeration (translated from provider's geometryType()) GeometryType has just coarse differentiation (Point, Line, Polygon, UnknownGeometry, NoGeometry), while WKBType is more fine grained (WKBPoint, WKBPoint2D, WKBMultiPoint, ...) I totally agree that it is confusing... they should be at least called differently (e.g. geometryWkbType vs geometryType). Regards Martin On Sat, Oct 19, 2013 at 9:46 PM, Anita Graser anitagra...@gmx.at wrote: Hi Victor, I've been porting one of my scripts to the new Processing. Everything seems fine but I'm confused about one issue: It seems like almost everything can be accessed via the layer now, e.g. crs(), pendingFields(), etc. However, if I try to use layer.geometryType() in the VectorWriter constructor, I get an error. It only works if I do: writer = VectorWriter(output, None, fields, provider.geometryType(), layer.crs() ) What's the reason for this unintuitive behavior? Thanks and best wishes, Anita ___ Qgis-developer mailing list Qgis-developer@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/qgis-developer ___ Qgis-developer mailing list Qgis-developer@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/qgis-developer