[QGIS-Developer] Retrieving error details for when a loaded layer is not valid

2021-11-26 Thread Ricardo Filipe Soares Garcia da
Hi list

When loading a vector layer via Python, is there a way to get a hold of the
error message for when the loading fails?

I can check if the layer is valid or not, but I'd like to get a description
of the error. I see the error on the QGIS log panel, so I'm hoping it is
possible to access it from Python.

```
# a sample of my code
layer = QgsVectorLayer("some-bogus-url", "mylayer", "WFS")
layer.isValid()  # this returns False
```

Thanks in advance!

-- 
___ ___ __
Ricardo Garcia Silva
___
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer


Re: [QGIS-Developer] QGIS API - recent changes to QgsSettings

2021-06-02 Thread Ricardo Filipe Soares Garcia da
Thanks for the feedback.

I've glanced through the QEP and it seems nice. I'll check it out with some
more depth in the coming days.

As for the missing QgsSettings, I must admit I prefer to look at the C++
API docs instead of the Python ones - a bad habit I got from the olden days
;) But now I see that it is there and I was the one looking at the wrong
place.

Cheers

Denis Rouzaud  escreveu no dia quarta, 2/06/2021
à(s) 09:09:

>
>
> Le mar. 1 juin 2021 à 16:43, Ricardo Filipe Soares Garcia da <
> ricardo.garcia.si...@gmail.com> a écrit :
>
>> Hi all
>>
>> I see that settings management in QGIS seems to be changing for the
>> upcoming 3.20 release. I got this clue when consulting the online API docs
>> for master and then realizing there is no QgsSettings class in there
>> anymore.
>>
>
> To complete what Damiano wrote, QgsSettings didn't disappear:
> https://qgis.org/pyqgis/master/core/QgsSettings.html
>
>
>
>> I then searched the commit history on github and found some commits
>> dating from April, which I guess are relevant here:
>>
>>
>> https://github.com/qgis/QGIS/commits?after=415d4831b05cb3821ccbefe0b67307035bc0fb75+34=domi4484
>>
>> Is there some place where I can read about these changes in order to gain
>> some more context on them?
>>
>> I'm interested in knowing how I can support both QGIS LTR and the
>> upcoming 3.20 on plugins. Is QgsSettings gone forever from 3.20 on or is
>> this going to be backwards compatible for a while? If not, what is going to
>> be the new approach for settings management?
>>
>> Thanks in advance
>>
>> --
>> ___ ___ __
>> Ricardo Garcia Silva
>> ___
>> QGIS-Developer mailing list
>> QGIS-Developer@lists.osgeo.org
>> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
>> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
>>
>

-- 
___ ___ __
Ricardo Garcia Silva
___
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer


[QGIS-Developer] QGIS API - recent changes to QgsSettings

2021-06-01 Thread Ricardo Filipe Soares Garcia da
Hi all

I see that settings management in QGIS seems to be changing for the
upcoming 3.20 release. I got this clue when consulting the online API docs
for master and then realizing there is no QgsSettings class in there
anymore.
I then searched the commit history on github and found some commits dating
from April, which I guess are relevant here:

https://github.com/qgis/QGIS/commits?after=415d4831b05cb3821ccbefe0b67307035bc0fb75+34=domi4484

Is there some place where I can read about these changes in order to gain
some more context on them?

I'm interested in knowing how I can support both QGIS LTR and the upcoming
3.20 on plugins. Is QgsSettings gone forever from 3.20 on or is this going
to be backwards compatible for a while? If not, what is going to be the new
approach for settings management?

Thanks in advance

-- 
___ ___ __
Ricardo Garcia Silva
___
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer


Re: [QGIS-Developer] qgis flatpak - how to install additional python packages required by plugins?

2019-02-19 Thread Ricardo Filipe Soares Garcia da
Daniele, all

I've checked the linked issue (and the others too) and it seems like there
isn't much traction to this. I'm just bringing it to attention here on the
list.

>From what I've gathered there is currently no easy way of installing
additional python packages that might be required by plugins when using the
flatpak install.

The flatpak effort seems great, but IMO, without a working strategy for
installation of plugin dependencies it is hard to consider it a viable
approach.

Anyone else has had success rocking the flatpak build with additional
python packges?


Daniele Viganò  escreveu no dia terça, 19/02/2019 à(s)
11:57:

> Here you can find some workarounds and the open discussion about this issue
> https://github.com/flathub/org.qgis.qgis/issues/13
>
>
> Cheers,
> Daniele
>
> ---
> Daniele Viganò
> http://daniele.vigano.me
>
> On mobile, please excuse my brevity.
>
> On Tue, Feb 19, 2019, 12:50 Ricardo Filipe Soares Garcia da <
> ricardo.garcia.si...@gmail.com wrote:
>
>> Hi all
>> I'm using the flatpak version of QGIS and I'd like to install some
>> additional python packages. Is this possible?
>>
>> My current use case is I'd like to install the Time Manager plugin. This
>> requires the `future` package, which I do not have installed. So I want to
>> install it.
>>
>> The flatpak is using its own internal python and I'm not sure how I'd go
>> about pip installing stuff.
>>
>> Looking around the web I couldn't find much info on this. Seems like a
>> tool like flapjack[1] might be usable for this, but it is seeming like
>> overkill.
>>
>> Thanks
>>
>> [1] - https://github.com/endlessm/flapjack
>>
>> --
>> ___ ___ __
>> Ricardo Garcia Silva
>> ___
>> QGIS-Developer mailing list
>> QGIS-Developer@lists.osgeo.org
>> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
>> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
>
>

-- 
___ ___ __
Ricardo Garcia Silva
___
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer

[QGIS-Developer] qgis flatpak - how to install additional python packages required by plugins?

2019-02-19 Thread Ricardo Filipe Soares Garcia da
Hi all
I'm using the flatpak version of QGIS and I'd like to install some
additional python packages. Is this possible?

My current use case is I'd like to install the Time Manager plugin. This
requires the `future` package, which I do not have installed. So I want to
install it.

The flatpak is using its own internal python and I'm not sure how I'd go
about pip installing stuff.

Looking around the web I couldn't find much info on this. Seems like a tool
like flapjack[1] might be usable for this, but it is seeming like overkill.

Thanks

[1] - https://github.com/endlessm/flapjack

-- 
___ ___ __
Ricardo Garcia Silva
___
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer

Re: [QGIS-Developer] Adding Layer tree embedded widgets programmatically

2019-02-13 Thread Ricardo Filipe Soares Garcia da
Hi Richard

You can add widgets to a specific layer if you know the widget provider's
id. It is simply a matter of setting up the relevant custom properties.

Take a look at the code in the PR you linked, more specifically here:

https://github.com/qgis/QGIS/pull/3170/files#diff-0c8d41d794f1b84a1291aa29bb39392aR114


For example, the standard widget that provides a transparency slider has an
id of "transparency". Lets imagine I select the current layer in the canvas
and then want to make this widgets appear in its legend:

```python
layer = iface.activeLayer()
layer.setCustomProperty("embeddedWidgets/count", 1)
layer.setCustomProperty("embeddedWidgets/0/id", "transparency")
iface.layerTreeView().refreshLayerSymbology(layer.id())
```

This code assumes that the layer doesn't currently have any embedded
widgets.


P.S. - Now that I've tried it, it seems that the transparency slider works
differently for raster and vector layers.


Richard Duivenvoorde  escreveu no dia quarta,
13/02/2019 à(s) 11:38:

> Hi Devs,
>
> Thinking about creating a small plugin which would add a 'Layer tree
> embedded widget' to a layer in the legend, I hit:
>
> https://github.com/qgis/QGIS/pull/3170
>
> with a nice example on how to create such a widget (with 2 minor tweaks
> see below).
>
> But my question is if it is possible (in the python plugin) to attach
> such widget to a specific layer? Now it is working but you can only
> activate it via the layerproperties dialog.
>
> I could not find a example or hint for it.
>
> Any pointers appreciated.
>
> Regards,
>
> Richard Duivenvoorde
>
> PS
>
> To make Martins example https://github.com/qgis/QGIS/pull/3170) work in
> QGIS3:
>
> from PyQt4.QtGui import QComboBox
> becomes
> from qgis.PyQt.QtWidgets import QComboBox
>
> QgsLayerTreeEmbeddedWidgetRegistry.instance().addProvider(provider)
> becomes
> QgsGui.layerTreeEmbeddedWidgetRegistry().addProvider(provider)
> ___
> QGIS-Developer mailing list
> QGIS-Developer@lists.osgeo.org
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer



-- 
___ ___ __
Ricardo Garcia Silva
___
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer

[QGIS-Developer] Updating a WMS layer's legend with the same style as the one used by the data provider

2019-02-08 Thread Ricardo Filipe Soares Garcia da
Hi all

I have a working python code snippet that enables updating a WMS layer with
a different named style.

It basically manipulates the raster provider's `dataSourceUri` property,
replacing the `style=` with a different substring. and then it calls for a
reload of the data and triggers a repaint of the layer. Something like this:

```
provider = layer.dataProvider()
original_uri = provider.dataSourceUri()
new_uri = modify_uri(original_uri)
provider.setDataSourceUri(new_uri)
provider.reloadData()
provider.dataChanged.emit()
```

It is working fine and the layer is shown with the updated style. Now I'd
like to have also the layer's legend be refreshed with the correct style.

Is this possible?

I've tried

```
iface.layerTreeView().refreshLayerSymboogy(layer.id())
```

This does not work, I am monitoring the WMS server's logs and I don't see
any new `GetLegendGraphic` request being issued.

Thanks in advance

-- 
___ ___ __
Ricardo Garcia Silva
___
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer

Re: [QGIS-Developer] Adding a panel to layer properties dialog from a python plugin

2018-10-18 Thread Ricardo Filipe Soares Garcia da
Hi Denis, all

I keep forgetting there are now also (totally cool) docs for the python
API... I guess old habits die hard ;)

>From your tip I guess the problem I'm facing is likely related to my class
inheriting from the wrong base ( as I'm not using QgsOptionsPageWidget).

I'll try it out later and let you know ;)

As for the raster layer properties dialog , is this indeed not implemented
there?

Best regards


Denis Rouzaud  escreveu no dia quinta, 18/10/2018
à(s) 01:49:

> Hi Ricardo,
>
> For python, looking at the python API is always a good start ;)
>
> https://qgis.org/pyqgis/master/gui/other/QgisInterface.html#qgis.gui.QgisInterface.registerOptionsWidgetFactory
>
> This means you must give a QgsOptionsWidgetFactory
> https://qgis.org/pyqgis/master/gui/Options/QgsOptionsWidgetFactory.html
>
> Here the docs could be clearer but this is the class you have to inherit.
> You need to implement title, icon and createWidget. In the latter, you'll
> be able to load your UI and return the widget to be displayed. The widget
> you return must inherit QgsOptionsPageWidget.
>
> I hope this helps!
>
>
> Denis
>
> On Wed, 17 Oct 2018, 18:24 Ricardo Filipe Soares Garcia da, <
> ricardo.garcia.si...@gmail.com> wrote:
>
>> Hi all
>>
>> The API docs for QgisInterface[1] mention the existence of a
>> `registerMapLayerConfigWidgetFactory()` method which says in its
>> documentation:
>>
>> > Register a new tab in the vector layer properties dialog.
>>
>> I've been trying to test this out and see if I can add a new panel to a
>> layer's properties dialog via a Python plugin. So far I've had no luck.
>> Couldn't find any other docs/samples online showing how to do this. Perhaps
>> someone can help me out?
>>
>> Here is what I have:
>>
>> -  made a custom .ui file in Qt designer with a simple QWidget that only
>> has a QLabel inside
>> -  implemented a class inheriting from both
>> `qgis.gui.QgsMapLayerConfigWidget` and my ui file (after it is loaded with
>> uic.loadUiType)
>> - implemented a class inheriting from
>> `qgis.gui.QgsMapLayerConfigWidgetFactory`. This class implements all of the
>> methods declared as *virtual* in the cpp API, including the
>> `createWidget()`, which returns a new instance of my custom
>> maplayerconfigwidget class
>> - in my plugin's `initGui()` method I'm calling
>> `iface.registerMapLayerConfigWidgetFactory()` and pass along my custom
>> factory
>>
>> I guess this should be enough to have a minimum working prototype.
>> However, this is what happens:
>>
>> - When I load up a vector layer and then open it's properties dialog,
>> QGIS just crashes with a core dumped message.
>> - When I load up a raster layer and then open it's properties dialog,
>> nothing happens. I suspect this functionality is probably not even
>> available for raster layers. Is this true?
>>
>> Can someone provide some pointers or some existing reference on how this
>> would work? Thanks in advance
>>
>> [1] -
>> https://qgis.org/api/classQgisInterface.html#a2c64949239a7717d181e34d6f2c47851
>>
>> --
>> ___ ___ __
>> Ricardo Garcia Silva
>> ___
>> QGIS-Developer mailing list
>> QGIS-Developer@lists.osgeo.org
>> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
>> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
>
> --
>
> Denis Rouzaud
> de...@opengis.ch  
> +41 76 370 21 22
>
>
>

-- 
___ ___ __
Ricardo Garcia Silva
___
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer

[QGIS-Developer] Adding a panel to layer properties dialog from a python plugin

2018-10-17 Thread Ricardo Filipe Soares Garcia da
Hi all

The API docs for QgisInterface[1] mention the existence of a
`registerMapLayerConfigWidgetFactory()` method which says in its
documentation:

