mirror of
https://github.com/ARUP-CAS/aiscr-qgis-amcr-viewer.git
synced 2026-06-19 12:22:54 +02:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 9a935261e6 | |||
| a4e30bf334 | |||
| 56389e27d7 | |||
| c8d42e2459 |
@@ -2,7 +2,7 @@
|
|||||||
import os
|
import os
|
||||||
import csv
|
import csv
|
||||||
import requests
|
import requests
|
||||||
import xml.etree.ElementTree as ET # nosec B314
|
import xml.etree.ElementTree as ET # nosec
|
||||||
import time
|
import time
|
||||||
from qgis.core import QgsMessageLog, Qgis
|
from qgis.core import QgsMessageLog, Qgis
|
||||||
|
|
||||||
@@ -101,7 +101,7 @@ def fetch_set(internal_name, api_set, task=None):
|
|||||||
try:
|
try:
|
||||||
response = requests.get(BASE_URL, params=params, timeout=30)
|
response = requests.get(BASE_URL, params=params, timeout=30)
|
||||||
response.raise_for_status()
|
response.raise_for_status()
|
||||||
root = ET.fromstring(response.content)
|
root = ET.fromstring(response.content) # nosec
|
||||||
|
|
||||||
records = root.findall('.//oai:record', NS)
|
records = root.findall('.//oai:record', NS)
|
||||||
for rec in records:
|
for rec in records:
|
||||||
|
|||||||
@@ -142,6 +142,13 @@ def tr_code(code):
|
|||||||
return ""
|
return ""
|
||||||
return TRANSLATIONS.get(code, code)
|
return TRANSLATIONS.get(code, code)
|
||||||
|
|
||||||
|
def komp_projde_filtrem(komp, filter_areal, filter_datace, filters):
|
||||||
|
if filter_areal and komp.get('komponenta_areal', {}).get('id', "") not in filters.get('f_areal', []):
|
||||||
|
return False
|
||||||
|
if filter_datace and komp.get('komponenta_obdobi', {}).get('id', "") not in filters.get('f_obdobi', []):
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
|
||||||
def load_amcr_data(canvas, bb, filters=None, typ_dat="akce", komponenty="false"):
|
def load_amcr_data(canvas, bb, filters=None, typ_dat="akce", komponenty="false"):
|
||||||
"""
|
"""
|
||||||
Main processing function:
|
Main processing function:
|
||||||
@@ -203,6 +210,10 @@ def load_amcr_data(canvas, bb, filters=None, typ_dat="akce", komponenty="false")
|
|||||||
|
|
||||||
# Check if we should skip negative results based on filter
|
# Check if we should skip negative results based on filter
|
||||||
skip_negativni = filters.get('posevidence') == 'true' if filters else False
|
skip_negativni = filters.get('posevidence') == 'true' if filters else False
|
||||||
|
|
||||||
|
# Check whether we should filter results based on component filters
|
||||||
|
filter_areal = "f_areal" in filters if filters else False
|
||||||
|
filter_datace = "f_obdobi" in filters if filters else False
|
||||||
|
|
||||||
# --- API PAGINATION LOOP ---
|
# --- API PAGINATION LOOP ---
|
||||||
while True:
|
while True:
|
||||||
@@ -339,6 +350,14 @@ def load_amcr_data(canvas, bb, filters=None, typ_dat="akce", komponenty="false")
|
|||||||
if skip_negativni and dj.get('dj_negativni_jednotka') is True:
|
if skip_negativni and dj.get('dj_negativni_jednotka') is True:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
komps = dj.get('dj_komponenta', [])
|
||||||
|
|
||||||
|
if filter_areal or filter_datace:
|
||||||
|
if not komps:
|
||||||
|
continue
|
||||||
|
if not any(komp_projde_filtrem(komp, filter_areal, filter_datace, filters) for komp in komps):
|
||||||
|
continue
|
||||||
|
|
||||||
dj_id = dj.get('ident_cely')
|
dj_id = dj.get('ident_cely')
|
||||||
dj_typ = dj.get('dj_typ')
|
dj_typ = dj.get('dj_typ')
|
||||||
|
|
||||||
@@ -361,9 +380,11 @@ def load_amcr_data(canvas, bb, filters=None, typ_dat="akce", komponenty="false")
|
|||||||
|
|
||||||
if komponenty == "true":
|
if komponenty == "true":
|
||||||
# One feature per component — all data on a single row, no relations needed
|
# One feature per component — all data on a single row, no relations needed
|
||||||
komps = dj.get('dj_komponenta', [])
|
|
||||||
if komps:
|
if komps:
|
||||||
for komp in komps:
|
for komp in komps:
|
||||||
|
if not komp_projde_filtrem(komp, filter_areal, filter_datace, filters):
|
||||||
|
continue
|
||||||
|
|
||||||
komp_meta = {
|
komp_meta = {
|
||||||
**dj_meta,
|
**dj_meta,
|
||||||
'komponenta_id': komp.get('ident_cely', ""),
|
'komponenta_id': komp.get('ident_cely', ""),
|
||||||
@@ -374,6 +395,9 @@ def load_amcr_data(canvas, bb, filters=None, typ_dat="akce", komponenty="false")
|
|||||||
target_pian_ids_count += 1
|
target_pian_ids_count += 1
|
||||||
else:
|
else:
|
||||||
# DJ without components — still include with empty component fields
|
# DJ without components — still include with empty component fields
|
||||||
|
if filter_areal or filter_datace:
|
||||||
|
continue
|
||||||
|
|
||||||
empty_meta = {
|
empty_meta = {
|
||||||
**dj_meta,
|
**dj_meta,
|
||||||
'komponenta_id': "",
|
'komponenta_id': "",
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ name=AMČR Viewer
|
|||||||
qgisMinimumVersion=3.4.0
|
qgisMinimumVersion=3.4.0
|
||||||
qgisMaximumVersion=4.99.0
|
qgisMaximumVersion=4.99.0
|
||||||
description=Viewing and downloading the AMČR data.
|
description=Viewing and downloading the AMČR data.
|
||||||
version=2.0.0-alpha.2
|
version=2.0.0-alpha.4
|
||||||
author=David Spáčil
|
author=David Spáčil
|
||||||
email=spacil@arub.cz
|
email=spacil@arub.cz
|
||||||
|
|
||||||
@@ -22,7 +22,16 @@ repository=https://github.com/ARUP-CAS/aiscr-qgis-amcr-viewer
|
|||||||
|
|
||||||
hasProcessingProvider=no
|
hasProcessingProvider=no
|
||||||
# Uncomment the following line and add your changelog:
|
# Uncomment the following line and add your changelog:
|
||||||
# changelog=
|
changelog=
|
||||||
|
v2.0.0-alpha.4 (2026-06-03)
|
||||||
|
* Backend filtering of the results based on the component-related filters improvement (plugin not only loads the results from API, it filters them further)
|
||||||
|
v2.0.0-alpha.2–3 (2026-05-19)
|
||||||
|
* Security vulnerabilities fix
|
||||||
|
v2.0.0-alpha.1 (2026-05-19):
|
||||||
|
* Attribute fields renamed to be ASCII compliant
|
||||||
|
* Codelist update; codelist can be recompiled from AMČR API
|
||||||
|
* Basic element changed from Documentation Unit to Component if user asks for components to simplify result filtering
|
||||||
|
* Plugin now supports logging with an AMČR account and enables the downloading of Events and Sites available to the roles Researcher and higher
|
||||||
|
|
||||||
# Tags are comma separated with spaces allowed
|
# Tags are comma separated with spaces allowed
|
||||||
tags=python,AMCR,AIS CR,archaeology,PIAN,AMČR
|
tags=python,AMCR,AIS CR,archaeology,PIAN,AMČR
|
||||||
|
|||||||
Reference in New Issue
Block a user