>gLine = QgsGeometry.fromPolyline( [ QgsPoint(1,1), QgsPoint(2,2) ] )
># buffer with distance 0.5, use 5 segments to approximate curves
>gBuffer = gLine.buffer(0.5, 5)
>print gBuffer.asPolygon()

The buffer() method is a great starting point to create a geoprocessing
plugin. At the moment we want to implement a geoprocessing plugin with
functions like buffer, union, difference etc. At the moment we realised
it with Shapely. But this approach with third party libs is not nice and
would be obsolete when QGIS offers the mentioned methods. QGIS native
methods() based on GEOS would be the much better approach! What are your
plans? Do you plan to implement union(), difference(), intersect() and
relate() as QgsGeometry methods? 

A second question. I want to create a dissolved buffer polygon. To
achieve this it is neccessary to combine all single objects p.e.
LineStrings to one MultiLineString before buffer(). How do I concatenate
single Linstrings into one Multilinestring?

Best Regards
Horst

------------------------------------------------

Dr. Horst Düster
GIS-Koordinator, Stv. Amtschef

Kanton Solothurn
Bau- und Justizdepartement
Amt für Geoinformation
SO!GIS Koordination
Rötistrasse 4
CH-4501 Solothurn

Telefon ++41(0)32 627 25 32
Telefax ++41(0)32 627 22 14

mailto:[EMAIL PROTECTED]
http://www.agi.so.ch



-----Ursprüngliche Nachricht-----
Von: Martin Dobias [mailto:[EMAIL PROTECTED]
Gesendet am: Mittwoch, 16. Januar 2008 23:41
An: Richard Duivenvoorde
Cc: [EMAIL PROTECTED]
Betreff: Re: [Qgis-user] python plugin action vs mode tool

On Jan 16, 2008 8:42 PM, Richard Duivenvoorde <[EMAIL PROTECTED]>
wrote:
>
> My  'problem': I've build a sort of XY-Info tool plugin, like the
raster
> info plugin in the repository. But mine is suppossed to be a tool like
> the zoom tool, or the select tool: you click on the
tool/plugin-button,
> the button gets activated/surpressed/darker, and keeps in that state
> until you select one of the other (zoom, select or info) tools.
Current
> plugin-buttons do not get 'activated', when you click the plugin
button
> it doesn't stay visually(!)'active', it's a clickclack button.

To get the behaviour the only thing you have to do is to call map
tool's setAction() or setButton() method. That will cause that when
the tool is activated/deactivated, the associated action or button
will get selected/delected.

(This behaviour is implemented in QgsMapTool::activate() and
QgsMapTool::deactivate() so that's why it's good to call them also if
you reimplement these methods.)


> But still some details were not clear for me: for example it's not
clear
> for me if you must make a new 'tool' when you want to make a plugin
> which does something with a click in the mapcanvas.

No, you can use ready-made QgsMapToolEmitPoint tool and just connect
to its gotPoint signal.

> Another question is
> the one about keeping a button 'activated'.

I hope that one got answered above.

> My idea is to make some 'plugin-stubs' for different kind of simple
> plugins: eg starting with a very simple plugin which does not have an
> interaction with the map, to a tool like the xy-info tool which must
> handle a mouse click, and finally your copyright-plugin which was
really
> helpful for me.
> But maybe a plugin stubb is not what I'm looking for: it's either to
> complicated because you want to make it technically useful, or it's to
> simple to be functionally useful. The idea was to hand beginners the
> first steps to to a really easy plugin.

Probably the best way would be to create the same "starting" plugin as
the template plugin written in c++.
For the rest I think it's better to use code snippets...

> But maybe we need a code-snippets wiki page with questions like:
> - I want to keep de plugin button activated
> - I want to get hold of the active geometries of the active layer
> - I want to loop through all geometries of this layer
> - How do I test the type of a geometry
> - How do I make pixel coordinates from world coordinates and vice
versa
> - How can I add a label to a (new) layer
> - How can I add a new geometry to a layer
> - How can I keep some project info by writing it to a project file
> etc etc.
> ... I should start this page myself maybe ...

Well, some of those are already on PythonBindings wiki page, however
some are probably missing :)
I'll see what more could I add. For sure you can start a list of such
simple tasks, we could address them with the code snippets.

> ps (referring to my buffer questions a while a go) if you point me to
> some 'easy' buffer algorithms, I'm ready to give C++ a try :-)  )

Uhm, starting from r7986 you can use QgsGeometry::buffer() function
that does exactly what you need :-)
Obligatory snippet:

gLine = QgsGeometry.fromPolyline( [ QgsPoint(1,1), QgsPoint(2,2) ] )
# buffer with distance 0.5, use 5 segments to approximate curves
gBuffer = gLine.buffer(0.5, 5)
print gBuffer.asPolygon()

Enjoy!

Martin
_______________________________________________
Qgis-user mailing list
Qgis-user@lists.qgis.org
http://lists.qgis.org/cgi-bin/mailman/listinfo/qgis-user

_______________________________________________
Qgis-user mailing list
Qgis-user@lists.qgis.org
http://lists.qgis.org/cgi-bin/mailman/listinfo/qgis-user

Reply via email to