Re: [Qgis-user] getting QgsMapCanvasSnapper to work

2008-11-18 Thread Carson Farmer
> I used your code lines and started the debugger. It seems that the 
> QgsMapCanvasSnapper works correctly. I think the problem has to do with the 
> QList reference in the binding:
>
> int snapToCurrentLayer( const QPoint& p, QList& results, 
> QgsSnapper::SnappingType snap_to, double snappingTol = -1, const 
> QList& excludePoints = QList() );

I wonder if this is related to a similar problem I was having with
python bindings for uniqueValues on QgsVectorDataProvider?

> But then Python complains about a wrong type of the results parameter with 
> your code. I tried to use a 'QList' instead of '[]', but it seems there is no 
> QList in PyQt?
> Python experts: How can we deal with QList in PyQGIS?

Short answer: you should be able to use a python list in place of a QList


>
> Regards,
> Marco
>
>
> -Ursprüngliche Nachricht-
> Von: [EMAIL PROTECTED] im Auftrag von Möri Cedric
> Gesendet: Di 18.11.2008 18:43
> An: qgis-user@lists.osgeo.org
> Betreff: [Qgis-user] getting QgsMapCanvasSnapper to work
>
> Hi all!
>
> I'm trying to snap a vertex with my python plugin. (Many thanks to Martin for 
> the quick work with the bindings!)
>
> My code looks like this:
>
> def canvasReleaseEvent(self,event):
>x = event.pos().x()
>y = event.pos().y()
>
>startingPoint = QPoint(x,y)
>result = []
>excludePoints = []
>
>snapper = QgsMapCanvasSnapper(self.canvas)
>
>snapper.snapToCurrentLayer (startingPoint,result,QgsSnapper.SnapToVertex, 
> 1, excludePoints)
>print "result: ",result
>
> The problem is, whatever I do, the result keeps empty. I tried to play with 
> tolerance and scale and I'm quite sure it has to find a vertex but without 
> any success (the layer unit is meter).
>
> So I thought about using QgsSnapper directly. But I'm not able to set it up 
> properly. Doing the following snippet always leads to a attribut error on the 
> snapLayer struct.
>
>  snapLayer = QgsSnapper.SnapLayer
>  snapLayer.mLayer = self.iface.mapCanvas().currentLayer()
>  snapLayer.mTolerance = 1000
>  snapLayer.mSnapTo = QgsSnapper.SnapToVertex
>
>
> So, if anyone has a hint why the QgsMapCanvasSnapper doesn't want to give me 
> a result or how I set up the struct correctly, it would be wonderful to share 
> it with me :-)
>
> Best regards and kudos to all the helping people here on the list!
> Cédric
>
>
> mit freundlichen Grüssen
>
> Cédric Möri
> GIS-Informatiker
>
> --
> Kanton Solothurn
> Bau- und Justizdepartement
> Amt für Geoinformation
> Rötistrasse 4
> 4501 Solothurn
>
> Telefon: +41 (0)32 627 24 75
> Telefax: +41 (0)32 627 22 14
> mailto:[EMAIL PROTECTED]
> http://www.agi.so.ch
> ___
> Qgis-user mailing list
> Qgis-user@lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/qgis-user
>
> ___
> Qgis-user mailing list
> Qgis-user@lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/qgis-user
>



-- 
Carson Farmer
National Centre for Geocomputation
John Hume Building,
National University of Ireland, Maynooth,
Maynooth,
Co. Kildare,
Ireland.
www.carsonfarmer.com
___
Qgis-user mailing list
Qgis-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-user


AW: [Qgis-user] getting QgsMapCanvasSnapper to work

2008-11-18 Thread Hugentobler Marco
Hi Cedric

I used your code lines and started the debugger. It seems that the 
QgsMapCanvasSnapper works correctly. I think the problem has to do with the 
QList reference in the binding:

int snapToCurrentLayer( const QPoint& p, QList& results, 
QgsSnapper::SnappingType snap_to, double snappingTol = -1, const 
QList& excludePoints = QList() );

I tried to change that to:

int snapToCurrentLayer( const QPoint& p, QList& results 
/Out/, QgsSnapper::SnappingType snap_to, double snappingTol = -1, const 
QList& excludePoints = QList() );