> Register a new tab in the vector layer properties dialog.

I've been trying to test this out and see if I can add a new panel to a
layer's properties dialog via a Python plugin. So far I've had no luck.
Couldn't find any other docs/samples online showing how to do this. Perhaps
someone can help me out?

Here is what I have:

-  made a custom .ui file in Qt designer with a simple QWidget that only
has a QLabel inside
-  implemented a class inheriting from both
`qgis.gui.QgsMapLayerConfigWidget` and my ui file (after it is loaded with
uic.loadUiType)
- implemented a class inheriting from
`qgis.gui.QgsMapLayerConfigWidgetFactory`. This class implements all of the
methods declared as *virtual* in the cpp API, including the
`createWidget()`, which returns a new instance of my custom
maplayerconfigwidget class
- in my plugin's `initGui()` method I'm calling
`iface.registerMapLayerConfigWidgetFactory()` and pass along my custom
factory

I guess this should be enough to have a minimum working prototype. However,
this is what happens:

- When I load up a vector layer and then open it's properties dialog, QGIS
just crashes with a core dumped message.
- When I load up a raster layer and then open it's properties dialog,
nothing happens. I suspect this functionality is probably not even
available for raster layers. Is this true?

Can someone provide some pointers or some existing reference on how this
would work? Thanks in advance

[1] -
https://qgis.org/api/classQgisInterface.html#a2c64949239a7717d181e34d6f2c47851

-- 
___ ___ __
Ricardo Garcia Silva
___
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer

Re: [QGIS-Developer] Using embedded widgets in the layer tree on a python plugin

2018-09-26 Thread Ricardo Filipe Soares Garcia da
Thanks for the feedback.

I've opened the relevant tickets in the bug tracker:

https://issues.qgis.org/issues/19960
https://issues.qgis.org/issues/19964

Might take a stab at a fix myself, if I can spare some free time.


Martin Dobias  escreveu no dia quarta, 26/09/2018 à(s)
20:30:

> Hi Ricardo
>
> Sorry for the delayed answer...
>
> On Mon, Sep 17, 2018 at 12:10 AM Ricardo Filipe Soares Garcia da
>  wrote:
> >
> > This code kind of works, but I'm facing two problems at the moment:
> >
> > 1. The `MyWidgetProvider.supportsLayer()` method is never called. The
> logging call does not show up on the console and I also see that my
> provider is offered on WMS layers, but also on some local vector layers
> (which is not what I intend). grep'ping around the QGIS' source code I
> could not find some place where this method would be called and used, so
> I'm wondering if this is implemented. I would expect this method to be
> called when the layer properties dialog is opened, so that my provider
> would get filtered out for layers that were of the wrong type;
> >
> > 2. This code does not update the legend for the layer, UNLESS it is a
> vector layer. If I try to add this provider to a WMS layer, the legend is
> not updated. If I add it to a shapefile, it works as expected. In order to
> get my QLabel to show up on WMS layers, I have to manually run this in the
> QGIS python shell:
>
> I have looked into the code and figured out that both of these issues
> seem like bugs in the implementation. The supportLayer() method indeed
> seems unused (my test implementation always returned true, that
> explains I haven't realized it was not wired in) and the legend
> refresh of vector layer is probably done by some other part within the
> vector layer properties dialog, while in raster layer properties that
> does not happen. Feel free to report them in the bug tracker...
>
> Cheers
> Martin
>


-- 
___ ___ __
Ricardo Garcia Silva
___
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer

[QGIS-Developer] Using embedded widgets in the layer tree on a python plugin

2018-09-16 Thread Ricardo Filipe Soares Garcia da
Hi all (specially Martin Dobias)

I'm working on a plugin that will use embedded widgets in the layer tree. I
am using the following as reference:

-  Martin's PR that brought this feature into existence (thanks for that
BTW):
https://github.com/qgis/QGIS/pull/3170/files#diff-3b9be845f2ea37602ca451f18acceab4

-  This QGIS dev thread where Martin provides some more detail on how to
refresh the legend:
http://osgeo-org.1560.x6.nabble.com/QgsLayerTreeViewMenuProvider-and-default-values-tt5296424.html#a5296695

-  This stackexchange thread where the transparency slider is discussed:
https://gis.stackexchange.com/questions/232367/showing-transparency-slider-by-default-in-layers-panel-of-qgis

-  The master branch of QGIS' repo

I'm starting out by just showing a simple QLabel in the layer's legend,
just as a proof of concept. I want my plugin to work with OGC services
layers (WMS, WFS, etc), meaning it shall only try to add widgets to layers
that are of these types.

I have roughly the following python code:

```
logger = partial(qgis.utils.QgsMessageLog.logMessage, tag=__name__)

class MyWidgetProvider(
qgis.gui.QgsLayerTreeEmbeddedWidgetProvider):

SUPPORTED_DATA_PROVIDERS = [
"wms",
]

def __init__(self, *args, **kwargs):
logger("Instantiating provider...")
super().__init__(*args, **kwargs)
self.creation_timestamp = int(time.time())

def id(self):
logger("id called")
return "{}_{}".format(self.__class__.__name__,
self.creation_timestamp)

def name(self):
logger("name called")
return "My Widgetss"

def createWidget(self, map_layer, widget_index):
logger("createWidget called")
widget = widgets.QLabel("hi world!")
widget.setAutoFillBackground(True)
return widget

def supportsLayer(self, map_layer):
logger("supportsLayer called")
provider = map_layer.dataProvider()
name = provider.name()
result = True if name in self.SUPPORTED_DATA_PROVIDERS else False
logger("supportsLayer: {}".format(result),
level=qgis.core.Qgis.Debug)
return result
```


This code kind of works, but I'm facing two problems at the moment:

1. The `MyWidgetProvider.supportsLayer()` method is never called. The
logging call does not show up on the console and I also see that my
provider is offered on WMS layers, but also on some local vector layers
(which is not what I intend). grep'ping around the QGIS' source code I
could not find some place where this method would be called and used, so
I'm wondering if this is implemented. I would expect this method to be
called when the layer properties dialog is opened, so that my provider
would get filtered out for layers that were of the wrong type;

2. This code does not update the legend for the layer, UNLESS it is a
vector layer. If I try to add this provider to a WMS layer, the legend is
not updated. If I add it to a shapefile, it works as expected. In order to
get my QLabel to show up on WMS layers, I have to manually run this in the
QGIS python shell:

```
view = iface.layerTreeView()
view.model().refreshLayerLegend(view.currentNode())
```

However, I am not seeing where in my plugin's code can I add this snippet.
I only want the layer tree to be updated AFTER my provider creates the
widget, but this moment seems to be out of my control. Also, I am puzzled
by the fact that vector layers work just fine while my raster (WMS) does
not.


Thanks in advance for your help :)


Best regards

-- 
___ ___ __
Ricardo Garcia Silva
___
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer

Re: [QGIS-Developer] Qt Model-View updates blocked when Python console not open

2017-10-05 Thread Ricardo Filipe Soares Garcia da
Hi Peter

In addition to Matthias' advice perhaps try using QNetworkAccessManager[1]
and related classes in order to deal with your http requests
asynchronously. This should fix the UI blocking issues.

Best regards


[1] -
http://pyqt.sourceforge.net/Docs/PyQt4/qnetworkaccessmanager.html#details


Em 05/10/2017 15:18, "Matthias Kuhn"  escreveu:

Hi Peter,

Have a look at this answer here, which explains how you can trigger the
same behavior without using the print and relying on side-effects of the
console open.

It also outlines the risks involved in using this kind of approach.

https://gis.stackexchange.com/a/257016

Cheers
Matthias


On 10/05/2017 03:25 PM, Peter Devoy wrote:

> Just a little update; it is the fact I am using print() to output
> debug information upon each request which is allowing the UI to
> repaint.  Also, it seems that opening and closing the Python console
> once is enough.
>
> Peter
>
> 3XE
> P: 01326 567155
> M: 07770 693662
> A: 3XE Ltd
> Tremough Innovation Centre
> PENRYN
> TR10 9TA
> 3XE Ltd · Registered in England and Wales · 9356871
>
>
> On 4 October 2017 at 20:53, Peter Devoy  wrote:
>
>> Hi all
>>
>> In my plugin I have extended QAbstractListModel to create a list of
>> objects; each object in the list has a 'url' property containing the
>> URL of an API resource.  When the user selects a feature in main QGIS
>> interface, each object in the list makes a HTTP request to its URL and
>> updates its properties from the response data.
>>
>> Changes in the objects' properties are reflected in a QListView.  E.g.
>> a  property 'status'  is set to 'WARN' if the HTTP request fails --
>> this is reflected in the QListView by the respective list item's icon
>> turning yellow.
>>
>> If I have the Python console open in QGIS the QListView items update
>> as the ListModel's objects update. However, if the Python console is
>> not open, the plugin's UI thread appears to be blocked until each item
>> in the list has completed its changes and all the items update at
>> once; please can anyone recommend a way to avoid this?
>>
>> I have been developing on QGIS 2.1X.
>>
>> Kind regards
>>
>>
>> Peter
>>
> ___
> QGIS-Developer mailing list
> QGIS-Developer@lists.osgeo.org
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
>
>
___
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
___
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer

Re: [QGIS-Developer] Replacing a dialogue with another at runtime with Python

2017-10-03 Thread Ricardo Filipe Soares Garcia da
Hi Dennis

On Tue, Oct 3, 2017 at 3:21 PM, Denis Rouzaud <denis.rouz...@gmail.com>
wrote:

> Hi Ricardo,
>
> Sorry to bother, but I think this kind of hack should be discouraged.
>


No bother at all :)

I am just playing around with some ideas for improving the WMS layer
support. The whole 'hijack QGIS native dialog' thing is just a sidetrack
that is not really my main goal. It just seemed like a wacky, fun idea to
try out. just to see if it is possible!




>
> This modifies QGIS behavior in a hidden way by replacing native dialogs.
> And as you pointed, there is probably no way of uninstalling your plugin
> properly. It will require QGIS to restart to work as expected, which is not
> that bad, but still.
>
> If you think current behavior is not optimal, I would suggest to either:
> * bring your improvements into master instead of a plugin
>


That might be the plan for the long run. For now I'm just having some fun
at lunch break ;)




> * create a dedicated button and menu entry in your plugin for your
> customized dialog
>
> With the latter option, I think it would be possible to add your menu
> entry and button in the layer menu and layer toolbar, respectively.
>


Yeah I am aware there is a proper way to do this, and this is not it. This
is just toying and poking at stuff to see what is possible.
On a more "serious" tone, I agree with you 100%. This is not something that
I'd be putting out there for the world to use.




>
> Just my two cents.
>
> Denis
>
>

Cheers



>
>
>
>
> Le mar. 3 oct. 2017 à 16:09, Ricardo Filipe Soares Garcia da <
> ricardo.garcia.si...@gmail.com> a écrit :
>
>> Hi all
>>
>> Answering my own question for posterity
>>
>> Turns out I can disconnect all slots from a signal by calling
>> `my_action.triggered.disconnect()` without any arguments. My goal of
>> replacing the native QGIS 'Add WMS/WMTS layer' dialogue with another one
>> can be achieved like this:
>>
>> ```python
>>
>> def my_handler():
>> print("Hello")
>>
>> action = iface.actionAddWmsLayer()
>> action.triggered.disconnect()
>> action.triggered.connect(my_handler)
>> ```
>>
>> This leaves another problem to be solved: How to restore the native QGIS
>> dialogue when my would-be plugin is deactivated by the user. The following
>> seems to work on QGIS 2.18:
>>
>> ```
>> provider_registry = qgis.core.QgsProviderRegistry.instance()
>> add_wms_dialog = provider_registry.selectWidget("wms")
>> action.triggered.disconnect()
>> action.triggered.connect(add_wms_dialog.show)
>>
>> ```
>>
>> Best regards
>>
>>
>>
>> On Mon, Oct 2, 2017 at 12:41 PM, Ricardo Filipe Soares Garcia da <
>> ricardo.garcia.si...@gmail.com> wrote:
>>
>>> Hi all
>>>
>>> Is it possible to replace one of QGIS' dialogues with a custom one
>>> during runtime by using Python?
>>>
>>> My concrete goal is to replace the dialogue that shows when clicking the
>>> 'Add WMS/WMTS Layer' with something custom. I'd like to enhance the native
>>> QGIS dialogue with additional elements for selecting additional dimensions,
>>> like time or elevation.
>>>
>>> Can this be done?
>>>
>>> I'm thinking that I'd only have to replace whatever slot is currently
>>> defined on the `iface.actionAddWmsLayer()` action with a custom function
>>> that would load my UI instead. The problem is that I can't seem to find
>>> where a signal's connected slots are stored with Qt.
>>>
>>> Ideally there would be some introspection mechanism by which I'd be able
>>> to retrieve which slots are associated with the action's `triggered` signal
>>> - I can't seem to find it though. After knowing which slot(s) were
>>> connected to the action's signal, I would presumably be able to
>>> `disconnect()` them and then connect my own.
>>>
>>> By looking at Qt's docs I thought that the QMetaObject class might be
>>> the place to look, but I still cannot find anything that looks seems to
>>> hold the registry of a signal's connected slots.
>>>
>>> Thanks in advance :)
>>>
>>>
>>>
>>> --
>>> ___ ___ __
>>> Ricardo Garcia Silva
>>>
>>
>>
>>
>> --
>> ___ ___ __
>> Ricardo Garcia Silva
>> ___
>> QGIS-Developer mailing list
>> QGIS-Developer@lists.osgeo.org
>> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
>> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
>
>


-- 
___ ___ __
Ricardo Garcia Silva
___
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer

Re: [QGIS-Developer] Replacing a dialogue with another at runtime with Python

2017-10-03 Thread Ricardo Filipe Soares Garcia da
Hi all

Answering my own question for posterity

Turns out I can disconnect all slots from a signal by calling
`my_action.triggered.disconnect()` without any arguments. My goal of
replacing the native QGIS 'Add WMS/WMTS layer' dialogue with another one
can be achieved like this:

```python

def my_handler():
print("Hello")

action = iface.actionAddWmsLayer()
action.triggered.disconnect()
action.triggered.connect(my_handler)
```

This leaves another problem to be solved: How to restore the native QGIS
dialogue when my would-be plugin is deactivated by the user. The following
seems to work on QGIS 2.18:

```
provider_registry = qgis.core.QgsProviderRegistry.instance()
add_wms_dialog = provider_registry.selectWidget("wms")
action.triggered.disconnect()
action.triggered.connect(add_wms_dialog.show)

```

Best regards



On Mon, Oct 2, 2017 at 12:41 PM, Ricardo Filipe Soares Garcia da <
ricardo.garcia.si...@gmail.com> wrote:

> Hi all
>
> Is it possible to replace one of QGIS' dialogues with a custom one during
> runtime by using Python?
>
> My concrete goal is to replace the dialogue that shows when clicking the
> 'Add WMS/WMTS Layer' with something custom. I'd like to enhance the native
> QGIS dialogue with additional elements for selecting additional dimensions,
> like time or elevation.
>
> Can this be done?
>
> I'm thinking that I'd only have to replace whatever slot is currently
> defined on the `iface.actionAddWmsLayer()` action with a custom function
> that would load my UI instead. The problem is that I can't seem to find
> where a signal's connected slots are stored with Qt.
>
> Ideally there would be some introspection mechanism by which I'd be able
> to retrieve which slots are associated with the action's `triggered` signal
> - I can't seem to find it though. After knowing which slot(s) were
> connected to the action's signal, I would presumably be able to
> `disconnect()` them and then connect my own.
>
> By looking at Qt's docs I thought that the QMetaObject class might be the
> place to look, but I still cannot find anything that looks seems to hold
> the registry of a signal's connected slots.
>
> Thanks in advance :)
>
>
>
> --
> ___ ___ __
> Ricardo Garcia Silva
>



-- 
___ ___ __
Ricardo Garcia Silva
___
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer

[QGIS-Developer] Replacing a dialogue with another at runtime with Python

2017-10-02 Thread Ricardo Filipe Soares Garcia da
Hi all

Is it possible to replace one of QGIS' dialogues with a custom one during
runtime by using Python?

My concrete goal is to replace the dialogue that shows when clicking the
'Add WMS/WMTS Layer' with something custom. I'd like to enhance the native
QGIS dialogue with additional elements for selecting additional dimensions,
like time or elevation.

Can this be done?

I'm thinking that I'd only have to replace whatever slot is currently
defined on the `iface.actionAddWmsLayer()` action with a custom function
that would load my UI instead. The problem is that I can't seem to find
where a signal's connected slots are stored with Qt.

Ideally there would be some introspection mechanism by which I'd be able to
retrieve which slots are associated with the action's `triggered` signal -
I can't seem to find it though. After knowing which slot(s) were connected
to the action's signal, I would presumably be able to `disconnect()` them
and then connect my own.

By looking at Qt's docs I thought that the QMetaObject class might be the
place to look, but I still cannot find anything that looks seems to hold
the registry of a signal's connected slots.

Thanks in advance :)



-- 
___ ___ __
Ricardo Garcia Silva
___
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer

Re: [QGIS-Developer] OTB 6 and Processing

2017-05-16 Thread Ricardo Filipe Soares Garcia da
It's looking great :)

Having processing algs run in the background will really improve the user
experience IMO.

Having the possibility to use expressions in order to define parameters
dynamically is really awesome too! In your video demo you effectively
turned the fixed distance buffer algorithm into a variable distance buffer
(maybe a hint that we'll need only one of those from now on?) ;)

Keep up the good work!


On Tue, May 16, 2017 at 9:41 AM, Nyall Dawson 
wrote:

> On 16 May 2017 at 18:16, Paolo Cavallini  wrote:
> > Il 16/05/2017 10:08, Rashad Kanavath ha scritto:
> >> Hello Paolo,
> >>
> >> Is the processing plugin ported to c++? or just the core part with
> >> wrappers in python?
> >
> > core in C++, with Python bindings. Nyall can be more precise on this.
>
> That's right. Gui will remain in python. Algs will mostly be python,
> unless they benefit from the speed boost of the native c++ code. All
> the algorithms which rely on external apps will remain Python.
>
> If anyone's curious, here's a video demonstrating the current state of the
> work:
> https://www.youtube.com/watch?v=6DIAc6ATOh0=youtu.be
>
> Not much to get excited about from an end user's perspective yet, but
> what you see here is:
> - a native buffer algorithm, fully written in c++
> - background algorithm execution using task manager
> - the new API which uses a dictionary of algorithm parameters
> - a demo of dynamic property based parameters (will be exposed via the
> UI just like data defined symbols/labels/etc)
>
> Nyall
> ___
> QGIS-Developer mailing list
> QGIS-Developer@lists.osgeo.org
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
>



-- 
___ ___ __
Ricardo Garcia Silva
___
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer

Re: [QGIS-Developer] Converting plugins to QGIS 3

2017-05-10 Thread Ricardo Filipe Soares Garcia da
I generally avoid wildcard imports. Two additional reasons not to use them:

- When you use the wildcard form it is harder for other people (and for
yourself in the future) to know just what it is that you are actually
importing. As such, debugging eventual errors takes more time.

- wildcard imports also increase the chance of having name clashes and of
hiding functions with identical names.

Em 10/05/2017 20:38, "Raymond Nijssen"  escreveu:

> Hi Calvin,
>
> Here are some thoughts on python imports:
>
> https://www.python.org/dev/peps/pep-0008/#imports
>
> The last paragraph is about using wildcards.
>
> Raymond
>
> On 10-05-17 20:03, C Hamilton wrote:
>
>> I am wondering how important it is to import the modules separately.
>> Such as:
>>
>> from qgis.core import QGis, QgsCoordinateTransform, QgsRectangle,
>> QgsPoint, QgsGeometry
>>
>> Does it really make a difference? I am finding that you have to make
>> sure every part of your code is exercised so that nothing was missed. By
>> doing the above there is more of a chance to have a bug. Perhaps for
>> PyQt4.QtGui it makes sense, but there is less chance to have a python
>> error if you keep.
>>
>> from qgis.core import *
>> from PyQt4.QtGui import *
>> from qgis.gui import *
>>
>> Thoughts?
>>
>> Thanks,
>>
>> Calvin
>>
>>
>>
>> On Wed, May 10, 2017 at 12:00 PM, Luigi Pirelli > > wrote:
>>
>> this is a slide about plugin porting I'll be presenting to the next
>> spanish foss4g:
>> http://slides.com/luigipirelli/desdarrolloplugindeqgis-xi-girona#/17
>> > >
>> sorry it's in spanish
>>
>> about
>>
>> from PyQt4 import QtGui
>>
>> or
>>
>> from PyQt4.QtGui import QDialog
>>
>> I would prefer the second so to avoid to postpone lib version errors
>> at pyc time and not at runtime.
>> it make it simpler to mock or alias a class globally if you need
>>
>> regards
>> Luigi Pirelli
>>
>> 
>> **
>> * Boundless QGIS Support/Development: lpirelli AT boundlessgeo DOT com
>> * LinkedIn: https://www.linkedin.com/in/luigipirelli
>> 
>> * Stackexchange:
>> http://gis.stackexchange.com/users/19667/luigi-pirelli
>> 
>> * GitHub: https://github.com/luipir
>> * Mastering QGIS 2nd Edition:
>> *
>> https://www.packtpub.com/big-data-and-business-intelligence/
>> mastering-qgis-second-edition
>> > /mastering-qgis-second-edition>
>> 
>> **
>>
>>
>>
>> ___
>> QGIS-Developer mailing list
>> QGIS-Developer@lists.osgeo.org
>> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
>> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
>>
>>
> ___
> QGIS-Developer mailing list
> QGIS-Developer@lists.osgeo.org
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
___
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer

Re: [Qgis-developer] Sandboxing python

2016-10-17 Thread Ricardo Filipe Soares Garcia da
My two cents:

Personally I see this whole sandbox thing as being more suitable for the
application as a whole and not specifically for the python plugins part. As
such, it seems to me that sandboxing would be a job better suited for the
OS that is running apps, and not for the apps themselves. This is what is
happening on mobile apps, and is also the direction new distribution
formats for linux such as snaps and flatpak are heading.

I'd be bummed if, as a plugin author, I'd be able to do less stuff with a
machine's resources than the core QGIS code. I mean the great thing about
QGIS' plugins is that you can use Python + QT + QGIS API in order to do
magical stuff. If all of a sudden plugins cannot access the filesystem, or
do web requests or access some sensor's output while core QGIS can still do
those things it would be less attractive to write plugins and to use QGIS
as a general GIS platform.

On a more practical note, sandboxing just for the Python side seems like a
ton of work in an area that is not related to the core QGIS mission and
that requires highly specialized talent.

Regards




On Mon, Oct 17, 2016 at 11:53 AM, Geo DrinX  wrote:

>
>
> 2016-10-17 12:35 GMT+02:00 Nathan Woodrow :
>
>> And Qt.
>>
>> On Mon, Oct 17, 2016 at 8:35 PM, Nathan Woodrow 
>> wrote:
>>
>>> Yes I have read it, however we don't run on PyPy, we use CPython.
>>>
>>>
> So for you,  there is no chance to implement a good python sandbox in
> QGIS,
> at least in the short term ?
>
> Okay, well good to know.
>
> Regards
>
> Geo
>
>
>
> ___
> Qgis-developer mailing list
> Qgis-developer@lists.osgeo.org
> List info: http://lists.osgeo.org/mailman/listinfo/qgis-developer
> Unsubscribe: http://lists.osgeo.org/mailman/listinfo/qgis-developer
>



-- 
___ ___ __
Ricardo Garcia Silva
___
Qgis-developer mailing list
Qgis-developer@lists.osgeo.org
List info: http://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: http://lists.osgeo.org/mailman/listinfo/qgis-developer

Re: [Qgis-developer] QGIS 3 plugins - require implementation as processing algs?

2016-09-12 Thread Ricardo Filipe Soares Garcia da
+1 it is a great idea. I've been teaching a few training courses on Python
and QGIS for prospecting plugin writers and I'm always reccommending
creating new plugins via processing rather than standalone (after going
through what is possible and what is not).

The main issue here, in my opinion, is the lack of documentation on
processing. In my training courses I usually provide a UML class diagram
with the main classes of processing and then direct people directly to the
source code at github. I think this scares them a bit, but I haven't found
a better way.

What about improving  processing's docstrings with more detail and then
including them in the QGIS docs site as Sphinx docs?
I can volunteer to help out with writing some of these docstrings, if
needed.

Best regards

On Monday, September 12, 2016, Paolo Cavallini 
wrote:
> Il 12/09/2016 08:22, Alexander Bruy ha scritto:
>> +1 from me too.
>>
>> As Victor said we already have enough documentation and
>> there are many Processing providers in our repo which can
>> be used as examples.
>
> Hi,
> sure, we just have to make all this very easy to find and follow.
> Thanks.
>
> --
> Paolo Cavallini - www.faunalia.eu
> QGIS & PostGIS courses: http://www.faunalia.eu/training.html
> ___
> Qgis-developer mailing list
> Qgis-developer@lists.osgeo.org
> List info: http://lists.osgeo.org/mailman/listinfo/qgis-developer
> Unsubscribe: http://lists.osgeo.org/mailman/listinfo/qgis-developer

-- 
___ ___ __
Ricardo Garcia Silva
___
Qgis-developer mailing list
Qgis-developer@lists.osgeo.org
List info: http://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: http://lists.osgeo.org/mailman/listinfo/qgis-developer

[Qgis-developer] hub.qgis.org and storing plugin source code repositories

2014-04-20 Thread Ricardo Filipe Soares Garcia da
Hi list

hub.qgis.org seems to be broken for people who want to use it as a
repository for plugin's source code.

I'm having problems with it since almost a year:

http://osgeo-org.1560.x6.nabble.com/using-hub-qgis-org-git-repository-td5057063.html

and there are also several tickets related to it:

http://hub.qgis.org/issues/9741
http://hub.qgis.org/issues/5969
http://hub.qgis.org/issues/4890

Currently there isn't even a way to manage SSH keys on the GUI, so it is
impossible to use it as a source code repository.

What is the word on this? Is hub.qgis.org no longer the preferred place to
store plugin's source code?

-- 
___ ___ __
Ricardo Garcia Silva
___
Qgis-developer mailing list
Qgis-developer@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-developer

Re: [Qgis-developer] how to distribute Processing modules?

2013-09-15 Thread Ricardo Filipe Soares Garcia da
Hi Victor

In this case I don't think it is useful if you add the models to the
default install because they are all meant use this plugin's GeoAlgorithms
to do some composite analysis.

For this reason I'd like to bundle them together with the plugin.

I guess I can post them in the plugin's page and let users download them as
needed.

In the future I'd like to make them available in this new platform for
sharing QGIS related stuff.

Sounds reasonable?

Best regards


On Sun, Sep 15, 2013 at 10:48 AM, Victor Olaya vola...@gmail.com wrote:

 Ricardo

 There is a project going on now for creating a platform for sharing
 resources. in QGIS. Models are clearly a good item to share in there.

 I am lookng for example models to add to Processing so if you can send
 them to me I can add them in the [example models] category. They will
 be useful for other people to study them and run them. I think this is
 the best way of distributing them. If the number of example models is
 high I might even classify them differently.

 Thanks!

 Victor


 2013/9/15 Ricardo Filipe Soares Garcia da ricardo.garcia.si...@gmail.com
 :
  Sorry for the noise, but this message's title should say 'how to
 distribute
  Processing models' instead of modules...
 
 
  On Sun, Sep 15, 2013 at 2:39 AM, Ricardo Filipe Soares Garcia da
  ricardo.garcia.si...@gmail.com wrote:
 
  Hi list
 
  I am building a plugin for Processing (former Sextante). Besides the
  GeoAlgorithms,  I'd like to include some ready-made models along with
 the
  plugin.
 
  Is this feasible? How to do it?
 
  I am currently using a 'models' subdir under my plugin's code with the
  models.
 
  It seems I should be able to register the models with processing's own
  ModelerAlgorithmProvider, but I am missing something
 
  # python code
  alg = ModelerAlgorithm()
  alg.openModel('path_to_model_file')
  modeler_provider = Processing.modeler
  modeler_provider.algs.append(alg)
  Processing.updateProviders()
 
  When running the above from the Python console I get no errors. But the
  Processing Toolbox does not show my models.
 
  What am I missing?
 
  Is there another way to do this? Is including models in plugins a nice
 way
  of distributing them? In this case it seems like a good thing, beacuse I
  want to provide some examples on how the plugin can be used.
 
  Best regards
 
  --
  ___ ___ __
  Ricardo Garcia Silva
 
 
 
 
  --
  ___ ___ __
  Ricardo Garcia Silva
 
  ___
  Qgis-developer mailing list
  Qgis-developer@lists.osgeo.org
  http://lists.osgeo.org/mailman/listinfo/qgis-developer




-- 
___ ___ __
Ricardo Garcia Silva
___
Qgis-developer mailing list
Qgis-developer@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-developer

[Qgis-developer] how to distribute Processing modules?

2013-09-14 Thread Ricardo Filipe Soares Garcia da
Hi list

I am building a plugin for Processing (former Sextante). Besides the
GeoAlgorithms,  I'd like to include some ready-made models along with the
plugin.

Is this feasible? How to do it?

I am currently using a 'models' subdir under my plugin's code with the
models.

It seems I should be able to register the models with processing's own
ModelerAlgorithmProvider, but I am missing something

# python code
alg = ModelerAlgorithm()
alg.openModel('path_to_model_file')
modeler_provider = Processing.modeler
modeler_provider.algs.append(alg)
Processing.updateProviders()

When running the above from the Python console I get no errors. But the
Processing Toolbox does not show my models.

What am I missing?

Is there another way to do this? Is including models in plugins a nice way
of distributing them? In this case it seems like a good thing, beacuse I
want to provide some examples on how the plugin can be used.

Best regards

-- 
___ ___ __
Ricardo Garcia Silva
___
Qgis-developer mailing list
Qgis-developer@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-developer

Re: [Qgis-developer] how to distribute Processing modules?

2013-09-14 Thread Ricardo Filipe Soares Garcia da
Sorry for the noise, but this message's title should say 'how to distribute
Processing models' instead of modules...


On Sun, Sep 15, 2013 at 2:39 AM, Ricardo Filipe Soares Garcia da 
ricardo.garcia.si...@gmail.com wrote:

 Hi list

 I am building a plugin for Processing (former Sextante). Besides the
 GeoAlgorithms,  I'd like to include some ready-made models along with the
 plugin.

 Is this feasible? How to do it?

 I am currently using a 'models' subdir under my plugin's code with the
 models.

 It seems I should be able to register the models with processing's own
 ModelerAlgorithmProvider, but I am missing something

 # python code
 alg = ModelerAlgorithm()
 alg.openModel('path_to_model_file')
 modeler_provider = Processing.modeler
 modeler_provider.algs.append(alg)
 Processing.updateProviders()

 When running the above from the Python console I get no errors. But the
 Processing Toolbox does not show my models.

 What am I missing?

 Is there another way to do this? Is including models in plugins a nice way
 of distributing them? In this case it seems like a good thing, beacuse I
 want to provide some examples on how the plugin can be used.

 Best regards

 --
 ___ ___ __
 Ricardo Garcia Silva




-- 
___ ___ __
Ricardo Garcia Silva
___
Qgis-developer mailing list
Qgis-developer@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-developer

[Qgis-developer] iteration over a layer's features in python plugins

2013-06-17 Thread Ricardo Filipe Soares Garcia da
Hi list

When building plugins that operate on vector layers, it is a common pattern
to include a checkbox in the plugin's GUI where the user can choose to
perform the plugin analysis on the whole layer or just using the currently
selected features (see for example most fTools dialogs).

However, I think the QGIS API does not make the implementation of this
pattern as easy as it could be. The QgsVectorLayer.getFeatures() method
returns an iterator but the QgsVectorLayer.selectedFeatures() returns a
list. It would be nice if they both returned an iterator.

When working with all the features in a layer, I  use:

feat = QgsFeature()
feat_iterator = v_layer.getFeatures()
while feat_iterator.nextFeature(feat):
# do stuff with the feature

When working with only the currently selected features the code is like:

selected_feats = v_layer.selectedFeatures()
for feat in selected_feats:
# do stuff with the feature

Since QgsVectorLayer.getFeatures can take a QgsFeatureRequest as argument,
I think a nice solution could be to add one more filter to
QgsFeatureRequest to allow iterating over a list of feature ids. It
currently already allows to pass in a single feature id, it would just be a
matter of expanding that.

In the meantime I am using a custom iterator class[1] in Python that wraps
this different behaviour and lets me use the same logic for processing the
whole layer or just the selected features. I think it would be cleaner if
this could be done on the API side.

Maybe I am asking for too much too late because of the feature freeze for
2.0?


[1] - (see the FeatureIterator class)
https://github.com/ricardogsilva/coneforinputs/blob/master/coneforinputs.py


-- 
___ ___ __
Ricardo Garcia Silva
___
Qgis-developer mailing list
Qgis-developer@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-developer


Re: [Qgis-developer] iteration over a layer's features in python plugins

2013-06-17 Thread Ricardo Filipe Soares Garcia da
 I've got that functionality ready in a separate branch but it will have
 to wait for 2.1 due to the feature freeze as you mentioned


Great! Will be looking forward to it then :)


-- 
___ ___ __
Ricardo Garcia Silva
___
Qgis-developer mailing list
Qgis-developer@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-developer


Re: [Qgis-developer] iteration over a layer's features in python

2013-06-17 Thread Ricardo Filipe Soares Garcia da
Thanks for the tip Nathan!

I thought the while loop was necessary because we had to call
QgsFeatureIterator.nextFeature() and just now realized that the for loop
will do it implicitly. I thought that would work only for python
iterators... I guess QgsFeatureIterator is one of them ;)



On Mon, Jun 17, 2013 at 6:33 PM, Nathan Woodrow madman...@gmail.com wrote:

  plugins
 MIME-Version: 1.0
 Content-Type: multipart/mixed;
 boundary3430773931903739203==

 --===3430773931903739203==
 Content-Type: multipart/alternative; boundary=089e0102eaa65b15f904df59d6c1

 --089e0102eaa65b15f904df59d6c1
 Content-Type: text/plain; charset=utf-8
 Content-Transfer-Encoding: 7bit

 You don't need go use a while, I don't know why people keep using that
 pattern when a simple for will do and is cleaner.

 For f in layer.getFeatures:

 No it just comes down to

 If selected:
 features = layers.selectedFeatures()[]
 Else:
 features = layer.getFeatures()
 From: Ricardo Filipe Soares Garcia da
 Sent: 17/06/2013 11:47 PM
 To: qgis-developer@lists.osgeo.org
 Subject: [Qgis-developer] iteration over a layer's features in python
 plugins
 Hi list

 When building plugins that operate on vector layers, it is a common pattern
 to include a checkbox in the plugin's GUI where the user can choose to
 perform the plugin analysis on the whole layer or just using the currently
 selected features (see for example most fTools dialogs).

 However, I think the QGIS API does not make the implementation of this
 pattern as easy as it could be. The QgsVectorLayer.getFeatures() method
 returns an iterator but the QgsVectorLayer.selectedFeatures() returns a
 list. It would be nice if they both returned an iterator.

 When working with all the features in a layer, I  use:

 feat = QgsFeature()
 feat_iterator = v_layer.getFeatures()
 while feat_iterator.nextFeature(feat):
 # do stuff with the feature

 When working with only the currently selected features the code is like:

 selected_feats = v_layer.selectedFeatures()
 for feat in selected_feats:
 # do stuff with the feature

 Since QgsVectorLayer.getFeatures can take a QgsFeatureRequest as argument,
 I think a nice solution could be to add one more filter to
 QgsFeatureRequest to allow iterating over a list of feature ids. It
 currently already allows to pass in a single feature id, it would just be a
 matter of expanding that.

 In the meantime I am using a custom iterator class[1] in Python that wraps
 this different behaviour and lets me use the same logic for processing the
 whole layer or just the selected features. I think it would be cleaner if
 this could be done on the API side.

 Maybe I am asking for too much too late because of the feature freeze for
 2.0?


 [1] - (see the FeatureIterator class)
 https://github.com/ricardogsilva/coneforinputs/blob/master/coneforinputs.py


 --
 ___ ___ __
 Ricardo Garcia Silva

 --089e0102eaa65b15f904df59d6c1
 Content-Type: text/html; charset=utf-8
 Content-Transfer-Encoding: quoted-printable

 htmlheadmeta content=3Dtext/html; charset=3Dutf-8
 http-equiv=3DCont=
 ent-Type/headbodydivdiv style=3Dfont-family: Calibri,sans-serif;
 =
 font-size: 11pt;You don't need go use a while, I don't know why people
 ke=
 ep using that pattern when a simple for will do and is cleaner.brbrFor
 =
 f in layer.getFeatures:brbrNo it just comes down tobrbrIf
 selected:=
 brnbsp;nbsp;nbsp; features =3D
 layers.selectedFeatures()[]brElse:br=
 nbsp;nbsp;nbsp; features =3D
 layer.getFeatures()br/div/divhrsp=
 an style=3Dfont-family: Tahoma,sans-serif; font-size: 10pt; font-weight:
 b=
 old;From: /spanspan style=3Dfont-family: Tahoma,sans-serif;
 font-size=
 : 10pt;Ricardo Filipe Soares Garcia da/spanbrspan
 style=3Dfont-fami=
 ly: Tahoma,sans-serif; font-size: 10pt; font-weight: bold;Sent:
 /spans=
 pan style=3Dfont-family: Tahoma,sans-serif; font-size: 10pt;17/06/2013
 1=
 1:47 PM/spanbrspan style=3Dfont-family: Tahoma,sans-serif;
 font-size:=
  10pt; font-weight: bold;To: /spanspan style=3Dfont-family:
 Tahoma,sa=
 ns-serif; font-size: 10pt;qgis-developer@lists.osgeo.org/spanbrspan
 =
 style=3Dfont-family: Tahoma,sans-serif; font-size: 10pt; font-weight:
 bold=
 ;Subject: /spanspan style=3Dfont-family: Tahoma,sans-serif;
 font-size=
 : 10pt;[Qgis-developer] iteration over a layer's features in python
 plugi=
 ns/spanbrbr/body/htmldiv dir=3DltrHi
 listdivbr/divdiv=
 When building plugins that operate on vector layers, it is a common
 pattern=
  to include a checkbox in the plugin#39;s GUI where the user can choose
 to=
  perform the plugin analysis on the whole layer or just using the
 currently=
  selected features (see for example most fTools dialogs)./div

 divbr/divdivHowever, I think the QGIS API does not make the
 impleme=
 ntation of this pattern as easy as it could be. The
 QgsVectorLayer.getFeatu=
 res() method returns an iterator but the QgsVectorLayer.selectedFeatures()
 =
 returns a list. It would be nice

[Qgis-developer] Showing a help page on plugins

2013-06-17 Thread Ricardo Filipe Soares Garcia da
Hi list

What is the recommended way to show a help dialog in a plugin?

The pyqgis cookbook[1] advises using the qgis.utils.showPluginHelp()
function. However, this function calls iface.openURL(), which logs a
DeprecationWarning, so I guess it should not be used anymore.

Is there another recommended way?

[1] - http://qgis.org/pyqgis-cookbook/plugins.html#documentation

-- 
___ ___ __
Ricardo Garcia Silva
___
Qgis-developer mailing list
Qgis-developer@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-developer


[Qgis-developer] New plugin manager and plugin errors

2013-06-11 Thread Ricardo Filipe Soares Garcia da
Hello list

When dealing with plugins with broken code, as is my current case, while
updating to the new SIP API, the new plugin manager (which is super nice,
by the way) will only show a portion of the error.

In my case I get an 'invalid syntax' message, which does not include the
line number anymore (like the old plugin manager) so that I can easily find
it.

Is there a way to get the full output of the error? If not, can I ask that
this be re-added?

Thanks

-- 
___ ___ __
Ricardo Garcia Silva
___
Qgis-developer mailing list
Qgis-developer@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-developer


Re: [Qgis-developer] New plugin manager and plugin errors

2013-06-11 Thread Ricardo Filipe Soares Garcia da
Nevermind... I just add to click to enable the plugin and it showed me the
error just as the old plugin manager. Sorry for the noise.


On Tue, Jun 11, 2013 at 11:10 PM, Ricardo Filipe Soares Garcia da 
ricardo.garcia.si...@gmail.com wrote:

 Hello list

 When dealing with plugins with broken code, as is my current case, while
 updating to the new SIP API, the new plugin manager (which is super nice,
 by the way) will only show a portion of the error.

 In my case I get an 'invalid syntax' message, which does not include the
 line number anymore (like the old plugin manager) so that I can easily find
 it.

 Is there a way to get the full output of the error? If not, can I ask that
 this be re-added?

 Thanks

 --
 ___ ___ __
 Ricardo Garcia Silva




-- 
___ ___ __
Ricardo Garcia Silva
___
Qgis-developer mailing list
Qgis-developer@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-developer


Re: [Qgis-developer] using hub.qgis.org git repository

2013-06-02 Thread Ricardo Filipe Soares Garcia da
Hi

I still cannot configure a repository for this project on hub.qgis.org

When running git remote -v I get:

ricardo@portatil:~/.qgis2/python/plugins/coneforinputs$ git remote -v
origingito...@qgis.org:coneforinputs.git (fetch)
origingito...@qgis.org:coneforinputs.git (push)

I think this is the expected result.

I've added myself as a developer on the project's settings. And configured
git to be the SCM.
When accessing the 'Repository' tab on redmine I am shown a page that says:

Repository does not exist. Create one using the instructions below.
...

Following the instructions, I've added my SSH public key again (and again)
to my redmine profile. I've tried various combinations appending my e-mail
address to it and not. The result is always the same. git asks me for a
passowrd when I try to git push to the remote and then fails with
permission denied.

What could be the problem?

On Thu, May 30, 2013 at 11:50 PM, Alex Mandel tech_...@wildintellect.comwrote:

 On 05/30/2013 03:42 PM, Ricardo Filipe Soares Garcia da wrote:

 Hi list

 I created a new plugin in hub.qgis.org and I'd like to use a git
 repository. I've done this in the past and had no problems but now I am
 having dificulties pushing the initial commit to gitosis.qgis.org

 In redmine I created the repository and added my SSH key. Then I
 initialized my git repo locally and added the remote repo using the URL
 that redmine gave me. I did my first commit and now I want to push it to
 the remote repository. I keep getting an error about not having permission
 when I input my password.

 What could be the problem?

 Must I first upload the code and ask for approval in order to get the
 remote repository created?

 The plugin's name is 'Conefor inputs'.


 The first sign the something isn't right is if gitosis asks you for a
 password. It uses ssh keys which at most will ask you to unlock your local
 passphrase for the key in use.

 Can you please list the git commands you ran.
 Also what's the output of:
 git remote -v

 Thanks,
 Alex




-- 
___ ___ __
Ricardo Garcia Silva
___
Qgis-developer mailing list
Qgis-developer@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-developer


[Qgis-developer] using hub.qgis.org git repository

2013-05-30 Thread Ricardo Filipe Soares Garcia da
Hi list

I created a new plugin in hub.qgis.org and I'd like to use a git
repository. I've done this in the past and had no problems but now I am
having dificulties pushing the initial commit to gitosis.qgis.org

In redmine I created the repository and added my SSH key. Then I
initialized my git repo locally and added the remote repo using the URL
that redmine gave me. I did my first commit and now I want to push it to
the remote repository. I keep getting an error about not having permission
when I input my password.

What could be the problem?

Must I first upload the code and ask for approval in order to get the
remote repository created?

The plugin's name is 'Conefor inputs'.


-- 
___ ___ __
Ricardo Garcia Silva
___
Qgis-developer mailing list
Qgis-developer@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-developer


[Qgis-developer] How to get project's CRS in Python

2013-05-29 Thread Ricardo Filipe Soares Garcia da
Hi list

How could I extract the current project's CRS from python?

I've tried looking for it in QSettings but came up short. Mybe somewhere in
QgsProject? I can't figure out how to use the readListEntry() method though.

Thanks

-- 
___ ___ __
Ricardo Garcia Silva
___
Qgis-developer mailing list
Qgis-developer@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-developer


Re: [Qgis-developer] Adding features with an editing buffer - undo action unavailable in the GUI?

2012-05-23 Thread Ricardo Filipe Soares Garcia da
Thanks Martin
It's working fine now!

On Tue, May 22, 2012 at 8:35 PM, Martin Dobias wonder...@gmail.com wrote:
 On Mon, May 21, 2012 at 1:26 AM, Ricardo Filipe Soares Garcia da
 ricardo.garcia.si...@gmail.com wrote:
 Hi list

 I am writing a plugin that creates new features. According to the
 pyqgis cookbook[0], and the API docs[1], when I call the addFeatures
 method on a QgsVectorLayer, the features should get added to the
 layers editing buffer. It is my understanding that this action ought
 to be undo-able, since the changes haven't been commited yet. But the
 undo icon in the QGIS GUI doesn't seem to be aware of the changes that
 the plugin is making to the layer. Do I have to hook up the changes to
 the undo/redo stack myself? How can I do this?

 Ooops, it seems that some documentation is missing! I have just added
 some notes to PyQGIS cookbook, hope that helps:
 https://github.com/qgis/QGIS-Developer-Cookbook/commit/869c9e19af3278f67770895326fb9fbcfeece848


 Also, when I press the 'toggle editing' button in the digitizing
 toolbar, in order to save the changes I am getting a strange
 behaviour:

 - If I choose to save my changes, everything goes fine,
 - If I choose to close without saving, QGIS crashes with:

 Fatal: ASSERT: mAddedFeatures.isEmpty() in file
 /home/ricardo/dev/Quantum-GIS/src/core/qgsvectorlayer.cpp, line 3982

 That's a check to ensure that the undo stack is working properly - it
 will not crash if you wrap it into the edit commands.

 Martin



-- 
___ ___ __
Ricardo Garcia Silva
___
Qgis-developer mailing list
Qgis-developer@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-developer


[Qgis-developer] Adding features with an editing buffer - undo action unavailable in the GUI?

2012-05-20 Thread Ricardo Filipe Soares Garcia da
Hi list

I am writing a plugin that creates new features. According to the
pyqgis cookbook[0], and the API docs[1], when I call the addFeatures
method on a QgsVectorLayer, the features should get added to the
layers editing buffer. It is my understanding that this action ought
to be undo-able, since the changes haven't been commited yet. But the
undo icon in the QGIS GUI doesn't seem to be aware of the changes that
the plugin is making to the layer. Do I have to hook up the changes to
the undo/redo stack myself? How can I do this?

The code is available on github[2], and here is an excerpt:

def create_point(self):
layer = self.canvas.currentLayer()
point = self.calculate_point() # returns a QgsPoint
f = qgis.core.QgsFeature()
geom = qgis.core.QgsGeometry.fromPoint(point)
f.setGeometry(geom)
layer.addFeatures([f], False)
self.canvas.refresh()


Please note that the new feature is being created successfully. I just
want the user to have the ability to undo the feature creation.

Also, when I press the 'toggle editing' button in the digitizing
toolbar, in order to save the changes I am getting a strange
behaviour:

- If I choose to save my changes, everything goes fine,
- If I choose to close without saving, QGIS crashes with:

Fatal: ASSERT: mAddedFeatures.isEmpty() in file
/home/ricardo/dev/Quantum-GIS/src/core/qgsvectorlayer.cpp, line 3982

and a lot more output in the stacktrace.

Thanks for you help!


[0] - 
http://www.qgis.org/pyqgis-cookbook/vector.html#modifying-vector-layers-with-an-editing-buffer
[1] - 
http://qgis.org/api/classQgsVectorLayer.html#a9936fbfbd69efc6583062e16c6c219ed
[2] - https://github.com/ricardogsilva/geomtools

-- 
___ ___ __
Ricardo Garcia Silva
___
Qgis-developer mailing list
Qgis-developer@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-developer


Re: [Qgis-developer] how to create a new geometry from an existing one with python

2012-05-13 Thread Ricardo Filipe Soares Garcia da
Thanks
I got it working now!
I now have a different doubt, regarding geometry vertex iteration
(sending another e-mail with it).

On Sun, May 13, 2012 at 9:24 AM, Martin Dobias wonder...@gmail.com wrote:
 Hi Ricardo

 On Sun, May 13, 2012 at 1:39 AM, Ricardo Filipe Soares Garcia da
 ricardo.garcia.si...@gmail.com wrote:
 [...]

 # python code

 line_geometry =
 qgis.utils.iface.mapCanvas().currentLayer().selectedFeatures()[-1].geometry()

 # approach 1
 new_geometry = QgsGeometry(line_geometry)

 This approach is correct (and other seems to be fine, too). The
 problem is elsewhere: you are being bitten by this bug:
 http://hub.qgis.org/issues/777

 Basically the problem is that the feature containing the line_geometry
 gets deleted when the first line is executed. So your line_geometry
 contains an invalid pointer leading to these strange errors. To
 overcome this, store the list of features and then access it without
 problems...

 Regards
 Martin



-- 
___ ___ __
Ricardo Garcia Silva
___
Qgis-developer mailing list
Qgis-developer@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-developer


[Qgis-developer] How to iterate over the vertices of a geometry from python

2012-05-13 Thread Ricardo Filipe Soares Garcia da
Hi list

I'm trying to translate and rotate a geometry using python, in order
to create parallel lines.

For the translation I could use QgsGeometry's translate() method, but
for the rotation I haven't found a ready-made solution. So my current
strategy is to individually rotate each vertex, according to a
specified angle and length. For this i'd like to iterate over the
geometry's vertices.

The problem seems to be that the api methods that return vertex
coordinates (vertexAt(), adjacentVertices, ...) always return a value
even if the specified vertex index is wrong. For example, if I use a
geometry with 5 vertices and call:

geometry.vertexAt(100)

- (0,0)

I cannot know if there is a vertex placed at the (0, 0) coordinates or
if there is no vertex at all.
Is there some way to iterate over a geometry's vertices? Or maybe get
an exception when asking for an invalid one?

Thanks


-- 
___ ___ __
Ricardo Garcia Silva
___
Qgis-developer mailing list
Qgis-developer@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-developer


[Qgis-developer] how to create a new geometry from an existing one with python

2012-05-12 Thread Ricardo Filipe Soares Garcia da
Hi list

I'm trying to code some tools for working with lines layers using
python. One such tool is meant to create parallel lines.
I am trying to create my new line geometry by first copying the
geometry of a previously selected linestring and then translating it
according to a specified distance.
But I can't seem to find the correct way of copying the geometry.

I am on Ubuntu 11.10, using QGIS compiled from master #033d58d, built today.
For testing, I'm using layers created with the 'New Memory Layer'
plugin, which uses the memory provider.

I've tried the following approaches:

# python code

line_geometry =
qgis.utils.iface.mapCanvas().currentLayer().selectedFeatures()[-1].geometry()

# approach 1
new_geometry = QgsGeometry(line_geometry)

- Exception: unknown

# approach 2
new_geometry = QgsGeometry.fromPolyline(line_geometry.asPolyline())

- no error is thrown, but nothing happens

# approach 3

wkb = line_geometry.asWkb()
g.fromWkb(wkb, len(wkb))

- RuntimeError: underlying C/C++ object has been deleted

Thanks for your input!

-- 
___ ___ __
Ricardo Garcia Silva
___
Qgis-developer mailing list
Qgis-developer@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-developer


Re: [Qgis-developer] profile from line: 2 issues

2012-02-07 Thread Ricardo Filipe Soares Garcia da
Hi Paolo

Thanks for your reports, I am the author of this plugin. I'll be
looking into the mentioned issues in a short while.

I am using hub.qgis.org for this plugin, so feel free to open new
tickets there in the future. For these issues I will do it myself.

 - it is important (and does not look too difficult) to add a plot of the
 profile, which is what users want.

This is a new feature request. I guess I can try to add this feature,
although the really cool thing would be a shiny new plugin for
plotting all kinds of charts using vector and raster values - any
takers? I've been wanting to do something like this for ages (see my
infant chartMaker plugin for a start) but haven't been able to focus
on it.

Best regards


-- 
___ ___ __
Ricardo Garcia Silva
___
Qgis-developer mailing list
Qgis-developer@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-developer


Re: [Qgis-developer] profile from line: 2 issues

2012-02-07 Thread Ricardo Filipe Soares Garcia da
Hi Paolo

 One more:


 Traceback (most recent call last):
  File C:\Documents and Settings\eleauser/.
 qgis/python/plugins\profiletool\doProfile.py, line 244, in selectLayer1
    self.readData(0)

  File C:\Documents and Settings\eleauser/.
 qgis/python/plugins\profiletool\doProfile.py, line 152, in readData
    res = self.profiles[nr][layer].rasterUnitsPerPixel() * 1.2    # a * 1.2
 is a mean dimiesion of pixel on any direction
 AttributeError: 'QgsVectorLayer' object has no attribute
 'rasterUnitsPerPixel'

This crash is refering to the 'Profile tool' plugin, not 'Profile from line'.

I guess the name of my plugin is kind of unfortunate... it could
probably be changed to something like 'sample along line'...

Best regards


