mirror of
https://github.com/ARUP-CAS/aiscr-qgis-amcr-viewer.git
synced 2026-06-17 11:22:53 +02:00
Merge pull request #20 from ARUP-CAS/import-lokalit
Sites importing implementation
This commit is contained in:
@@ -205,3 +205,8 @@ cython_debug/
|
||||
marimo/_static/
|
||||
marimo/_lsp/
|
||||
__marimo__/
|
||||
|
||||
|
||||
|
||||
README_files/
|
||||
README.html
|
||||
|
||||
@@ -12,14 +12,13 @@
|
||||
|
||||
## 1. Overview
|
||||
|
||||
**AMCR Viewer** is a QGIS plugin designed to facilitate direct access to the Digital Archive of the Archaeological Map of the Czech Republic (AMČR). It allows researchers to **query, retrieve, and visualize Fieldwork events[^1] data (metadata and geometry) directly within the GIS environment**, eliminating the need to manually export data from the web interface. **Only publicly accessible data are supported at the time** (accessibility = anonymous).
|
||||
**AMCR Viewer** is a QGIS plugin designed to facilitate direct access to the Digital Archive of the Archaeological Map of the Czech Republic (AMČR). It allows researchers to **query, retrieve, and visualize *Fieldwork events* and *Sites* data (metadata and geometry) directly within the GIS environment**, eliminating the need to manually export data from the web interface. **Only publicly accessible data are supported at the time** (accessibility = anonymous).
|
||||
|
||||
[^1]: Only Fieldwork events (Akce) are supported at the time.
|
||||
|
||||
### Key Features
|
||||
|
||||
* **Spatial Querying:** Option to filter records based on the current map canvas extent (Bounding Box).
|
||||
* **Advanced Attribute Filtering:** Supports multi-criteria filtering using controlled vocabularies (Cadastral Area, District, Period, Type of Fieldwork event, Organization, Fieldwork Manager).
|
||||
* **Advanced Attribute Filtering:** Supports multi-criteria filtering using controlled vocabularies.
|
||||
* **Dynamic Geometry Retrieval:** Automatically downloads and categorizes spatial data into Point, Line, and Polygon layers.
|
||||
* **Semantic Interoperability:** Automatically translates internal system codes into human-readable labels using the AIS CR API.
|
||||
|
||||
@@ -44,14 +43,14 @@
|
||||
|
||||
### 3.1 Data Retrieval
|
||||
|
||||
To initiate a search query, click the **Load AMCR Data** icon. The filter dialog provides the following options:
|
||||
To initiate a search query, click either the **Stáhnout data akcí** or the **Stáhnout data lokalit** icon from the dropdown menu. The filter dialog provides the following options. Shown options vary based on the choosed tool.
|
||||
|
||||
* **Spatial Filter:** *Checkbox "Limit search to current map extent":* If checked, the query is restricted to the geographical area currently visible in the QGIS canvas. If unchecked, the query searches the entire database (use with caution regarding data volume).
|
||||
* It is possible to view only those Fieldwork events with positive outcome, if "Positive findings only" is checked. Only PIANs marked as (or rather PIANs belonging to Documentation units marked as) "Type of evidence" = "positive" are rendered.
|
||||
* It is possible to view only those Fieldwork events with positive outcome, if "Positive findings only" is checked. Only *PIANs* marked as (or rather *PIANs* belonging to Documentation units marked as) "Type of evidence" = "positive" are rendered.
|
||||
|
||||
|
||||
* **Attribute Filters:**
|
||||
* The dialog utilizes "Picker" widgets for controlled vocabularies (Region, District, Cadastral area, Organisation, Period, Activity Area, PIAN accuracy.
|
||||
* The dialog utilizes "Picker" widgets for controlled vocabularies (common: Region, District, Cadastral area, Period, Activity Area, *PIAN* accuracy; *events* related: Organisation, Researcher, Event type; *sites* related: Site type and class, Level of confidence, State of preservation).
|
||||
* Click **Select...** to open a searchable selection window. Multiple values can be selected simultaneously (Logic: OR).
|
||||
|
||||
|
||||
@@ -104,7 +103,7 @@ The plugin interacts with three primary endpoints of the AIS CR infrastructure:
|
||||
### 4.3 Data Persistence
|
||||
|
||||
* **Vocabularies:** Static vocabularies (e.g., Periods, Regions) are stored in `codelists/heslar.csv`.
|
||||
* **Dynamic Data:** The list of investigators is downloaded on-demand and cached in `codelists/vedouci.csv`.
|
||||
* **Dynamic Data:** The list of researchers is downloaded on-demand and cached in `codelists/vedouci.csv`.
|
||||
* **Layers:** Output layers are created as `memory` layers. They are non-persistent and will be lost if QGIS is closed without saving.
|
||||
|
||||
### 4.4 Constraints
|
||||
@@ -115,3 +114,4 @@ The plugin interacts with three primary endpoints of the AIS CR infrastructure:
|
||||
## 6. Links and resources
|
||||
|
||||
* [AMCR/Digiarchive Documentation](https://amcr-help.aiscr.cz/) (only in Czech).
|
||||
* [AMCR Viewer tutorial](https://amcr-help.aiscr.cz/digiarchiv/qgis-viewer.html) (only in Czech).
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 869 B |
@@ -62,7 +62,8 @@ def load_all_data():
|
||||
categorized_data = {
|
||||
'obdobi': {}, 'typ_akce': {}, 'areal': {},
|
||||
'kraj': {}, 'organizace': {}, 'okres': {}, 'katastr': {},
|
||||
'vedouci': {}, 'pian_presnost': {}
|
||||
'vedouci': {}, 'pian_presnost': {}, 'typ_lokality': {}, 'druh_lokality': {},
|
||||
'jistota': {}, 'lokalita_zachovalost': {}
|
||||
}
|
||||
|
||||
# Funkce pro roztřídění načteného slovníku (tohle je trochu redundance, ale pro zachování logiky)
|
||||
@@ -156,8 +157,12 @@ KRAJE = _DATA['kraj']
|
||||
ORGANIZACE = _DATA['organizace']
|
||||
OKRESY = _DATA['okres']
|
||||
KATASTRY = _DATA['katastr']
|
||||
VEDOUCI = _DATA['vedouci'] # Tady to bude zpočátku prázdné, pokud soubor neexistuje
|
||||
VEDOUCI = _DATA['vedouci']
|
||||
PIAN_PRESNOST = _DATA['pian_presnost']
|
||||
TYP_LOKALITY = _DATA['typ_lokality']
|
||||
DRUH_LOKALITY = _DATA['druh_lokality']
|
||||
JISTOTA = _DATA['jistota']
|
||||
LOKALITA_ZACHOVALOST = _DATA['lokalita_zachovalost']
|
||||
|
||||
def refresh_vedouci_cache():
|
||||
"""
|
||||
|
||||
+63
-18
@@ -6,7 +6,8 @@ from qgis.PyQt.QtWidgets import (QDialog, QVBoxLayout, QFormLayout,
|
||||
QLabel, QMessageBox, QApplication, QWidget)
|
||||
from qgis.PyQt.QtCore import Qt
|
||||
from .amcr_codelists import (OBDOBI, TYP_AKCE, KRAJE, AREAL, ORGANIZACE,
|
||||
OKRESY, KATASTRY, VEDOUCI, PIAN_PRESNOST,
|
||||
OKRESY, KATASTRY, VEDOUCI, PIAN_PRESNOST, TYP_LOKALITY,
|
||||
DRUH_LOKALITY, JISTOTA, LOKALITA_ZACHOVALOST,
|
||||
download_vedouci, refresh_vedouci_cache)
|
||||
|
||||
class FilterableSelectionDialog(QDialog):
|
||||
@@ -65,15 +66,19 @@ class FilterableSelectionDialog(QDialog):
|
||||
|
||||
# --- Main window ---
|
||||
class AmcrFilterDialog(QDialog):
|
||||
def __init__(self, parent=None):
|
||||
super().__init__(parent)
|
||||
def __init__(self, typ_dat, parent=None):
|
||||
super(AmcrFilterDialog, self).__init__(parent)
|
||||
self.setWindowTitle("Filtr AMČR")
|
||||
self.resize(500, 750)
|
||||
self.typ_dat = typ_dat
|
||||
|
||||
|
||||
|
||||
# Cache for filtering
|
||||
self.selection_cache = {
|
||||
'organizace': [], 'kraj': [], 'obdobi': [], 'areal': [],
|
||||
'typ_akce': [], 'okres': [], 'katastr': [], 'vedouci': [], 'pian_presnost': []
|
||||
'typ_akce': [], 'okres': [], 'katastr': [], 'vedouci': [], 'pian_presnost': [],
|
||||
'typ_lokality': [], 'druh_lokality': [], 'jistota': [], 'lokalita_zachovalost': []
|
||||
}
|
||||
|
||||
layout = QVBoxLayout()
|
||||
@@ -82,6 +87,9 @@ class AmcrFilterDialog(QDialog):
|
||||
self.chk_bbox.setChecked(True)
|
||||
layout.addWidget(self.chk_bbox)
|
||||
|
||||
# Positive/negative evidence – valid for Akce
|
||||
|
||||
if self.typ_dat == "akce":
|
||||
self.chk_posevidence = QCheckBox("Pouze pozitivní zjištění")
|
||||
layout.addWidget(self.chk_posevidence)
|
||||
|
||||
@@ -127,6 +135,8 @@ class AmcrFilterDialog(QDialog):
|
||||
row_widget.setLayout(row_layout)
|
||||
return row_widget
|
||||
|
||||
# Spatial information – valid for all
|
||||
|
||||
self.picker_kraj = setup_picker("Kraj", 'kraj', KRAJE)
|
||||
layout.addWidget(self.picker_kraj)
|
||||
|
||||
@@ -136,6 +146,12 @@ class AmcrFilterDialog(QDialog):
|
||||
self.picker_katastr = setup_picker("Katastr", 'katastr', KATASTRY)
|
||||
layout.addWidget(self.picker_katastr)
|
||||
|
||||
self.picker_presnost = setup_picker("PIAN – přesnost", 'pian_presnost', PIAN_PRESNOST)
|
||||
layout.addWidget(self.picker_presnost)
|
||||
|
||||
# Filters valid for Akce
|
||||
|
||||
if self.typ_dat == "akce":
|
||||
self.picker_org = setup_picker("Organizace", 'organizace', ORGANIZACE)
|
||||
layout.addWidget(self.picker_org)
|
||||
|
||||
@@ -147,17 +163,35 @@ class AmcrFilterDialog(QDialog):
|
||||
self.picker_vedouci = setup_picker("Vedoucí výzkumu", 'vedouci', VEDOUCI, extra_btn=self.btn_update_vedouci)
|
||||
layout.addWidget(self.picker_vedouci)
|
||||
|
||||
self.picker_obdobi = setup_picker("Období", 'obdobi', OBDOBI)
|
||||
layout.addWidget(self.picker_obdobi)
|
||||
|
||||
self.picker_areal = setup_picker("Areál / Druh", 'areal', AREAL)
|
||||
layout.addWidget(self.picker_areal)
|
||||
# Type of event
|
||||
|
||||
self.picker_typ = setup_picker("Typ výzkumu", 'typ_akce', TYP_AKCE)
|
||||
layout.addWidget(self.picker_typ)
|
||||
|
||||
self.picker_presnost = setup_picker("PIAN – přesnost", 'pian_presnost', PIAN_PRESNOST)
|
||||
layout.addWidget(self.picker_presnost)
|
||||
# Filters valid for Lokality
|
||||
|
||||
if self.typ_dat == "lokalita":
|
||||
self.picker_typ_lokality = setup_picker("Lokalita – typ", 'typ_lokality', TYP_LOKALITY)
|
||||
layout.addWidget(self.picker_typ_lokality)
|
||||
|
||||
self.picker_druh_lokality = setup_picker("Lokalita – druh", 'druh_lokality', DRUH_LOKALITY)
|
||||
layout.addWidget(self.picker_druh_lokality)
|
||||
|
||||
self.picker_jistota = setup_picker("Lokalita – jistota určení", 'jistota', JISTOTA)
|
||||
layout.addWidget(self.picker_jistota)
|
||||
|
||||
self.picker_lokalita_zachovalost = setup_picker("Lokalita - stav dochování", 'lokalita_zachovalost', LOKALITA_ZACHOVALOST)
|
||||
layout.addWidget(self.picker_lokalita_zachovalost)
|
||||
|
||||
# Contextual information
|
||||
|
||||
self.picker_obdobi = setup_picker("Období", 'obdobi', OBDOBI)
|
||||
layout.addWidget(self.picker_obdobi)
|
||||
|
||||
self.picker_areal = setup_picker("Areál", 'areal', AREAL)
|
||||
layout.addWidget(self.picker_areal)
|
||||
|
||||
|
||||
|
||||
layout.addStretch(1)
|
||||
|
||||
@@ -188,12 +222,7 @@ class AmcrFilterDialog(QDialog):
|
||||
|
||||
def get_filters(self):
|
||||
filters = {}
|
||||
if self.chk_posevidence.isChecked():
|
||||
filters['posevidence'] = 'true'
|
||||
|
||||
# Loading from cache
|
||||
if self.selection_cache['organizace']:
|
||||
filters['f_organizace'] = self.selection_cache['organizace']
|
||||
if self.selection_cache['kraj']:
|
||||
filters['f_kraj'] = self.selection_cache['kraj']
|
||||
if self.selection_cache['okres']:
|
||||
@@ -204,11 +233,27 @@ class AmcrFilterDialog(QDialog):
|
||||
filters['f_obdobi'] = self.selection_cache['obdobi']
|
||||
if self.selection_cache['areal']:
|
||||
filters['f_areal'] = self.selection_cache['areal']
|
||||
if self.selection_cache['pian_presnost']:
|
||||
filters['f_pian_presnost'] = self.selection_cache['pian_presnost']
|
||||
|
||||
if self.typ_dat == "akce":
|
||||
if self.chk_posevidence.isChecked():
|
||||
filters['posevidence'] = 'true'
|
||||
if self.selection_cache['organizace']:
|
||||
filters['f_organizace'] = self.selection_cache['organizace']
|
||||
if self.selection_cache['typ_akce']:
|
||||
filters['f_typ_vyzkumu'] = self.selection_cache['typ_akce']
|
||||
if self.selection_cache['vedouci']:
|
||||
filters['f_vedouci'] = self.selection_cache['vedouci']
|
||||
if self.selection_cache['pian_presnost']:
|
||||
filters['f_pian_presnost'] = self.selection_cache['pian_presnost']
|
||||
|
||||
if self.typ_dat == "lokalita":
|
||||
if self.selection_cache['typ_lokality']:
|
||||
filters['f_typ_lokality'] = self.selection_cache['typ_lokality']
|
||||
if self.selection_cache['druh_lokality']:
|
||||
filters['f_druh_lokality'] = self.selection_cache['druh_lokality']
|
||||
if self.selection_cache['jistota']:
|
||||
filters['f_jistota'] = self.selection_cache['jistota']
|
||||
if self.selection_cache['lokalita_zachovalost']:
|
||||
filters['f_lokalita_zachovalost'] = self.selection_cache['lokalita_zachovalost']
|
||||
|
||||
return filters
|
||||
+90
-40
@@ -33,7 +33,7 @@ def tr_code(code):
|
||||
return ""
|
||||
return TRANSLATIONS.get(code, code)
|
||||
|
||||
def load_amcr_data(canvas, bb, filters=None):
|
||||
def load_amcr_data(canvas, bb, filters=None, typ_dat="akce"):
|
||||
load_translations()
|
||||
|
||||
# 1. Bounding box
|
||||
@@ -46,20 +46,21 @@ def load_amcr_data(canvas, bb, filters=None):
|
||||
|
||||
url = "https://digiarchiv.aiscr.cz/api/search/query"
|
||||
|
||||
iface.messageBar().pushMessage("AMCR", "Hledám akce...", level=1)
|
||||
iface.messageBar().pushMessage("AMCR", "Hledám záznamy...", level=1)
|
||||
QApplication.setOverrideCursor(Qt.WaitCursor)
|
||||
|
||||
try:
|
||||
# ===================
|
||||
# A) METADATA (Fieldwork event)
|
||||
# A) METADATA (Fieldwork event/Site)
|
||||
# ===================
|
||||
|
||||
base_params = {
|
||||
"mapa": "true",
|
||||
"entity": "akce",
|
||||
"sort": "ident_cely asc"
|
||||
}
|
||||
|
||||
base_params["entity"] = typ_dat
|
||||
|
||||
if bb == "true":
|
||||
base_params["loc_rpt"] = bbox_str
|
||||
|
||||
@@ -73,24 +74,24 @@ def load_amcr_data(canvas, bb, filters=None):
|
||||
else:
|
||||
base_params[key] = str(value).strip()
|
||||
|
||||
docs_akce = []
|
||||
docs = []
|
||||
current_page = 0
|
||||
BATCH_AKCE = 500
|
||||
BATCH_DOCS = 500
|
||||
MAX_LIMIT = 20000
|
||||
|
||||
seen_ids = set()
|
||||
target_pian_ids_count = 0
|
||||
|
||||
while True:
|
||||
base_params['rows'] = BATCH_AKCE
|
||||
base_params['rows'] = BATCH_DOCS
|
||||
if current_page > 0:
|
||||
base_params['page'] = current_page
|
||||
elif 'page' in base_params:
|
||||
del base_params['page']
|
||||
|
||||
try:
|
||||
resp_akce = requests.get(url, params=base_params, timeout=30)
|
||||
resp_json = resp_akce.json()
|
||||
resp_docs = requests.get(url, params=base_params, timeout=30)
|
||||
resp_json = resp_docs.json()
|
||||
data = resp_json.get('response', {})
|
||||
batch_docs = data.get('docs', [])
|
||||
num_found = data.get('numFound', 0)
|
||||
@@ -105,12 +106,12 @@ def load_amcr_data(canvas, bb, filters=None):
|
||||
seen_ids.add(ident)
|
||||
new_docs.append(d)
|
||||
|
||||
docs_akce.extend(new_docs)
|
||||
print(f"Strana {current_page} stažena. Celkem záznamů: {len(docs_akce)} / {num_found}")
|
||||
docs.extend(new_docs)
|
||||
print(f"Strana {current_page} stažena. Celkem záznamů: {len(docs)} / {num_found}")
|
||||
|
||||
if len(docs_akce) >= num_found:
|
||||
if len(docs) >= num_found:
|
||||
break
|
||||
if len(docs_akce) >= MAX_LIMIT:
|
||||
if len(docs) >= MAX_LIMIT:
|
||||
iface.messageBar().pushMessage("AMCR", f"Limit {MAX_LIMIT} záznamů dosažen.", level=1)
|
||||
break
|
||||
|
||||
@@ -121,8 +122,8 @@ def load_amcr_data(canvas, bb, filters=None):
|
||||
print(f"Chyba při stránkování na straně {current_page}: {e}")
|
||||
break
|
||||
|
||||
if not docs_akce:
|
||||
iface.messageBar().pushMessage("AMCR", "Žádné akce nenalezeny.", level=1)
|
||||
if not docs:
|
||||
iface.messageBar().pushMessage("AMCR", "Žádné záznamy nenalezeny.", level=1)
|
||||
return
|
||||
|
||||
# ==========================================
|
||||
@@ -132,29 +133,29 @@ def load_amcr_data(canvas, bb, filters=None):
|
||||
target_pian_ids = set()
|
||||
actions_with_geom = 0
|
||||
|
||||
for akce in docs_akce:
|
||||
piani = akce.get('az_dj_pian', [])
|
||||
for doc in docs:
|
||||
piani = doc.get('az_dj_pian', [])
|
||||
if not piani:
|
||||
continue
|
||||
|
||||
actions_with_geom += 1
|
||||
|
||||
def g(key, default=""):
|
||||
val = akce.get(key)
|
||||
val = doc.get(key)
|
||||
if isinstance(val, list):
|
||||
return str(val[0]) if val else default
|
||||
return str(val) if val is not None else default
|
||||
|
||||
def g_list(key, translate=False):
|
||||
val = akce.get(key, [])
|
||||
val = doc.get(key, [])
|
||||
if not isinstance(val, list):
|
||||
val = [val] if val else []
|
||||
if translate:
|
||||
return ", ".join([tr_code(str(x)) for x in val if x])
|
||||
return ", ".join([str(x) for x in val if x])
|
||||
|
||||
az_chranene = akce.get('az_chranene_udaje', {})
|
||||
akce_chranene = akce.get('akce_chranene_udaje', {})
|
||||
az_chranene = doc.get('az_chranene_udaje', {})
|
||||
chranene = doc.get('akce_chranene_udaje') or doc.get('lokalita_chranene_udaje') or {}
|
||||
|
||||
dalsi_kat = az_chranene.get('dalsi_katastr', [])
|
||||
dalsi_kat_str = ""
|
||||
@@ -162,14 +163,22 @@ def load_amcr_data(canvas, bb, filters=None):
|
||||
items = [x.get('value', '') if isinstance(x, dict) else str(x) for x in dalsi_kat]
|
||||
dalsi_kat_str = ", ".join([i for i in items if i])
|
||||
|
||||
lokalizace = akce_chranene.get('lokalizace_okolnosti', "")
|
||||
lokalizace = chranene.get('lokalizace_okolnosti', "")
|
||||
lokalita_nazev = chranene.get('nazev', "")
|
||||
lokalita_popis = chranene.get('popis', "")
|
||||
|
||||
# Prepate metadata for fieldwork event
|
||||
# Prepate common metadata
|
||||
meta = {
|
||||
"ident_cely": akce.get('ident_cely', ''),
|
||||
"ident_cely": doc.get('ident_cely', ''),
|
||||
"az_okres": g('az_okres'),
|
||||
"katastr": g_list('katastr'),
|
||||
"dalsi_katastr": dalsi_kat_str,
|
||||
"pristupnost": g('pristupnost'),
|
||||
"loc": g_list('loc')
|
||||
}
|
||||
|
||||
if typ_dat == "akce":
|
||||
meta.update({
|
||||
"akce_hlavni_vedouci": g('akce_hlavni_vedouci'),
|
||||
"akce_organizace": tr_code(g('akce_organizace')),
|
||||
"akce_specifikace_data": tr_code(g('akce_specifikace_data')),
|
||||
@@ -178,12 +187,19 @@ def load_amcr_data(canvas, bb, filters=None):
|
||||
"akce_hlavni_typ": tr_code(g('akce_hlavni_typ')),
|
||||
"akce_vedlejsi_typ": g_list('akce_vedlejsi_typ', translate=True),
|
||||
"lokalizace_okolnosti": str(lokalizace) if lokalizace else "",
|
||||
"akce_je_nz": "Ano" if akce.get('akce_je_nz') is True else "Ne",
|
||||
"pristupnost": g('pristupnost'),
|
||||
"loc": g_list('loc')
|
||||
}
|
||||
"akce_je_nz": "Ano" if doc.get('akce_je_nz') is True else "Ne",
|
||||
})
|
||||
|
||||
djs = akce.get('az_dokumentacni_jednotka', [])
|
||||
elif typ_dat == "lokalita":
|
||||
meta.update({
|
||||
"lokalita_nazev": lokalita_nazev,
|
||||
"lokalita_popis": lokalita_popis,
|
||||
"lokalita_zachovalost": tr_code(g('lokalita_zachovalost')),
|
||||
"lokalita_druh": tr_code(g('lokalita_druh')),
|
||||
"lokalita_typ": tr_code(g('lokalita_typ_lokality')),
|
||||
})
|
||||
|
||||
djs = doc.get('az_dokumentacni_jednotka', [])
|
||||
|
||||
for dj in djs:
|
||||
if filters and filters.get('posevidence') == 'true' and dj.get('dj_negativni_jednotka') is True:
|
||||
@@ -205,7 +221,7 @@ def load_amcr_data(canvas, bb, filters=None):
|
||||
pian_lookup[dj_pian_value].append(dj_meta)
|
||||
|
||||
if not target_pian_ids:
|
||||
iface.messageBar().pushMessage("AMCR", f"Nalezeno {len(docs_akce)} akcí, ale žádná nemá geometrii.", level=1)
|
||||
iface.messageBar().pushMessage("AMCR", f"Nalezeno {len(docs)} záznamů, ale žádný nemá geometrii.", level=1)
|
||||
return
|
||||
|
||||
|
||||
@@ -217,7 +233,7 @@ def load_amcr_data(canvas, bb, filters=None):
|
||||
docs_pian = []
|
||||
BATCH_PIAN = 50
|
||||
|
||||
iface.messageBar().pushMessage("AMCR", f"Akcí: {len(docs_akce)} (z toho {actions_with_geom} s mapou). Stahuji {total_pians} unikátních geometrií, vykresluji {target_pian_ids_count} geometrií...", level=1)
|
||||
iface.messageBar().pushMessage("AMCR", f"Záznamů: {len(docs)} (z toho {actions_with_geom} s mapou). Stahuji {total_pians} unikátních geometrií, vykresluji {target_pian_ids_count} geometrií...", level=1)
|
||||
|
||||
# Seznam polí pro PIAN
|
||||
fl_pian = ["ident_cely", "pian_typ", "pian_chranene_udaje", "pian_presnost"]
|
||||
@@ -250,6 +266,11 @@ def load_amcr_data(canvas, bb, filters=None):
|
||||
vl_point = QgsVectorLayer("Point?crs=epsg:5514", "AMCR Body", "memory")
|
||||
layers = [vl_poly, vl_line, vl_point]
|
||||
|
||||
if typ_dat == "akce":
|
||||
archeologicky_zaznam = "Akce"
|
||||
elif typ_dat == "lokalita":
|
||||
archeologicky_zaznam = "Lokalita"
|
||||
|
||||
# Definice sloupců atributové tabulky
|
||||
cols = [
|
||||
QgsField("PIAN", QVariant.String),
|
||||
@@ -258,11 +279,15 @@ def load_amcr_data(canvas, bb, filters=None):
|
||||
QgsField("Dokumentační jednotka", QVariant.String),
|
||||
QgsField("Typ dokumentační jednotky", QVariant.String),
|
||||
QgsField("Definiční bod(y) (WGS-84)", QVariant.String),
|
||||
QgsField("Akce", QVariant.String),
|
||||
QgsField(archeologicky_zaznam, QVariant.String),
|
||||
QgsField("Odkaz do Digitálního archivu AMČR", QVariant.String),
|
||||
QgsField("Okres", QVariant.String),
|
||||
QgsField("Katastr", QVariant.String),
|
||||
QgsField("Další katastry", QVariant.String),
|
||||
QgsField("Další katastry", QVariant.String)
|
||||
]
|
||||
|
||||
if typ_dat == "akce":
|
||||
cols += [
|
||||
QgsField("Vedoucí akce", QVariant.String),
|
||||
QgsField("Organizace", QVariant.String),
|
||||
QgsField("Specifikace data", QVariant.String),
|
||||
@@ -273,8 +298,17 @@ def load_amcr_data(canvas, bb, filters=None):
|
||||
QgsField("Zjištění", QVariant.String),
|
||||
QgsField("Akce – lokalizace", QVariant.String),
|
||||
QgsField("Akce – nahrazuje NZ", QVariant.String),
|
||||
QgsField("Přístupnost", QVariant.String)
|
||||
]
|
||||
elif typ_dat == "lokalita":
|
||||
cols += [
|
||||
QgsField("Název lokality", QVariant.String),
|
||||
QgsField("Popis lokality", QVariant.String),
|
||||
QgsField("Typ lokality", QVariant.String),
|
||||
QgsField("Druh lokality", QVariant.String),
|
||||
QgsField("Zachovalost", QVariant.String)
|
||||
]
|
||||
|
||||
cols.append(QgsField("Přístupnost", QVariant.String))
|
||||
|
||||
for vl in layers:
|
||||
vl.dataProvider().addAttributes(cols)
|
||||
@@ -316,7 +350,7 @@ def load_amcr_data(canvas, bb, filters=None):
|
||||
for meta in metas:
|
||||
feat = QgsFeature()
|
||||
feat.setGeometry(geom)
|
||||
feat.setAttributes([
|
||||
atributy = [
|
||||
pid,
|
||||
pian_presnost,
|
||||
pian_typ,
|
||||
@@ -327,7 +361,10 @@ def load_amcr_data(canvas, bb, filters=None):
|
||||
"https://digiarchiv.aiscr.cz/id/" + meta['ident_cely'],
|
||||
meta['az_okres'],
|
||||
meta['katastr'],
|
||||
meta['dalsi_katastr'],
|
||||
meta['dalsi_katastr']
|
||||
]
|
||||
if typ_dat == "akce":
|
||||
atributy += [
|
||||
meta['akce_hlavni_vedouci'],
|
||||
meta['akce_organizace'],
|
||||
meta['akce_specifikace_data'],
|
||||
@@ -337,9 +374,22 @@ def load_amcr_data(canvas, bb, filters=None):
|
||||
meta['akce_vedlejsi_typ'],
|
||||
meta['dj_negativni'],
|
||||
meta['lokalizace_okolnosti'],
|
||||
meta['akce_je_nz'],
|
||||
meta['pristupnost']
|
||||
])
|
||||
meta['akce_je_nz']
|
||||
]
|
||||
|
||||
elif typ_dat == "lokalita":
|
||||
atributy += [
|
||||
meta['lokalita_nazev'],
|
||||
meta['lokalita_popis'],
|
||||
meta['lokalita_typ'],
|
||||
meta['lokalita_druh'],
|
||||
meta['lokalita_zachovalost']
|
||||
]
|
||||
|
||||
atributy.append(meta['pristupnost'])
|
||||
|
||||
feat.setAttributes(atributy)
|
||||
|
||||
t = geom.type()
|
||||
if t == QgsWkbTypes.PolygonGeometry:
|
||||
feats_p.append(feat)
|
||||
@@ -362,7 +412,7 @@ def load_amcr_data(canvas, bb, filters=None):
|
||||
added += len(f)
|
||||
|
||||
if added > 0:
|
||||
iface.messageBar().pushMessage("AMCR", f"Hotovo. Akcí: {len(docs_akce)} (s geom: {actions_with_geom}). Vykresleno: {added} prvků.", level=0)
|
||||
iface.messageBar().pushMessage("AMCR", f"Hotovo. Záznamů: {len(docs)} (s geom: {actions_with_geom}). Vykresleno: {added} prvků.", level=0)
|
||||
else:
|
||||
iface.messageBar().pushMessage("AMCR", "Žádná data k zobrazení.", level=1)
|
||||
|
||||
|
||||
+42
-11
@@ -1,7 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from qgis.PyQt.QtCore import QSettings, QTranslator, QCoreApplication
|
||||
from qgis.PyQt.QtGui import QIcon
|
||||
from qgis.PyQt.QtWidgets import QAction
|
||||
from qgis.PyQt.QtWidgets import QMenu, QAction, QToolButton
|
||||
|
||||
from .amcr_tools import load_amcr_data
|
||||
from .amcr_dialog import AmcrFilterDialog
|
||||
@@ -58,16 +58,47 @@ class AmcrViewer:
|
||||
|
||||
import os
|
||||
plugin_dir = os.path.dirname(__file__)
|
||||
icon_akce_path = os.path.join(plugin_dir, 'akce.png')
|
||||
icon_lokality_path = os.path.join(plugin_dir, 'lokality.png')
|
||||
|
||||
icon = QIcon(os.path.join(plugin_dir, 'download.png'))
|
||||
# 1. Vytvoření společného menu
|
||||
self.plugin_menu = QMenu()
|
||||
|
||||
# 2. Vytvoření akcí (bez automatického přidání do lišty a menu)
|
||||
self.action_download_akce = self.add_action(
|
||||
icon_path=icon_akce_path,
|
||||
text=self.tr(u'Stáhnout data akcí | AMČR Viewer'),
|
||||
callback=lambda checked=False: self.run_download('akce'),
|
||||
parent=self.iface.mainWindow(),
|
||||
add_to_menu=False,
|
||||
add_to_toolbar=False
|
||||
)
|
||||
self.plugin_menu.addAction(self.action_download_akce)
|
||||
|
||||
# Download data button
|
||||
self.action_download = self.add_action(
|
||||
icon,
|
||||
text=self.tr(u'Načíst data z AMČR'),
|
||||
callback=self.run_download,
|
||||
parent=self.iface.mainWindow())
|
||||
self.action_download_lokality = self.add_action(
|
||||
icon_path=icon_lokality_path,
|
||||
text=self.tr(u'Stáhnout data lokalit | AMČR Viewer'),
|
||||
callback=lambda checked=False: self.run_download('lokalita'),
|
||||
parent=self.iface.mainWindow(),
|
||||
add_to_menu=False,
|
||||
add_to_toolbar=False
|
||||
)
|
||||
self.plugin_menu.addAction(self.action_download_lokality)
|
||||
|
||||
# 3. Přidání rozbalovacího menu do hlavního menu QGIS
|
||||
main_icon = QIcon(icon_akce_path)
|
||||
self.main_action = QAction(main_icon, 'AMČR Viewer', self.iface.mainWindow())
|
||||
self.main_action.setMenu(self.plugin_menu)
|
||||
self.iface.addPluginToMenu(self.menu, self.main_action)
|
||||
|
||||
# 4. Přidání rozevíracího tlačítka do nástrojové lišty (Toolbar)
|
||||
self.tool_button = QToolButton()
|
||||
self.tool_button.setMenu(self.plugin_menu)
|
||||
self.tool_button.setDefaultAction(self.action_download_akce)
|
||||
self.tool_button.setPopupMode(QToolButton.MenuButtonPopup)
|
||||
|
||||
# Vložení vytvořeného tlačítka do QGIS rozhraní
|
||||
self.iface.addToolBarWidget(self.tool_button)
|
||||
|
||||
self.first_start = True
|
||||
|
||||
@@ -80,9 +111,9 @@ class AmcrViewer:
|
||||
self.iface.mapCanvas().unsetMapTool(self.tool)
|
||||
|
||||
# --- Data downloading ---
|
||||
def run_download(self):
|
||||
def run_download(self, typ_dat):
|
||||
|
||||
dlg = AmcrFilterDialog()
|
||||
dlg = AmcrFilterDialog(typ_dat)
|
||||
result = dlg.exec_()
|
||||
|
||||
if result == 1:
|
||||
@@ -90,4 +121,4 @@ class AmcrViewer:
|
||||
bbox = dlg.get_bbox()
|
||||
|
||||
canvas = self.iface.mapCanvas()
|
||||
load_amcr_data(canvas, bbox, filters)
|
||||
load_amcr_data(canvas, bbox, filters, typ_dat)
|
||||
|
||||
@@ -13618,3 +13618,30 @@ odchylka jednotky metrů;HES-000861;pian_presnost
|
||||
odchylka desítky metrů;HES-000862;pian_presnost
|
||||
odchylka stovky metrů;HES-000863;pian_presnost
|
||||
poloha podle katastru;HES-000864;pian_presnost
|
||||
nemovitá památka;HES-001122;typ_lokality
|
||||
polygon průzkumu;HES-001123;typ_lokality
|
||||
krajina;HES-001124;typ_lokality
|
||||
polygon leteckého průzkumu;HES-000111;druh_lokality
|
||||
osídlený skalní prostor;HES-000112;druh_lokality
|
||||
krajina;HES-000117;druh_lokality
|
||||
pomník/památník;HES-000128;druh_lokality
|
||||
muzeum/skanzen;HES-000129;druh_lokality
|
||||
pozůstatek mohylníku;HES-001430;druh_lokality
|
||||
pozůstatek ohrazení;HES-001431;druh_lokality
|
||||
pozůstatek represe;HES-001432;druh_lokality
|
||||
pozůstatek kultu;HES-001433;druh_lokality
|
||||
pozůstatek sídla elity;HES-001434;druh_lokality
|
||||
pozůstatek sídliště;HES-001435;druh_lokality
|
||||
pozůstatek těžby;HES-001436;druh_lokality
|
||||
pozůstatek vojenství;HES-001437;druh_lokality
|
||||
pozůstatek výroby;HES-001438;druh_lokality
|
||||
pozůstatek komunikace;HES-001429;druh_lokality
|
||||
jisté (> 95 %);HES-001449;jistota
|
||||
nejisté (50–95 %);HES-001450;jistota
|
||||
domnělé (5–50 %);HES-001451;jistota
|
||||
pseudolokalita (< 5 %);HES-001452;jistota
|
||||
zaniklá lokalita;HES-001453;lokalita_zachovalost
|
||||
lokalita pod zástavbou;HES-001454;lokalita_zachovalost
|
||||
nadzemní relikty;HES-001455;lokalita_zachovalost
|
||||
ruina;HES-001456;lokalita_zachovalost
|
||||
historická budova/komplex;HES-001457;lokalita_zachovalost
|
||||
|
||||
|
Binary file not shown.
|
Before Width: | Height: | Size: 993 B |
Binary file not shown.
|
Before Width: | Height: | Size: 967 B |
Binary file not shown.
|
After Width: | Height: | Size: 877 B |
@@ -1,16 +1,17 @@
|
||||
# This file contains metadata for your plugin.
|
||||
|
||||
# This file should be included when you package your plugin.# Mandatory items:
|
||||
# This file should be included when you package your plugin.
|
||||
# Mandatory items:
|
||||
|
||||
[general]
|
||||
name=AMČR Viewer
|
||||
qgisMinimumVersion=3.4
|
||||
description=Viewing and downloading the AMČR data.
|
||||
version=1.1.0
|
||||
version=1.2.0
|
||||
author=David Spáčil
|
||||
email=spacil@arub.cz
|
||||
|
||||
about=This plugin is intended for downloading the data (Fieldwork events data only, at the time) from the Digiarchive of the Archaeological Map of the Czech Republic (AMCR). As of now, only publicly accessible data can be downloaded.
|
||||
about=This plugin is intended for downloading the data (Fieldwork events data only, at the time) from the Digiarchive of the Archaeological Map of the Czech Republic (https://digiarchiv.aiscr.cz/). As of now, only publicly accessible data can be downloaded.
|
||||
|
||||
tracker=https://github.com/ARUP-CAS/aiscr-qgis-amcr-viewer/issues
|
||||
repository=https://github.com/ARUP-CAS/aiscr-qgis-amcr-viewer
|
||||
|
||||
@@ -0,0 +1,99 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||
|
||||
<svg
|
||||
width="24"
|
||||
height="24"
|
||||
viewBox="0 0 6.3499998 6.35"
|
||||
version="1.1"
|
||||
id="svg1"
|
||||
xml:space="preserve"
|
||||
sodipodi:docname="icon.svg"
|
||||
inkscape:version="1.4.3 (0d15f75, 2025-12-25)"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"><sodipodi:namedview
|
||||
id="namedview1"
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#000000"
|
||||
borderopacity="0.25"
|
||||
inkscape:showpageshadow="2"
|
||||
inkscape:pageopacity="0.0"
|
||||
inkscape:pagecheckerboard="0"
|
||||
inkscape:deskcolor="#d1d1d1"
|
||||
inkscape:document-units="mm"
|
||||
inkscape:zoom="22.627417"
|
||||
inkscape:cx="6.8059028"
|
||||
inkscape:cy="14.606174"
|
||||
inkscape:window-width="1920"
|
||||
inkscape:window-height="1009"
|
||||
inkscape:window-x="1912"
|
||||
inkscape:window-y="-8"
|
||||
inkscape:window-maximized="1"
|
||||
inkscape:current-layer="layer1" /><defs
|
||||
id="defs1"><clipPath
|
||||
id="clip-0"><path
|
||||
clip-rule="nonzero"
|
||||
d="M 56 202 L 64 202 L 64 212.582031 L 56 212.582031 Z M 56 202 "
|
||||
id="path1" /></clipPath><clipPath
|
||||
id="clip-1"><path
|
||||
clip-rule="nonzero"
|
||||
d="M 111 202 L 120 202 L 120 212.582031 L 111 212.582031 Z M 111 202 "
|
||||
id="path2" /></clipPath><clipPath
|
||||
id="clip-2"><path
|
||||
clip-rule="nonzero"
|
||||
d="M 183 202 L 191 202 L 191 212.582031 L 183 212.582031 Z M 183 202 "
|
||||
id="path3" /></clipPath><clipPath
|
||||
id="clip-3"><path
|
||||
clip-rule="nonzero"
|
||||
d="M 220 202 L 227.445312 202 L 227.445312 212.582031 L 220 212.582031 Z M 220 202 "
|
||||
id="path4" /></clipPath></defs><g
|
||||
inkscape:label="Layer 1"
|
||||
inkscape:groupmode="layer"
|
||||
id="layer1"><path
|
||||
id="path39"
|
||||
style="display:inline"
|
||||
d="M 81.817206 0.011405799 C 62.571113 1.6910933 45.354524 13.210298 36.479524 30.538423 C 32.381867 38.534516 30.312854 47.189295 30.312854 56.243982 C 30.312854 69.122889 34.534136 81.246352 42.526324 91.312758 L 43.405375 92.378274 C 46.932719 96.698587 50.2156 100.55118 53.367944 104.05899 C 53.414814 104.10979 53.454254 104.16803 53.501133 104.21881 L 66.540378 73.385461 C 62.46616 68.596398 60.240518 62.587732 60.240518 56.243982 C 60.240518 52.493982 61.017351 48.846969 62.544695 45.429001 C 66.806414 35.882126 76.317127 29.725967 86.758533 29.725967 C 89.688221 29.725967 92.538869 30.194768 95.269338 31.124456 L 99.957606 21.201844 L 84.214615 14.209399 L 81.817206 0.011405799 z M 90.381286 0.35769831 L 92.152705 10.813068 L 110.39966 18.924304 L 103.31398 34.107899 C 107.88529 36.880579 111.46702 40.963271 113.6628 45.722017 C 116.28908 45.714971 119.29963 45.708698 122.71968 45.708698 C 133.11322 45.708698 139.70768 45.745211 143.25749 45.81525 C 143.26209 45.815341 143.27953 45.815159 143.28413 45.81525 L 144.8824 45.349087 C 144.8707 45.298307 144.85424 45.240042 144.84244 45.18926 C 139.4715 19.302542 117.04145 0.71707431 90.381286 0.35769831 z M 70.962267 79.791873 L 57.590049 110.8916 C 62.425987 115.99706 66.178471 119.43931 69.510502 122.50572 C 75.319096 127.84947 80.037477 132.17422 86.771852 142.01797 C 92.93488 133.01459 97.405493 128.62293 102.56812 123.85094 C 91.347418 109.36236 78.096901 91.972441 77.661695 90.939828 C 76.892417 89.114561 76.908479 86.67687 77.701652 84.946304 C 77.897699 84.518565 78.148245 84.087284 78.434194 83.681004 C 75.760133 82.798967 73.242325 81.491624 70.962267 79.791873 z "
|
||||
transform="matrix(0.0387992,0,0,0.0387992,-0.55393024,0.41865333)" /><path
|
||||
id="rect30"
|
||||
style="display:none;opacity:1;fill:#00b200;stroke:#ffffff;stroke-width:0.615;stroke-linecap:butt;stroke-linejoin:round;stroke-dasharray:none;paint-order:stroke fill markers"
|
||||
d="m 3.3486328,2.4970052 v 1.335319 H 2.7424683 L 4.2085286,5.738151 5.674589,3.8323242 H 5.0684245 v -1.335319 z" /><rect
|
||||
style="opacity:1;fill:#247e4b;fill-opacity:1;stroke:none;stroke-width:0.414999;stroke-linecap:butt;stroke-linejoin:round;stroke-dasharray:none;paint-order:stroke fill markers"
|
||||
id="rect31"
|
||||
width="1.672105"
|
||||
height="1.2511554"
|
||||
x="-4.501821"
|
||||
y="0.84189904" /><text
|
||||
xml:space="preserve"
|
||||
style="font-size:0.705556px;font-family:'Open Sans';-inkscape-font-specification:'Open Sans';text-align:start;writing-mode:lr-tb;direction:ltr;text-anchor:start;opacity:1;fill:#247e4b;fill-opacity:1;stroke:none;stroke-width:0.414999;stroke-linecap:butt;stroke-linejoin:round;stroke-dasharray:none;paint-order:stroke fill markers"
|
||||
x="-2.6080971"
|
||||
y="1.7071842"
|
||||
id="text31"><tspan
|
||||
sodipodi:role="line"
|
||||
id="tspan31"
|
||||
style="font-size:0.705556px;stroke-width:0.415"
|
||||
x="-1.8942729"
|
||||
y="1.7071842">akce</tspan></text><rect
|
||||
style="opacity:1;fill:#951e7a;fill-opacity:1;stroke:none;stroke-width:0.414999;stroke-linecap:butt;stroke-linejoin:round;stroke-dasharray:none;paint-order:stroke fill markers"
|
||||
id="rect32"
|
||||
width="1.672105"
|
||||
height="1.2511554"
|
||||
x="-4.501821"
|
||||
y="2.6939824" /><text
|
||||
xml:space="preserve"
|
||||
style="font-size:0.705556px;font-family:'Open Sans';-inkscape-font-specification:'Open Sans';text-align:start;writing-mode:lr-tb;direction:ltr;text-anchor:start;opacity:1;fill:#951e7a;fill-opacity:1;stroke:none;stroke-width:0.414999;stroke-linecap:butt;stroke-linejoin:round;stroke-dasharray:none;paint-order:stroke fill markers"
|
||||
x="-2.6360023"
|
||||
y="3.5261946"
|
||||
id="text32"><tspan
|
||||
sodipodi:role="line"
|
||||
id="tspan32"
|
||||
style="font-size:0.705556px;fill:#951e7a;fill-opacity:1;stroke-width:0.415"
|
||||
x="-2.6360023"
|
||||
y="3.5261946">lokality</tspan></text><path
|
||||
id="path32"
|
||||
style="opacity:1;fill:#00b200;stroke-width:0.615;paint-order:stroke fill markers;stroke:none;stroke-linecap:butt;stroke-linejoin:round;stroke-dasharray:none"
|
||||
d="M 3.3486328 2.4970052 L 3.3486328 3.8323242 L 2.7424683 3.8323242 L 4.2085286 5.738151 L 5.674589 3.8323242 L 5.0684245 3.8323242 L 5.0684245 2.4970052 L 3.3486328 2.4970052 z "
|
||||
inkscape:export-filename="path32.png"
|
||||
inkscape:export-xdpi="3000"
|
||||
inkscape:export-ydpi="3000" /></g></svg>
|
||||
|
After Width: | Height: | Size: 6.3 KiB |
Reference in New Issue
Block a user