But then Python complains about a wrong type of the results parameter with your 
code. I tried to use a 'QList' instead of '[]', but it seems there is no QList 
in PyQt?

Python experts: How can we deal with QList in PyQGIS?

Regards,
Marco


-Ursprüngliche Nachricht-
Von: [EMAIL PROTECTED] im Auftrag von Möri Cedric
Gesendet: Di 18.11.2008 18:43
An: qgis-user@lists.osgeo.org
Betreff: [Qgis-user] getting QgsMapCanvasSnapper to work
 
Hi all!

I'm trying to snap a vertex with my python plugin. (Many thanks to Martin for 
the quick work with the bindings!)

My code looks like this:

def canvasReleaseEvent(self,event):
x = event.pos().x()
y = event.pos().y()
   
startingPoint = QPoint(x,y)
result = []
excludePoints = []
  
snapper = QgsMapCanvasSnapper(self.canvas)
   
snapper.snapToCurrentLayer (startingPoint,result,QgsSnapper.SnapToVertex, 
1, excludePoints)
print "result: ",result

The problem is, whatever I do, the result keeps empty. I tried to play with 
tolerance and scale and I'm quite sure it has to find a vertex but without any 
success (the layer unit is meter).

So I thought about using QgsSnapper directly. But I'm not able to set it up 
properly. Doing the following snippet always leads to a attribut error on the 
snapLayer struct.

  snapLayer = QgsSnapper.SnapLayer
  snapLayer.mLayer = self.iface.mapCanvas().currentLayer()
  snapLayer.mTolerance = 1000
  snapLayer.mSnapTo = QgsSnapper.SnapToVertex


So, if anyone has a hint why the QgsMapCanvasSnapper doesn't want to give me a 
result or how I set up the struct correctly, it would be wonderful to share it 
with me :-)

Best regards and kudos to all the helping people here on the list!
Cédric


mit freundlichen Grüssen

Cédric Möri
GIS-Informatiker

--
Kanton Solothurn
Bau- und Justizdepartement
Amt für Geoinformation
Rötistrasse 4
4501 Solothurn

Telefon: +41 (0)32 627 24 75
Telefax: +41 (0)32 627 22 14
mailto:[EMAIL PROTECTED]
http://www.agi.so.ch
___
Qgis-user mailing list
Qgis-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-user

___
Qgis-user mailing list
Qgis-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-user


Re: [Qgis-user] getting QgsMapCanvasSnapper to work

2008-11-18 Thread Stefanie Tellex

Here's what I do for snapping in python:
  def canvasReleaseEvent(self, e):
print "mouse click", e
mapcoords = 
self.canvas.getCoordinateTransform().toMapCoordinates(e.x(), e.y())

print "map position", mapcoords
snapdist = 2
r = qgis_utils.snap(self.layer, mapcoords,
QgsSnapper.SnapToVertexAndSegment,
snapdist=0.3)
if r != None:
fid = r.snappedAtGeometry
self.emit(SIGNAL("selectedFeature(int)"), (fid))





def snap(layer, point, snaptype, snapdist=1):
print "\nsnapping"
x, reslist = layer.snapWithContext(point, snapdist, snaptype)
print "x", x
if x != 0:
return None
return getBestSnapResult(reslist)

def getBestSnapResult(snapresult):
print "result", snapresult
keys = snapresult.keys()
keys.sort()
for k in keys:
l = snapresult[k]
for r in l:
return r


It works, but not great.  It doesn't always get a snap result, even when 
I think it really should.  I think part of the problem is that I'm using 
a fixed snapdist no matter what the zoom level is... but I haven't 
looked at it closely.


Möri Cedric pisze:

Hi all!

I'm trying to snap a vertex with my python plugin. (Many thanks to Martin for 
the quick work with the bindings!)

My code looks like this:

def canvasReleaseEvent(self,event):
x = event.pos().x()
y = event.pos().y()
   
startingPoint = QPoint(x,y)

result = []
excludePoints = []
  
snapper = QgsMapCanvasSnapper(self.canvas)
   
snapper.snapToCurrentLayer (startingPoint,result,QgsSnapper.SnapToVertex, 1, excludePoints)

print "result: ",result

The problem is, whatever I do, the result keeps empty. I tried to play with 
tolerance and scale and I'm quite sure it has to find a vertex but without any 
success (the layer unit is meter).

