[Qgis-user] Qgis-user Digest, Vol 109, Issue 60

herath kumara herathda at yahoo.com
Sun Mar 29 21:59:54 PDT 2015


Dear User How to convert Sri Lanka (Kadawala National  Kilometer  coordinate to WGS1984 Decimal  New Grid Co-ordinate SystemThe transverse mercator projection on Everest ellipsoid (1830) with the following parameters is used to compute new grid co-ordinate system.
Central meridian E 80° 46’ 18.16710”
Latitude of Origin N 7° 00’ 1.69750”
Scale factor 0.9999238418
False Northing 500000m
False Easting 500000m 
Pidurutalagala trigonometrical station is used as the latitude of origin and central meridian.   


     On Monday, 30 March 2015, 0:31, "qgis-user-request at lists.osgeo.org" <qgis-user-request at lists.osgeo.org> wrote:
   

 Send Qgis-user mailing list submissions to
    qgis-user at lists.osgeo.org

To subscribe or unsubscribe via the World Wide Web, visit
    http://lists.osgeo.org/mailman/listinfo/qgis-user
or, via email, send a message with subject or body 'help' to
    qgis-user-request at lists.osgeo.org

You can reach the person managing the list at
    qgis-user-owner at lists.osgeo.org

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Qgis-user digest..."


Today's Topics:

  1. Re: QCompleter in QGIS form (Matthias Kuhn)
  2. Re: Label line between points and labels. (Nicolas Cadieux)
  3. Saga is not working (azizul haque)
  4. Re: QCompleter in QGIS form (Blumentrath, Stefan)


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

Message: 1
Date: Sun, 29 Mar 2015 19:56:53 +0200
From: Matthias Kuhn <matthias.kuhn at gmx.ch>
To: qgis-user at lists.osgeo.org
Subject: Re: [Qgis-user] QCompleter in QGIS form
Message-ID: <55183CE5.6050209 at gmx.ch>
Content-Type: text/plain; charset="windows-1252"

PS:

1) couldn't reproduce the "global name is not defined" error... You
script works here with .ui and autogenerated forms.
2) You may use a global variable to cache your completer (or its values)

Best,
Matthias



On 03/28/2015 08:32 PM, Blumentrath, Stefan wrote:
>
> Dear all,
>
>  
>
> Thanks to Nathan`s excellent example here:
>
> http://nathanw.net/2011/09/05/qgis-tips-custom-feature-forms-with-python-logic/
>
> I managed to implement a simple QCompleter for a LineEdit in my form
> where the completer items are being fetched from DB (see init function
> code at the end of my mail).
>
>  
>
> This is very, very promising stuff which comes in quite handy for
> entering species names (from an official list of (thousands of)
> species names in my case)!
>
>  
>
> Yet there are two things I am struggling with:
>
> 1) Would it be possible to use this QCompleter solution to an
> autogenerated form? The auto generated forms are more than good enough
> for most of my use-cases. When I tried the Init function on an
> autogenerated form I got ?NameError: global name 'TextEdit' is not
> defined?? Any ideas how to fix that?
>
>  
>
> 2) It seems to me that the query - which is used to fill the
> QCompleter - is executed each time the form is opened. Would it be
> possible to avoid this, I mean that the query is only run once (e.g.
> when I open the project)? I hoped this could speed up the start of the
> form (even if the query gets cached in PostgreSQL)?
>
> Many thanks in advance for helping.
>
>  
>
> Kind regards,
>
> Stefan
>
>  
>
> P.S.: Next thing I will have to do is understand SIGNALS and SLOTS so
> I can adjust the completer content depending on other data entered in
> the form (e.g. filter species by kingdom or known occurrence in a
> country (here Norway)) ?
>
>  
>
> P.P.S.: My form_init.py looks like this:
>
>  
>
> from PyQt4.QtCore import *
>
> from PyQt4.QtGui import *
>
> from PyQt4.QtSql import *
>
> import psycopg2
>
> nameField = None
>
> myDialog = None
>
>  
>
> def formOpen(dialog,layerid,featureid):
>
>    global myDialog
>
>    myDialog = dialog
>
>    global nameField
>
>    nameField = dialog.findChild(QLineEdit,"latinsk_navn")
>
>    
>
>    #Initiate completer
>
>    completer = QCompleter()
>
>    nameField.setCompleter(completer)
>
>    
>
>    #Fetch data from DB to fill completer
>
>    conn = psycopg2.connect("dbname='MYDB' user='MYUSERNAME'
> host='MYHOST' password='MYPASSWD'")
>
>    cur = conn.cursor()
>
>    cur.execute("""SELECT scientificname FROM kls.l_artsliste WHERE
> finnesinorge = 'Ja'""")
>
>    completition_items = []
>
>    for row in cur.fetchall():
>
>        completition_items.append(row[0])
>
>  
>
>                #Add data to Qt Model / QCompleter
>
>                model = QStringListModel()
>
>    model.setStringList(completition_items)
>
>    completer.setModel(model)
>
>
>
> _______________________________________________
> Qgis-user mailing list
> Qgis-user at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/qgis-user

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20150329/90a70d60/attachment-0001.html>

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

Message: 2
Date: Sun, 29 Mar 2015 14:26:01 -0400
From: Nicolas Cadieux <nicolas.cadieux at archeotec.ca>
To: Alexandre Neto <senhor.neto at gmail.com>
Cc: Qgis Users List <qgis-user at lists.osgeo.org>
Subject: Re: [Qgis-user] Label line between points and labels.
Message-ID:
    <b56b7f3f-548a-4070-be07-2c20822fded8 at HUCCAS02P.hostedmsx.local>
Content-Type: text/plain; charset="us-ascii"

An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20150329/f8c44014/attachment-0001.html>

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

Message: 3
Date: Sun, 29 Mar 2015 18:34:26 +0000 (UTC)
From: azizul haque <haque.azizul320 at yahoo.com>
To: "qgis-user at lists.osgeo.org" <qgis-user at lists.osgeo.org>
Subject: [Qgis-user] Saga is not working
Message-ID:
    <389248122.700773.1427654066189.JavaMail.yahoo at mail.yahoo.com>
Content-Type: text/plain; charset="utf-8"

Hi All,As I told you I am now using QGIS 2.8.1. I have to do some analysis using SAGA under QGIS environment. Unfortunately it is not working. I mean when I run it immediately it goes hang out. I installed SAGA gis for Mac Pro and configure it on terminal. I assume that do not configure it right way.?Any help is much appreciated.Please, please,RegardsAzizul
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20150329/be48585b/attachment-0001.html>

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

Message: 4
Date: Sun, 29 Mar 2015 18:59:30 +0000
From: "Blumentrath, Stefan" <Stefan.Blumentrath at nina.no>
To: Matthias Kuhn <matthias.kuhn at gmx.ch>, "qgis-user at lists.osgeo.org"
    <qgis-user at lists.osgeo.org>
Subject: Re: [Qgis-user] QCompleter in QGIS form
Message-ID: <c0dfbf4b6289498dbb1b390c042f2ac0 at NINSRV23.nina.no>
Content-Type: text/plain; charset="us-ascii"

Hi Matthias,

Wow, cool! Thanks for implementing that so fast!

I just tested caching in a global variable. It works like a charm and speeds up the GUI significantly.

And yes, the completer works fine with autogenerated forms too (I only had to restart QGIS).
So all my problems in this regards are solved now.

The only, minor issue is, that one has to set Settings->Options->Enable Macros to "Always", or "Only this session" (with "Ask" (the default setting) the startup macro does not load, see: http://hub.qgis.org/issues/9523)

For those who are interested and who can`t wait for the next release with Matthias additions (and who like me are absolute Python beginners),
here is how it works (quite simple actually once you know how to do it):

The openProject() Python marco function (in my case named generate_completer.py, located in the project directory)
looks like this (completer content could also be loaded from file of course):
-----------------------------
#!/usr/bin/env python

from PyQt4.QtCore import *
from qgis.core import *
import psycopg2

def fetch_citems():

    global ci
    #Fetch data from DB to fill completer
    conn = psycopg2.connect("dbname='MYDB' user='MYUSER' host='MYHOST' password='MYDB'")
    cur = conn.cursor()
    cur.execute("""SELECT scientificname FROM kls.l_artsliste WHERE finnesinorge = 'Ja'""")
    ci = []
    for row in cur.fetchall():
        ci.append(row[0])

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

It is referenced in the project like this:
    import generate_completer
    generate_completer.fetch_citems()

And the form init function (in my case named completer.py, located in the project directory) looks like this:
-----------------------------

from PyQt4.QtCore import *
from PyQt4.QtGui import *
import generate_completer

