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

Error handling conflicts #100

Closed
geoteixeira opened this issue May 12, 2023 · 3 comments
Closed

Error handling conflicts #100

geoteixeira opened this issue May 12, 2023 · 3 comments

Comments

@geoteixeira
Copy link

Hello
I am a Kart new user, and just need your help.
So i have a repositorie that i cloned, postgis data, everything is working ok except one thing. When there is conflict and after i say KArt how to handle the conflict, when it tries to do the merge it always appears this error:

Traceback (most recent call last):
File "sqlalchemy\engine\base.py", line 1900, in _execute_context
File "sqlalchemy\engine\default.py", line 736, in do_execute
psycopg2.errors.InvalidParameterValue: Geometry SRID (0) does not match column SRID (3763)
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "kart_cli.py", line 4, in
File "kart\cli.py", line 406, in entrypoint
File "click\core.py", line 1130, in call
File "click\core.py", line 1055, in main
File "kart\cli_util.py", line 72, in invoke
File "click\core.py", line 1657, in invoke
File "click\core.py", line 1404, in invoke
File "click\core.py", line 760, in invoke
File "click\decorators.py", line 26, in new_func
File "kart\resolve.py", line 583, in resolve
File "kart\resolve.py", line 284, in update_workingcopy_with_resolve
File "sqlalchemy\orm\session.py", line 1714, in execute
File "sqlalchemy\engine\base.py", line 1705, in _execute_20
File "sqlalchemy\sql\elements.py", line 334, in _execute_on_connection
File "sqlalchemy\engine\base.py", line 1572, in _execute_clauseelement
File "sqlalchemy\engine\base.py", line 1943, in _execute_context
File "sqlalchemy\engine\base.py", line 2124, in handle_dbapi_exception
File "sqlalchemy\util\compat.py", line 211, in raise

File "sqlalchemy\engine\base.py", line 1900, in _execute_context
File "sqlalchemy\engine\default.py", line 736, in do_execute
sqlalchemy.exc.DataError: (psycopg2.errors.InvalidParameterValue) Geometry SRID (0) does not match column SRID (3763)
[SQL: INSERT INTO "Landbase_Topo".numeros_policia (fid, geom, id, numero_de_policia, numero_antigo, tipo_porta, denominacao_predio, verificado, observacoes, codigo_postal, rua_nome, local, freguesia, id_rua) VALUES (%(fid)s, %(geom)s, %(id)s, %(numero_de_policia)s, %(numero_antigo)s, %(tipo_porta)s, %(denominacao_predio)s, %(verificado)s, %(observacoes)s, %(codigo_postal)s, %(rua_nome)s, %(local)s, %(freguesia)s, %(id_rua)s) ON CONFLICT (fid) DO UPDATE SET geom = excluded.geom, id = excluded.id, numero_de_policia = excluded.numero_de_policia, numero_antigo = excluded.numero_antigo, tipo_porta = excluded.tipo_porta, denominacao_predio = excluded.denominacao_predio, verificado = excluded.verificado, observacoes = excluded.observacoes, codigo_postal = excluded.codigo_postal, rua_nome = excluded.rua_nome, local = excluded.local, freguesia = excluded.freguesia, id_rua = excluded.id_rua]
[parameters: {'fid': 17256, 'geom': , 'id': 1806793, 'numero_de_policia': '533', 'numero_antigo': '', 'tipo_porta': '', 'denominacao_predio': '', 'verificado': 'Não', 'observacoes': '', 'codigo_postal': '', 'rua_nome': 'Rua do Estabelecimento Prisional do Linhó', 'local': 'Linhó', 'freguesia': 'Alcabideche', 'id_rua': 1680385}]
(Background on this error at: https://sqlalche.me/e/14/9h9h)
[2208] Failed to execute script 'kart_cli' due to unhandled exception!

It happens with geopackage files, with Postgis data. I have checked all data and SRID´s are all ok EPSG:3763.
Any help i would be thankfull

Rui Teixeira

@olsen232
Copy link
Contributor

olsen232 commented May 15, 2023

I haven't been able to reproduce yet - I think the PostGIS instance that I'm using for testing seems to be more accepting of my inserting geometries with the wrong SRID than the PostGIS version you have.

Nevertheless I can see the root cause of the bug in the code, so I'll have a fix out soon. If you don't want to wait until the next Kart patch-release for the fix, you could try the following workaround in the meantime:

Workaround:
Modify the constraint on the geometry column of your database table after you start the merge, but before you try to resolve any of the conflicts, so that it accepts geometries of any SRID. This shouldn't have any affect on the data that Kart actually stores, and Kart will put it back to how it was when you complete the merge.
You would do this by connecting to your working copy with psql and then executing something like the following:

ALTER TABLE "Landbase_Topo".numeros_policia ALTER COLUMN geom SET DATA TYPE geometry;

Sorry about the added complication!

@olsen232
Copy link
Contributor

Duplicate of koordinates/kart#840

Moving issue to the koordinates/kart repository

olsen232 added a commit to koordinates/kart that referenced this issue May 15, 2023
Missing the piece of code that adds SRIDs to features while writing
them to the working copy, specifically during kart resolve.

The Kart model doesn't store SRIDs per-row, so normal checkout operations
add them in (at least for those working copies that do store them
per row).
olsen232 added a commit to koordinates/kart that referenced this issue May 15, 2023
@geoteixeira
Copy link
Author

Thank you, will try that.

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

2 participants