Re: [QGIS-Developer] Question on @atlas_featureid

2021-07-11 Thread Matthias Kuhn
Hi

It depends on the implementation in the data provider (and normally on the
data type for the primary key).

In the postgres case, (up to) 32 bit integer primary keys are normally used
as fid.
With others like 64 bit integer, string or compound foreign keys it's not
possible to stick to this approach, so an internal fid to pk map is
generated by the provider at runtime.

64 bit integers cannot be directly reused as fid because QGIS stores fids
internally with 64 bit, but reserves the (negative, -1, -2, ...) half of
the available values for new, uncommitted features.

Matthias


On Thu, Jul 8, 2021 at 11:50 AM Andreas Neumann  wrote:

> Ok - that explains it.
>
> It is quite confusing that QGIS uses a different internal ID than the
> primary key column of the database. Is there a technical reason for this
> behaviour?
>
> Andreas
>
>
>
> On Thu, 8 Jul 2021 at 11:43, Alexandre Neto  wrote:
>
>> As far as I remember @atlas_featureid has always returned the same as the
>> $id in the attributes table, which is kind of the internal row number.
>>
>> Alex
>>
>> A quinta, 8/07/2021, 10:35, Andreas Neumann  escreveu:
>>
>>> HI Jürgen,
>>>
>>> Yes - I provided the primary key column
>>>
>>> Here is my data source string:
>>>
>>> service='edit' authcfg=sogis00 key='t_id' srid=2056 type=Polygon
>>> checkPrimaryKeyUnicity='1'
>>> table="alw_strukturverbesserungen"."projekt_aggregiert_v"
>>> (geometrie_convex_hull) sql=geometrie_bbox IS NOT NULL
>>>
>>> @atlas_featureid returns something like an internal "row number" or
>>> similar, but not the column "t_id" as defined in the data source string.
>>>
>>> Andreas
>>>
>>> On Thu, 8 Jul 2021 at 10:42, Jürgen E. Fischer  wrote:
>>>
 Hi Andreas,

 On Thu, 08. Jul 2021 at 10:30:08 +0200, Andreas Neumann wrote:
 > attribute(@atlas_feature,'pkey_name'), but it is a little more
 complicated
 > than @atlas_featureid - and I'm pretty sure that @atlas_featureid was
 using
 > the pkey column in th past?
 >
 > My data source for the atlas coverage layer is a Postgis View.

 It's probably not using the column you expect for the feature id.  Did
 you
 specify the key column when adding the view?


 Jürgen

 --
 Jürgen E. Fischer   norBIT GmbH Tel.
 +49-4931-918175-31
 Dipl.-Inf. (FH) Rheinstraße 13  Fax.
 +49-4931-918175-50
 Software Engineer   D-26506 Norden
 https://www.norbit.de
 QGIS release manager (PSC)  Germany IRC: jef on
 Libera|OFTC
 ___
 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

>>>
>>>
>>> --
>>>
>>> --
>>> Andreas Neumann
>>> QGIS.ORG board member (treasurer)
>>> ___
>>> 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
>>>
>>
>
> --
>
> --
> Andreas Neumann
> QGIS.ORG board member (treasurer)
> ___
> 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] Using environment variables in QGIS.ini

2021-07-11 Thread Thomas Gratier
Hi,

I'm not aware QSettings provided by Qt can do it. Your %APPDATA% is not
portable as would only work on Windows

You can always try generate the QGIS.ini file using a templating system

File QGIS.ini.j2 with following content

Configuration\MODELS_FOLDER={{APPDATA}}\\QGIS\\QGIS3\\profiles\\default\\processing\\models
Configuration\SCRIPTS_FOLDERS={{APPDATA}}\\QGIS\\QGIS3\\profiles\\default\\processing\\scripts


File generate_ini.py with following content

import os
import jinja2

templateLoader = jinja2.FileSystemLoader(searchpath="./")
templateEnv = jinja2.Environment(loader=templateLoader)
TEMPLATE_FILE = "QGIS.ini.j2"
template = templateEnv.get_template(TEMPLATE_FILE)
mydict = {
"APPDATA": os.environ.get("APPDATA")
}
outputText = template.render(**mydict)
with open('QGIS.ini', 'w') as outputfile:
outputfile.write(outputText)

Then, to write your QGIS.ini file, do


python3 generate_ini.py


The possible deal breakers with this approach are:
- you depend from jinja2, a third party Python library,
- you can't later reuse the mechanism if for instance QGIS changes the
QGIS.ini file later on


Regards

Thomas


Le mar. 6 juil. 2021 à 09:18, Bo Victor Thomsen 
a écrit :

> To the list -
>
> Is there a method to use OS (Linux, Windows...) environment variables in
> the QGIS.ini setup file ?
>
> I had a number of customers asking for a method to "generalize" QGIS.ini,
> so it doesn't contain any "user" specific file and directory references, i.e
>
> (From qgis.ini)
>
> Configuration\MODELS_FOLDER=*C:\\Users\\Bo Victor
> Thomsen\\AppData\\Roaming*
> \\QGIS\\QGIS3\\profiles\\default\\processing\\models
> Configuration\SCRIPTS_FOLDERS=*C:\\Users\\Bo Victor
> Thomsen\\AppData\\Roaming*
> \\QGIS\\QGIS3\\profiles\\default\\processing\\scripts
>
> could be:
>
> Configuration\MODELS_FOLDER=*%APPDATA%*
> \\QGIS\\QGIS3\\profiles\\default\\processing\\models
> Configuration\SCRIPTS_FOLDERS=*%APPDATA%*
> \\QGIS\\QGIS3\\profiles\\default\\processing\\scripts
>
> or likewise.
>
> The ultimate reason is to have a method to distribute a "standard" setup
> for QGIS, complete with plugins and specialized setup parameters. This can
> be done by making a standard QGIS installation (which the IT departments
> love, especially with the new .msi package) and afterwards replace the
> "default" profile directory with at  directory specific for the
> organisation. However, the process of making the new profile will place a
> lot of file/directory references in QGIS.ini that is specific for the
> super-user developing the new profile.
>
> --
> Med venlig hilsen / Kind regards
>
> Bo Victor Thomsen
>
> ___
> 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