nameField = None
myDialog = None

def formOpen(dialog,layerid,featureid):
    global myDialog
    myDialog = dialog
    global nameField
    nameField = dialog.findChild(QLineEdit,"latinn")

    #Initiate completer
    completer = QCompleter()
    nameField.setCompleter(completer)

    #Add data to Qt Model / QCompleter
    model = QStringListModel()
    model.setStringList(generate_completer.ci)
    completer.setModel(model)

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

It is referenced in the Fields tab as: completer.formOpen
"latinn" is the name of the attribute column BTW for which the completer is used.

I guess the global variable "ci" (Python list with Unicode strings) could also be used for data validation (in Nathan`s example)...

Thanks for this amazing Software!

Kind regards,
Stefan

From: qgis-user-bounces at lists.osgeo.org [mailto:qgis-user-bounces at lists.osgeo.org] On Behalf Of Matthias Kuhn
Sent: 29. mars 2015 19:56
To: qgis-user at lists.osgeo.org
Subject: Re: [Qgis-user] QCompleter in QGIS form

Hi Stefan,

I had some spare time on the Sunday evening train. So I have just added this possibility to the ValueRelation widget. You can now choose the option "Use Completer" there.
The query is still run every time the form is opened at the moment. There is actually a caching mechanism for the value relation widget prepared, so it should be possible to make use of that and initialize the cache only once.
But that will have to wait until I have some spare time again or one may speed up the process by funding this or tackling the issue if coding skills are available (for the last option, please get in touch first, there are a couple of different approaches to doing this),

Testing is appreciated.
Matthias
On 03/28/2015 08:32 PM, Blumentrath, Stefan wrote:
Dear all,

Thanks to Nathan`s excellent example here:
http://nathanw.net/2011/09/05/qgis-tips-custom-feature-forms-with-python-logic/
I managed to implement a simple QCompleter for a LineEdit in my form where the completer items are being fetched from DB (see init function code at the end of my mail).

This is very, very promising stuff which comes in quite handy for entering species names (from an official list of (thousands of) species names in my case)!

Yet there are two things I am struggling with:
1) Would it be possible to use this QCompleter solution to an autogenerated form? The auto generated forms are more than good enough for most of my use-cases. When I tried the Init function on an autogenerated form I got "NameError: global name 'TextEdit' is not defined"... Any ideas how to fix that?

2) It seems to me that the query - which is used to fill the QCompleter - is executed each time the form is opened. Would it be possible to avoid this, I mean that the query is only run once (e.g. when I open the project)? I hoped this could speed up the start of the form (even if the query gets cached in PostgreSQL)...
Many thanks in advance for helping.

Kind regards,
Stefan

P.S.: Next thing I will have to do is understand SIGNALS and SLOTS so I can adjust the completer content depending on other data entered in the form (e.g. filter species by kingdom or known occurrence in a country (here Norway)) ...

P.P.S.: My form_init.py looks like this:

from PyQt4.QtCore import *
from PyQt4.QtGui import *
from PyQt4.QtSql import *
import psycopg2
nameField = None
myDialog = None

def formOpen(dialog,layerid,featureid):
    global myDialog
    myDialog = dialog
    global nameField
    nameField = dialog.findChild(QLineEdit,"latinsk_navn")

    #Initiate completer
    completer = QCompleter()
    nameField.setCompleter(completer)

    #Fetch data from DB to fill completer
    conn = psycopg2.connect("dbname='MYDB' user='MYUSERNAME' host='MYHOST' password='MYPASSWD'")
    cur = conn.cursor()
    cur.execute("""SELECT scientificname FROM kls.l_artsliste WHERE finnesinorge = 'Ja'""")
    completition_items = []
    for row in cur.fetchall():
        completition_items.append(row[0])

              #Add data to Qt Model / QCompleter
              model = QStringListModel()
    model.setStringList(completition_items)
    completer.setModel(model)




_______________________________________________

Qgis-user mailing list

Qgis-user at lists.osgeo.org<mailto:Qgis-user at lists.osgeo.org>

http://lists.osgeo.org/mailman/listinfo/qgis-user

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20150329/bc09918f/attachment.html>

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

_______________________________________________
Qgis-user mailing list
Qgis-user at lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-user

End of Qgis-user Digest, Vol 109, Issue 60
******************************************


  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20150330/a9ac9083/attachment.html>


More information about the Qgis-user mailing list