Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding editable layer to a new project #59

Open
jshirokov-bs opened this issue Mar 28, 2023 · 25 comments
Open

Adding editable layer to a new project #59

jshirokov-bs opened this issue Mar 28, 2023 · 25 comments

Comments

@jshirokov-bs
Copy link

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
Copy link
Member

tpo commented Mar 28, 2023

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

@manisandro
Copy link
Member

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
Copy link
Author

@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
Copy link
Member

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

@jshirokov-bs
Copy link
Author

@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
Copy link
Member

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
Copy link
Author

@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
Copy link
Member

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
Copy link
Author

@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
Copy link
Member

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
Copy link
Author

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

@manisandro
Copy link
Member

Yes

@jshirokov-bs
Copy link
Author

@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
Copy link
Member

tpo commented Mar 29, 2023

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
Copy link
Author

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

@tpo
Copy link
Member

tpo commented Mar 29, 2023

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

@tpo
Copy link
Member

tpo commented Mar 29, 2023

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
Copy link
Member

tpo commented Mar 29, 2023

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

@jshirokov-bs
Copy link
Author

@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
Copy link
Author

jshirokov-bs commented Mar 29, 2023

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
Copy link

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
Copy link
Member

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
Copy link
Contributor

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

@RodolfoMontenegro Please open a new issue for your problem.

@RodolfoMontenegro
Copy link

@RodolfoMontenegro Please open a new issue for your problem.

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

@lperozzi
Copy link

lperozzi commented Feb 8, 2024

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants