qwc-services / qwc-docker

Docker containers for qwc-services
MIT License
46 stars 36 forks source link

Adding editable layer to a new project #59

Open jshirokov-bs opened 1 year ago

jshirokov-bs commented 1 year ago

Hello.

I can add a new project to QWC2 using WFS. But how can I add an editable layer to a new project? If I add an editable layer from a demo project to my own project from Postgres, an error occurs during configuration.

tpo commented 1 year ago

@jshirokov-bs : including the error you see here would be helpful

manisandro commented 1 year ago

For editing, you need a dataset stored in a postgis DB which is added to your qgis project as a layer. Additionally, you need to set write permissions to the respective data resources in the admin gui - look at the demo edit_points/edit_lines/edit_polygons for an example.

jshirokov-bs commented 1 year ago

@tpo

As a test example, I simply add the "edit_points" layer from the demo project (directly from postgre) to the new "world13" project , place the .qgs in the "scan" folder and start configuring services. After that, this error occurs.

image

manisandro commented 1 year ago

Are you using a pg service connection in the datasource for edit_points or are you using hostname/port/username/password?

jshirokov-bs commented 1 year ago

@manisandro

Something like this. I connect to Postgres, load a layer from the database, create a project and put it in "scan". Is that correct?

image

manisandro commented 1 year ago

No, you need to use a service definition (as defined in pg_service.conf), as the necessary connection information differs inside the docker from the host system (i.e. in the container the DB can be found at qwc-postgis:5432 whereas on the host it can be found at localhost:5439).

So rather than specifying host/port/database/etc, just set service to qwc_geodb and add a matching service definition to your host ~/.pg_service.conf

[qwc_geodb]
host=localhost
port=5439
dbname=qwc_demo
user=qwc_service
password=qwc_service
sslmode=disable
jshirokov-bs commented 1 year ago

@manisandro So, if i get this correct, i need to do this pipeline:

  1. I need to change the connection in the file, according to the configuration from your message
  2. In the QGIS-PostGIS connection, specify the service - qwc_geodb

But after that, unfortunately, I can't connect to the database. I think I'm foolishly missing something. image

manisandro commented 1 year ago

QGIS isn't picking up your service definition. Either you have not restarted QGIS since changing your pg_service.conf, or you have added your service definition to file which is not picked up by the postgres library. The default location for the pg service configuration file for your user is ~/.pg_service.conf aka /home/$USER/.pg_service.conf.

(If you specify service, you don't need to specify host/port/database/user/password as they are specified in the service definition.)

jshirokov-bs commented 1 year ago

@manisandro Is it a file that is located in the qwc-doker directory, or is it some other file with the .conf extension? image

manisandro commented 1 year ago

The pg_service.conf located in the qwc-docker folder is the one which is mounted into the docker containers and contains the service definitions used by the docker containers.

The service definitions for the host system need to be placed in your home directory as I wrote above.

jshirokov-bs commented 1 year ago

@manisandro But I don 't ~/.pg_service.conf in the directory /home/$USER/. Should I add it manually? image

manisandro commented 1 year ago

Yes

jshirokov-bs commented 1 year ago

@manisandro okey, so i create /.pg_service.conf in /home/$USER/. I added this text:

[qwc_geodb]
host=localhost
port=5439
dbname=qwc_demo
user=qwc_service
password=qwc_service
sslmode=disable

After that, I restarted QWC2 and tried to connect through the "Service". Nothing has changed. image

tpo commented 1 year ago

In order to test your connection to the local DB start with psql (and not QGIS).

So from the commandline do this:

PGSERVICE=qwc_geodb psql

Only after you are able to connect in this way via psql to your local DB try to connect to it from QGIS.

jshirokov-bs commented 1 year ago

@tpo I got this result. This doesnt look helpful. image

tpo commented 1 year ago

It is helpful :-D - it tells you that your DB and PGSERVICE configuration indeed works!

tpo commented 1 year ago

I am guessing from the screenshots you posted: you are running QGIS on a windows machine? If that is the case then you need to put the pg_service.conf file under C:\Users\<YOUR_USER_NAME_HERE>\AppData\postgresql\.pg_service.conf

tpo commented 1 year ago

Also what is hidden by the "Enter Credentials" window? There are authentication settings that are not visible in the screenshot

jshirokov-bs commented 1 year ago

@tpo It worked! Now I can connect via the service. The question remains with editable layers. I need to copy a layer from a demo project and place .qgs in "scan", then reconfigure the service, click "import maps" in resources... and then? Or am I incorrectly describing the sequence of actions? image

jshirokov-bs commented 1 year ago

When I try to add an editable layer from demo to the natural-earth-countries project, I get the following message in the log: image

but in the project I have a layer image

RodolfoMontenegro commented 8 months ago

Hello, I'm having the same issue, while trying to load project and its layers from the postgis connections. I manually configures the themesConfig.json to add the project. And when i run the config generator I get the following error.

error

manisandro commented 8 months ago

That error message is most likely accurate. Verify that the credentials you have specified for qgisprojects in you pg_service.conf do indeed have read access to qwc_geodb.qgis_projects.

HusseinKabbout commented 8 months ago

@jshirokov-bs Were you able to fix your issue?

@RodolfoMontenegro Please open a new issue for your problem.

RodolfoMontenegro commented 8 months ago

@RodolfoMontenegro Please open a new issue for your problem.

Thank you @HusseinKabbout , I was able to fix the issue.

lperozzi commented 7 months ago

Hello.

I can add a new project to QWC2 using WFS. But how can I add an editable layer to a new project? If I add an editable layer from a demo project to my own project from Postgres, an error occurs during configuration.

Hello @jshirokov-bs How have you been able to add a project to QWC2 using WFS?