-- 
___ ___ __
Ricardo Garcia Silva
___
Qgis-developer mailing list
Qgis-developer@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-developer


Re: [Qgis-developer] build error

2012-02-03 Thread Ricardo Filipe Soares Garcia da
FYI, just opened ticket #4941 describing this issue.



-- 
___ ___ __
Ricardo Garcia Silva
___
Qgis-developer mailing list
Qgis-developer@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-developer


Re: [Qgis-developer] build error

2012-02-02 Thread Ricardo Filipe Soares Garcia da
Hi all

I'm getting the same error trying to compile latest trunk on Ubuntu
11.10 (Oneiric) 32 bit. Is there some way to solve this without
messing around with sip source? Borys, did you solve it?



-- 
___ ___ __
Ricardo Garcia Silva
___
Qgis-developer mailing list
Qgis-developer@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-developer


[Qgis-developer] can't render geostationary projection correctly

2011-09-23 Thread Ricardo Filipe Soares Garcia da
Hi list

Sorry for the noise, but I just want to bring some attention to bug #4302.

Being able to visualize data using the GEOS projection would be a big
plus for people working with meteorological satellites, like me ;)

I guess I am hitting two separate issues, one of them seems to be
related to map canvas rendering and the other to raster OTF
reprojection.

Cheers

-- 
___ ___ __
Ricardo Garcia Silva
___
Qgis-developer mailing list
Qgis-developer@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-developer


[Qgis-developer] where is QGIS_PLUGINPATH defined?

2011-05-08 Thread Ricardo Filipe Soares Garcia da
Hi list

Sorry for the newbish question:
I remember reading somewhere online about the QGIS_PLUGINPATH
environment variable and thinking it was a cool idea. I set it up to
point to my local development folder.
Now I want to disable it to test some improvements on a plugin, but I
don't remember where it is set...

I've checked ~/.bashrc, ~/.profile, /etc/environment and I couldn't find it.

So I'm thinking this online source where I remember reading about this
variable probably had some tip on how to set it up. Maybe it is even
inside one of Qgis's internal folders. Anyone knows where it is
defined?

Thanks

-- 
___ ___ __
Ricardo Garcia Silva
___
Qgis-developer mailing list
Qgis-developer@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-developer


[Qgis-developer] How to get a string's english translation with pyhton?

2011-05-08 Thread Ricardo Filipe Soares Garcia da
Hello list

in order to identify pixel values I'm using QgsRasterLayer.identify()

This method returns a tuple, with first value being a boolean (by the
way, see ticket[1] on trac). The second value is a dictionary with
band names as keys and pixel value.

I want to check for the pixel value and, in case it is null or out of
extents, I want to assign a value to some variable. I am testing the
pixel value for the presence of out of extent and null strings.
This works OK when the user is using an english locale. When the
locale is different, these strings show up translated and my code
fails miserably.

How can I solve this problem? I'd like to be able to get the english
version of the string independently of the locale being used by the
user.
Thanks


[1] - https://trac.osgeo.org/qgis/ticket/3807

-- 
___ ___ __
Ricardo Garcia Silva
___
Qgis-developer mailing list
Qgis-developer@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-developer


Re: [Qgis-developer] GSoC proposal: DBManager

2011-04-05 Thread Ricardo Filipe Soares Garcia da
Hi Guiseppe

I think it is great that you're willing to develop the Database manager idea :)

Me and Luiz Motta have been collaborating on the customDBQuery plugin,
which also allows for loading of spatial queries on the map canvas. It
takes a more minimalist approach than the other plugins, requiring
hand typing of the SQL commands, but it works with postgis and
spatialite. In fact you can't call it a manager at all. Still, I think
your suggestion is way better ;)

Codewise, I think that using the geoalchemy project[1] is probably a
great starting point in order to achieve specific DBMS independence.
It already has support for postgis, spatialite, mysql, oracle, and
MSSQL Server 2008. I have been wanting to get into it myself, but I'm
still learning sqlalchemy ;)

The code for the customDBQuery plugin is hosted at the new
hub.qgis.org, if you'd care to take a look at it.

As for suggestions, in addition to what you mentioned, I guess the
only comment I'd add is to try and keep the feature list to the more
common tasks for GIS users, as it is probably quite an effort to
develop a full and robust DB manager for lots of different backends.
Anyway, I support your proposal 100%.

[1] - http://www.geoalchemy.org/

On Tue, Apr 5, 2011 at 4:32 PM, Giuseppe Sucameli sucam...@faunalia.it wrote:
 Hi devs,

 I'd like to attend the GSoC 2011 as student to develop the following idea:
 http://www.qgis.org/wiki/Google_Summer_of_Code_2011#Database_Manager

 Brief.
 I think PG_manager is a very useful plugin because permits users to get
 informations
 and run queries on a PG database from within QGis. Furthermore PG_manager
 GUI is
 very intuitive!
 So, at the HF in Pisa (2010.04) I starting to develop SL_manager, based on
 PG_manager but working on SpatiaLite databases. Unfortunately I didn't
 adapted the
 existent code to manage SL databases, instead I forked it.

 Now there're 2 different plugins based on the same code and it's very
 difficult
 maintaining both as porting fixes between them and adding new features could
 require a lot of time.

 There's another plugin based on PG_manager, it's the RT_Sql_Layer plugin
 which
 allow users to load a PG or SL layer using whatever select statement.

 Proposal.
 My aim is to merge both 3 plugins together and create the DB_manager plugin.

 First and the most important requirement, the DB_manager plugin *must* be
 easily
 expandable to manage different kind of databases (e.g. mysql, ...).
 I didn't look ahead when I forked PG_manager, but I want to correct my
 mistakes.

 Second, it should permit an easy management of databases, running common
 tasks
 as create/alter/delete tables, retrieve infos about tables, run queries, ...
 .
 Those are implemented in PG/SL_manager yet, but I have to do some changes to
 make them more general than they are.

 Third, DB_manager should allow to load tables as layer on the QGis canvas
 and,
 on the contrary, import layers from the canvas into the db.

 What is your opinion? Did I miss something?
 What other features would you like to see? And what other plugins (if any)
 would it be
 good to integrate in?

 Thanks for your comments.

 --
 Giuseppe Sucameli


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





-- 
___ ___ __
Ricardo Garcia Silva
___
Qgis-developer mailing list
Qgis-developer@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-developer


Re: [Qgis-developer] Cleanly create memory layer in Python?

2011-01-06 Thread Ricardo Filipe Soares Garcia da
Hi Chris

In the 'Profile from lines' plugin I'm using a similar approach:

# python code
projectionSettingKey = Projections/defaultBehaviour
oldProjectionSetting = self.qgisSettings.value(projectionSettingKey)
self.qgisSettings.setValue(projectionSettingKey, useGlobal)
self.qgisSettings.sync()
pointLayer = QgsVectorLayer(Point, temporary_points, memory)
pointLayer.setCrs(linesLayer.crs())
self.qgisSettings.setValue(projectionSettingKey, oldProjectionSetting)

This was discussed a while back at another thread in this mailing-list
(08/09/2010) and this was a suggestion from Martin Dobias. It seems at
the moment it is as clean as it gets (its still a bit unclean though
;))

I'd also be interested in knowing alternative ways to do this.


On Thu, Jan 6, 2011 at 8:16 PM, Chris Crook ccr...@linz.govt.nz wrote:
 Hi All

 I'm wanting to create a memory provider in Python without invoking the CRS 
 selection dialog (even if the QGIS settings are set to Prompt for CRS when a 
 new layer is created.

 At the moment my code looks like:

        settings = QSettings()
        prjSetting = settings.value(/Projections/defaultBehaviour)
        settings.setValue(/Projections/defaultBehaviour, QVariant())
        layer = QgsVectorLayer(point,name,memory)
        if prjSetting:
            settings.setValue(/Projections/defaultBehaviour,prjSetting)

 This does work, but it seems a bit cumbersome (at first glance it doesn't 
 even look like creating a vector layer!), so I'm wondering if there is a 
 cleaner approach..

 Cheers
 Chris
 __

 This message contains information, which is confidential and may be subject 
 to legal privilege.
 If you are not the intended recipient, you must not peruse, use, disseminate, 
 distribute or copy this message.
 If you have received this message in error, please notify us immediately 
 (Phone 0800 665 463 or i...@linz.govt.nz) and destroy the original message.
 LINZ accepts no responsibility for changes to this email, or for any 
 attachments, after its transmission from LINZ.

 Thank you.
 __
 ___
 Qgis-developer mailing list
 Qgis-developer@lists.osgeo.org
 http://lists.osgeo.org/mailman/listinfo/qgis-developer




-- 
___ ___ __
Ricardo Garcia Silva
___
Qgis-developer mailing list
Qgis-developer@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-developer


[Qgis-developer] Python plugins style guide

2010-12-25 Thread Ricardo Filipe Soares Garcia da
Hi list

I have been working with Luiz Motta in the 'Custom db query' plugin
and we came about the dilemma of how to best format our Python code.

Looking around the QGIS wiki, we found the developers manual [1] and
read through the coding guidelines, but the rules defined in it are
for C++ programming and for QGIS core. We couldn't find anything
related to Python and plugins.

Has this been debated in the past? Is there a recommended style for
formatting Python code in QGIS plugins?
I usually follow the recommendation in the PEP8 [2], the official
style guide for Python. But Luiz argues (a valid point I guess) that
if we were to follow the C++ standard it would be more consistent with
the rest of the code.

I guess we are in a state where I have my opinion, he has his own, and
we'd like to reach a consensus by surveying your thoughts on this
subject. Also it seems like a good idea to raise this issue now, with
the upcoming possibility of having multiple people collaborating on
plugins.

Thanks

[1] - http://www.qgis.org/wiki/Developers_Manual
[2] - http://www.python.org/dev/peps/pep-0008/

-- 
___ ___ __
Ricardo Garcia Silva
___
Qgis-developer mailing list
Qgis-developer@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-developer


[Qgis-developer] Re: Built-in functions in Spatialite is not working in Spatialite Manager and Custom Query plugin.

2010-12-17 Thread Ricardo Filipe Soares Garcia da
Hi Noli

I can run your query in both plugins without any problem.
Maybe the real problem lies elsewhere.

I have been using using ubuntu almost exclusively lately, with
packages from the ubuntugis repository. So I really haven't had a
chance to test these things out on diferent OS/software versions. I
was expecting everything to work OK though.

What are your system specs?
Do you have the pyspatialite python module installed?

Can anyone else reproduce Noli's error?


On Fri, Dec 17, 2010 at 11:08 AM, Noli Sicad nsi...@gmail.com wrote:
 Hi,

 It seems that Built-in functions in Spatialite is not working in
 Spatialite Manager and Custom Query plugin.

 This query (below) is working in spatialite. However not in Spatialite
 Manager and Custom query plugin. See the results in spatialite
 terminal result.

 Select PK_UID, Area(Geometry) as Area, Glength(Geometry) as Perimeter
 from Regions where Name = 'VENETO';


 spatialite Select PK_UID, Area(Geometry) as Area, Glength(Geometry)
 as Perimeter from Regions where Name = 'VENETO';
 1|646397.805154562|3767.27751498312
 2|1290337.68600099|6293.47638232552
 3|8784619.91935909|26500.3924111861
 4|530524.678980947|3393.68314026964
 12|438895.715023518|3113.64992438381
 13|1080844.97356853|4257.52369736528
 27|631684.999314845|3312.26243379054
 28|697028.860538453|3883.34841424143
 29|1643348.74578464|7902.1272961186
 30|2059950.71955425|9280.26957054055
 31|3475156.56185258|8530.46975877753
 32|2837714.23986262|11833.608036565
 33|760252.960525573|3456.43315003721
 34|3548959.66717082|10910.225574648
 35|633458.679342464|3350.58352770575
 36|732165.134682328|4345.32619131389
 37|663225.180475533|3885.78466328978
 38|918705.089251876|4344.70107002211
 39|552058.274254918|4035.57280567915
 40|1054773.22809702|5408.63784325175
 41|1330499.79153974|6117.34545132715
 42|1400447.12052478|6740.60779784617
 43|464557.224632263|3508.45482974964
 44|723247.97768569|3599.45282522162
 45|651748.85301292|3801.78008569203
 46|548118.492645741|3712.45734461941
 47|488050.567765743|3177.6569314083
 48|752451.875753649|3537.1586256791
 49|6069461.72734681|23020.9974671427
 50|9739.59230065346|719.590296605301
 108|18045728269.4635|1202815.64345084
 spatialite

 Thanks.

 Noli




-- 
___ ___ __
Ricardo Garcia Silva
___
Qgis-developer mailing list
Qgis-developer@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-developer


Re: [Qgis-developer] Error for postgres's provider when table(statement SELECT ) is outside public's schema

2010-12-16 Thread Ricardo Filipe Soares Garcia da
I agree with everything :)
It will eventually get done.

Cheers

