Le 13/07/2018 à 21:51, Nikos Alexandris a écrit :
* Frank David <frank.david@geophom.fr> [2018-07-13 19:26:36 +0200]:
Le 11/07/2018 à 09:31, Nikos Alexandris a écrit :
* Frank David <frank.david@geophom.fr> [2018-07-10 15:44:51 +0200]:
Le 10/07/2018 à 12:25, Nikos Alexandris a écrit :
* frank <frank.david@geophom.fr> [2018-07-10 08:05:29 +0200]:
Hi dear grass users,
I'm trying to get two field name of an attribute table (ctx_map) by the options of the gui. But I can access only at the first one and I don't find why...??. See my code below :
#%option G_OPT_V_MAP
#% key: ctx_map
#% description: vector data
#% required : yes
#% guidependency:layer,ctx_wf,ctx_wtg
#%end
#%option G_OPT_V_FIELD
#% key:ctx_layer
#% guidependency:ctx_wf,ctx_wtg
#%end
#%option G_OPT_DB_COLUMN
#% key:ctx_wf
#% description: wf name
#% required: yes
#%end
#%option G_OPT_DB_COLUMN
#% key:ctx_wtg
#% description: wtg name
#% required: yes
#%end
Thank you for your help.
Frank
Dear Frank,
Hello Nikos,
if you refer to the last two "column" options,
how do you try to access these, in the script?
Like,
options['ctx_wf']
options['ctx_wtg']
Absolutely
?
Also, what .xml does
x.ScriptName --interface-description
generate?
There is no error on compilation, and help tab display Flags and Parameters information, like (french accent are not well encoded):
Parameters:
obj_map=name [required]
Name of vector map
MH ou WTG projet
obj_layer=string
Layer number or name
Vector features can have category values in different layers. This number determines which layer to use. When used with direct OGR access this is the layer name.
Default: 1
obj_name=name [required]
Nom de l'objet
*ctx_map=name [required] **
**Name of vector map **
*Contexte éolien *
**ctx_layer=string **
**Layer number or name **
**Vector features can have category values in different layers. This number determines which layer to use. When used with direct OGR access this is the layer name. **
**Default: 1 **
**ctx_wf=name [required] **
*Nom du parc *
**ctx_wtg=name [required] **
*Identifiant éolienne
Ah, and what does `x.ScriptName --ui` return?
Maybe an encoding related issue? Related entries in trac:
https://trac.osgeo.org/grass/search?q=encoding+french&noquickjump=1&changeset=on&milestone=on&ticket=on&wiki=on
Nikos
Hello Nikos,
x.myscript --ui just launch the gui box.
I have found a trick to run the script. Actually I need one field from on vector table and 2 fields from an other vector table. like that it works :
#%option G_OPT_V_MAP
#% label: MH ou WTG projet
#% required : yes
#% guidependency: layer,obj
#%end
#%option G_OPT_V_FIELD
#% guidependency: obj
#%end
#%option G_OPT_DB_COLUMN
#% key: obj
#% description: Nom de l'objet
#% required: yes
#%end
#%option G_OPT_V_MAP
#% key: ctx_map
#% label: Contexte éolien
#% required : yes
#% guidependency:ctx_layer,ctx_wf,ctx_wtg
#%end
#%option G_OPT_V_FIELD
#% key:ctx_layer
#% guidependency:ctx_wf,ctx_wtg
#%end
#%option G_OPT_DB_COLUMN
#% key:ctx_wf
#% description: Nom du parc
#% required: yes
#%end
#%option G_OPT_DB_COLUMN
#% key:ctx_wtg
#% description: Identifiant éolienne
#% required: yes
#%end
But as soon as I try to name myself the first table by Key parameter like #%key : obj_map and add key name at layer (like in the second part of the code) It does not work anymore... It looks like the fisrt map is automatically named "map" by the gui. I don't mind but I find this strange. I'm sure there is a explanation,somewhere...
Cheers,
Frank
Perhaps there is something, and experienced developers will notice it fast.
Yet, why don't you share a minimal working code? At least the interface,
so I can try myself to compile. Even in private if you
prefer. I am willig to help in understanding this error. So I will learn
about it as well.
Nikos
Hi Nikos,
You can find below the full interface script. The script is not yet finished. It may be helps you to understand the problem ?!
I don't really understand how works the parameter guidependency and with which key I must connect it. I did not find any doc about that.. do you know where I can find that ?
Thanks
Frank
#!/usr/bin/python
#-*-coding:UTF-8 -*-
#%Module
#% description: Calcul de l'intervisibilité entre WTG projet et contexte ou objets MH et WTG projet
#% keyword: display
#% keyword: raster
#% keyword: windfarm
#%End
#%option G_OPT_V_MAP
#% label: MH ou WTG projet
#% required : yes
#% guidependency: layer,obj
#%end
#%option G_OPT_V_FIELD
#% guidependency: obj
#%end
#%option G_OPT_DB_COLUMN
#% key: obj
#% description: Nom de l'objet
#% required: yes
#%end
#%option G_OPT_V_MAP
#% key: ctx_map
#% label: Contexte éolien
#% required : yes
#% guidependency:ctx_layer,ctx_wf,ctx_wtg
#%end
#%option G_OPT_V_FIELD
#% key:ctx_layer
#% guidependency:ctx_wf,ctx_wtg
#%end
#%option G_OPT_DB_COLUMN
#% key:ctx_wf
#% description: Nom du parc
#% required: yes
#%end
#%option G_OPT_DB_COLUMN
#% key:ctx_wtg
#% description: Identifiant éolienne
#% required: yes
#%end
#%Option
#% key: string_zvi_obj
#% type: string
#% answer : chaine{fichier}chaine[champ1]chaine[champ2]chaine
#% label: Nom des cartes ZVI des OBJETS MH ou WTG projet (Ha)
#% description : Nom des cartes ZVI : {} est remplacé par le nom du fichier vect, [champ] est remplacé par le contenu du champ
#% required : yes
#%End
#%Option
#% key: string_zvi_ctx
#% type: string
#% answer : chaine{fichier}chaine[champ1]chaine[champ2]chaine
#% label: Nom des cartes ZVI OBJETS WTG projet ou contexte (Ha)
#% description : Nom des cartes ZVI : {} est remplacé par le nom du fichier vect, [champ] est remplacé par le contenu du champ
#% required : yes
#%End
#%option
#% key: obj_haut_mini
#% type: double
#% label: Hauteur minimum (unité de la zvi)
#% description: Hauteur minimum de l'objet visé (projet ou MH)
#% required : yes
#% answer : 0
#%end
#%option
#% key: champ_visuel
#% type: integer
#% label: Champ visuel
#% description: Champ visuel maximum étudié
#% required : yes
#% answer : 50
#%end
#%option
#% key: calculs_dg
#% type: string
#% required: no
#% multiple: yes
#% options: sum,average,moyen,minimum,maximum,stddev
#% label: Calcul cumulatif des cartes delta-Gis
#% description: Calcul cumulatif des cartes delta-Gis
#% guisection: Cumul
#%end
#%option
#% key: calculs_zvifu
#% type: string
#% required: no
#% multiple: yes
#% options: sum,average,moyen,minimum,maximum,stddev
#% description: Calculs cumulatif des cartes ZVT filtrées de chaque eol ou MH
#% guisection: Cumul
#%end
#%option
#% key: calculs_zvif
#% type: string
#% required: no
#% multiple: yes
#% options: sum,average,moyen,minimum,maximum,stddev
#% description: Calculs cumulatif des cartes ZVT filtrées
#% guisection: Cumul
#%end
#%option
#% key: where_obj
#% type: string
#% required: no
#% multiple: no
#% key_desc: sql_query
#% label: Condition SQL (sans WHERE) sur n'importe quel champ de la table MH/projet
#% description: Example: hauteur=180 and (cat > 2 and cat < 5)
#% answer: cat > 0
#%end
#%option
#% key: where_ctx
#% type: string
#% required: no
#% multiple: no
#% key_desc: sql_query
#% label: Condition SQL (sans WHERE) sur n'importe quel champ de la table projet/contexte
#% description: Example: hauteur=180 and (cat > 2 and cat < 5)
#% answer: cat > 0
#%end
#%option
#% key: output
#% label: Nom des cartes de sortie (complément)
#% description: Nom des cartes de sortie
#% required : no
#%end
#%option
#% key: desc
#% label: Commentaire a integrer aux meta-données des cartes produites
#% description: Commentaire a integrer aux meta-données des cartes produites
#% required : no
#%end
#%flag
#% key: r
#% label: Forcer le résultat en degrés, sinon formaté de 0 à 100%
#% description: degrés ou pourcent du champ visuel (0 à 1)
#%end
#%flag
#% key: v
#% label: impose que l'objet de référence (MH ou WTG projet) soit visible (sur la base de sa zvi)
#% description: par défaut, le MH/WTG n'a pas besoin d'être visible pour comptabiliser les éoliennes du projet/contexte vues dans le champ visuel
#%end
#%flag
#% key: s
#% label: Supprimer les couches intermédiaires au niveau de l'objet
#% description: Supprimer les couches intermédiaires au niveau de l'objet
#%end
#%flag
#% key: t
#% label: Supprimer les couches intermédiaires au niveau du groupe
#% description: Supprimer les couches intermédiaires au niveau du groupe
#%end
#%flag
#% key: u
#% label: Faire un calcul général sans double comptage des ZVT contexte
#% description: Faire un calcul général sans double comptage des ZVT contexte
#%end
#%flag
#% key: o
#% label: Autoriser à écraser les fichiers existants
#% description: Ecraser les fichiers existants
#%end