envirosolutionspl / uldk_gugik

EN: The plugin allows user to download geometry of parcells, communies, regions. Plugin uses ULDK API of The Central Office of Geodesy and Cartography of Poland; PL: Wtyczka QGIS, która pozwala na pobieranie geometrii granic działek katastralnych, obrębów, gmin, powiatów i województw. Pobieranie danych jest realizowane przez usługę ULDK udostępnianą przez Główny Urząd Geodezji i Kartografii.
https://www.envirosolutions.pl/news/105/129/Usluga-Lokalizacji-Dzialek-Katastralnych.html
GNU General Public License v3.0
3 stars 5 forks source link

Encoding error #9

Closed gsapijaszko closed 11 months ago

gsapijaszko commented 2 years ago

When installing the plugin I got the error:

Couldn't load plugin 'uldk_gugik' due to an error when calling its classFactory() method 

LookupError: unknown encoding: ANSI 
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/qgis/utils.py", line 423, in _startPlugin
    plugins[packageName] = package.classFactory(iface)
  File "/home/sapi/.local/share/QGIS/QGIS3/profiles/default/python/plugins/uldk_gugik/__init__.py", line 36, in classFactory
    return UldkGugik(iface)
  File "/home/sapi/.local/share/QGIS/QGIS3/profiles/default/python/plugins/uldk_gugik/uldk_gugik.py", line 100, in __init__
    self.dlg = UldkGugikDialog()
  File "/home/sapi/.local/share/QGIS/QGIS3/profiles/default/python/plugins/uldk_gugik/uldk_gugik_dialog.py", line 58, in __init__
    self.regionFetch = RegionFetch()
  File "/home/sapi/.local/share/QGIS/QGIS3/profiles/default/python/plugins/uldk_gugik/uldk.py", line 8, in __init__
    self.obrebDict = self.__fetchObrebDict()
  File "/home/sapi/.local/share/QGIS/QGIS3/profiles/default/python/plugins/uldk_gugik/uldk.py", line 22, in __fetchObrebDict
    resp=RegionFetch.openObrebList(self)
  File "/home/sapi/.local/share/QGIS/QGIS3/profiles/default/python/plugins/uldk_gugik/uldk.py", line 14, in openObrebList
    with open(os.path.join(os.path.dirname(__file__),'obreby.csv'), encoding="ANSI") as f:
LookupError: unknown encoding: ANSI

Python version: 3.8.10 (default, Jun 22 2022, 20:18:18) [GCC 9.4.0] 
QGIS version: 3.26.0-Buenos Aires Buenos Aires, 0aece2818e 

Python Path:
/home/sapi/.local/share/QGIS/QGIS3/profiles/default/python/plugins/LAStools
/usr/share/qgis/python
/home/sapi/.local/share/QGIS/QGIS3/profiles/default/python
/home/sapi/.local/share/QGIS/QGIS3/profiles/default/python/plugins
/usr/share/qgis/python/plugins
/usr/lib/python38.zip
/usr/lib/python3.8
/usr/lib/python3.8/lib-dynload
/home/sapi/.local/lib/python3.8/site-packages
/usr/local/lib/python3.8/dist-packages
/usr/lib/python3/dist-packages
/home/sapi/.local/share/QGIS/QGIS3/profiles/default/python
/home/sapi/.local/share/QGIS/QGIS3/profiles/default/python/plugins/postgisQueryBuilder
/home/sapi/.local/share/QGIS/QGIS3/profiles/default/python/plugins/postgisQueryBuilder/extlibs

As the ANSI isn't standard python encoding, changing uldk.py from:

        with open(os.path.join(os.path.dirname(__file__),'obreby.csv'), encoding="ANSI") as f:

to

       with open(os.path.join(os.path.dirname(__file__),'obreby.csv'), encoding="iso8859_2") as f:

resolves the issue.

Hope it helps, Grzegorz

kacpertarka commented 11 months ago

Błąd poprawiony

wojtek19022 commented 11 months ago

Wtyczka nie korzysta już z pliku powodującego błąd

wojtek19022 commented 11 months ago

@gsapijaszko  pod poniższym linkiem znajduje się najnowsza wersja wtyczki: https://github.com/envirosolutionspl/uldk/tree/development

Zapraszam do testów