On Thu, Dec 16, 2010 at 8:59 PM, Noli Sicad nsi...@gmail.com wrote:
 Hi Ricardo,

 Thanks for explaining these things.

 The default of Spatialite uses Geometry and PK_UID as you can see
 test-2.3.sqlite. All spatialite databases immigrated using the
 utilities of spatialite have Geometry and PK_UID as default. You
 can also see it in the Spatialite Tutorials.

 http://www.gaia-gis.it/spatialite/spatialite-tutorial-2.3.1.html#t1

 As suggestion, if you don't mind, probably you can change the default
 to Geometry and PK_UID to avoid confusion especially for the new
 users. However, you also put a checkbox option if you like.

 I think it would be nice to some documentation in plugin.

 e.g. PRAGMA TABLE_INFO(table_name) to view table before you start
 using the plugin. The probably a link to this Spatialite Tutorials
 (i.e. http://www.gaia-gis.it/spatialite/spatialite-tutorial-2.3.1.html#t1
 ).

 Thanks.

 Noli


 On 12/17/10, Ricardo Filipe Soares Garcia da
 ricardo.garcia.si...@gmail.com wrote:
 Hi Noli, Guiseppe, all

 I downloaded the spatialite sample database and ran your query.
 I could run it fine without the errors you mention. The problem here
 seems to be that I still need to write some documentation on how to
 use the plugin so that you (the user) can know how to operate it
 correctly ;)

 I will improve the Help page of the plugin in order to clarify these issues.

 As for your specific problem:

 the SQL query you are using is:

 Select * from Regions where NAME = 'VENETO'

 - If you only intend to visualize the results in the 'result' tab of
 the plugin, without loading to map canvas, it works fine just like
 this.

 - BUT, If you want to load the result of the query to the map canvas,
 you must ensure that the 'Geometry column' and 'Identifier column'
 text boxes are showing the correct values for your specific tables.
 Using a spatialite db, I've set the default values for these text
 boxes as 'geometry' and 'pkuid', but you need to confirm if your data
 are using these names as well. In this case, the correct values should
 be 'Geometry' and 'PK_UID'.
 You can check the names of the columns in an sqlite table by using the
 spatialite manager, or by running the following query:

 PRAGMA TABLE_INFO(table_name)

 If you use the wrong geometry and identifier values you may (or may
 not) still be able to visualize your data over the map canvas but the
 attribute values will come as ERROR.


 As for the deletion of tables from the spatialite db, there isn't a
 nice way of doing this. To the best of my knowledge you still have to
 manually create the SQL DROP TABLE... statement and also remove the
 triggers and geometry info from spatialite by running the SQL SELECT
 DiscardGeometryColumn...
 I think this feature will come around sooner or later. It belongs to
 the (spatialite)manager plugin, and, even if I miss it as well, I
 don't think it should be implemented in the custom db query plugin.

 Cheers




-- 
___ ___ __
Ricardo Garcia Silva
___
Qgis-developer mailing list
Qgis-developer@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-developer


Re: [Qgis-developer] Error for postgres's provider when table(statement SELECT ) is outside public's schema

2010-12-15 Thread Ricardo Filipe Soares Garcia da
Hi all
To celebrate the fixing of this bug by brushtyler (Guiseppe maybe?), I
have updated 'custom db query' to version 0.4.
The plugin's window is now modeless, and it stays on top of the QGIS
main window. So you can interact with the rest of QGIS while having
the plugin open. This way you can, for example remove your query
layers from the map.


On Tue, Dec 14, 2010 at 7:03 PM, Luiz Motta motta.l...@gmail.com wrote:
 Hi Guiseppe,
 Sorry for the mistake on the author of the provider.
 I made both test, for both plugins, 'Custom database query' and 'Rt  Sql
 Layer, and
 with the same result.
 When the table is inside public's schema don't have message of error,
 otherwise,
 i have the message of error, but the layer is created perfect.
 I saved the project of QGIS (with the created layer) and open again this
 project the message of error was showed.
 In this point isolat the  factor of plugin, then, have some problem with
 provider.
 Regards,
 Luiz Motta
 2010/12/14 Giuseppe Sucameli sucam...@faunalia.it

 Hi Luiz and Ricardo,

 On Tue, Dec 14, 2010 at 1:04 PM, Luiz Motta motta.l...@gmail.com wrote:

 The author of provider told me about this problem, see ticket
 (https://trac.osgeo.org/qgis/ticket/3329).

 to Luiz: as Ricardo wrote, he is the author of the plugin
 (CustomDatabaseQuery),
 not the author of the provider at all.
 BTW, I'm the author of both the patches for executing a custom query with
 postgres and spatialite provider, so I'm one of the guys you're searching
 for :)

 to Ricardo: the ticket told about an Error for postgres's provider, not
 custom
 database query plugin issue.
 Furthermore, the QGis trac is not for plugins' issues, except for those
 that are
 in trunk. For this reason we're working to create a plugins trac.

 If you're sure the issue is only related to your plugin source code and
 not to the
 qgis functions called in your code, you should close the ticket as
 invalid.

 SELECT
   l.id AS gid, l.the_geom AS the_geom
 FROM gis.tl_20101117_101056_limite l

 Doesn't anyone confirm that it's a provider's issue, not just a plugin
 issue??
 Please, could you try to execute the same query using the RT Sql Layer
 plugin,
 in order to confirm the provider issue?

 Thanks a lot.
 Cheers.


 Please inform about your enviroment.
 It  can be util for understand what is happened.
 Regards,
 Luiz Motta




 2010/12/14 Giuseppe Sucameli sucam...@faunalia.it

 Hi Luiz,

 On Tue, Dec 14, 2010 at 2:43 AM, Luiz Motta motta.l...@gmail.com
 wrote:

 I am testing the 'Custom database query' plugins, where, i use layers
 outside public's schema.
 The plugin create the layer, but, before, i receive the message error
 about cursor od database.
 If the layers are inside public's schema not appear message.
 The one ticket is open, number 3329.

 I'm unable to reproduce it, both 'Custom database query' and 'RT Sql
 Layer' plugins
 seems to work with tables not in the public schema.
 Maybe does your layer contain invalid geometries?

 Cheers.

 --
 Giuseppe Sucameli





 --
 Giuseppe Sucameli






-- 
___ ___ __
Ricardo Garcia Silva
___
Qgis-developer mailing list
Qgis-developer@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-developer


Re: best.Re: [Qgis-developer] Spatialite ’select ’ statement as vector layer in QGIS

2010-12-13 Thread Ricardo Filipe Soares Garcia da
Hi all

 But after upgrading to v. 3.0 I get following traceback when trying to
 load every query in PostGIS (for example: SELECT * from schema.table).

I uploaded v 0.3.1 that (hopefully) fixes the bug you are refering.

I will think about adding Noli's feature requests, which seem
reasonable enough. My initial plan was to have a quick'n'dirty plugin
to query databases, while we waited for a great
postgis/spatialite-super-manager! so I am reluctant to add too much to
this plugin. I would like to polish it a bit more though.
One thing I'd like to implement is having the plugin's window to be
modeless, so that it becomes possible to add and remove layers from
the map canvas without having to close the window.


-- 
___ ___ __
Ricardo Garcia Silva
___
Qgis-developer mailing list
Qgis-developer@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-developer


Re: best.Re: [Qgis-developer] Spatialite ’select ’ statement as vector layer in QGIS

2010-12-12 Thread Ricardo Filipe Soares Garcia da
Hi Paolo, all

Uploaded a new version (v0.3) of the 'Custom DB query' plugin.

I've added it to the 'database' menu. Also, it is now possible to save
the result of the SQL query as a new table in its corresponding
database.

So, to summarize, you can run SQL queries over postgis or spatialite
databases and get the results:

- in a table view
- as a 'real time' layer displayed over the map canvas
- as a new table, that gets saved to the database and is immediately
loaded to the map canvas

It is still pretty raw, so I'm keeping it in the 'experimental'
section, but it seems to work OK with my small test datasets.


-- 
___ ___ __
Ricardo Garcia Silva
___
Qgis-developer mailing list
Qgis-developer@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-developer


Re: [Qgis-developer] Spatialite ’select’ stateme nt as vector layer in QGIS

2010-12-10 Thread Ricardo Filipe Soares Garcia da
Hi all
I've added a new version of this plugin (v 0.2).
It is now possible to query spatialite and postgis layers. The results
are displayed on the map canvas or as a table. I added a small help
page to the plugin as well. I started writing some documentation on
how to use it, but it is still unfinished.

A small gotcha: if you decide to test it with postgis layers, don't
forget to include the schema name when you reference a table.

Please let me have some feedback, if you have the time to test it out. Thanks


On Thu, Dec 9, 2010 at 10:40 AM, Ricardo Filipe Soares Garcia da
ricardo.garcia.si...@gmail.com wrote:
 Sorry, forgot to add this:

 I will add a small help page explaining the functionality later.
 Probably tomorrow.

 Cheers

 On Thu, Dec 9, 2010 at 10:38 AM, Ricardo Filipe Soares Garcia da
 ricardo.garcia.si...@gmail.com wrote:
 Hello

 I have uploaded my plugin to the contributed repository. I marked it
 as experimental. It is called 'Custom DB query'. I did a bit of
 cleaning up and even managed to get the 'normal query' feature to
 work.

 So, by now you can:

 - run an SQL query and choose to view the result in the map canvas or
 in a table format. This is only working for spatialite layers. Postgis
 will come later.

 Beware that I am not parsing the SQL in any way! So please be careful
 about what SQL queries you write, that can potentially damage your
 database. If you stick to SELECT statements it is OK.

 I didn't mean to bring one more spatial db plugin to the table, when
 there are currently so many ;)
 I will retire this one in due time.


 --
 ___ ___ __
 Ricardo Garcia Silva




 --
 ___ ___ __
 Ricardo Garcia Silva




-- 
___ ___ __
Ricardo Garcia Silva
___
Qgis-developer mailing list
Qgis-developer@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-developer


Re: [Qgis-developer] Spatialite ’select’ stateme nt as vector layer in QGIS

2010-12-09 Thread Ricardo Filipe Soares Garcia da
Sorry, forgot to add this:

I will add a small help page explaining the functionality later.
Probably tomorrow.

Cheers

On Thu, Dec 9, 2010 at 10:38 AM, Ricardo Filipe Soares Garcia da
ricardo.garcia.si...@gmail.com wrote:
 Hello

 I have uploaded my plugin to the contributed repository. I marked it
 as experimental. It is called 'Custom DB query'. I did a bit of
 cleaning up and even managed to get the 'normal query' feature to
 work.

 So, by now you can:

 - run an SQL query and choose to view the result in the map canvas or
 in a table format. This is only working for spatialite layers. Postgis
 will come later.

 Beware that I am not parsing the SQL in any way! So please be careful
 about what SQL queries you write, that can potentially damage your
 database. If you stick to SELECT statements it is OK.

 I didn't mean to bring one more spatial db plugin to the table, when
 there are currently so many ;)
 I will retire this one in due time.


 --
 ___ ___ __
 Ricardo Garcia Silva




-- 
___ ___ __
Ricardo Garcia Silva
___
Qgis-developer mailing list
Qgis-developer@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-developer


Re: [Qgis-developer] Spatialite ’select’ stateme nt as vector layer in QGIS

2010-12-08 Thread Ricardo Filipe Soares Garcia da
Hi all
In fact, I have a plugin that allows to load custom spatialite queries
to the map canvas. I started it as a pet project, to see if I could
improve my Qt skills ;)

Currently it is really crude. I can make it available at the
experimental repository if you are interested.
My initial goal was to make something that could be made to work for
spatialite and postgis alike. Currently, only the spatialite part
works (and just barely).

I was trying to make a more stripped plugin, that I could just use to
write some SQL and see the results in 3 ways:

- directly over the map canvas, creating a temporary layer (that
cannot be edited), a la RT SQL style  - this already works and it
seems to be what you want;
- saving a new layer to the database, based on the query, and
immediately loading it to the canvas - not implemented (yet);
- just making a normal query, without visualizing the results in the
map canvas - not implemented (yet).


On Wed, Dec 8, 2010 at 4:27 PM, Giuseppe Sucameli sucam...@faunalia.it wrote:
 Hi Noli,

 On Wed, Dec 8, 2010 at 11:00 AM, Noli Sicad nsi...@gmail.com wrote:

 Would be possible to be implemented for Spatialite Manager so it can
 do the same thing for Spatialite (i.e. Spatialite ’select’ statement
 as vector layer in QGIS)?

 in this moment the SL_manager doesn't allow to do this, but the spatialite
 provider supports it yet (see [1]).

 Or is this already implemented in Spatialite Manager plugin?

 No, I'm sorry.
 BTW you can use the python console and the code snippet you find at the
 previous
 link, obviously after adapting it to your needs.

 SL_manager needs some work, it exports very few functionalities compared to
 PG_manager... But in this moment we've no time to improve it.
 If anyone want help us in developing it, i.e. providing patches, they're
 welcome.

 Cheers.

 [1] http://www.mail-archive.com/qgis-developer@lists.osgeo.org/msg00878.html

 Thanks.

 Regards,

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



 --
 Giuseppe Sucameli


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





-- 
___ ___ __
Ricardo Garcia Silva
___
Qgis-developer mailing list
Qgis-developer@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-developer


[Qgis-developer] bug in the pyqgis online plugin creator

2010-12-02 Thread Ricardo Filipe Soares Garcia da
Hi list

There is a bug in the generation of the Makefile in the online pyqgis
plugin builder [1].
I'm no expert on Makefile generation, but I think the only issue is an
evil tabspace, right after the 'compile' rule.

Didn't know where to report this, hopefully here is the right place.

[1] - http://pyqgis.org/builder/plugin_builder.py

-- 
___ ___ __
Ricardo Garcia Silva
___
Qgis-developer mailing list
Qgis-developer@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-developer


Re: [Qgis-developer] PostGIS plugins