So I thought about using QgsSnapper directly. But I'm not able to set it up 
properly. Doing the following snippet always leads to a attribut error on the 
snapLayer struct.

  snapLayer = QgsSnapper.SnapLayer
  snapLayer.mLayer = self.iface.mapCanvas().currentLayer()
  snapLayer.mTolerance = 1000
  snapLayer.mSnapTo = QgsSnapper.SnapToVertex


So, if anyone has a hint why the QgsMapCanvasSnapper doesn't want to give me a 
result or how I set up the struct correctly, it would be wonderful to share it 
with me :-)

Best regards and kudos to all the helping people here on the list!
Cédric


mit freundlichen Grüssen

Cédric Möri
GIS-Informatiker

--
Kanton Solothurn
Bau- und Justizdepartement
Amt für Geoinformation
Rötistrasse 4
4501 Solothurn

Telefon: +41 (0)32 627 24 75
Telefax: +41 (0)32 627 22 14
mailto:[EMAIL PROTECTED]
http://www.agi.so.ch
___
Qgis-user mailing list
Qgis-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-user

x   
___
Qgis-user mailing list
Qgis-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-user


[Qgis-user] getting QgsMapCanvasSnapper to work

2008-11-18 Thread Möri Cedric
Hi all!

I'm trying to snap a vertex with my python plugin. (Many thanks to Martin for 
the quick work with the bindings!)

My code looks like this:

def canvasReleaseEvent(self,event):
x = event.pos().x()
y = event.pos().y()
   
startingPoint = QPoint(x,y)
result = []
excludePoints = []
  
snapper = QgsMapCanvasSnapper(self.canvas)
   
snapper.snapToCurrentLayer (startingPoint,result,QgsSnapper.SnapToVertex, 
1, excludePoints)
print "result: ",result

The problem is, whatever I do, the result keeps empty. I tried to play with 
tolerance and scale and I'm quite sure it has to find a vertex but without any 
success (the layer unit is meter).

So I thought about using QgsSnapper directly. But I'm not able to set it up 
properly. Doing the following snippet always leads to a attribut error on the 
snapLayer struct.

  snapLayer = QgsSnapper.SnapLayer
  snapLayer.mLayer = self.iface.mapCanvas().currentLayer()
  snapLayer.mTolerance = 1000
  snapLayer.mSnapTo = QgsSnapper.SnapToVertex


So, if anyone has a hint why the QgsMapCanvasSnapper doesn't want to give me a 
result or how I set up the struct correctly, it would be wonderful to share it 
with me :-)

Best regards and kudos to all the helping people here on the list!
Cédric


mit freundlichen Grüssen

Cédric Möri
GIS-Informatiker

--
Kanton Solothurn
Bau- und Justizdepartement
Amt für Geoinformation
Rötistrasse 4
4501 Solothurn

Telefon: +41 (0)32 627 24 75
Telefax: +41 (0)32 627 22 14
mailto:[EMAIL PROTECTED]
http://www.agi.so.ch
___
Qgis-user mailing list
Qgis-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-user


[Qgis-user] Problems with grass plugin

2008-11-18 Thread Agustin Lobo

Hi!

I'm not sure if this problem is specific to the Qgis
grass plugin or is just a grass question.

Once the location and mapset are set and some raster and vector layers
are imported to grass through r.in.gdal and r.in.ogr, I observe that 
some of the interactive menus to run grass

commands (i.e., r.statistics, r.mask) do not let me select among any
of the grass layers that I already have. Is this behavior documented
somewhere?

Thanks

Agus
--
Dr. Agustin Lobo
Institut de Ciencies de la Terra "Jaume Almera" (CSIC)
LLuis Sole Sabaris s/n
08028 Barcelona
Spain
Tel. 34 934095410
Fax. 34 934110012
email: [EMAIL PROTECTED]
http://www.ija.csic.es/gt/obster
___
Qgis-user mailing list
Qgis-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-user


Re: [Qgis-user] Error running fTools_preview2/Random points

2008-11-18 Thread Carson Farmer
Hi Agus,


