mirror of
https://github.com/ARUP-CAS/aiscr-qgis-amcr-viewer.git
synced 2026-06-19 12:22:54 +02:00
Compare commits
38 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c0d054d22a | |||
| ba41039468 | |||
| 499b3b3f0a | |||
| 54f154b264 | |||
| c679e776df | |||
| a5604dfaa8 | |||
| 11f44d025b | |||
| 7f3b2b46fb | |||
| be53edefa5 | |||
| 3be7832b40 | |||
| 8c0c540fa4 | |||
| 8088b32661 | |||
| c17275ef66 | |||
| 9ec866f1d2 | |||
| 5a951edec7 | |||
| 8825ac3272 | |||
| 3957b87a2b | |||
| 158f623574 | |||
| d54b4e476e | |||
| 6b39a05207 | |||
| f9bfe02597 | |||
| 36835c825d | |||
| d6d520e612 | |||
| 78bad9aaa7 | |||
| 9559712af9 | |||
| 9ccb9319b4 | |||
| a696872b0c | |||
| bcde600433 | |||
| 8b71d75701 | |||
| 6131c7ff9d | |||
| 396f4fbb4e | |||
| 0f07a40bb0 | |||
| 0d3bd0a696 | |||
| 777b1900d5 | |||
| 27303fdf53 | |||
| fbe5c6a113 | |||
| 8693179fa9 | |||
| a314dd3758 |
@@ -205,3 +205,9 @@ cython_debug/
|
|||||||
marimo/_static/
|
marimo/_static/
|
||||||
marimo/_lsp/
|
marimo/_lsp/
|
||||||
__marimo__/
|
__marimo__/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
README_files/
|
||||||
|
README.html
|
||||||
|
amcr_viewer.zip
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
[](https://www.gnu.org/licenses/gpl-3.0)
|
[](https://www.gnu.org/licenses/gpl-3.0)
|
||||||
|
|
||||||
**Platform:** QGIS 3.4.x
|
**Platform:** QGIS 3.4.0–4.99.0
|
||||||
|
|
||||||
**Module Type:** Data Acquisition & Visualization
|
**Module Type:** Data Acquisition & Visualization
|
||||||
|
|
||||||
@@ -12,77 +12,122 @@
|
|||||||
|
|
||||||
## 1. Overview
|
## 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. Both *Fieldwork events* and *Sites* layers may be accompanied by a *Components* layer with additional information. **Only publicly accessible data are supported at the time** (accessibility = anonymous).
|
||||||
|
|
||||||
[^1]: Only Fieldwork events (Akce) are supported at the time.
|
|
||||||
|
|
||||||
### Key Features
|
### Key Features
|
||||||
|
|
||||||
* **Spatial Querying:** Option to filter records based on the current map canvas extent (Bounding Box).
|
* **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.
|
* **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.
|
* **Semantic Interoperability:** Automatically translates internal system codes into human-readable labels using the AIS CR API.
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 2. Installation Guide
|
## 2. Installation Guide
|
||||||
|
|
||||||
1. Obtain the [plugin distribution package](https://github.com/ARUP-CAS/aiscr-qgis-amcr-viewer/releases) (ZIP archive containing the `amcr_viewer` directory).
|
**Install the plugin from QGIS plugin repository.**
|
||||||
2. Launch QGIS.
|
|
||||||
3. Navigate to **Plugins** **Manage and Install Plugins...**
|
|
||||||
4. Select the **Install from ZIP** tab.
|
|
||||||
5. Locate the source ZIP file and click **Install Plugin**.
|
|
||||||
6. Upon successful installation, the AMCR download button (load AMCR data) will appear in the interface.
|
|
||||||
|
|
||||||
**OR**
|
**OR**
|
||||||
|
|
||||||
Install the plugin from QGIS plugin repository.
|
*1. Obtain the [plugin distribution package](https://github.com/ARUP-CAS/aiscr-qgis-amcr-viewer/releases) (ZIP archive containing the `amcr_viewer` directory).*
|
||||||
|
*2. Launch QGIS.*
|
||||||
---
|
*3. Navigate to Plugins → Manage and Install Plugins...*
|
||||||
|
*4. Select the Install from ZIP tab.*
|
||||||
|
*5. Locate the source ZIP file and click Install Plugin.*
|
||||||
|
*6. Upon successful installation, the AMCR download button (load AMCR data) will appear in the interface.*
|
||||||
|
|
||||||
## 3. User Manual
|
## 3. User Manual
|
||||||
|
|
||||||
### 3.1 Data Retrieval
|
### 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).
|
* **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:**
|
* **Attribute Filters:**
|
||||||
* The dialog utilizes "Picker" widgets for controlled vocabularies (Region, District, Cadastral area, Organisation, Period, Activity Area).
|
* 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).
|
* Click **Select...** to open a searchable selection window. Multiple values can be selected simultaneously (Logic: OR).
|
||||||
|
|
||||||
|
|
||||||
* **Fieldwork Manager (Dynamic List):**
|
* **Fieldwork Manager (Dynamic List):**
|
||||||
* Due to the dynamic nature of the persons database, the list of Fieldwork Managers is retrieved from the AIS CR servers and needs to be updated the first time (and subsequently, if there is need).
|
* Due to the dynamic nature of the persons database, the list of Fieldwork Managers is retrieved from the AIS CR servers and needs to be updated the first time (and subsequently, if there is need).
|
||||||
* To refresh the list from the server, click the **Refresh (🔄)** button next to the selection field. This downloads the latest list of researchers from the API.
|
* To refresh the list from the server, click the **Refresh (🔄)** button next to the selection field. This downloads the latest list of researchers from the API.
|
||||||
|
|
||||||
|
* **Components:** The *components* data are downloaded as well upon checking the corresponding check box. This enriches the main (*Events* and *Sites*) layers with additional information (period and activity area).
|
||||||
|
|
||||||
* If no filter is used, all accessible Fieldwork events/PIANs are returned (although the number of Fieldwork events to be loaded is capped at 20000 records; it is advisable to set at least one filter).
|
* If no filter is used, all accessible Fieldwork events/PIANs are returned (although the number of Fieldwork events to be loaded is capped at 20000 records; it is advisable to set at least one filter).
|
||||||
|
|
||||||
|
For a more in-depth tutorial refer to the [AMČR Documentation](https://amcr-help.aiscr.cz/digiarchiv/qgis-viewer.html) (only in Czech).
|
||||||
|
|
||||||
### 3.2 Layer Structure & Attributes
|
### 3.2 Layer Structure & Attributes
|
||||||
|
|
||||||
Upon successful retrieval, the plugin generates three temporary memory layers:
|
Upon successful retrieval, the plugin generates four temporary memory layers:
|
||||||
|
|
||||||
1. **AMCR Plochy (Polygons)**
|
1. **AMCR Plochy (Polygons)**
|
||||||
2. **AMČR Linie (Lines)**
|
2. **AMČR Linie (Lines)**
|
||||||
3. **AMČR Body (Points)**
|
3. **AMČR Body (Points)**
|
||||||
|
4. **AMČR Komponenty (*Components*/no geometry)**
|
||||||
|
|
||||||
The Attribute Table includes standardized fields such as:
|
The Attribute Table includes standardized fields with important metadata. The components layer has no geometry on its own and depend solely on a relation with the other three layers.
|
||||||
|
|
||||||
* **Identification:** `Identifikátor` (Fieldwork event ID), `PIAN` (PIAN ID).
|
#### 3.2.1 Fields of the layers with geometry
|
||||||
* **Classification:** `Hlavní typ` (Main Fieldwork event Type), `Vedlejší typ` (Secondary Fieldwork event Type), `PIAN – typ` (PIAN Type).
|
|
||||||
* **Administration:** `Vedoucí akce` (Fieldwork Manager), `Organizace` (Organization), `Datum zahájeni`/`Datum ukončení` (Dates of start and end of the Fieldwork event).
|
|
||||||
* **Location:** `Katastr` (Main Cadastral area), `Další katastry` (Other Cadastral areas), `Okres` (District), `Definiční bod(y)` (PIAN point localization).
|
|
||||||
* **Links:** `Odkaz do Digiarchivu` (Direct URL to the DigiArchive record).
|
|
||||||
|
|
||||||
---
|
| Field | Description |
|
||||||
|
| --- | --- |
|
||||||
|
| PIAN | PIAN (spatial identifier) ID |
|
||||||
|
| Přesnost | spatial deviation [in units/tens/hundreds of meters/defined by cadastre] |
|
||||||
|
| PIAN – typ | [point/line/polygon] |
|
||||||
|
| Dokumentační jednotka | Documentation unit ID |
|
||||||
|
| Typ dokumentační jednotky | [trench/event part/whole event/cadastral territory] |
|
||||||
|
| Definiční bod(y) (WGS-84) | feature centroid in WGS-84 coordinate system |
|
||||||
|
| Akce/Lokalita | Event/Site ID |
|
||||||
|
| Odkaz do Digitálního archivu AMČR | link to the Event/Site record in the Digital Archive |
|
||||||
|
| Okres | district |
|
||||||
|
| Katastr | main cadastre |
|
||||||
|
| Další katastr | other cadastres, if the event extends beyond the main cadastre |
|
||||||
|
| Přístupnost | record accessibility [A/B/C/D] |
|
||||||
|
|
||||||
|
> Common fields
|
||||||
|
|
||||||
|
| Field | Description |
|
||||||
|
| --- | --- |
|
||||||
|
| Vedoucí akce | main fieldwork manager |
|
||||||
|
| Organizace | organization conducting the research |
|
||||||
|
| Specifikace data | [exact date/exact years/sometime in years] |
|
||||||
|
| Datum zahájení | Event start date |
|
||||||
|
| Datum ukončení | Event end date |
|
||||||
|
| Hlavní typ | primary research method [total excavation/pit trench/surface collection survey/…] |
|
||||||
|
| Vedlejší typ | secondary research method [same options as in Hlavní typ] |
|
||||||
|
| Zjištění | did the research reveal archaeological contexts? [positive/negative] |
|
||||||
|
| Akce – lokalizace | verbal description of the event location |
|
||||||
|
| Akce – nahrazuje NZ | replaces a fieldwork report? [yes/no] |
|
||||||
|
|
||||||
|
> Fields related to *Fieldwork events*
|
||||||
|
|
||||||
|
| Field | Description |
|
||||||
|
| --- | --- |
|
||||||
|
| nazev_lokality | site name |
|
||||||
|
| popis_lokality | site description |
|
||||||
|
| typ_lokality | site classification by definition method [survey polygon/heritage site/landscape] |
|
||||||
|
| druh_lokality | site classification by the nature of identified field relics [aerial survey polygon/landscape/remains of settlement/…] |
|
||||||
|
| zachovalost | site preservation state [buried site/ruin/aboveground remains/…] |
|
||||||
|
|
||||||
|
> Fields related to *Sites*
|
||||||
|
|
||||||
|
#### 3.2.2 Fields of the *Components* layer
|
||||||
|
|
||||||
|
| Field | Description |
|
||||||
|
| --- | --- |
|
||||||
|
| komponenta | Component ID |
|
||||||
|
| dj_id | parent Documentation unit ID |
|
||||||
|
| komponenta_areal | Activity area [settlement/burial area/field/…] |
|
||||||
|
| komponenta_obdobi | Period [Neolithic/High Middle Ages–Modern Period/Middle La Tène (LtB–C1)/…] |
|
||||||
|
| vrstva | system value linking to a specific geometry table with the corresponding documentation unit |
|
||||||
|
|
||||||
## 4. Technical Architecture
|
## 4. Technical Architecture
|
||||||
|
|
||||||
The plugin is developed in **Python 3** using the **PyQt5** framework for the GUI and the **Requests** library for HTTP communication.
|
The plugin is developed in **Python 3** using the **PyQt6** framework for the GUI and the **Requests** library for HTTP communication.
|
||||||
|
|
||||||
### 4.1 File Structure
|
### 4.1 File Structure
|
||||||
|
|
||||||
@@ -98,26 +143,28 @@ The plugin interacts with three primary endpoints of the AIS CR infrastructure:
|
|||||||
1. **Search API (Solr):**
|
1. **Search API (Solr):**
|
||||||
* Endpoint: `https://digiarchiv.aiscr.cz/api/search/query`
|
* Endpoint: `https://digiarchiv.aiscr.cz/api/search/query`
|
||||||
* Method: `GET`
|
* Method: `GET`
|
||||||
* Parameters: `entity=akce`, `fl` (field list), `q` (query), `rows/page` (pagination).
|
* Parameters: `entity=akce`, `rows/page` (pagination).
|
||||||
* Logic: The plugin implements a `while True` loop to handle pagination, processing data in batches of 500 records to ensure stability.
|
* Logic: The plugin implements a `while True` loop to handle pagination, processing data in batches of 500 records to ensure stability.
|
||||||
|
|
||||||
|
|
||||||
2. **Translation API:**
|
2. **Translation API:**
|
||||||
* Endpoint: `https://digiarchiv.aiscr.cz/api/assets/i18n/cs.json`
|
* Endpoint: `https://digiarchiv.aiscr.cz/api/assets/i18n/cs.json`
|
||||||
* Function: Retrieves the mapping between system codes (e.g., `HES-xxxx`) and Czech labels. This dictionary is cached in memory during the session.
|
* Function: Retrieves the mapping between system codes (e.g., `HES-xxxx`) and Czech labels. This dictionary is cached in memory during the session.
|
||||||
|
|
||||||
|
|
||||||
### 4.3 Data Persistence
|
### 4.3 Data Persistence
|
||||||
|
|
||||||
* **Vocabularies:** Static vocabularies (e.g., Periods, Regions) are stored in `codelists/heslar.csv`.
|
* **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.
|
* **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
|
### 4.4 Constraints
|
||||||
|
|
||||||
* **Record Limit:** A safety cap of 20,000 records is enforced to prevent memory overflow in QGIS.
|
* **Record Limit:** A safety cap of 20,000 records is enforced.
|
||||||
* **Batch Processing:** Geometry fetching is batched (50 IDs per request) to comply with URL length limitations and server load balancing.
|
* **Batch Processing:** Geometry fetching is batched (50 IDs per request) to comply with URL length limitations and server load balancing.
|
||||||
|
|
||||||
## 6. Links and resources
|
### 4.5 Relational Data Linking
|
||||||
|
The plugin automatically utilizes advanced QGIS features for data relationship management, specifically Polymorphic Relations. The *Components* layer is dynamically linked within the project to the spatial layers of events and sites via the documentation unit identifier (dj_id). This allows users to immediately see all *components* belonging to a given geometry (point, line, or polygon) directly in the attribute form or the identify features tool, without the need to manually filter or join the data.
|
||||||
|
|
||||||
|
## 5. Links and resources
|
||||||
|
|
||||||
* [AMCR/Digiarchive Documentation](https://amcr-help.aiscr.cz/) (only in Czech).
|
* [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 |
+195
-124
@@ -1,79 +1,65 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
import os
|
import os
|
||||||
import csv
|
import csv
|
||||||
import codecs
|
|
||||||
import requests
|
import requests
|
||||||
import json
|
import xml.etree.ElementTree as ET
|
||||||
|
import time
|
||||||
|
from qgis.core import QgsMessageLog, Qgis
|
||||||
|
|
||||||
# Cesta k adresáři pluginu
|
# Define paths for the plugin and its codelists directory
|
||||||
PLUGIN_DIR = os.path.dirname(__file__)
|
PLUGIN_DIR = os.path.dirname(__file__)
|
||||||
CODELISTS_DIR = os.path.join(PLUGIN_DIR, 'codelists')
|
CODELISTS_DIR = os.path.join(PLUGIN_DIR, 'codelists')
|
||||||
|
BASE_URL = "https://api.aiscr.cz/2.2/oai"
|
||||||
|
OUTPUT_FILE = os.path.join(CODELISTS_DIR, 'heslar.csv')
|
||||||
|
|
||||||
|
slovnicek = {
|
||||||
|
'obdobi' : 'heslo:obdobi',
|
||||||
|
'typ_akce' : 'heslo:akce_typ',
|
||||||
|
'areal' : 'heslo:areal',
|
||||||
|
'kraj' : 'ruian_kraj',
|
||||||
|
'organizace' : 'organizace',
|
||||||
|
'okres' : 'ruian_okres',
|
||||||
|
'katastr' : 'ruian_katastr',
|
||||||
|
'vedouci' : 'osoba',
|
||||||
|
'pian_presnost' : 'heslo:pian_presnost',
|
||||||
|
'typ_lokality' : 'heslo:lokalita_typ',
|
||||||
|
'druh_lokality' : 'heslo:lokalita_druh',
|
||||||
|
'jistota' : 'heslo:jistota_urceni',
|
||||||
|
'lokalita_zachovalost' : 'heslo:stav_dochovani',
|
||||||
|
'pristupnost' : 'heslo:pristupnost'
|
||||||
|
}
|
||||||
|
|
||||||
|
NS = {
|
||||||
|
'oai': 'http://www.openarchives.org/OAI/2.0/',
|
||||||
|
'dc': 'http://purl.org/dc/elements/1.1/',
|
||||||
|
'oai_dc': 'http://www.openarchives.org/OAI/2.0/oai_dc/'
|
||||||
|
}
|
||||||
|
|
||||||
def ensure_codelists_dir():
|
def ensure_codelists_dir():
|
||||||
|
"""Creates the codelists directory if it does not exist."""
|
||||||
if not os.path.exists(CODELISTS_DIR):
|
if not os.path.exists(CODELISTS_DIR):
|
||||||
os.makedirs(CODELISTS_DIR)
|
os.makedirs(CODELISTS_DIR)
|
||||||
|
|
||||||
# --- 1. NAČÍTÁNÍ DAT ---
|
def parse_codelist_file(filename, target_dict=None):
|
||||||
|
"""Reads a CSV codelist file and populates the target dictionary grouped by categories."""
|
||||||
|
if target_dict is None:
|
||||||
|
target_dict = {}
|
||||||
|
|
||||||
def load_csv_data(filename):
|
|
||||||
"""Obecná funkce pro načtení CSV souboru do slovníku"""
|
|
||||||
data = {}
|
|
||||||
path = os.path.join(CODELISTS_DIR, filename)
|
path = os.path.join(CODELISTS_DIR, filename)
|
||||||
|
|
||||||
|
# Return early if the file doesn't exist to avoid missing file errors
|
||||||
if not os.path.exists(path):
|
if not os.path.exists(path):
|
||||||
return data
|
return target_dict
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with codecs.open(path, 'r', 'utf-8') as f:
|
# Open the file using standard UTF-8 encoding
|
||||||
|
with open(path, 'r', encoding='utf-8') as f:
|
||||||
reader = csv.reader(f, delimiter=';')
|
reader = csv.reader(f, delimiter=';')
|
||||||
# Zkusíme přeskočit hlavičku, pokud tam je
|
|
||||||
first_row = next(reader, None)
|
|
||||||
|
|
||||||
# Pokud soubor není prázdný, zpracujeme ho
|
# Skip the CSV header row
|
||||||
if first_row:
|
next(reader, None)
|
||||||
# Pokud první řádek vypadá jako data (neobsahuje slovo "Název"), vrátíme ho do hry
|
|
||||||
# Ale my budeme generovat soubory s hlavičkou, takže OK.
|
|
||||||
pass
|
|
||||||
|
|
||||||
for row in reader:
|
# Iterate through rows and extract label, code, and category
|
||||||
if len(row) >= 3:
|
|
||||||
label = row[0].strip()
|
|
||||||
code = row[1].strip()
|
|
||||||
category = row[2].strip()
|
|
||||||
|
|
||||||
# Tady můžeme filtrovat podle kategorie,
|
|
||||||
# nebo prostě vrátit všechno jako {label: code}
|
|
||||||
# Pro jednoduchost vracíme {label: code}
|
|
||||||
clean_code = code if code else None
|
|
||||||
data[label] = clean_code
|
|
||||||
except Exception as e:
|
|
||||||
print(f"AMČR Chyba čtení {filename}: {e}")
|
|
||||||
|
|
||||||
return data
|
|
||||||
|
|
||||||
def load_all_data():
|
|
||||||
"""
|
|
||||||
Načte statický heslář I dynamický heslář vedoucích.
|
|
||||||
Vrací slovník slovníků.
|
|
||||||
"""
|
|
||||||
ensure_codelists_dir()
|
|
||||||
|
|
||||||
# 1. Načteme hlavní statický heslář
|
|
||||||
# Musíme ho rozparsovat podle kategorií, tak jak to bylo předtím
|
|
||||||
categorized_data = {
|
|
||||||
'obdobi': {}, 'typ_akce': {}, 'areal': {},
|
|
||||||
'kraj': {}, 'organizace': {}, 'okres': {}, 'katastr': {},
|
|
||||||
'vedouci': {}
|
|
||||||
}
|
|
||||||
|
|
||||||
# Funkce pro roztřídění načteného slovníku (tohle je trochu redundance, ale pro zachování logiky)
|
|
||||||
def parse_file(filename):
|
|
||||||
path = os.path.join(CODELISTS_DIR, filename)
|
|
||||||
if not os.path.exists(path): return
|
|
||||||
|
|
||||||
try:
|
|
||||||
with codecs.open(path, 'r', 'utf-8') as f:
|
|
||||||
reader = csv.reader(f, delimiter=';')
|
|
||||||
next(reader, None) # Skip header
|
|
||||||
for row in reader:
|
for row in reader:
|
||||||
if len(row) >= 3:
|
if len(row) >= 3:
|
||||||
label = row[0].strip()
|
label = row[0].strip()
|
||||||
@@ -81,92 +67,177 @@ def load_all_data():
|
|||||||
cat = row[2].strip()
|
cat = row[2].strip()
|
||||||
clean = code if code else None
|
clean = code if code else None
|
||||||
|
|
||||||
if cat in categorized_data:
|
# Initialize a new dictionary for a category if encountered for the first time
|
||||||
categorized_data[cat][label] = clean
|
if cat not in target_dict:
|
||||||
except: pass
|
target_dict[cat] = {}
|
||||||
|
|
||||||
# Načteme soubory
|
# Assign the extracted code to the corresponding label within the category
|
||||||
parse_file('heslar.csv') # Statické
|
target_dict[cat][label] = clean
|
||||||
parse_file('vedouci.csv') # Dynamické (pokud existuje)
|
except Exception as e:
|
||||||
|
QgsMessageLog.logMessage(f"AMČR Codelist Read Error for {filename}: {e}", "AMČR", Qgis.Critical)
|
||||||
|
|
||||||
|
return target_dict
|
||||||
|
|
||||||
|
def load_all_data():
|
||||||
|
"""Loads the codelist during plugin startup."""
|
||||||
|
ensure_codelists_dir()
|
||||||
|
categorized_data = {k: {} for k in slovnicek.keys()}
|
||||||
|
parse_codelist_file('heslar.csv', categorized_data)
|
||||||
return categorized_data
|
return categorized_data
|
||||||
|
|
||||||
# --- 2. AKTUALIZACE DAT (DOWNLOAD) ---
|
def fetch_set(internal_name, api_set, task=None):
|
||||||
|
dataset = []
|
||||||
|
params = {
|
||||||
|
"verb": "ListRecords",
|
||||||
|
"metadataPrefix": "oai_dc",
|
||||||
|
"set": api_set
|
||||||
|
}
|
||||||
|
|
||||||
def download_vedouci():
|
while True:
|
||||||
"""
|
# Kontrola zrušení v každém kroku
|
||||||
Stáhne seznam vedoucích z API (pomocí onlyFacets) a uloží do codelists/vedouci.csv.
|
if task and task.isCanceled():
|
||||||
"""
|
return None
|
||||||
ensure_codelists_dir()
|
|
||||||
|
|
||||||
# Tvá URL + pojistka, abychom dostali všechny záznamy (limit -1)
|
|
||||||
url = "https://digiarchiv.aiscr.cz/api/search/query?entity=akce&sort=datestamp%20desc&page=0&onlyFacets=True&rows=0"
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
r = requests.get(url, timeout=20) # Raději delší timeout pro velký seznam
|
response = requests.get(BASE_URL, params=params, timeout=30)
|
||||||
r.raise_for_status()
|
response.raise_for_status()
|
||||||
data = r.json()
|
root = ET.fromstring(response.content)
|
||||||
|
|
||||||
# Cesta k datům dle tvého JSONu:
|
records = root.findall('.//oai:record', NS)
|
||||||
# {"facet_counts": { "f_vedouci": [ {"name": "Novák", ...}, ... ] }}
|
for rec in records:
|
||||||
vedouci_list = data.get('facet_counts', {}).get('f_vedouci', [])
|
metadata = rec.find('.//oai_dc:dc', NS)
|
||||||
|
if metadata is not None:
|
||||||
|
# Kód (identifier)
|
||||||
|
kod = metadata.find('dc:identifier', NS).text if metadata.find('dc:identifier', NS) is not None else ""
|
||||||
|
|
||||||
if not vedouci_list:
|
# Název (title) - filtrujeme systémové popisky "AMČR - ..."
|
||||||
# Zkusíme ještě alternativní cestu, kdyby API vrátilo standardní Solr strukturu
|
titles = metadata.findall('dc:title', NS)
|
||||||
# (facet_counts -> facet_fields -> f_vedouci)
|
nazev = ""
|
||||||
vedouci_list = data.get('facet_counts', {}).get('facet_fields', {}).get('f_vedouci', [])
|
for t in titles:
|
||||||
|
if t.text and not t.text.startswith("AMČR -") and not t.text.startswith(" AMČR -"):
|
||||||
|
nazev = t.text
|
||||||
|
break
|
||||||
|
# Pokud by náhodou žádný title neprošel filtrem, vezmeme první dostupný
|
||||||
|
if not nazev and titles:
|
||||||
|
nazev = titles[0].text
|
||||||
|
|
||||||
csv_path = os.path.join(CODELISTS_DIR, 'vedouci.csv')
|
specialni_pripady = ['okres', 'katastr']
|
||||||
|
|
||||||
count = 0
|
if internal_name in specialni_pripady:
|
||||||
with codecs.open(csv_path, 'w', 'utf-8') as f:
|
kod = nazev
|
||||||
writer = csv.writer(f, delimiter=';')
|
|
||||||
writer.writerow(['Název', 'Kód', 'Kategorie'])
|
|
||||||
|
|
||||||
# NOVÁ LOGIKA PARSOVÁNÍ
|
if internal_name == 'pristupnost':
|
||||||
for item in vedouci_list:
|
kod = next((t.text for t in titles if t.text and len(t.text) == 1 and t.text.isalpha()), None)
|
||||||
name = None
|
|
||||||
|
|
||||||
# Varianta A: Položka je slovník {"name": "Jan Novák", "value": 10}
|
dataset.append({
|
||||||
if isinstance(item, dict):
|
'Název': nazev,
|
||||||
name = item.get('name')
|
'Kód': kod,
|
||||||
|
'Kategorie': internal_name
|
||||||
|
})
|
||||||
|
|
||||||
# Varianta B: Položka je jen string (kdyby se API vrátilo k plochému seznamu)
|
# Stránkování
|
||||||
elif isinstance(item, str):
|
token = root.find('.//oai:resumptionToken', NS)
|
||||||
name = item
|
if token is not None and token.text:
|
||||||
|
params = {
|
||||||
# Pokud máme jméno a není to číslo (count), zapíšeme
|
"verb": "ListRecords",
|
||||||
if name and not str(name).isdigit():
|
"resumptionToken": token.text
|
||||||
writer.writerow([name, name, 'vedouci'])
|
}
|
||||||
count += 1
|
time.sleep(0.5)
|
||||||
|
else:
|
||||||
return True, f"Staženo {count} jmen."
|
break
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return False, str(e)
|
QgsMessageLog.logMessage(f"Chyba u setu {api_set}: {e}", "AMČR", Qgis.Warning)
|
||||||
|
break
|
||||||
|
|
||||||
# --- GLOBAL DATA ---
|
return dataset
|
||||||
# Toto se načte při startu QGISu
|
|
||||||
_DATA = load_all_data()
|
|
||||||
|
|
||||||
OBDOBI = _DATA['obdobi']
|
def download_heslare(task=None):
|
||||||
TYP_AKCE = _DATA['typ_akce']
|
"""Fetches the codelists from the AMČR API and saves it to a CSV file."""
|
||||||
AREAL = _DATA['areal']
|
ensure_codelists_dir()
|
||||||
KRAJE = _DATA['kraj']
|
all_data = []
|
||||||
ORGANIZACE = _DATA['organizace']
|
total_sets = len(slovnicek)
|
||||||
OKRESY = _DATA['okres']
|
|
||||||
KATASTRY = _DATA['katastr']
|
|
||||||
VEDOUCI = _DATA['vedouci'] # Tady to bude zpočátku prázdné, pokud soubor neexistuje
|
|
||||||
|
|
||||||
def refresh_vedouci_cache():
|
for index, (interni, api_nazev) in enumerate(slovnicek.items()):
|
||||||
"""
|
# Pokud uživatel task zrušil v liště QGISu
|
||||||
Znovu načte soubor vedouci.csv a aktualizuje globální proměnnou VEDOUCI.
|
if task and task.isCanceled():
|
||||||
Použijeme 'update', aby se zachovala reference na objekt (pokud ho dialog už používá).
|
return False
|
||||||
"""
|
|
||||||
temp_data = load_all_data()
|
|
||||||
new_vedouci = temp_data['vedouci']
|
|
||||||
|
|
||||||
# Vyčistíme a naplníme existující slovník (in-place update)
|
QgsMessageLog.logMessage(f"Zpracovávám kategorii: {interni}...", "AMČR", Qgis.Info)
|
||||||
|
|
||||||
|
# Nyní předáváme task správně do upravené funkce
|
||||||
|
data = fetch_set(interni, api_nazev, task=task)
|
||||||
|
|
||||||
|
if data is None:
|
||||||
|
return False # Bylo zrušeno uprostřed stahování
|
||||||
|
|
||||||
|
all_data.extend(data)
|
||||||
|
|
||||||
|
# Reportování postupu (0-100)
|
||||||
|
if task:
|
||||||
|
progress = (index + 1) / total_sets * 100
|
||||||
|
task.setProgress(progress)
|
||||||
|
|
||||||
|
# Uložení do CSV
|
||||||
|
with open(OUTPUT_FILE, 'w', newline='', encoding='utf-8-sig') as f:
|
||||||
|
fieldnames = ['Název', 'Kód', 'Kategorie']
|
||||||
|
writer = csv.DictWriter(f, fieldnames=fieldnames, delimiter=';')
|
||||||
|
writer.writeheader()
|
||||||
|
writer.writerows(all_data)
|
||||||
|
|
||||||
|
return True
|
||||||
|
|
||||||
|
def refresh_globals():
|
||||||
|
"""Znovu načte data ze souborů do globálních proměnných."""
|
||||||
|
global OBDOBI, TYP_AKCE, AREAL, KRAJE, ORGANIZACE, OKRESY, KATASTRY
|
||||||
|
global VEDOUCI, PIAN_PRESNOST, TYP_LOKALITY, DRUH_LOKALITY, JISTOTA, LOKALITA_ZACHOVALOST, PRISTUPNOST
|
||||||
|
|
||||||
|
data = load_all_data()
|
||||||
|
|
||||||
|
OBDOBI.clear()
|
||||||
|
OBDOBI.update(data.get('obdobi', {}))
|
||||||
|
TYP_AKCE.clear()
|
||||||
|
TYP_AKCE.update(data.get('typ_akce', {}))
|
||||||
|
AREAL.clear()
|
||||||
|
AREAL.update(data.get('areal', {}))
|
||||||
|
KRAJE.clear()
|
||||||
|
KRAJE.update(data.get('kraj', {}))
|
||||||
|
ORGANIZACE.clear()
|
||||||
|
ORGANIZACE.update(data.get('organizace', {}))
|
||||||
|
OKRESY.clear()
|
||||||
|
OKRESY.update(data.get('okres', {}))
|
||||||
|
KATASTRY.clear()
|
||||||
|
KATASTRY.update(data.get('katastr', {}))
|
||||||
VEDOUCI.clear()
|
VEDOUCI.clear()
|
||||||
VEDOUCI.update(new_vedouci)
|
VEDOUCI.update(data.get('vedouci', {}))
|
||||||
return len(VEDOUCI)
|
PIAN_PRESNOST.clear()
|
||||||
|
PIAN_PRESNOST.update(data.get('pian_presnost', {}))
|
||||||
|
TYP_LOKALITY.clear()
|
||||||
|
TYP_LOKALITY.update(data.get('typ_lokality', {}))
|
||||||
|
DRUH_LOKALITY.clear()
|
||||||
|
DRUH_LOKALITY.update(data.get('druh_lokality', {}))
|
||||||
|
JISTOTA.clear()
|
||||||
|
JISTOTA.update(data.get('jistota', {}))
|
||||||
|
LOKALITA_ZACHOVALOST.clear()
|
||||||
|
LOKALITA_ZACHOVALOST.update(data.get('lokalita_zachovalost', {}))
|
||||||
|
PRISTUPNOST.clear()
|
||||||
|
PRISTUPNOST.update(data.get('pristupnost', {}))
|
||||||
|
|
||||||
|
|
||||||
|
# Inicializace prázdných diktů, které se naplní hned pod tím
|
||||||
|
OBDOBI = {}
|
||||||
|
TYP_AKCE = {}
|
||||||
|
AREAL = {}
|
||||||
|
KRAJE = {}
|
||||||
|
ORGANIZACE = {}
|
||||||
|
OKRESY = {}
|
||||||
|
KATASTRY = {}
|
||||||
|
VEDOUCI = {}
|
||||||
|
PIAN_PRESNOST = {}
|
||||||
|
TYP_LOKALITY = {}
|
||||||
|
DRUH_LOKALITY = {}
|
||||||
|
JISTOTA = {}
|
||||||
|
LOKALITA_ZACHOVALOST = {}
|
||||||
|
PRISTUPNOST = {}
|
||||||
|
|
||||||
|
refresh_globals()
|
||||||
+332
-77
@@ -1,95 +1,247 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from qgis.PyQt.QtWidgets import (QDialog, QVBoxLayout, QFormLayout,
|
import base64
|
||||||
|
from qgis.PyQt.QtWidgets import (QDialog, QVBoxLayout,
|
||||||
QLineEdit, QDialogButtonBox,
|
QLineEdit, QDialogButtonBox,
|
||||||
QCheckBox, QGroupBox, QPushButton,
|
QCheckBox, QGroupBox, QPushButton,
|
||||||
QListWidget, QListWidgetItem, QHBoxLayout,
|
QListWidget, QListWidgetItem, QHBoxLayout,
|
||||||
QLabel, QMessageBox, QApplication, QWidget)
|
QMessageBox, QLabel, QFormLayout)
|
||||||
from qgis.PyQt.QtCore import Qt
|
from qgis.PyQt.QtCore import Qt, QSettings
|
||||||
|
from qgis.core import QgsTask, QgsApplication, QgsMessageLog, Qgis
|
||||||
from .amcr_codelists import (OBDOBI, TYP_AKCE, KRAJE, AREAL, ORGANIZACE,
|
from .amcr_codelists import (OBDOBI, TYP_AKCE, KRAJE, AREAL, ORGANIZACE,
|
||||||
OKRESY, KATASTRY, VEDOUCI,
|
OKRESY, KATASTRY, VEDOUCI, PIAN_PRESNOST, TYP_LOKALITY,
|
||||||
download_vedouci, refresh_vedouci_cache)
|
DRUH_LOKALITY, JISTOTA, LOKALITA_ZACHOVALOST, PRISTUPNOST,
|
||||||
|
download_heslare, refresh_globals)
|
||||||
|
|
||||||
|
class UpdateCodelistsTask(QgsTask):
|
||||||
|
def __init__(self, description):
|
||||||
|
super().__init__(description, QgsTask.CanCancel)
|
||||||
|
self.success = False
|
||||||
|
self.exception = None
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
"""Tato část běží ve vedlejším vlákně."""
|
||||||
|
try:
|
||||||
|
# Voláme upravenou funkci
|
||||||
|
self.success = download_heslare(task=self)
|
||||||
|
return self.success
|
||||||
|
except Exception as e:
|
||||||
|
self.exception = e
|
||||||
|
return False
|
||||||
|
|
||||||
|
def finished(self, result):
|
||||||
|
"""Tato část běží v hlavním vlákně po skončení run()."""
|
||||||
|
if result:
|
||||||
|
# Teď bezpečně aktualizujeme globální proměnné v hlavním vlákně
|
||||||
|
refresh_globals()
|
||||||
|
QgsMessageLog.logMessage("Hesláře AMČR byly úspěšně aktualizovány.", "AMČR", Qgis.Info)
|
||||||
|
else:
|
||||||
|
if self.isCanceled():
|
||||||
|
QgsMessageLog.logMessage("Aktualizace heslářů byla zrušena.", "AMČR", Qgis.Warning)
|
||||||
|
else:
|
||||||
|
QgsMessageLog.logMessage(f"Chyba aktualizace: {self.exception}", "AMČR", Qgis.Critical)
|
||||||
|
|
||||||
class FilterableSelectionDialog(QDialog):
|
class FilterableSelectionDialog(QDialog):
|
||||||
|
"""
|
||||||
|
A custom dialog for selecting multiple items from a list with a search filter.
|
||||||
|
Updated for PyQt6/Qt6 compatibility.
|
||||||
|
"""
|
||||||
def __init__(self, title, data_dict, preselected_codes, parent=None):
|
def __init__(self, title, data_dict, preselected_codes, parent=None):
|
||||||
super().__init__(parent)
|
super().__init__(parent)
|
||||||
self.setWindowTitle(f"Výběr: {title}")
|
self.setWindowTitle(f"Výběr: {title}")
|
||||||
self.resize(400, 500)
|
self.resize(400, 500)
|
||||||
|
|
||||||
|
# Store the source data and previously selected items
|
||||||
self.data_dict = data_dict
|
self.data_dict = data_dict
|
||||||
self.preselected = preselected_codes if preselected_codes else []
|
self.preselected = preselected_codes if preselected_codes else []
|
||||||
|
|
||||||
layout = QVBoxLayout()
|
layout = QVBoxLayout()
|
||||||
|
|
||||||
|
# Setup search input for filtering items
|
||||||
self.search_bar = QLineEdit()
|
self.search_bar = QLineEdit()
|
||||||
self.search_bar.setPlaceholderText("Hledat v seznamu...")
|
self.search_bar.setPlaceholderText("Hledat v seznamu...")
|
||||||
self.search_bar.textChanged.connect(self.filter_list)
|
self.search_bar.textChanged.connect(self.filter_list)
|
||||||
layout.addWidget(self.search_bar)
|
layout.addWidget(self.search_bar)
|
||||||
|
|
||||||
|
# Main list widget for displaying selectable items
|
||||||
self.list_widget = QListWidget()
|
self.list_widget = QListWidget()
|
||||||
self.populate_list()
|
self.populate_list()
|
||||||
layout.addWidget(self.list_widget)
|
layout.addWidget(self.list_widget)
|
||||||
buttons = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
|
|
||||||
|
# Standard OK/Cancel dialog buttons
|
||||||
|
buttons = QDialogButtonBox(
|
||||||
|
QDialogButtonBox.StandardButton.Ok | QDialogButtonBox.StandardButton.Cancel
|
||||||
|
)
|
||||||
buttons.accepted.connect(self.accept)
|
buttons.accepted.connect(self.accept)
|
||||||
buttons.rejected.connect(self.reject)
|
buttons.rejected.connect(self.reject)
|
||||||
layout.addWidget(buttons)
|
layout.addWidget(buttons)
|
||||||
|
|
||||||
self.setLayout(layout)
|
self.setLayout(layout)
|
||||||
|
|
||||||
def populate_list(self):
|
def populate_list(self):
|
||||||
|
# Sort items alphabetically by their display name
|
||||||
sorted_names = sorted(self.data_dict.keys())
|
sorted_names = sorted(self.data_dict.keys())
|
||||||
for name in sorted_names:
|
for name in sorted_names:
|
||||||
code = self.data_dict[name]
|
code = self.data_dict[name]
|
||||||
item = QListWidgetItem(name)
|
item = QListWidgetItem(name)
|
||||||
item.setData(Qt.UserRole, code)
|
|
||||||
item.setFlags(item.flags() | Qt.ItemIsUserCheckable)
|
# Store the actual code (ID) hidden in the UserRole
|
||||||
if code in self.preselected: item.setCheckState(Qt.Checked)
|
item.setData(Qt.ItemDataRole.UserRole, code)
|
||||||
else: item.setCheckState(Qt.Unchecked)
|
|
||||||
|
# Make the item checkable (adds a checkbox)
|
||||||
|
item.setFlags(item.flags() | Qt.ItemFlag.ItemIsUserCheckable)
|
||||||
|
|
||||||
|
# Restore previous selection state
|
||||||
|
if code in self.preselected:
|
||||||
|
item.setCheckState(Qt.CheckState.Checked)
|
||||||
|
else:
|
||||||
|
item.setCheckState(Qt.CheckState.Unchecked)
|
||||||
|
|
||||||
self.list_widget.addItem(item)
|
self.list_widget.addItem(item)
|
||||||
|
|
||||||
def filter_list(self, text):
|
def filter_list(self, text):
|
||||||
|
# Hide items that don't match the search text (case-insensitive)
|
||||||
search_text = text.lower()
|
search_text = text.lower()
|
||||||
for i in range(self.list_widget.count()):
|
for i in range(self.list_widget.count()):
|
||||||
item = self.list_widget.item(i)
|
item = self.list_widget.item(i)
|
||||||
if search_text not in item.text().lower(): item.setHidden(True)
|
item.setHidden(search_text not in item.text().lower())
|
||||||
else: item.setHidden(False)
|
|
||||||
|
|
||||||
def get_selected_codes(self):
|
def get_selected_codes(self):
|
||||||
|
"""Returns the hidden codes and display labels of all checked items."""
|
||||||
codes = []
|
codes = []
|
||||||
labels = []
|
labels = []
|
||||||
for i in range(self.list_widget.count()):
|
for i in range(self.list_widget.count()):
|
||||||
item = self.list_widget.item(i)
|
item = self.list_widget.item(i)
|
||||||
if item.checkState() == Qt.Checked:
|
if item.checkState() == Qt.CheckState.Checked:
|
||||||
codes.append(item.data(Qt.UserRole))
|
codes.append(item.data(Qt.ItemDataRole.UserRole))
|
||||||
labels.append(item.text())
|
labels.append(item.text())
|
||||||
return codes, labels
|
return codes, labels
|
||||||
|
|
||||||
|
|
||||||
# --- Main window ---
|
# --- Main window ---
|
||||||
class AmcrFilterDialog(QDialog):
|
class AmcrFilterDialog(QDialog):
|
||||||
def __init__(self, parent=None):
|
"""
|
||||||
|
The main filtering UI where users set criteria before downloading data.
|
||||||
|
"""
|
||||||
|
def __init__(self, typ_dat, parent=None):
|
||||||
super().__init__(parent)
|
super().__init__(parent)
|
||||||
self.setWindowTitle("Filtr AMČR")
|
self.setWindowTitle("Filtr AMČR")
|
||||||
self.resize(500, 750)
|
self.resize(500, 750)
|
||||||
|
|
||||||
# Cache for filtering
|
# Determines if we are fetching 'akce' (projects) or 'lokalita' (locations)
|
||||||
|
self.typ_dat = typ_dat
|
||||||
|
|
||||||
|
|
||||||
|
# Cache dictionary to store selected codes for each category
|
||||||
self.selection_cache = {
|
self.selection_cache = {
|
||||||
'organizace': [], 'kraj': [], 'obdobi': [], 'areal': [],
|
'organizace': [], 'kraj': [], 'obdobi': [], 'areal': [],
|
||||||
'typ_akce': [], 'okres': [], 'katastr': [], 'vedouci': []
|
'typ_akce': [], 'okres': [], 'katastr': [], 'vedouci': [], 'pian_presnost': [], 'pristupnost': [],
|
||||||
|
'typ_lokality': [], 'druh_lokality': [], 'jistota': [], 'lokalita_zachovalost': []
|
||||||
}
|
}
|
||||||
|
|
||||||
layout = QVBoxLayout()
|
layout = QVBoxLayout()
|
||||||
|
|
||||||
|
# Filter by current map canvas extent
|
||||||
self.chk_bbox = QCheckBox("Omezit vyhledávání rozsahem okna")
|
self.chk_bbox = QCheckBox("Omezit vyhledávání rozsahem okna")
|
||||||
self.chk_bbox.setChecked(True)
|
self.chk_bbox.setChecked(True)
|
||||||
layout.addWidget(self.chk_bbox)
|
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í")
|
self.chk_posevidence = QCheckBox("Pouze pozitivní zjištění")
|
||||||
layout.addWidget(self.chk_posevidence)
|
layout.addWidget(self.chk_posevidence)
|
||||||
|
|
||||||
layout.addSpacing(10)
|
layout.addSpacing(10)
|
||||||
|
|
||||||
def setup_picker(label_text, cache_key, data_source, extra_btn=None):
|
# Spatial information – valid for all
|
||||||
row_widget = QGroupBox(label_text)
|
|
||||||
# row_widget.setFlat(True)
|
|
||||||
|
|
||||||
|
self.picker_kraj = self.setup_picker("Kraj", 'kraj', KRAJE)
|
||||||
|
layout.addWidget(self.picker_kraj)
|
||||||
|
|
||||||
|
self.picker_okres = self.setup_picker("Okres", 'okres', OKRESY)
|
||||||
|
layout.addWidget(self.picker_okres)
|
||||||
|
|
||||||
|
self.picker_katastr = self.setup_picker("Katastr", 'katastr', KATASTRY)
|
||||||
|
layout.addWidget(self.picker_katastr)
|
||||||
|
|
||||||
|
self.picker_presnost = self.setup_picker("PIAN – přesnost", 'pian_presnost', PIAN_PRESNOST)
|
||||||
|
layout.addWidget(self.picker_presnost)
|
||||||
|
|
||||||
|
self.picker_pristupnost = self.setup_picker("Přístupnost", 'pristupnost', PRISTUPNOST)
|
||||||
|
layout.addWidget(self.picker_pristupnost)
|
||||||
|
|
||||||
|
# Filters valid for Akce
|
||||||
|
|
||||||
|
if self.typ_dat == "akce":
|
||||||
|
self.picker_org = self.setup_picker("Organizace", 'organizace', ORGANIZACE)
|
||||||
|
layout.addWidget(self.picker_org)
|
||||||
|
|
||||||
|
self.picker_vedouci = self.setup_picker("Vedoucí výzkumu", 'vedouci', VEDOUCI)
|
||||||
|
layout.addWidget(self.picker_vedouci)
|
||||||
|
|
||||||
|
# Type of event
|
||||||
|
|
||||||
|
self.picker_typ = self.setup_picker("Typ výzkumu", 'typ_akce', TYP_AKCE)
|
||||||
|
layout.addWidget(self.picker_typ)
|
||||||
|
|
||||||
|
# Filters valid for Lokality
|
||||||
|
|
||||||
|
if self.typ_dat == "lokalita":
|
||||||
|
self.picker_typ_lokality = self.setup_picker("Lokalita – typ", 'typ_lokality', TYP_LOKALITY)
|
||||||
|
layout.addWidget(self.picker_typ_lokality)
|
||||||
|
|
||||||
|
self.picker_druh_lokality = self.setup_picker("Lokalita – druh", 'druh_lokality', DRUH_LOKALITY)
|
||||||
|
layout.addWidget(self.picker_druh_lokality)
|
||||||
|
|
||||||
|
self.picker_jistota = self.setup_picker("Lokalita – jistota určení", 'jistota', JISTOTA)
|
||||||
|
layout.addWidget(self.picker_jistota)
|
||||||
|
|
||||||
|
self.picker_lokalita_zachovalost = self.setup_picker("Lokalita - stav dochování", 'lokalita_zachovalost', LOKALITA_ZACHOVALOST)
|
||||||
|
layout.addWidget(self.picker_lokalita_zachovalost)
|
||||||
|
|
||||||
|
# Contextual information
|
||||||
|
|
||||||
|
self.picker_obdobi = self.setup_picker("Období", 'obdobi', OBDOBI)
|
||||||
|
layout.addWidget(self.picker_obdobi)
|
||||||
|
|
||||||
|
self.picker_areal = self.setup_picker("Areál", 'areal', AREAL)
|
||||||
|
layout.addWidget(self.picker_areal)
|
||||||
|
|
||||||
|
# Option to download related components table
|
||||||
|
self.chk_komponenty = QCheckBox("Načíst komponenty")
|
||||||
|
layout.addWidget(self.chk_komponenty)
|
||||||
|
|
||||||
|
# Pushes everything above to the top
|
||||||
|
layout.addStretch(1)
|
||||||
|
|
||||||
|
# Main dialog OK/Cancel/Update buttons
|
||||||
|
|
||||||
|
buttons = QDialogButtonBox()
|
||||||
|
|
||||||
|
self.btn_update = QPushButton("Aktualizovat hesláře 🔄")
|
||||||
|
self.btn_update.setToolTip("Provede kompletní aktualizaci heslářů AMČR. Toto bude trvat pár minut.")
|
||||||
|
self.btn_update.clicked.connect(self.action_update_heslare)
|
||||||
|
|
||||||
|
buttons.addButton(self.btn_update, QDialogButtonBox.ButtonRole.ActionRole)
|
||||||
|
buttons.addButton(QDialogButtonBox.StandardButton.Ok)
|
||||||
|
buttons.addButton(QDialogButtonBox.StandardButton.Cancel)
|
||||||
|
|
||||||
|
buttons.accepted.connect(self.accept)
|
||||||
|
buttons.rejected.connect(self.reject)
|
||||||
|
layout.addWidget(buttons)
|
||||||
|
|
||||||
|
self.setLayout(layout)
|
||||||
|
|
||||||
|
def setup_picker(self, label_text, cache_key, data_source, extra_btn=None):
|
||||||
|
"""
|
||||||
|
Creates a reusable UI component consisting of a label, a read-only
|
||||||
|
text field showing selected items, and a button to open the selection dialog.
|
||||||
|
"""
|
||||||
|
row_widget = QGroupBox(label_text)
|
||||||
row_layout = QHBoxLayout()
|
row_layout = QHBoxLayout()
|
||||||
row_layout.setContentsMargins(5, 5, 5, 5)
|
row_layout.setContentsMargins(5, 5, 5, 5)
|
||||||
|
|
||||||
|
# Read-only field displaying the names of selected items
|
||||||
display_field = QLineEdit()
|
display_field = QLineEdit()
|
||||||
display_field.setReadOnly(True)
|
display_field.setReadOnly(True)
|
||||||
display_field.setPlaceholderText("Nic nevybráno (vše)")
|
display_field.setPlaceholderText("Nic nevybráno (vše)")
|
||||||
@@ -98,93 +250,196 @@ class AmcrFilterDialog(QDialog):
|
|||||||
btn = QPushButton("Vybrat...")
|
btn = QPushButton("Vybrat...")
|
||||||
btn.setFixedWidth(80)
|
btn.setFixedWidth(80)
|
||||||
|
|
||||||
|
# Nested function that handles opening the dialog and saving results
|
||||||
def open_dialog():
|
def open_dialog():
|
||||||
dlg = FilterableSelectionDialog(label_text, data_source, self.selection_cache[cache_key], self)
|
dlg = FilterableSelectionDialog(label_text, data_source, self.selection_cache[cache_key], self)
|
||||||
if dlg.exec_() == QDialog.Accepted:
|
if dlg.exec() == QDialog.DialogCode.Accepted:
|
||||||
codes, labels = dlg.get_selected_codes()
|
codes, labels = dlg.get_selected_codes()
|
||||||
|
# Update local cache with selected IDs
|
||||||
self.selection_cache[cache_key] = codes
|
self.selection_cache[cache_key] = codes
|
||||||
if labels: display_field.setText(", ".join(labels))
|
# Update the UI text field with selected names
|
||||||
else: display_field.clear()
|
if labels:
|
||||||
|
display_field.setText(", ".join(labels))
|
||||||
|
else:
|
||||||
|
display_field.clear()
|
||||||
|
|
||||||
|
# Special case: Pre-fill specific accuracy levels by default
|
||||||
|
if cache_key == 'pian_presnost':
|
||||||
|
display_field.setText("odchylka jednotky metrů, odchylka desítky metrů, odchylka stovky metrů")
|
||||||
|
self.selection_cache[cache_key] = ['HES-000861', 'HES-000862', 'HES-000863']
|
||||||
|
|
||||||
btn.clicked.connect(open_dialog)
|
btn.clicked.connect(open_dialog)
|
||||||
|
|
||||||
row_layout.addWidget(display_field)
|
row_layout.addWidget(display_field)
|
||||||
row_layout.addWidget(btn)
|
row_layout.addWidget(btn)
|
||||||
|
|
||||||
|
# Add an optional extra button (e.g., the refresh button for leaders)
|
||||||
if extra_btn:
|
if extra_btn:
|
||||||
row_layout.addWidget(extra_btn)
|
row_layout.addWidget(extra_btn)
|
||||||
|
|
||||||
row_widget.setLayout(row_layout)
|
row_widget.setLayout(row_layout)
|
||||||
return row_widget
|
return row_widget
|
||||||
|
|
||||||
self.picker_kraj = setup_picker("Kraj", 'kraj', KRAJE)
|
def action_update_heslare(self):
|
||||||
layout.addWidget(self.picker_kraj)
|
# Vytvoření instance tasku
|
||||||
|
task = UpdateCodelistsTask("Aktualizace heslářů AMČR")
|
||||||
|
|
||||||
self.picker_okres = setup_picker("Okres", 'okres', OKRESY)
|
# Povolíme tlačítko zpět bez ohledu na výsledek
|
||||||
layout.addWidget(self.picker_okres)
|
task.taskCompleted.connect(lambda: self.btn_update.setEnabled(True))
|
||||||
|
task.taskTerminated.connect(lambda: self.btn_update.setEnabled(True))
|
||||||
|
|
||||||
self.picker_katastr = setup_picker("Katastr", 'katastr', KATASTRY)
|
task.taskCompleted.connect(lambda: QMessageBox.information(self, "Hotovo", "Hesláře byly úspěšně aktualizovány."))
|
||||||
layout.addWidget(self.picker_katastr)
|
|
||||||
|
|
||||||
self.picker_org = setup_picker("Organizace", 'organizace', ORGANIZACE)
|
# Ošetření, aby se přesně ukázala případná chyba
|
||||||
layout.addWidget(self.picker_org)
|
def on_error():
|
||||||
|
if task.exception:
|
||||||
|
# Tohle ti přesně řekne, na čem to teď padá (např. PermissionError)
|
||||||
|
msg = f"Aktualizace selhala z důvodu chyby:\n{str(task.exception)}"
|
||||||
|
else:
|
||||||
|
msg = "Aktualizace byla zrušena uživatelem."
|
||||||
|
QMessageBox.warning(self, "Chyba / Zrušeno", msg)
|
||||||
|
|
||||||
self.btn_update_vedouci = QPushButton("🔄")
|
task.taskTerminated.connect(on_error)
|
||||||
self.btn_update_vedouci.setToolTip("Aktualizovat seznam vedoucích z API")
|
|
||||||
self.btn_update_vedouci.setFixedWidth(30)
|
|
||||||
self.btn_update_vedouci.clicked.connect(self.action_update_vedouci)
|
|
||||||
|
|
||||||
self.picker_vedouci = setup_picker("Vedoucí výzkumu", 'vedouci', VEDOUCI, extra_btn=self.btn_update_vedouci)
|
QgsApplication.taskManager().addTask(task)
|
||||||
layout.addWidget(self.picker_vedouci)
|
|
||||||
|
|
||||||
self.picker_obdobi = setup_picker("Období", 'obdobi', OBDOBI)
|
def get_bbox(self):
|
||||||
layout.addWidget(self.picker_obdobi)
|
return "true" if self.chk_bbox.isChecked() else "false"
|
||||||
|
|
||||||
self.picker_areal = setup_picker("Areál / Druh", 'areal', AREAL)
|
def get_komponenty(self):
|
||||||
layout.addWidget(self.picker_areal)
|
return "true" if self.chk_komponenty.isChecked() else "false"
|
||||||
|
|
||||||
self.picker_typ = setup_picker("Typ výzkumu", 'typ_akce', TYP_AKCE)
|
def get_filters(self):
|
||||||
layout.addWidget(self.picker_typ)
|
"""Compiles the user selections from the cache into API-ready filter parameters."""
|
||||||
|
filters = {}
|
||||||
|
|
||||||
|
if self.selection_cache['kraj']:
|
||||||
|
filters['f_kraj'] = self.selection_cache['kraj']
|
||||||
|
if self.selection_cache['okres']:
|
||||||
|
filters['f_okres'] = self.selection_cache['okres']
|
||||||
|
if self.selection_cache['katastr']:
|
||||||
|
filters['f_katastr'] = self.selection_cache['katastr']
|
||||||
|
if self.selection_cache['obdobi']:
|
||||||
|
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.selection_cache['pristupnost']:
|
||||||
|
filters['pristupnost'] = self.selection_cache['pristupnost']
|
||||||
|
|
||||||
|
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.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
|
||||||
|
|
||||||
|
class LoginDialog(QDialog):
|
||||||
|
"""
|
||||||
|
Dialog pro uložení přihlašovacích údajů do AMČR.
|
||||||
|
Ukládá do QSettings (username plaintext, heslo base64).
|
||||||
|
"""
|
||||||
|
|
||||||
|
KEY_USER = "amcr_viewer/username"
|
||||||
|
KEY_PASS = "amcr_viewer/password"
|
||||||
|
|
||||||
|
def __init__(self, parent=None):
|
||||||
|
super().__init__(parent)
|
||||||
|
self.setWindowTitle("Přihlášení do AMČR")
|
||||||
|
self.setMinimumWidth(360)
|
||||||
|
|
||||||
|
layout = QVBoxLayout()
|
||||||
|
|
||||||
|
settings = QSettings()
|
||||||
|
has_saved = bool(settings.value(self.KEY_USER, ""))
|
||||||
|
|
||||||
|
if has_saved:
|
||||||
|
info = QLabel("✔ Přihlašovací údaje jsou uloženy. Vyplňte pole níže pro jejich změnu.")
|
||||||
|
info.setStyleSheet("color: green; font-style: italic;")
|
||||||
|
else:
|
||||||
|
info = QLabel("Zadejte přihlašovací údaje k Digitálnímu archivu AMČR.\nVarování: přihlašovací údaje budou nezašifrovaně uloženy v registrech systému.")
|
||||||
|
info.setWordWrap(True)
|
||||||
|
layout.addWidget(info)
|
||||||
|
layout.addSpacing(8)
|
||||||
|
|
||||||
|
form = QFormLayout()
|
||||||
|
|
||||||
|
self.txt_user = QLineEdit()
|
||||||
|
self.txt_user.setPlaceholderText("např. jan.novak@email.cz")
|
||||||
|
# Předvyplnit uložené jméno pro pohodlí
|
||||||
|
self.txt_user.setText(settings.value(self.KEY_USER, ""))
|
||||||
|
form.addRow("E-mail:", self.txt_user)
|
||||||
|
|
||||||
|
self.txt_pass = QLineEdit()
|
||||||
|
self.txt_pass.setEchoMode(QLineEdit.EchoMode.Password)
|
||||||
|
self.txt_pass.setPlaceholderText("heslo")
|
||||||
|
form.addRow("Heslo:", self.txt_pass)
|
||||||
|
|
||||||
|
layout.addLayout(form)
|
||||||
|
layout.addSpacing(8)
|
||||||
|
|
||||||
|
if has_saved:
|
||||||
|
btn_forget = QPushButton("Zapomenout uložené přihlašovací údaje")
|
||||||
|
btn_forget.setStyleSheet("color: #c0392b;")
|
||||||
|
btn_forget.clicked.connect(self._forget_credentials)
|
||||||
|
layout.addWidget(btn_forget)
|
||||||
|
|
||||||
layout.addStretch(1)
|
layout.addStretch(1)
|
||||||
|
|
||||||
buttons = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
|
buttons = QDialogButtonBox(
|
||||||
buttons.accepted.connect(self.accept)
|
QDialogButtonBox.StandardButton.Ok | QDialogButtonBox.StandardButton.Cancel
|
||||||
|
)
|
||||||
|
buttons.accepted.connect(self._save_and_accept)
|
||||||
buttons.rejected.connect(self.reject)
|
buttons.rejected.connect(self.reject)
|
||||||
layout.addWidget(buttons)
|
layout.addWidget(buttons)
|
||||||
|
|
||||||
self.setLayout(layout)
|
self.setLayout(layout)
|
||||||
|
|
||||||
def action_update_vedouci(self):
|
def _save_and_accept(self):
|
||||||
QApplication.setOverrideCursor(Qt.WaitCursor)
|
username = self.txt_user.text().strip()
|
||||||
|
password = self.txt_pass.text()
|
||||||
|
|
||||||
|
if not username or not password:
|
||||||
|
QMessageBox.warning(self, "Chybí údaje", "Vyplňte prosím uživatelské jméno i heslo.")
|
||||||
|
return
|
||||||
|
|
||||||
|
settings = QSettings()
|
||||||
|
settings.setValue(self.KEY_USER, username)
|
||||||
|
# base64 není šifrování, ale heslo aspoň neleží v plaintextu v registru
|
||||||
|
settings.setValue(self.KEY_PASS, base64.b64encode(password.encode()).decode())
|
||||||
|
self.accept()
|
||||||
|
|
||||||
|
def _forget_credentials(self):
|
||||||
|
settings = QSettings()
|
||||||
|
settings.remove(self.KEY_USER)
|
||||||
|
settings.remove(self.KEY_PASS)
|
||||||
|
QMessageBox.information(self, "Hotovo", "Přihlašovací údaje byly odstraněny.")
|
||||||
|
self.reject()
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def get_credentials() -> tuple[str, str]:
|
||||||
|
"""Vrátí (username, password) z QSettings, nebo ('', '') pokud nejsou uloženy."""
|
||||||
|
settings = QSettings()
|
||||||
|
username = settings.value(LoginDialog.KEY_USER, "")
|
||||||
|
encoded = settings.value(LoginDialog.KEY_PASS, "")
|
||||||
try:
|
try:
|
||||||
success, msg = download_vedouci()
|
password = base64.b64decode(encoded.encode()).decode() if encoded else ""
|
||||||
if success:
|
except Exception:
|
||||||
count = refresh_vedouci_cache()
|
password = ""
|
||||||
QApplication.restoreOverrideCursor()
|
return username, password
|
||||||
QMessageBox.information(self, "Úspěch", f"{msg}\nNyní je v paměti {count} osob.")
|
|
||||||
else:
|
|
||||||
QApplication.restoreOverrideCursor()
|
|
||||||
QMessageBox.warning(self, "Chyba", f"Nepodařilo se stáhnout data:\n{msg}")
|
|
||||||
except Exception as e:
|
|
||||||
QApplication.restoreOverrideCursor()
|
|
||||||
QMessageBox.critical(self, "Chyba", str(e))
|
|
||||||
|
|
||||||
def get_bbox(self):
|
|
||||||
return "true" if self.chk_bbox.isChecked() else "false"
|
|
||||||
|
|
||||||
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']: filters['f_okres'] = self.selection_cache['okres']
|
|
||||||
if self.selection_cache['katastr']: filters['f_katastr'] = self.selection_cache['katastr']
|
|
||||||
if self.selection_cache['obdobi']: filters['f_obdobi'] = self.selection_cache['obdobi']
|
|
||||||
if self.selection_cache['areal']: filters['f_areal'] = self.selection_cache['areal']
|
|
||||||
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']
|
|
||||||
|
|
||||||
return filters
|
|
||||||
+451
-228
@@ -1,23 +1,132 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from qgis.gui import QgsMapToolIdentifyFeature
|
|
||||||
from qgis.core import (QgsProject, QgsVectorLayer, QgsFeature, QgsGeometry,
|
from qgis.core import (QgsProject, QgsVectorLayer, QgsFeature, QgsGeometry,
|
||||||
QgsField, QgsCoordinateReferenceSystem, QgsCoordinateTransform,
|
QgsField, QgsCoordinateReferenceSystem, QgsCoordinateTransform,
|
||||||
QgsWkbTypes)
|
QgsWkbTypes, Qgis, QgsApplication, QgsAuthMethodConfig, QgsMessageLog)
|
||||||
from qgis.utils import iface
|
from qgis.utils import iface
|
||||||
from qgis.PyQt.QtCore import QVariant, Qt
|
from qgis.PyQt.QtCore import Qt, QMetaType
|
||||||
from qgis.PyQt.QtWidgets import QMessageBox, QApplication
|
from qgis.PyQt.QtWidgets import QApplication
|
||||||
|
from qgis.PyQt.QtGui import QCursor
|
||||||
import requests
|
import requests
|
||||||
import json
|
import json
|
||||||
import xml.etree.ElementTree as ET
|
|
||||||
import re
|
|
||||||
|
|
||||||
# Global translations cache
|
# Global cache to store translated terms from the Digital Archive
|
||||||
TRANSLATIONS = {}
|
TRANSLATIONS = {}
|
||||||
|
|
||||||
# Download Digiarchive's vocabulary
|
# Session s autentizační cookie po přihlášení; None = nepřihlášen (anonymní přístup)
|
||||||
|
AMCR_SESSION: requests.Session | None = None
|
||||||
|
|
||||||
|
def _log(msg: str, level=Qgis.MessageLevel.Info):
|
||||||
|
"""Shortcut: zapíše zprávu do QGIS logu (panel Zprávy → záložka AMČR)."""
|
||||||
|
QgsMessageLog.logMessage(msg, "AMČR login", level)
|
||||||
|
|
||||||
|
|
||||||
|
def login_to_api(username: str, password: str):
|
||||||
|
"""
|
||||||
|
Přihlásí se do Digiarchiv API pomocí username a hesla.
|
||||||
|
Vrátí requests.Session s nastavenou session cookie, nebo None při chybě.
|
||||||
|
"""
|
||||||
|
login_url = "https://digiarchiv.aiscr.cz/api/user/login"
|
||||||
|
|
||||||
|
_log(f"Přihlašuji uživatele: '{username}'")
|
||||||
|
|
||||||
|
if not username or not password:
|
||||||
|
_log("CHYBA: username nebo heslo je prázdné.", Qgis.MessageLevel.Critical)
|
||||||
|
return None
|
||||||
|
|
||||||
|
session = requests.Session()
|
||||||
|
session.headers.update({
|
||||||
|
"Accept": "application/json, text/plain, */*",
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
"User-Agent": "QGIS-Plugin/1.0 (AISCR Data Fetcher)"
|
||||||
|
})
|
||||||
|
|
||||||
|
try:
|
||||||
|
_log(f"Odesílám POST na {login_url} ...")
|
||||||
|
response = session.post(login_url, json={"user": username, "pwd": password}, timeout=10)
|
||||||
|
_log(f"HTTP status: {response.status_code}")
|
||||||
|
response.raise_for_status()
|
||||||
|
|
||||||
|
# API vrací chyby se status kódem 200 – je nutné zkontrolovat tělo odpovědi
|
||||||
|
body = response.json()
|
||||||
|
if "error" in body:
|
||||||
|
_log(f"CHYBA přihlášení (API): {body['error']}", Qgis.MessageLevel.Critical)
|
||||||
|
return None
|
||||||
|
|
||||||
|
_log("Přihlášení proběhlo úspěšně.")
|
||||||
|
global AMCR_SESSION
|
||||||
|
AMCR_SESSION = session
|
||||||
|
return session
|
||||||
|
|
||||||
|
except requests.exceptions.HTTPError as e:
|
||||||
|
_log(f"CHYBA HTTP {e.response.status_code if e.response else '?'}: "
|
||||||
|
f"{e.response.text[:300] if e.response else 'žádná odpověď'}", Qgis.MessageLevel.Critical)
|
||||||
|
return None
|
||||||
|
except requests.exceptions.RequestException as e:
|
||||||
|
_log(f"CHYBA sítě: {e}", Qgis.MessageLevel.Critical)
|
||||||
|
return None
|
||||||
|
|
||||||
|
def _get_session() -> requests.Session | None:
|
||||||
|
"""
|
||||||
|
Vrátí aktivní session. Pokud žádná není (restart QGIS), pokusí se
|
||||||
|
automaticky přihlásit pomocí uložených přihlašovacích údajů.
|
||||||
|
Vrátí None pokud přihlašovací údaje nejsou uloženy.
|
||||||
|
"""
|
||||||
|
global AMCR_SESSION
|
||||||
|
if AMCR_SESSION is not None:
|
||||||
|
return AMCR_SESSION
|
||||||
|
|
||||||
|
# Zkusit auto-login pomocí uložených údajů
|
||||||
|
from .amcr_dialog import LoginDialog
|
||||||
|
username, password = LoginDialog.get_credentials()
|
||||||
|
if username and password:
|
||||||
|
_log("Session vypršela nebo chybí – automatické přihlášení...")
|
||||||
|
AMCR_SESSION = login_to_api(username, password)
|
||||||
|
|
||||||
|
return AMCR_SESSION
|
||||||
|
|
||||||
|
|
||||||
|
def _api_get(url, params, timeout=30) -> requests.Response:
|
||||||
|
"""
|
||||||
|
Provede GET request. Pokud API signalizuje vypršení přihlášení,
|
||||||
|
provede jedno opakované přihlášení a zkusí znovu.
|
||||||
|
"""
|
||||||
|
global AMCR_SESSION
|
||||||
|
|
||||||
|
def _is_auth_error(resp: requests.Response) -> bool:
|
||||||
|
"""API vrací auth chyby se status 200 – je nutné zkontrolovat tělo."""
|
||||||
|
if resp.status_code == 401:
|
||||||
|
return True
|
||||||
|
try:
|
||||||
|
body = resp.json()
|
||||||
|
err = str(body.get("error", "")).lower()
|
||||||
|
return "unauthorized" in err or "not logged" in err or "session" in err
|
||||||
|
except Exception:
|
||||||
|
return False
|
||||||
|
|
||||||
|
session = _get_session()
|
||||||
|
resp = (session or requests).get(url, params=params, timeout=timeout)
|
||||||
|
|
||||||
|
if _is_auth_error(resp):
|
||||||
|
_log("Session vypršela během stahování – obnovuji přihlášení...", Qgis.MessageLevel.Warning)
|
||||||
|
AMCR_SESSION = None # Zrušit starou session
|
||||||
|
from .amcr_dialog import LoginDialog
|
||||||
|
username, password = LoginDialog.get_credentials()
|
||||||
|
if username and password:
|
||||||
|
AMCR_SESSION = login_to_api(username, password)
|
||||||
|
if AMCR_SESSION:
|
||||||
|
resp = AMCR_SESSION.get(url, params=params, timeout=timeout)
|
||||||
|
else:
|
||||||
|
_log("Opakované přihlášení selhalo.", Qgis.MessageLevel.Critical)
|
||||||
|
else:
|
||||||
|
_log("Přihlašovací údaje nejsou uloženy – pokračuji anonymně.", Qgis.MessageLevel.Warning)
|
||||||
|
|
||||||
|
return resp
|
||||||
|
|
||||||
def load_translations():
|
def load_translations():
|
||||||
|
"""Fetches the official Czech translation dictionary from the AISCR API."""
|
||||||
global TRANSLATIONS
|
global TRANSLATIONS
|
||||||
if TRANSLATIONS: return
|
if TRANSLATIONS:
|
||||||
|
return
|
||||||
|
|
||||||
url = "https://digiarchiv.aiscr.cz/api/assets/i18n/cs.json"
|
url = "https://digiarchiv.aiscr.cz/api/assets/i18n/cs.json"
|
||||||
try:
|
try:
|
||||||
@@ -25,69 +134,87 @@ def load_translations():
|
|||||||
if r.status_code == 200:
|
if r.status_code == 200:
|
||||||
TRANSLATIONS = r.json()
|
TRANSLATIONS = r.json()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"Chyba při stahování hesláře: {e}")
|
print(f"Error downloading vocabulary: {e}")
|
||||||
|
|
||||||
def tr_code(code):
|
def tr_code(code):
|
||||||
if not code: return ""
|
"""Translates a technical code into a human-readable string using the global cache."""
|
||||||
|
if not code:
|
||||||
|
return ""
|
||||||
return TRANSLATIONS.get(code, code)
|
return TRANSLATIONS.get(code, code)
|
||||||
|
|
||||||
def load_amcr_data(canvas, bb, filters=None):
|
def load_amcr_data(canvas, bb, filters=None, typ_dat="akce", komponenty="false"):
|
||||||
|
"""
|
||||||
|
Main processing function:
|
||||||
|
1. Determines search area (Bounding Box)
|
||||||
|
2. Fetches metadata and geometries from API
|
||||||
|
3. Creates QGIS memory layers and populates them with features
|
||||||
|
"""
|
||||||
load_translations()
|
load_translations()
|
||||||
|
|
||||||
# 1. Bounding box
|
# --- 1. COORDINATE TRANSFORMATION ---
|
||||||
|
# Get current map extent and transform it from project CRS (usually S-JTSK) to WGS-84 for the API
|
||||||
extent = canvas.extent()
|
extent = canvas.extent()
|
||||||
crs_src = canvas.mapSettings().destinationCrs()
|
crs_src = canvas.mapSettings().destinationCrs()
|
||||||
crs_dest = QgsCoordinateReferenceSystem("EPSG:4326")
|
crs_dest = QgsCoordinateReferenceSystem("EPSG:4326")
|
||||||
xform = QgsCoordinateTransform(crs_src, crs_dest, QgsProject.instance())
|
xform = QgsCoordinateTransform(crs_src, crs_dest, QgsProject.instance())
|
||||||
extent_wgs = xform.transformBoundingBox(extent)
|
extent_wgs = xform.transformBoundingBox(extent)
|
||||||
|
|
||||||
|
# Format the bounding box string as required by the API: minLat,minLon,maxLat,maxLon
|
||||||
bbox_str = f"{extent_wgs.yMinimum()},{extent_wgs.xMinimum()},{extent_wgs.yMaximum()},{extent_wgs.xMaximum()}"
|
bbox_str = f"{extent_wgs.yMinimum()},{extent_wgs.xMinimum()},{extent_wgs.yMaximum()},{extent_wgs.xMaximum()}"
|
||||||
|
|
||||||
url = "https://digiarchiv.aiscr.cz/api/search/query"
|
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=Qgis.MessageLevel.Info)
|
||||||
QApplication.setOverrideCursor(Qt.WaitCursor)
|
QApplication.setOverrideCursor(QCursor(Qt.CursorShape.WaitCursor))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# ===================
|
# ==========================================
|
||||||
# A) METADATA (Fieldwork event)
|
# A) METADATA FETCHING (Fieldwork/Site)
|
||||||
# ===================
|
# ==========================================
|
||||||
|
|
||||||
base_params = {
|
base_params = {
|
||||||
"mapa": "true",
|
"mapa": "true",
|
||||||
#"isExport": "true",
|
"sort": "ident_cely asc",
|
||||||
"entity": "akce",
|
"entity": typ_dat
|
||||||
"sort": "ident_cely asc"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Restrict search to map window if requested
|
||||||
if bb == "true":
|
if bb == "true":
|
||||||
base_params["loc_rpt"] = bbox_str
|
base_params["loc_rpt"] = bbox_str
|
||||||
|
|
||||||
# Apply filters
|
# Apply multi-select filters from the dialog using the ':or' syntax required by the API
|
||||||
if filters:
|
if filters:
|
||||||
for key, value in filters.items():
|
for key, value in filters.items():
|
||||||
if not value: continue
|
if not value:
|
||||||
|
continue
|
||||||
if isinstance(value, list):
|
if isinstance(value, list):
|
||||||
base_params[key] = [f"{v}:or" for v in value]
|
base_params[key] = [f"{v}:or" for v in value]
|
||||||
else:
|
else:
|
||||||
base_params[key] = str(value).strip()
|
base_params[key] = str(value).strip()
|
||||||
|
|
||||||
docs_akce = []
|
docs = []
|
||||||
current_page = 0
|
current_page = 0
|
||||||
BATCH_AKCE = 500
|
BATCH_DOCS = 500 # Records per API request
|
||||||
MAX_LIMIT = 20000
|
MAX_LIMIT = 20000 # Safety limit to prevent QGIS from freezing
|
||||||
|
|
||||||
|
|
||||||
seen_ids = set()
|
seen_ids = set()
|
||||||
|
target_pian_ids_count = 0
|
||||||
|
|
||||||
|
# Check if we should skip negative results based on filter
|
||||||
|
skip_negativni = filters.get('posevidence') == 'true' if filters else False
|
||||||
|
|
||||||
|
# --- API PAGINATION LOOP ---
|
||||||
while True:
|
while True:
|
||||||
base_params['rows'] = BATCH_AKCE
|
base_params['rows'] = BATCH_DOCS
|
||||||
if current_page > 0:
|
if current_page > 0:
|
||||||
base_params['page'] = current_page
|
base_params['page'] = current_page
|
||||||
elif 'page' in base_params:
|
elif 'page' in base_params:
|
||||||
del base_params['page']
|
del base_params['page']
|
||||||
|
|
||||||
try:
|
try:
|
||||||
resp_akce = requests.get(url, params=base_params, timeout=30)
|
resp_docs = _api_get(url, params=base_params, timeout=30)
|
||||||
resp_json = resp_akce.json()
|
resp_json = resp_docs.json()
|
||||||
data = resp_json.get('response', {})
|
data = resp_json.get('response', {})
|
||||||
batch_docs = data.get('docs', [])
|
batch_docs = data.get('docs', [])
|
||||||
num_found = data.get('numFound', 0)
|
num_found = data.get('numFound', 0)
|
||||||
@@ -95,6 +222,7 @@ def load_amcr_data(canvas, bb, filters=None):
|
|||||||
if not batch_docs:
|
if not batch_docs:
|
||||||
break
|
break
|
||||||
|
|
||||||
|
# Filter out duplicates and append to main list
|
||||||
new_docs = []
|
new_docs = []
|
||||||
for d in batch_docs:
|
for d in batch_docs:
|
||||||
ident = d.get('ident_cely')
|
ident = d.get('ident_cely')
|
||||||
@@ -102,124 +230,178 @@ def load_amcr_data(canvas, bb, filters=None):
|
|||||||
seen_ids.add(ident)
|
seen_ids.add(ident)
|
||||||
new_docs.append(d)
|
new_docs.append(d)
|
||||||
|
|
||||||
docs_akce.extend(new_docs)
|
docs.extend(new_docs)
|
||||||
print(f"Strana {current_page} stažena. Celkem záznamů: {len(docs_akce)} / {num_found}")
|
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
|
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)
|
iface.messageBar().pushMessage("AMCR", f"Limit {MAX_LIMIT} záznamů dosažen.", level=Qgis.MessageLevel.Warning)
|
||||||
break
|
break
|
||||||
|
|
||||||
current_page += 1
|
current_page += 1
|
||||||
QApplication.processEvents()
|
QApplication.processEvents() # Keep UI responsive
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"Chyba při stránkování na straně {current_page}: {e}")
|
print(f"Chyba při stránkování na straně {current_page}: {e}")
|
||||||
break
|
break
|
||||||
|
|
||||||
if not docs_akce:
|
if not docs:
|
||||||
iface.messageBar().pushMessage("AMCR", "Žádné akce nenalezeny.", level=1)
|
iface.messageBar().pushMessage("AMCR", "Žádné záznamy nenalezeny.", level=Qgis.MessageLevel.Warning)
|
||||||
return
|
return
|
||||||
|
|
||||||
# ==========================================
|
# ==========================================
|
||||||
# Attribute parsing
|
# B) ATTRIBUTE PARSING
|
||||||
# ==========================================
|
# ==========================================
|
||||||
|
|
||||||
|
# pian_lookup maps a Geometry ID (PIAN) to a list of its associated metadata
|
||||||
pian_lookup = {}
|
pian_lookup = {}
|
||||||
target_pian_ids = set()
|
target_pian_ids = set()
|
||||||
actions_with_geom = 0
|
actions_with_geom = 0
|
||||||
negative_dj_pian_ids = set()
|
|
||||||
|
|
||||||
for akce in docs_akce:
|
# Helper function for safe single-value extraction
|
||||||
piani = akce.get('az_dj_pian', [])
|
def g(doc, key, default=""):
|
||||||
if not piani: continue
|
val = doc.get(key)
|
||||||
|
if isinstance(val, list):
|
||||||
negative_pians = set()
|
return str(val[0]) if val else default
|
||||||
# Pokud je aktivní filtr 'posevidence', projdeme dokumentační jednotky
|
|
||||||
if filters and filters.get('posevidence') == 'true':
|
|
||||||
djs = akce.get('az_dokumentacni_jednotka', [])
|
|
||||||
for dj in djs:
|
|
||||||
# Pokud je jednotka negativní
|
|
||||||
if dj.get('dj_negativni_jednotka') is True:
|
|
||||||
# Získáme ID pianu z objektu (např. {"id": "P-...", "value": "..."})
|
|
||||||
pian_obj = dj.get('dj_pian')
|
|
||||||
if pian_obj and isinstance(pian_obj, dict):
|
|
||||||
negative_pians.add(pian_obj.get('id'))
|
|
||||||
|
|
||||||
djs = akce.get('az_dokumentacni_jednotka', [])
|
|
||||||
for dj in djs:
|
|
||||||
is_negative = dj.get('dj_negativni_jednotka')
|
|
||||||
if is_negative is True or str(is_negative).lower() == 'true':
|
|
||||||
# Získáme ID pianu z objektu (např. {"id": "P-...", "value": "..."})
|
|
||||||
pian_obj = dj.get('dj_pian')
|
|
||||||
if pian_obj and isinstance(pian_obj, dict):
|
|
||||||
negative_dj_pian_ids.add(pian_obj.get('id'))
|
|
||||||
|
|
||||||
actions_with_geom += 1
|
|
||||||
|
|
||||||
def g(key, default=""):
|
|
||||||
val = akce.get(key)
|
|
||||||
if isinstance(val, list): return str(val[0]) if val else default
|
|
||||||
return str(val) if val is not None else default
|
return str(val) if val is not None else default
|
||||||
|
|
||||||
def g_list(key, translate=False):
|
# Helper function for safe list-value extraction and joining
|
||||||
val = akce.get(key, [])
|
def g_list(doc, key, translate=False):
|
||||||
if not isinstance(val, list): val = [val] if val else []
|
val = doc.get(key, [])
|
||||||
|
if not isinstance(val, list):
|
||||||
|
val = [val] if val else []
|
||||||
if translate:
|
if translate:
|
||||||
return ", ".join([tr_code(str(x)) for x in val if x])
|
return ", ".join([tr_code(str(x)) for x in val if x])
|
||||||
return ", ".join([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', {})
|
# Process each downloaded metadata record
|
||||||
akce_chranene = akce.get('akce_chranene_udaje', {})
|
for doc in docs:
|
||||||
|
piani = doc.get('az_dj_pian', [])
|
||||||
|
if not piani:
|
||||||
|
continue
|
||||||
|
|
||||||
|
actions_with_geom += 1
|
||||||
|
|
||||||
|
# Extract protected data (fields not available in public Solr index)
|
||||||
|
az_chranene = doc.get('az_chranene_udaje', {})
|
||||||
|
chranene = doc.get('akce_chranene_udaje') or doc.get('lokalita_chranene_udaje') or {}
|
||||||
|
|
||||||
|
# Format additional cadastral areas from dictionaries
|
||||||
dalsi_kat = az_chranene.get('dalsi_katastr', [])
|
dalsi_kat = az_chranene.get('dalsi_katastr', [])
|
||||||
dalsi_kat_str = ""
|
dalsi_kat_str = ""
|
||||||
if isinstance(dalsi_kat, list):
|
if isinstance(dalsi_kat, list):
|
||||||
items = [x.get('value', '') if isinstance(x, dict) else str(x) for x in dalsi_kat]
|
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])
|
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
|
# Core metadata structure
|
||||||
meta = {
|
meta = {
|
||||||
"ident_cely": akce.get('ident_cely', ''),
|
"ident_cely": doc.get('ident_cely', ''),
|
||||||
"az_okres": g('az_okres'),
|
"az_okres": g(doc, 'az_okres'),
|
||||||
"katastr": g_list('katastr'),
|
"katastr": g_list(doc, 'katastr'),
|
||||||
"dalsi_katastr": dalsi_kat_str,
|
"dalsi_katastr": dalsi_kat_str,
|
||||||
"akce_hlavni_vedouci": g('akce_hlavni_vedouci'),
|
"pristupnost": g(doc, 'pristupnost'),
|
||||||
"akce_organizace": tr_code(g('akce_organizace')),
|
"loc": g_list(doc, 'loc')
|
||||||
"akce_specifikace_data": tr_code(g('akce_specifikace_data')),
|
|
||||||
"akce_datum_zahajeni": g('akce_datum_zahajeni'),
|
|
||||||
"akce_datum_ukonceni": g('akce_datum_ukonceni'),
|
|
||||||
"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')
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for pid in piani:
|
# Add entity-specific metadata
|
||||||
if pid in negative_pians:
|
if typ_dat == "akce":
|
||||||
|
meta.update({
|
||||||
|
"akce_hlavni_vedouci": g(doc, 'akce_hlavni_vedouci'),
|
||||||
|
"akce_organizace": tr_code(g(doc, 'akce_organizace')),
|
||||||
|
"akce_specifikace_data": tr_code(g(doc, 'akce_specifikace_data')),
|
||||||
|
"akce_datum_zahajeni": g(doc, 'akce_datum_zahajeni'),
|
||||||
|
"akce_datum_ukonceni": g(doc, 'akce_datum_ukonceni'),
|
||||||
|
"akce_hlavni_typ": tr_code(g(doc, 'akce_hlavni_typ')),
|
||||||
|
"akce_vedlejsi_typ": g_list(doc, 'akce_vedlejsi_typ', translate=True),
|
||||||
|
"lokalizace_okolnosti": str(lokalizace) if lokalizace else "",
|
||||||
|
"akce_je_nz": "Ano" if doc.get('akce_je_nz') is True else "Ne",
|
||||||
|
})
|
||||||
|
|
||||||
|
elif typ_dat == "lokalita":
|
||||||
|
meta.update({
|
||||||
|
"lokalita_nazev": lokalita_nazev,
|
||||||
|
"lokalita_popis": lokalita_popis,
|
||||||
|
"lokalita_zachovalost": tr_code(g(doc, 'lokalita_zachovalost')),
|
||||||
|
"lokalita_druh": tr_code(g(doc, 'lokalita_druh')),
|
||||||
|
"lokalita_typ": tr_code(g(doc, 'lokalita_typ_lokality')),
|
||||||
|
})
|
||||||
|
|
||||||
|
# Documentation units (DJ) within the record
|
||||||
|
djs = doc.get('az_dokumentacni_jednotka', [])
|
||||||
|
|
||||||
|
for dj in djs:
|
||||||
|
# Filter out negative evidence units if requested
|
||||||
|
if skip_negativni and dj.get('dj_negativni_jednotka') is True:
|
||||||
continue
|
continue
|
||||||
pian_lookup[pid] = meta
|
|
||||||
target_pian_ids.add(pid)
|
dj_id = dj.get('ident_cely')
|
||||||
|
dj_typ = dj.get('dj_typ')
|
||||||
|
|
||||||
|
# Merge general meta with documentation unit specific data
|
||||||
|
dj_meta = {
|
||||||
|
**meta,
|
||||||
|
'dj_id': dj_id,
|
||||||
|
'dj_typ_value': dj_typ.get('value') if dj_typ else "",
|
||||||
|
'dj_negativni': "Negativní" if dj.get('dj_negativni_jednotka') is True else "Pozitivní"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Link Documentation Unit to Geometry (PIAN)
|
||||||
|
dj_pian = dj.get('dj_pian')
|
||||||
|
if dj_pian:
|
||||||
|
dj_pian_value = dj_pian.get('id')
|
||||||
|
if dj_pian_value:
|
||||||
|
target_pian_ids.add(dj_pian_value)
|
||||||
|
if dj_pian_value not in pian_lookup:
|
||||||
|
pian_lookup[dj_pian_value] = []
|
||||||
|
|
||||||
|
if komponenty == "true":
|
||||||
|
# One feature per component — all data on a single row, no relations needed
|
||||||
|
komps = dj.get('dj_komponenta', [])
|
||||||
|
if komps:
|
||||||
|
for komp in komps:
|
||||||
|
komp_meta = {
|
||||||
|
**dj_meta,
|
||||||
|
'komponenta_id': komp.get('ident_cely', ""),
|
||||||
|
'komponenta_areal': komp.get('komponenta_areal', {}).get('value', ""),
|
||||||
|
'komponenta_obdobi': komp.get('komponenta_obdobi', {}).get('value', ""),
|
||||||
|
}
|
||||||
|
pian_lookup[dj_pian_value].append(komp_meta)
|
||||||
|
target_pian_ids_count += 1
|
||||||
|
else:
|
||||||
|
# DJ without components — still include with empty component fields
|
||||||
|
empty_meta = {
|
||||||
|
**dj_meta,
|
||||||
|
'komponenta_id': "",
|
||||||
|
'komponenta_areal': "",
|
||||||
|
'komponenta_obdobi': "",
|
||||||
|
}
|
||||||
|
pian_lookup[dj_pian_value].append(empty_meta)
|
||||||
|
target_pian_ids_count += 1
|
||||||
|
else:
|
||||||
|
target_pian_ids_count += 1
|
||||||
|
pian_lookup[dj_pian_value].append(dj_meta)
|
||||||
|
|
||||||
|
|
||||||
if not target_pian_ids:
|
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=Qgis.MessageLevel.Warning)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
# ==========================================
|
# ==========================================
|
||||||
# B) Geometry (PIAN)
|
# C) GEOMETRY FETCHING (PIAN)
|
||||||
# ==========================================
|
# ==========================================
|
||||||
ids_list = list(target_pian_ids)
|
ids_list = list(target_pian_ids)
|
||||||
total_pians = len(ids_list)
|
total_pians = len(ids_list)
|
||||||
docs_pian = []
|
docs_pian = []
|
||||||
BATCH_PIAN = 50
|
BATCH_PIAN = 200 # Geometry requests are batch-processed to stay under URL length limits
|
||||||
|
|
||||||
iface.messageBar().pushMessage("AMCR", f"Akcí: {len(docs_akce)} (z toho {actions_with_geom} s mapou). Stahuji {total_pians} 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=Qgis.MessageLevel.Info)
|
||||||
|
|
||||||
# Seznam polí pro PIAN
|
|
||||||
fl_pian = ["ident_cely", "pian_typ", "pian_chranene_udaje", "pian_presnost"]
|
fl_pian = ["ident_cely", "pian_typ", "pian_chranene_udaje", "pian_presnost"]
|
||||||
|
|
||||||
for i in range(0, total_pians, BATCH_PIAN):
|
for i in range(0, total_pians, BATCH_PIAN):
|
||||||
@@ -236,187 +418,228 @@ def load_amcr_data(canvas, bb, filters=None):
|
|||||||
}
|
}
|
||||||
try:
|
try:
|
||||||
QApplication.processEvents()
|
QApplication.processEvents()
|
||||||
r_pian = requests.get(url, params=params_pian, timeout=15)
|
r_pian = _api_get(url, params=params_pian, timeout=15)
|
||||||
batch_docs = r_pian.json().get('response', {}).get('docs', [])
|
batch_docs = r_pian.json().get('response', {}).get('docs', [])
|
||||||
docs_pian.extend(batch_docs)
|
docs_pian.extend(batch_docs)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"Chyba PIAN: {e}")
|
print(f"Chyba PIAN: {e}")
|
||||||
|
|
||||||
# ==========================================
|
# ==========================================
|
||||||
# C) TVORBA VRSTEV
|
# D) LAYER CREATION (QGIS Memory Layers)
|
||||||
# ==========================================
|
# ==========================================
|
||||||
vl_poly = QgsVectorLayer("Polygon?crs=epsg:5514", "AMCR Plochy", "memory")
|
|
||||||
vl_line = QgsVectorLayer("LineString?crs=epsg:5514", "AMCR Linie", "memory")
|
archeologicky_zaznam = "Akce" if typ_dat == "akce" else "Lokalita"
|
||||||
vl_point = QgsVectorLayer("Point?crs=epsg:5514", "AMCR Body", "memory")
|
|
||||||
|
# Initialize three layers for different geometry types (S-JTSK CRS)
|
||||||
|
vl_poly = QgsVectorLayer("Polygon?crs=epsg:5514", f"AMCR_{archeologicky_zaznam}_Polygony", "memory")
|
||||||
|
vl_line = QgsVectorLayer("LineString?crs=epsg:5514", f"AMCR_{archeologicky_zaznam}_Linie", "memory")
|
||||||
|
vl_point = QgsVectorLayer("Point?crs=epsg:5514", f"AMCR_{archeologicky_zaznam}_Body", "memory")
|
||||||
layers = [vl_poly, vl_line, vl_point]
|
layers = [vl_poly, vl_line, vl_point]
|
||||||
|
|
||||||
# Definice sloupců atributové tabulky
|
# Define attribute table structure
|
||||||
cols = [
|
cols = [
|
||||||
QgsField("PIAN", QVariant.String),
|
QgsField("pian", QMetaType.Type.QString),
|
||||||
QgsField("Přesnost", QVariant.String),
|
QgsField("presnost", QMetaType.Type.QString),
|
||||||
QgsField("PIAN – typ", QVariant.String),
|
QgsField("pian_typ", QMetaType.Type.QString),
|
||||||
QgsField("Definiční bod(y) (WGS-84)", QVariant.String),
|
QgsField("dj", QMetaType.Type.QString),
|
||||||
QgsField("Identifikátor", QVariant.String),
|
QgsField("typ_dj", QMetaType.Type.QString),
|
||||||
QgsField("Odkaz do Digiarchivu", QVariant.String),
|
QgsField("definicni_body", QMetaType.Type.QString),
|
||||||
QgsField("Okres", QVariant.String),
|
QgsField(typ_dat, QMetaType.Type.QString),
|
||||||
QgsField("Katastr", QVariant.String),
|
QgsField("odkaz_do_digiarchivu", QMetaType.Type.QString),
|
||||||
QgsField("Další katastry", QVariant.String),
|
QgsField("okres", QMetaType.Type.QString),
|
||||||
QgsField("Vedoucí akce", QVariant.String),
|
QgsField("katastr", QMetaType.Type.QString),
|
||||||
QgsField("Organizace", QVariant.String),
|
QgsField("dalsi_katastry", QMetaType.Type.QString)
|
||||||
QgsField("Specifikace data", QVariant.String),
|
]
|
||||||
QgsField("Datum zahájeni", QVariant.String),
|
|
||||||
QgsField("Datum ukončení", QVariant.String),
|
# Extend table based on data type
|
||||||
QgsField("Hlavní typ", QVariant.String),
|
if typ_dat == "akce":
|
||||||
QgsField("Vedlejší typ", QVariant.String),
|
cols += [
|
||||||
QgsField("Zjištění", QVariant.String),
|
QgsField("akce_lokalizace", QMetaType.Type.QString),
|
||||||
QgsField("Akce – lokalizace", QVariant.String),
|
QgsField("vedouci", QMetaType.Type.QString),
|
||||||
QgsField("Akce - nahrazuje NZ", QVariant.String),
|
QgsField("organizace", QMetaType.Type.QString),
|
||||||
QgsField("Přístupnost", QVariant.String)
|
QgsField("specifikace_data", QMetaType.Type.QString),
|
||||||
|
QgsField("zahajeni", QMetaType.Type.QString),
|
||||||
|
QgsField("ukonceni", QMetaType.Type.QString),
|
||||||
|
QgsField("hlavni_typ", QMetaType.Type.QString),
|
||||||
|
QgsField("vedlejsi_typ", QMetaType.Type.QString),
|
||||||
|
QgsField("zjisteni", QMetaType.Type.QString),
|
||||||
|
QgsField("nahrazuje_NZ", QMetaType.Type.QString),
|
||||||
|
]
|
||||||
|
elif typ_dat == "lokalita":
|
||||||
|
cols += [
|
||||||
|
QgsField("nazev_lokality", QMetaType.Type.QString),
|
||||||
|
QgsField("popis_lokality", QMetaType.Type.QString),
|
||||||
|
QgsField("typ_lokality", QMetaType.Type.QString),
|
||||||
|
QgsField("druh_lokality", QMetaType.Type.QString),
|
||||||
|
QgsField("zachovalost", QMetaType.Type.QString)
|
||||||
|
]
|
||||||
|
|
||||||
|
cols.append(QgsField("Přístupnost", QMetaType.Type.QString))
|
||||||
|
|
||||||
|
# Use aliases for technical field names
|
||||||
|
alias_map = {
|
||||||
|
"pian": "PIAN",
|
||||||
|
"presnost": "Přesnost",
|
||||||
|
"pian_typ": "PIAN – typ",
|
||||||
|
"dj": "Dokumentační jednotka",
|
||||||
|
"typ_dj": "Typ dokumentační jednotky",
|
||||||
|
"definicni_body": "Definiční bod(y) (WGS-84)",
|
||||||
|
typ_dat: archeologicky_zaznam,
|
||||||
|
"odkaz_do_digiarchivu": "Odkaz do Digitálního archivu AMČR",
|
||||||
|
"okres": "Okres",
|
||||||
|
"katastr": "Katastr",
|
||||||
|
"dalsi_katastry": "Další katastry",
|
||||||
|
"akce_lokalizace": "Akce – lokalizace",
|
||||||
|
"vedouci": "Vedoucí akce",
|
||||||
|
"organizace": "Organizace",
|
||||||
|
"specifikace_data": "Specifikace data",
|
||||||
|
"zahajeni": "Datum zahájeni",
|
||||||
|
"ukonceni": "Datum ukončení",
|
||||||
|
"hlavni_typ": "Hlavní typ",
|
||||||
|
"vedlejsi_typ": "Vedlejší typ",
|
||||||
|
"zjisteni": "Zjištění",
|
||||||
|
"nahrazuje_NZ": "Akce – nahrazuje NZ",
|
||||||
|
"nazev_lokality": "Název lokality",
|
||||||
|
"popis_lokality": "Popis lokality",
|
||||||
|
"typ_lokality": "Typ lokality",
|
||||||
|
"druh_lokality": "Druh lokality",
|
||||||
|
"zachovalost": "Zachovalost",
|
||||||
|
"komponenta": "Komponenta",
|
||||||
|
"komponenta_areal": "Areál",
|
||||||
|
"komponenta_obdobi": "Období",
|
||||||
|
}
|
||||||
|
|
||||||
|
if komponenty == "true":
|
||||||
|
cols += [
|
||||||
|
QgsField("komponenta", QMetaType.Type.QString),
|
||||||
|
QgsField("komponenta_areal", QMetaType.Type.QString),
|
||||||
|
QgsField("komponenta_obdobi", QMetaType.Type.QString),
|
||||||
]
|
]
|
||||||
|
|
||||||
for vl in layers:
|
for vl in layers:
|
||||||
vl.dataProvider().addAttributes(cols)
|
vl.dataProvider().addAttributes(cols)
|
||||||
vl.updateFields()
|
vl.updateFields()
|
||||||
|
for tech_name, alias in alias_map.items():
|
||||||
|
idx = vl.fields().lookupField(tech_name)
|
||||||
|
if idx != -1:
|
||||||
|
vl.setFieldAlias(idx, alias)
|
||||||
|
|
||||||
|
# Lists to hold features before batch-adding to layers
|
||||||
feats_p, feats_l, feats_pt = [], [], []
|
feats_p, feats_l, feats_pt = [], [], []
|
||||||
|
|
||||||
|
# --- FEATURE POPULATION ---
|
||||||
for doc in docs_pian:
|
for doc in docs_pian:
|
||||||
try:
|
try:
|
||||||
pid = doc.get('ident_cely', '')
|
pid = doc.get('ident_cely', '')
|
||||||
if pid not in pian_lookup: continue
|
if pid not in pian_lookup:
|
||||||
|
continue
|
||||||
|
|
||||||
meta = pian_lookup[pid]
|
metas = pian_lookup[pid]
|
||||||
|
|
||||||
# Geometry processing
|
# Extract WKT geometry from protected JSON data
|
||||||
raw = doc.get('pian_chranene_udaje')
|
raw = doc.get('pian_chranene_udaje')
|
||||||
if isinstance(raw, list) and raw: raw = raw[0]
|
if isinstance(raw, list) and raw:
|
||||||
jdata = json.loads(raw) if isinstance(raw, str) else (raw if isinstance(raw, dict) else {})
|
raw = raw[0]
|
||||||
|
jdata = json.loads(raw) if isinstance(raw, str) else (raw or {})
|
||||||
|
|
||||||
wkt = None
|
wkt = None
|
||||||
if jdata.get('geom_sjtsk_wkt'): wkt = jdata['geom_sjtsk_wkt'].get('value')
|
if jdata.get('geom_sjtsk_wkt'):
|
||||||
elif jdata.get('geom_wkt'): wkt = jdata['geom_wkt'].get('value')
|
wkt = jdata.get('geom_sjtsk_wkt', {}).get('value')
|
||||||
|
elif jdata.get('geom_wkt'):
|
||||||
|
wkt = jdata.get('geom_wkt', {}).get('value')
|
||||||
|
|
||||||
# PIAN attributes
|
|
||||||
pian_presnost = tr_code(str(doc.get('pian_presnost', '')))
|
pian_presnost = tr_code(str(doc.get('pian_presnost', '')))
|
||||||
pian_typ = tr_code(str(doc.get('pian_typ', '')))
|
pian_typ = tr_code(str(doc.get('pian_typ', '')))
|
||||||
dj_negativni = "Negativní" if pid in negative_dj_pian_ids else "Pozitivní"
|
|
||||||
|
# Final precision filter check
|
||||||
|
if filters and filters.get('f_pian_presnost') and doc.get('pian_presnost') not in filters.get('f_pian_presnost'):
|
||||||
|
continue
|
||||||
|
|
||||||
if wkt:
|
if wkt:
|
||||||
geom = QgsGeometry.fromWkt(wkt)
|
geom = QgsGeometry.fromWkt(wkt)
|
||||||
if geom.isGeosValid():
|
if geom.isGeosValid():
|
||||||
|
t = geom.type()
|
||||||
|
target_list = None
|
||||||
|
if t == QgsWkbTypes.PolygonGeometry:
|
||||||
|
target_list = feats_p
|
||||||
|
referenced_layer = vl_poly
|
||||||
|
elif t == QgsWkbTypes.LineGeometry:
|
||||||
|
target_list = feats_l
|
||||||
|
referenced_layer = vl_line
|
||||||
|
elif t == QgsWkbTypes.PointGeometry:
|
||||||
|
target_list = feats_pt
|
||||||
|
referenced_layer = vl_point
|
||||||
|
|
||||||
|
if target_list is None:
|
||||||
|
continue
|
||||||
|
|
||||||
|
is_akce = (typ_dat == "akce")
|
||||||
|
|
||||||
|
# Create a QGIS feature for each documentation unit associated with this geometry
|
||||||
|
for meta in metas:
|
||||||
feat = QgsFeature()
|
feat = QgsFeature()
|
||||||
feat.setGeometry(geom)
|
feat.setGeometry(geom)
|
||||||
feat.setAttributes([
|
atributy = [
|
||||||
pid,
|
pid, pian_presnost, pian_typ, meta['dj_id'],
|
||||||
pian_presnost,
|
meta['dj_typ_value'], meta['loc'], meta['ident_cely'],
|
||||||
pian_typ,
|
|
||||||
meta['loc'],
|
|
||||||
meta['ident_cely'],
|
|
||||||
"https://digiarchiv.aiscr.cz/id/" + meta['ident_cely'],
|
"https://digiarchiv.aiscr.cz/id/" + meta['ident_cely'],
|
||||||
meta['az_okres'],
|
meta['az_okres'], meta['katastr'], meta['dalsi_katastr']
|
||||||
meta['katastr'],
|
]
|
||||||
meta['dalsi_katastr'],
|
if is_akce:
|
||||||
meta['akce_hlavni_vedouci'],
|
atributy.extend([
|
||||||
meta['akce_organizace'],
|
meta['lokalizace_okolnosti'], meta['akce_hlavni_vedouci'],
|
||||||
meta['akce_specifikace_data'],
|
meta['akce_organizace'], meta['akce_specifikace_data'],
|
||||||
meta['akce_datum_zahajeni'],
|
meta['akce_datum_zahajeni'], meta['akce_datum_ukonceni'],
|
||||||
meta['akce_datum_ukonceni'],
|
meta['akce_hlavni_typ'], meta['akce_vedlejsi_typ'],
|
||||||
meta['akce_hlavni_typ'],
|
meta['dj_negativni'], meta['akce_je_nz']
|
||||||
meta['akce_vedlejsi_typ'],
|
|
||||||
dj_negativni,
|
|
||||||
meta['lokalizace_okolnosti'],
|
|
||||||
meta['akce_je_nz'],
|
|
||||||
meta['pristupnost']
|
|
||||||
])
|
])
|
||||||
t = geom.type()
|
else:
|
||||||
if t == QgsWkbTypes.PolygonGeometry: feats_p.append(feat)
|
atributy.extend([
|
||||||
elif t == QgsWkbTypes.LineGeometry: feats_l.append(feat)
|
meta['lokalita_nazev'], meta['lokalita_popis'],
|
||||||
elif t == QgsWkbTypes.PointGeometry: feats_pt.append(feat)
|
meta['lokalita_typ'], meta['lokalita_druh'],
|
||||||
|
meta['lokalita_zachovalost']
|
||||||
|
])
|
||||||
|
|
||||||
|
atributy.append(meta['pristupnost'])
|
||||||
|
|
||||||
|
if komponenty == "true":
|
||||||
|
atributy.extend([
|
||||||
|
meta.get('komponenta_id', ""),
|
||||||
|
meta.get('komponenta_areal', ""),
|
||||||
|
meta.get('komponenta_obdobi', ""),
|
||||||
|
])
|
||||||
|
|
||||||
|
feat.setAttributes(atributy)
|
||||||
|
target_list.append(feat)
|
||||||
|
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
print(f"Chyba při tvorbě feature: {ex}")
|
print(f"Chyba při tvorbě feature: {ex}")
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
# --- ADDING TO QGIS INTERFACE ---
|
||||||
proj = QgsProject.instance()
|
proj = QgsProject.instance()
|
||||||
added = 0
|
added = 0
|
||||||
for f, l, n in [(feats_p, vl_poly, "Plochy"), (feats_l, vl_line, "Linie"), (feats_pt, vl_point, "Body")]:
|
layers_to_process = [
|
||||||
|
(feats_p, vl_poly, "Polygony"),
|
||||||
|
(feats_l, vl_line, "Linie"),
|
||||||
|
(feats_pt, vl_point, "Body"),
|
||||||
|
]
|
||||||
|
|
||||||
|
for f, l, n in layers_to_process:
|
||||||
if f:
|
if f:
|
||||||
l.dataProvider().addFeatures(f)
|
l.dataProvider().addFeatures(f)
|
||||||
l.updateExtents()
|
l.updateExtents()
|
||||||
l.setName(f"AMČR {n} (Filtrováno)")
|
l.setName(f"AMCR_{archeologicky_zaznam}_{n}")
|
||||||
proj.addMapLayer(l)
|
proj.addMapLayer(l)
|
||||||
added += len(f)
|
added += len(f)
|
||||||
|
|
||||||
if added > 0:
|
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=Qgis.MessageLevel.Success)
|
||||||
else:
|
else:
|
||||||
iface.messageBar().pushMessage("AMCR", "Žádná data k zobrazení.", level=1)
|
iface.messageBar().pushMessage("AMCR", "Žádná data k zobrazení.", level=Qgis.MessageLevel.Info)
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
iface.messageBar().pushMessage("Chyba", str(e), level=2)
|
iface.messageBar().pushMessage("Chyba", str(e), level=Qgis.MessageLevel.Critical)
|
||||||
finally:
|
finally:
|
||||||
|
# Always restore cursor, even after failure
|
||||||
QApplication.restoreOverrideCursor()
|
QApplication.restoreOverrideCursor()
|
||||||
|
|
||||||
# class AmcrIdentifyTool(QgsMapToolIdentifyFeature):
|
|
||||||
# def __init__(self, canvas):
|
|
||||||
# super().__init__(canvas)
|
|
||||||
# self.canvas = canvas
|
|
||||||
# self.setCursor(Qt.CrossCursor)
|
|
||||||
|
|
||||||
# def canvasReleaseEvent(self, event):
|
|
||||||
# results = self.identify(event.x(), event.y(), self.IdentifyMode.TopDownStopAtFirst, self.VectorLayer)
|
|
||||||
# if not results: return
|
|
||||||
# feature = results[0].mFeature
|
|
||||||
# akce_id = None
|
|
||||||
# # Změna: hledáme 'ident_cely' (ID akce)
|
|
||||||
# idx = feature.fieldNameIndex('ident_cely')
|
|
||||||
# if idx != -1:
|
|
||||||
# akce_id = feature.attributes()[idx]
|
|
||||||
|
|
||||||
# # Fallback na starší názvy polí, kdyby něco
|
|
||||||
# if not akce_id:
|
|
||||||
# for col in ['akce_id', 'ident_cely', 'pian_id']:
|
|
||||||
# if col in feature.fields().names():
|
|
||||||
# akce_id = feature[col]
|
|
||||||
# break
|
|
||||||
|
|
||||||
# if not akce_id: return
|
|
||||||
|
|
||||||
# full_id = akce_id if "api.aiscr.cz" in str(akce_id) else f"https://api.aiscr.cz/id/{akce_id}"
|
|
||||||
# url = f"https://api.aiscr.cz/2.2/oai?verb=GetRecord&metadataPrefix=oai_amcr&identifier={full_id}"
|
|
||||||
|
|
||||||
# iface.messageBar().pushMessage("AMCR", f"Detail: {akce_id}...", level=1)
|
|
||||||
# QApplication.setOverrideCursor(Qt.WaitCursor)
|
|
||||||
# try:
|
|
||||||
# r = requests.get(url, timeout=5)
|
|
||||||
# if r.status_code == 200: self.show_detail(akce_id, r.text)
|
|
||||||
# except Exception as e:
|
|
||||||
# iface.messageBar().pushMessage("Chyba", str(e), level=2)
|
|
||||||
# finally:
|
|
||||||
# QApplication.restoreOverrideCursor()
|
|
||||||
|
|
||||||
# def show_detail(self, title, raw_xml):
|
|
||||||
# xml = re.sub(r'\sxmlns="[^"]+"', '', raw_xml, count=1)
|
|
||||||
# xml = re.sub(r'<(/?)[a-zA-Z0-9]+:', r'<\1', xml)
|
|
||||||
# info = ""
|
|
||||||
# try:
|
|
||||||
# root = ET.fromstring(xml)
|
|
||||||
# rec = root.find('.//archeologicky_zaznam')
|
|
||||||
# if not rec: info = "Zadna data."
|
|
||||||
# else:
|
|
||||||
# kat = rec.find('.//hlavni_katastr')
|
|
||||||
# info += f"<h3>{kat.text if kat is not None else '?'}</h3>"
|
|
||||||
# for dj in rec.findall('.//dokumentacni_jednotka'):
|
|
||||||
# pn = dj.find('pian')
|
|
||||||
# p_txt = pn.text if pn is not None else ""
|
|
||||||
# info += f"<hr><b>PIAN: {p_txt}</b><ul>"
|
|
||||||
# for k in dj.findall('komponenta'):
|
|
||||||
# ob = k.find('obdobi').text or "?"
|
|
||||||
# ar = k.find('areal').text or "?"
|
|
||||||
# info += f"<li>{ob} ({ar})</li>"
|
|
||||||
# info += "</ul>"
|
|
||||||
# dlg = QMessageBox()
|
|
||||||
# dlg.setWindowTitle(str(title))
|
|
||||||
# dlg.setText(info)
|
|
||||||
# dlg.setTextFormat(Qt.RichText)
|
|
||||||
# dlg.exec_()
|
|
||||||
# except: pass
|
|
||||||
+124
-45
@@ -1,39 +1,58 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from qgis.PyQt.QtCore import QSettings, QTranslator, QCoreApplication
|
from qgis.PyQt.QtCore import QSettings, QTranslator, QCoreApplication
|
||||||
from qgis.PyQt.QtGui import QIcon
|
from qgis.PyQt.QtGui import QIcon
|
||||||
from qgis.PyQt.QtWidgets import QAction
|
from qgis.PyQt.QtWidgets import QMenu, QAction, QToolButton, QDialog
|
||||||
|
from qgis.core import Qgis
|
||||||
|
from qgis.utils import iface
|
||||||
|
|
||||||
from .amcr_tools import load_amcr_data#, AmcrIdentifyTool
|
from .amcr_tools import load_amcr_data, login_to_api
|
||||||
from .amcr_dialog import AmcrFilterDialog
|
from .amcr_dialog import AmcrFilterDialog, LoginDialog
|
||||||
from .resources import *
|
from .resources import *
|
||||||
import os.path
|
import os.path
|
||||||
|
|
||||||
class AmcrViewer:
|
class AmcrViewer:
|
||||||
|
"""
|
||||||
|
Main plugin class that manages the GUI elements, menu entries,
|
||||||
|
and coordinates the flow between user input and data processing.
|
||||||
|
"""
|
||||||
|
|
||||||
def __init__(self, iface):
|
def __init__(self, iface):
|
||||||
|
"""
|
||||||
|
Constructor initializes the connection to QGIS interface and sets up
|
||||||
|
internationalization (i18n).
|
||||||
|
"""
|
||||||
self.iface = iface
|
self.iface = iface
|
||||||
self.plugin_dir = os.path.dirname(__file__)
|
self.plugin_dir = os.path.dirname(__file__)
|
||||||
|
|
||||||
|
# Determine the user's locale to load appropriate translation files
|
||||||
locale = QSettings().value('locale/userLocale')[0:2]
|
locale = QSettings().value('locale/userLocale')[0:2]
|
||||||
locale_path = os.path.join(
|
locale_path = os.path.join(
|
||||||
self.plugin_dir,
|
self.plugin_dir,
|
||||||
'i18n',
|
'i18n',
|
||||||
'AmcrViewer_{}.qm'.format(locale))
|
'AmcrViewer_{}.qm'.format(locale))
|
||||||
|
|
||||||
|
# Install the translator if a translation file for the current locale exists
|
||||||
if os.path.exists(locale_path):
|
if os.path.exists(locale_path):
|
||||||
self.translator = QTranslator()
|
self.translator = QTranslator()
|
||||||
self.translator.load(locale_path)
|
self.translator.load(locale_path)
|
||||||
QCoreApplication.installTranslator(self.translator)
|
QCoreApplication.installTranslator(self.translator)
|
||||||
|
|
||||||
|
# Initialize internal state
|
||||||
self.actions = []
|
self.actions = []
|
||||||
self.menu = self.tr(u'&AMČR Viewer')
|
self.menu = self.tr(u'&AMČR Viewer')
|
||||||
self.first_start = None
|
self.first_start = None
|
||||||
|
|
||||||
def tr(self, message):
|
def tr(self, message):
|
||||||
|
"""Helper method for translating strings within the AmcrViewer context."""
|
||||||
return QCoreApplication.translate('AmcrViewer', message)
|
return QCoreApplication.translate('AmcrViewer', message)
|
||||||
|
|
||||||
def add_action(self, icon_path, text, callback, enabled_flag=True,
|
def add_action(self, icon_path, text, callback, enabled_flag=True,
|
||||||
add_to_menu=True, add_to_toolbar=True, status_tip=None,
|
add_to_menu=True, add_to_toolbar=True, status_tip=None,
|
||||||
whats_this=None, parent=None):
|
whats_this=None, parent=None):
|
||||||
|
"""
|
||||||
|
Helper method to create QActions and automatically register them
|
||||||
|
into the QGIS Menu and Toolbar.
|
||||||
|
"""
|
||||||
icon = QIcon(icon_path)
|
icon = QIcon(icon_path)
|
||||||
action = QAction(icon, text, parent)
|
action = QAction(icon, text, parent)
|
||||||
action.triggered.connect(callback)
|
action.triggered.connect(callback)
|
||||||
@@ -45,75 +64,135 @@ class AmcrViewer:
|
|||||||
if whats_this is not None:
|
if whats_this is not None:
|
||||||
action.setWhatsThis(whats_this)
|
action.setWhatsThis(whats_this)
|
||||||
|
|
||||||
|
# Standard QGIS API for adding icons and menu items
|
||||||
if add_to_toolbar:
|
if add_to_toolbar:
|
||||||
self.iface.addToolBarIcon(action)
|
self.iface.addToolBarIcon(action)
|
||||||
|
|
||||||
if add_to_menu:
|
if add_to_menu:
|
||||||
self.iface.addPluginToMenu(self.menu, action)
|
self.iface.addPluginToMenu(self.menu, action)
|
||||||
|
|
||||||
|
# Store only actions that are directly attached to the QGIS UI for later cleanup
|
||||||
|
if add_to_toolbar or add_to_menu:
|
||||||
self.actions.append(action)
|
self.actions.append(action)
|
||||||
|
|
||||||
return action
|
return action
|
||||||
|
|
||||||
def initGui(self):
|
def initGui(self):
|
||||||
|
"""
|
||||||
|
Called when the plugin is loaded. Creates the menu structure,
|
||||||
|
sub-actions, and the dropdown tool button in the toolbar.
|
||||||
|
"""
|
||||||
|
# Define paths for action-specific icons
|
||||||
|
icon_akce_path = os.path.join(self.plugin_dir, 'akce.png')
|
||||||
|
icon_lokality_path = os.path.join(self.plugin_dir, 'lokality.png')
|
||||||
|
|
||||||
import os
|
# 1. Create a container menu for the plugin
|
||||||
plugin_dir = os.path.dirname(__file__)
|
self.plugin_menu = QMenu()
|
||||||
|
|
||||||
icon = QIcon(os.path.join(plugin_dir, 'download.png'))
|
# 2. Create sub-actions (Download Projects / Download Sites)
|
||||||
|
# add_to_menu/toolbar is False because these go into our custom dropdown 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)
|
||||||
|
|
||||||
# icon_info = QIcon(os.path.join(plugin_dir, 'info.png'))
|
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)
|
||||||
|
|
||||||
# Download data button
|
self.action_login_dialog = self.add_action(
|
||||||
self.action_download = self.add_action(
|
icon_path=icon_akce_path,
|
||||||
icon,
|
text=self.tr(u'Přihlásit se | AMČR Viewer'),
|
||||||
text=self.tr(u'Načíst data z AMČR'),
|
callback=lambda checked=False: self.login(),
|
||||||
callback=self.run_download,
|
parent=self.iface.mainWindow(),
|
||||||
parent=self.iface.mainWindow())
|
add_to_menu=False,
|
||||||
|
add_to_toolbar=False
|
||||||
|
)
|
||||||
|
self.plugin_menu.addAction(self.action_login_dialog)
|
||||||
|
|
||||||
# # Info button (Checkable / Toggle)
|
# 3. Create the main project action and attach the menu to it
|
||||||
# self.action_tool = self.add_action(
|
main_icon = QIcon(icon_akce_path)
|
||||||
# icon_info,
|
self.main_action = QAction(main_icon, 'AMČR Viewer', self.iface.mainWindow())
|
||||||
# text=self.tr(u'Výpis údajů záznamu'),
|
self.main_action.setMenu(self.plugin_menu)
|
||||||
# callback=self.run_tool,
|
self.iface.addPluginToMenu(self.menu, self.main_action)
|
||||||
# parent=self.iface.mainWindow())
|
|
||||||
# self.action_tool.setCheckable(True) # Toto tlačítko se zamačkává
|
# 4. Create and configure a QToolButton for the QGIS Toolbar
|
||||||
|
# This button acts as a dropdown menu button (MenuButtonPopup)
|
||||||
|
self.tool_button = QToolButton()
|
||||||
|
self.tool_button.setMenu(self.plugin_menu)
|
||||||
|
self.tool_button.setDefaultAction(self.action_download_akce)
|
||||||
|
self.tool_button.setPopupMode(QToolButton.ToolButtonPopupMode.MenuButtonPopup)
|
||||||
|
|
||||||
|
# Add the widget directly to the toolbar and store the reference for cleanup
|
||||||
|
self.toolbar_action = self.iface.addToolBarWidget(self.tool_button)
|
||||||
|
|
||||||
self.first_start = True
|
self.first_start = True
|
||||||
|
|
||||||
def unload(self):
|
def unload(self):
|
||||||
for action in self.actions:
|
"""
|
||||||
self.iface.removePluginMenu(self.tr(u'&AMČR Viewer'), action)
|
Called when the plugin is disabled or removed.
|
||||||
self.iface.removeToolBarIcon(action)
|
Ensures all GUI elements are removed from QGIS to avoid ghost icons.
|
||||||
|
"""
|
||||||
|
# 1. Remove the custom entry from the main 'Plugins' menu
|
||||||
|
if hasattr(self, 'main_action'):
|
||||||
|
self.iface.removePluginMenu(self.menu, self.main_action)
|
||||||
|
|
||||||
|
# 2. Remove the custom QToolButton from the toolbar
|
||||||
|
if hasattr(self, 'toolbar_action'):
|
||||||
|
self.iface.removeToolBarIcon(self.toolbar_action)
|
||||||
|
|
||||||
|
# 3. Clean up any remaining actions registered in self.actions
|
||||||
|
for action in self.actions:
|
||||||
|
self.iface.removePluginMenu(self.menu, action)
|
||||||
|
self.iface.removeToolBarIcon(action)
|
||||||
|
self.actions.clear()
|
||||||
|
|
||||||
|
# 4. Reset map tools if currently active
|
||||||
if hasattr(self, 'tool'):
|
if hasattr(self, 'tool'):
|
||||||
self.iface.mapCanvas().unsetMapTool(self.tool)
|
self.iface.mapCanvas().unsetMapTool(self.tool)
|
||||||
|
|
||||||
# --- Data downloading ---
|
# --- Data downloading ---
|
||||||
def run_download(self):
|
def run_download(self, typ_dat):
|
||||||
|
"""
|
||||||
|
Triggered by menu/toolbar actions. Opens the filter dialog and
|
||||||
|
hands off the parameters to the data loader.
|
||||||
|
"""
|
||||||
|
# Open the specific filter dialog (Projects vs Sites)
|
||||||
|
dlg = AmcrFilterDialog(typ_dat)
|
||||||
|
result = dlg.exec()
|
||||||
|
|
||||||
dlg = AmcrFilterDialog()
|
# If user confirmed the dialog (OK button), gather filters and load data
|
||||||
result = dlg.exec_()
|
if result == QDialog.DialogCode.Accepted:
|
||||||
|
|
||||||
if result == 1:
|
|
||||||
filters = dlg.get_filters()
|
filters = dlg.get_filters()
|
||||||
bbox = dlg.get_bbox()
|
bbox = dlg.get_bbox()
|
||||||
|
komponenty = dlg.get_komponenty()
|
||||||
|
|
||||||
|
# Access the map canvas and start the fetch/render process from amcr_tools
|
||||||
canvas = self.iface.mapCanvas()
|
canvas = self.iface.mapCanvas()
|
||||||
load_amcr_data(canvas, bbox, filters)
|
load_amcr_data(canvas, bbox, filters, typ_dat, komponenty)
|
||||||
|
|
||||||
# --- Info button toggle ---
|
def login(self):
|
||||||
# def run_tool(self):
|
dlg = LoginDialog(parent=self.iface.mainWindow())
|
||||||
|
result = dlg.exec()
|
||||||
# if self.action_tool.isChecked():
|
if result == QDialog.DialogCode.Accepted:
|
||||||
# canvas = self.iface.mapCanvas()
|
username, password = LoginDialog.get_credentials()
|
||||||
|
session = login_to_api(username, password)
|
||||||
# if not hasattr(self, 'tool'):
|
if session:
|
||||||
# self.tool = AmcrIdentifyTool(canvas)
|
self.iface.messageBar().pushMessage(
|
||||||
# self.tool.deactivated.connect(lambda: self.action_tool.setChecked(False))
|
"AMČR", "Přihlášení proběhlo úspěšně.", level=Qgis.MessageLevel.Success
|
||||||
|
)
|
||||||
# canvas.setMapTool(self.tool)
|
else:
|
||||||
# self.iface.messageBar().pushMessage("AMČR", "Info nástroj aktivní.", level=0)
|
self.iface.messageBar().pushMessage(
|
||||||
|
"AMČR", "Přihlášení se nezdařilo – viz záložka AMČR login v panelu Zprávy.", level=Qgis.MessageLevel.Critical
|
||||||
# else:
|
)
|
||||||
# if self.iface.mapCanvas().mapTool() == getattr(self, 'tool', None):
|
|
||||||
# self.iface.mapCanvas().unsetMapTool(self.tool)
|
|
||||||
+21841
-13584
File diff suppressed because it is too large
Load Diff
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,18 @@
|
|||||||
# This file contains metadata for your plugin.
|
# 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]
|
[general]
|
||||||
name=AMČR Viewer
|
name=AMČR Viewer
|
||||||
qgisMinimumVersion=3.4
|
qgisMinimumVersion=3.4.0
|
||||||
|
qgisMaximumVersion=4.99.0
|
||||||
description=Viewing and downloading the AMČR data.
|
description=Viewing and downloading the AMČR data.
|
||||||
version=1.0.2
|
version=2.0.0-alpha.1
|
||||||
author=David Spáčil
|
author=David Spáčil
|
||||||
email=spacil@arub.cz
|
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, Sites, and their Components) from the Digital archive of the Archaeological Map of the Czech Republic (https://digiarchiv.aiscr.cz/).
|
||||||
|
|
||||||
tracker=https://github.com/ARUP-CAS/aiscr-qgis-amcr-viewer/issues
|
tracker=https://github.com/ARUP-CAS/aiscr-qgis-amcr-viewer/issues
|
||||||
repository=https://github.com/ARUP-CAS/aiscr-qgis-amcr-viewer
|
repository=https://github.com/ARUP-CAS/aiscr-qgis-amcr-viewer
|
||||||
@@ -25,11 +27,11 @@ hasProcessingProvider=no
|
|||||||
# 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
|
||||||
|
|
||||||
homepage=https://github.com/ARUP-CAS/aiscr-qgis-amcr-viewer
|
homepage=https://amcr-help.aiscr.cz/digiarchiv/qgis-viewer.html
|
||||||
category=Vector
|
category=Vector
|
||||||
icon=download.png
|
icon=download.png
|
||||||
# experimental flag
|
# experimental flag
|
||||||
experimental=False
|
experimental=True
|
||||||
|
|
||||||
# deprecated flag (applies to the whole plugin, not just a single version)
|
# deprecated flag (applies to the whole plugin, not just a single version)
|
||||||
deprecated=False
|
deprecated=False
|
||||||
@@ -39,9 +41,6 @@ deprecated=False
|
|||||||
# Check the documentation for more information.
|
# Check the documentation for more information.
|
||||||
# plugin_dependencies=
|
# plugin_dependencies=
|
||||||
|
|
||||||
# Category of the plugin: Raster, Vector, Database or Web
|
|
||||||
# category=
|
|
||||||
|
|
||||||
# If the plugin can run on QGIS Server.
|
# If the plugin can run on QGIS Server.
|
||||||
server=False
|
server=False
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
#
|
#
|
||||||
# WARNING! All changes made in this file will be lost!
|
# WARNING! All changes made in this file will be lost!
|
||||||
|
|
||||||
from PyQt5 import QtCore
|
from qgis.PyQt import QtCore
|
||||||
|
|
||||||
qt_resource_data = b"\
|
qt_resource_data = b"\
|
||||||
\x00\x00\x04\x0a\
|
\x00\x00\x04\x0a\
|
||||||
|
|||||||
@@ -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