2010-10-20 Thread Ricardo Filipe Soares Garcia da
Hi
I think it would be great if this new 'database' section could be made
to work with spatialite as well as with postgis. Maybe the creation of
a general manager for spatial databases that could integrate the
'Postgis manager', 'Spatialite manager', 'RT SQL layer' and the rest
of the functionality of the other plugins that are related. I guess
this would need some kind of abstraction layer, and some (probably a
lot of) extra work.
This could maybe become a solid base for other people to develop more
specialized plugins to deal with database queries and analysis.

Maybe I'm being too ambitious and starting with the incorporation of
Faunalia's tools is good enough ;)

On Wed, Oct 20, 2010 at 4:00 PM, Paolo Cavallini cavall...@faunalia.it wrote:
 Il 20/10/2010 16:30, Andreas Neumann ha scritto:

 I wonder what is the best way to organize all those Postgis plugins. Would
 they get their own toolbar or menu?

 I think we should have a Database dropdown close by the sister dropdowns 
 Vector
 (AKA fTools) and Raster (AKA GDALTools).
 All the best.
 --
 Paolo Cavallini: http://www.faunalia.it/pc
 ___
 Qgis-developer mailing list
 Qgis-developer@lists.osgeo.org
 http://lists.osgeo.org/mailman/listinfo/qgis-developer




-- 
___ ___ __
Ricardo Garcia Silva
___
Qgis-developer mailing list
Qgis-developer@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-developer


[Qgis-developer] QgsMapLayerRegistry questions

2010-09-04 Thread Ricardo Filipe Soares Garcia da
Hi list

I'm trying to toggle my plugin's availability based on the presence or
absence of loaded vector layers of type 'line'.
For this purpose I have a _get_loaded_layers() and a
toggle_availability() methods (code follows in the end of this
message).

After searching the online API docs, it seems that the
QgsMapLayerRegistry class is the one that notifies the rest of the
application about layers being added or removed.
So I connect my plugin's toggle_availability() method to the
layerWasAdded() and layerWillBeRemoved() signals of the
QgsMapLayerRegistry.instance() object.

When the user adds a new layer everything goes fine, my plugin's
availability is toggled based on the presence of vector lines,
including the new layer that was added.
Also, if the user removes just one layer at a time, everything works
as expected as well.

Unfortunately, when several layers are removed at the same time (for
example, if the user had an open project and decides to create a new
one), my plugin is causing Qgis to segfault (very ugly!).

It seems to be connected to what is happening with the
QgsmapLayerRegistry instance when the layerWillBeRemoved() signal is
emmited repeatedly. It seems to me that I am crashing Qgis because I
am trying to call QgsMapLayerRegistry.instance().mapLayers() while the
layers are being deleted... and that causes the segfault.
I don't know what happens to the mapLayerRegistry instance, but its
mapLayers() method seems to be the source of the error.

Reading the pyQgis cookbook, I realized that when layers are removed
from the mapLayerRegistry they are also deleted from Qgis, which seems
a bit inconsistent, compared with the loading procedure. What I mean
is, if layers can be loaded without being automatically added to the
mapLayerRegistry, maybe they could also be removed from the
mapLayerRegistry without being deleted from Qgis (Maybe this is the
reason for having a layerWillBeRemoved() signal instead of a
layerWasRemoved()?).

Anyway, I don't understand why it works OK if layers are removed one
at a time and not if they all get removed.
I've tried to use the QgsMapLayerRegistry.removedAll() signal to catch
those situations when all layers get removed at once. It does work,
but the problem is that the QgsMapLayerRegistry.layerWillBeRemoved()
is still geting called at the same time and will crash Qgis.

So, I'd like to request your help in determining the best way to be
notified when a layer is removed from the map canvas.

Thanks

#(python code follows)


def initGui(self):
self.action = QAction(QIcon(:/plugins/ProfileFromLine/icon.png), \
Profile from line, self.iface.mainWindow())
self.toggle_plugin_availability()
QObject.connect(self.action, SIGNAL(activated()), self.run)
self.iface.addToolBarIcon(self.action)
self.iface.addPluginToMenu(Profile from line, self.action)
QObject.connect(self.layerRegistry,
SIGNAL(layerWasAdded(QgsMapLayer *)),
self.toggle_plugin_availability)
QObject.connect(self.layerRegistry,
SIGNAL(layerWillBeRemoved(QString)),
self.toggle_plugin_availability)


def _get_loaded_layers(self):
availableLayers = {vectorLine : [], raster : []}
loadedLayers = self.layerRegistry.mapLayers()
for layer in loadedLayers.itervalues():
layerType = layer.type()
if layerType == 0: # it's a vector layer
if layer.geometryType() == 1: # it's a line
availableLayers[vectorLine].append(layer)
elif layerType == 1: #it's a raster layer
availableLayers[raster].append(layer)
return availableLayers

def toggle_plugin_availability(self, arg=None):
print(toggle_plugin_availability method called)
numLinesLayers = len(self._get_loaded_layers()[vectorLine])
if numLinesLayers == 0:
self.action.setEnabled(False)
elif numLinesLayers == 1 and type(arg) == QString:
layerAboutToGo = self.layerRegistry.mapLayer(arg)
if layerAboutToGo.type() == 0:
if layerAboutToGo.geometryType() == 1:
self.action.setEnabled(False)



-- 
___ ___ __
Ricardo Garcia Silva
___
Qgis-developer mailing list
Qgis-developer@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-developer


[Qgis-developer] Re: how to call qgis signal?

2010-08-17 Thread Ricardo Filipe Soares Garcia da
I am sorry, I accidentally pressed some key combination that caused
gmail to send the previous message before it was finished...
Please follow the rest of the code in the attached version of the
previous e-mail.

On Tue, Aug 17, 2010 at 12:29 PM, Ricardo Filipe Soares Garcia da
ricardo.garcia.si...@gmail.com wrote:
 Hello list
 I am trying to call the layerWasAdded and layerWillBeRemoved signals
 that are emmited by the mapLayerRegistry.instance() object, but I'm
 getting no luck.
 I am hoping to toggle my plugin on and off based on the user having
 any vector layer of type 'line' loaded on the map canvas.
 I've read [1], that says that the signal definition must match exactly
 with the signature of the function... I think that is what I am doing,
 but I'm not sure.

 I am trying:

 def __init__(self, iface):
    self.layerRegistry = iface.QgsMapLayerRegistry.instance()
  #more code

 def initGui(self):
    #...some other code
    QObject.connect(self.layerRegistry,
 SIGNAL(layerWasAdded(QgsMapLayer *theMapLayer)),
 self.toggle_plugin_availability)
    QObject.connect(self.layerRegistry,
 SIGNAL(layerWillBeRemoved(QString theLayerId)),
 self.toggle_plugin_availability)

 def toggle_plugin_availability(self, arg):
    if len(self._get_loaded_layers()[vectorLine]) == 0:
            self.action.setEnabled(False)
        else:
            self.action.setEnabled(True)




 [1] - http://blog.qgis.org/node/102


 --
 ___ ___ __
 Ricardo Garcia Silva




-- 
___ ___ __
Ricardo Garcia Silva
___
Qgis-developer mailing list
Qgis-developer@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-developer


Re: [Qgis-developer] Re: how to call qgis signal?

2010-08-17 Thread Ricardo Filipe Soares Garcia da
Thanks Jurgen, it is working now!

On Tue, Aug 17, 2010 at 12:37 PM, Jürgen E. j...@norbit.de wrote:
 Hi Ricardo,

 On Tue, 17. Aug 2010 at 12:32:06 +0100, Ricardo Filipe Soares Garcia da wrote:
  def initGui(self):
    some other code
    QObject.connect(self.layerRegistry, SIGNAL(layerWasAdded(QgsMapLayer 
  *theMapLayer)), self.toggle_plugin_availability)
    QObject.connect(self.layerRegistry, SIGNAL(layerWillBeRemoved(QString 
  theLayerId)), self.toggle_plugin_availability)

 Try:
      QObject.connect(self.layerRegistry, SIGNAL(layerWasAdded(QgsMapLayer 
 *)), self.toggle_plugin_availability)
      QObject.connect(self.layerRegistry, 
 SIGNAL(layerWillBeRemoved(QString)), self.toggle_plugin_availability)


 Jürgen

 --
 Jürgen E. Fischer         norBIT GmbH               Tel. +49-4931-918175-20
 Dipl.-Inf. (FH)           Rheinstraße 13            Fax. +49-4931-918175-50
 Software Engineer         D-26506 Norden               http://www.norbit.de

 --
 norBIT Gesellschaft fuer Unternehmensberatung und Informationssysteme mbH
 Rheinstrasse 13, 26506 Norden
 GF: Jelto Buurman, HR: Amtsgericht Emden, HRB 5502

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




-- 
___ ___ __
Ricardo Garcia Silva
___
Qgis-developer mailing list
Qgis-developer@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-developer


Re: [Qgis-developer] how to add a new field to an existing layer?

2010-08-10 Thread Ricardo Filipe Soares Garcia da
Oh... nevermind. I just realized after sending the previous e-mail
that I had a typo in my code (was calling the ChangeAttributeValues
method with a capital C in the beginning).
Please excuse the noise, and thanks Martin for your help :)

On Wed, Aug 11, 2010 at 12:49 AM, Ricardo Filipe Soares Garcia da
ricardo.garcia.si...@gmail.com wrote:
 Hi Martin, list

 I did as you recommended, but now I'm getting the following error:

 Traceback (most recent call last):
  File 
 /home/ricardo/.qgis/python/plugins/ChannelFromPoints/ChannelFromPointsDialog.py,
 line 41, in accept
    self.callbackFunction(pLayer, params)
  File 
 /home/ricardo/.qgis/python/plugins/ChannelFromPoints/ChannelFromPoints.py,
 line 119, in calculate_channel
    provider.ChangeAttributeValues(values)
 TypeError: 'Capability' object is not callable

 My revised code:


 provider = pointLayer.dataProvider()
 newField = QgsField(channel, QVariant.Double)
 provider.addAttributes([newField])
 newFieldIndex = provider.fieldNameIndex(newField.name())
 #more code
 allAttrs = provider.attributeIndexes()
 provider.select(allAttrs)
 feat = QgsFeature()
 while provider.nextFeature(feat):
    # more code, calculating the value of the 'channelValue' variable
    values = {feat.id() : {newFieldIndex: QVariant(channel)}}
    provider.ChangeAttributeValues(values)


 Do you have some insight on this error? Thanks for you help

 On Tue, Aug 10, 2010 at 9:55 PM, Martin Dobias wonder...@gmail.com wrote:
 Hi Ricardo

 On Mon, Aug 9, 2010 at 2:50 PM, Ricardo Filipe Soares Garcia da
 ricardo.garcia.si...@gmail.com wrote:
 Hello list

 How can I add a new field to an existing layer and insert some new
 values in it? In the following example, pointLayer refers to an
 existing layer, previously created using the memory provider. This
 code is creating the new field, but I cannot insert the values in it.
 Although it runs without any error, when I look at the layer's
 attribute table, the new field is there, but every feature has it as
 NULL.

 The problem is that in your code you only modify a local copy of the
 data - your change is not propagated to the provider. To actually
 modify the data, use something like this:

 values = { fid : { attr_1 : QVariant(value_1), attr_2 :
 QVariant(value_2) }, ... }
 provider.changeAttributeValues( values )

 You pass the provider a dictionary where keys are feature IDs, values
 are dictionaries of changed attributes (key = attribute index, value =
 new attribute value).

 By the way, I think this kind of operation would be a nice thing
 to go into the pyqgis cookbook

 Sure, it just needs some time :-)

 Regards
 Martin




 --
 ___ ___ __
 Ricardo Garcia Silva




-- 
___ ___ __
Ricardo Garcia Silva
___
Qgis-developer mailing list
Qgis-developer@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-developer


[Qgis-developer] how to print to the shell?

2010-08-05 Thread Ricardo Filipe Soares Garcia da
Hi list
A quick (and hopefully not too embarassing ;) ) question:

-How can I print some variables to the shell when creating a python plugin?
For example, I have a piece of code that goes:

# python code
parameters = dlg.return_parameters()
print(parameters: %s % parameters)
# end of code

I was expecting to see the output in the terminal, but I get
nothing... I remember doing this in previous versions of Qgis, so
something must have changed and I missed it.
I'm using Qgis 1.5 on kubuntu 10.4

Thank you.

-- 
___ ___ __
Ricardo Garcia Silva
___
Qgis-developer mailing list
Qgis-developer@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-developer


[Qgis-developer] Re: how to print to the shell?

2010-08-05 Thread Ricardo Filipe Soares Garcia da
Hi again
My problem has been solved, although I admit I don't know why. I just
had to restart Qgis, and now I can see the output of my print commands
in the shell again. Sorry for the noise

On Thu, Aug 5, 2010 at 4:25 PM, Ricardo Filipe Soares Garcia da
ricardo.garcia.si...@gmail.com wrote:
 Hi list
 A quick (and hopefully not too embarassing ;) ) question:

 -How can I print some variables to the shell when creating a python plugin?
 For example, I have a piece of code that goes:

 # python code
 parameters = dlg.return_parameters()
 print(parameters: %s % parameters)
 # end of code

 I was expecting to see the output in the terminal, but I get
 nothing... I remember doing this in previous versions of Qgis, so
 something must have changed and I missed it.
 I'm using Qgis 1.5 on kubuntu 10.4

 Thank you.

 --
 ___ ___ __
 Ricardo Garcia Silva




-- 
___ ___ __
Ricardo Garcia Silva
___
Qgis-developer mailing list
Qgis-developer@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-developer