> After entering the output file name and clicking OK
> in the fTools_preview2/Random points panel I get the following error
> (binary ubuntu preview2 version):
>
This is an error due to the recent api changes... These must have been
made after I updated fTools, and I missed it :-(

Sorry about that, I'll try to fix that as soon as possible.


Cheers,

Carson


-- 
Carson Farmer
National Centre for Geocomputation
John Hume Building,
National University of Ireland, Maynooth,
Maynooth,
Co. Kildare,
Ireland.
___
Qgis-user mailing list
Qgis-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-user


Re: [Qgis-user] uncheck editing tool (python plugin)

2008-11-18 Thread Martin Dobias
On Mon, Nov 17, 2008 at 7:38 PM, Möri Cedric <[EMAIL PROTECTED]> wrote:
> Hi all!
>
> I'm currently trying to uncheck an editing tool icon with my python plugin. 
> The following code works for non editing tools like zoom and pan:
>
> mc = self.iface.mapCanvas()
> layer = mc.currentLayer()
> tool = mc.mapTool()
> mc.unsetMapTool(tool)
>
> After this snippet, if the current tool is an non editing tool (e.g pan or 
> identify), there is no functionality  and the icons are unchecked. (That's 
> what I want)
>
> If I do the same for an editing tool (e.g capture polygon) as current tool, 
> the functionality has also gone but the icon is still checked.
>
> Has anybody a hint how I may uncheck editing icons (like it is when you 
> change from pan to capture an vice versa)?

Hi,

this was a minor bug in implementation... some of the map tools have
own implementation of deactivate() function and they were not calling
parent QgsMapTool::deactivate() so that's why for some map tools
unsetting was not working properly. I've fixed it in r9664 where I've
found this problem.

Regards
Martin
___
Qgis-user mailing list
Qgis-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-user


Re: [Qgis-user] QGIS Python Plugin Installer not UTF-8 aware?

2008-11-18 Thread Martin Dobias
2008/11/17 Borys Jurgiel <[EMAIL PROTECTED]>:
>
> def description():
>  return u'Danke schön'
>
>
> However... Installer do, but rest of QGIS doesn't support utf-8 in plugin
> metadata ;)

I've fixed that in SVN trunk, from r9663 it supports also metadata in unicode :)

Martin
___
Qgis-user mailing list
Qgis-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-user


[Qgis-user] Error running fTools_preview2/Random points

2008-11-18 Thread Agustin Lobo

Barry,

After entering the output file name and clicking OK
in the fTools_preview2/Random points panel I get the following error
(binary ubuntu preview2 version):

An error has occured while executing Python code:

Traceback (most recent call last):
  File 
"/home/alobo/.qgis/python/plugins/fTools_preview2/tools/doRandPoints.py", 
line 123, in accept
self.randomize(inLayer, outPath, minimum, design, value, 
self.progressBar)
  File 
"/home/alobo/.qgis/python/plugins/fTools_preview2/tools/doRandPoints.py", 
line 269, in randomize
points = self.simpleRandom(int(value), bound, ext.xMin(), 
ext.xMax(), ext.yMin(), ext.yMax())

AttributeError: xMin

Also, most of the options except "Use this number of points"
are greyed and cannot be filed.

Thanks!

Agus
--
Dr. Agustin Lobo
Institut de Ciencies de la Terra "Jaume Almera" (CSIC)
LLuis Sole Sabaris s/n
08028 Barcelona
Spain
Tel. 34 934095410
Fax. 34 934110012
email: [EMAIL PROTECTED]
http://www.ija.csic.es/gt/obster
___
Qgis-user mailing list
Qgis-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-user


[Qgis-user] select features slow down

2008-11-18 Thread Lionel Roubeyrie
Hi all,
needing to edit/copy/past features from a large vector layer (>72,000
features), the "select features" tool takes ~5sec. each time we want to
use it, where it is relatively faster on smalls vector layers (~4,000
features). Is there a flag at the compilation time to improve the speed,
or something else to do? In the same time, how can we deselect a
previously selected feature without deselecting all the others features?
Thanks
PS : We use QGIS1.0.0 preview2 from the ubuntu launchpad repository, on
a Intel Core2 6400 CPU (2.1GHz).

-- 
Lionel Roubeyrie
chargé d'études
LIMAIR - La Surveillance de l'Air en Limousin
http://www.limair.asso.fr


___
Qgis-user mailing list
Qgis-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-user