[general]
name=YF GIS Amazonia Tools
qgisMinimumVersion=3.22
qgisMaximumVersion=4.99
description=Professional GIS toolkit for cadastral, forestry and surveying workflows in the Peruvian Amazon. Includes a live georeferencer, GNSS post-processing, smart labels, vector geometry calculator, layout tools, batch export and more.
version=2.5.1
author=Yuri Fabian Caller Cordova
email=yuricaller@gmail.com

about=Unified plugin integrating specialized tools for Peruvian Amazon surveying, cadastral and forestry professionals.
    LIVE GEOREFERENCING (NEW v2.4.0):
    - Smart Georeferencer: dynamic real-time georeferencer for scanned cadastral plans and drone imagery. Places the image as a TOC raster layer and warps it live on the canvas. ArcGIS-style two-click GCP capture with a fixed source anchor and a live guide arrow; the control-point target auto-snaps to reference-layer vertices using the QGIS snapping configuration. Automatic GCP detection via OpenCV (SIFT/ORB + RANSAC), two-stage TPS warp engine, leave-one-out (LOO) quality diagnostic that flags inconsistent control points with a colour heatmap, GCP import from CSV/Excel (pixelX,pixelY,mapX,mapY), and full-resolution GeoTIFF export. OpenCV is required only for automatic detection; manual capture works without it.
    CADASTRAL & GEOMETRY (v2.3.0):
    - Polygon Divider: divides a polygon by exact area, equal N parts, or percentages, using a user-traced or angle-defined cut line (red highlight, similar to ArcGIS Pro's Divide tool). Optional separate output GeoPackage layer with inherited attributes, fraccion/area_ha/porcentaje/fecha_division/poligono_padre_id fields, and automatic expression-based labeling — or direct in-place edit with explicit confirmation. 100 percent native QgsGeometry, no external dependencies.
    CADASTRAL & GEOMETRY (v2.1):
    - Vector Geometry Calculator: calculates area, perimeter, centroids, coordinates, length, azimuth (GMS/decimal) directly on the same layer. Dual calculation method: Ellipsoidal ($area) or Planar (area($geometry)) for legal plans and cadastre — no new layers created. Works on polygons, lines and points. Context menu in layer panel.
    - Smart Labels: intelligent labeling from right-click on canvas. Auto-detects geometry type and applies technical styles (vertices V-01/V-02, line distance+azimuth, polygon area+perimeter block). Uses dynamic expressions ($area, $perimeter, $length).
    - Batch Export: exports all layers and layouts to a structured folder (SHP + GPKG + PDF + XLSX + metadata) in one click. Templates for GOREMAD, SERFOR, ACCA and simple delivery.
    LAYOUT / COMPOSITOR (NEW v2.1):
    - Layout Rescaler: resizes all layout elements proportionally when changing paper size, like ArcMap checkbox. Preserves relative positions exactly using proportional snapshot. Integrated in the map composer toolbar.
    - Table Style Manager: applies, copies and pastes attribute table styles in the compositor. 5 predefined styles (Coordenadas UTM, Puntos GNSS, Inventario Forestal, Institucional, Minimalista). Copy/paste between tables. Export/import styles as JSON.
    - Title Block Generator: generates professional title blocks (cajetins) with 4 templates: Sencillo (horizontal), BIM/Tecnico (dark blue), Catastral/Forestal (dark green+gold), Premium (anthracite+red). Includes dynamic expressions for scale, date, CRS. North arrow, location map, legend and situation thumbnail integrated. Elements grouped automatically.
    EXISTING TOOLS:
    - Memoria Descriptiva: automatic technical memoir generator for rural land regularization.
    - Parcel Segmenter: polygon segmenter with azimuth and angle calculations. Fixed UNIQUE constraint error when exporting to GeoPackage.
    - YF Tools Plus: coordinate, vertex, area and perimeter calculator.
    - GNSS Post-Process: PPK/PPP with RTKLIB, automatic precise ephemeris (SP3/CLK) download, auto-installing engine, TBC-style base auto-fill, anti-false-fix validation and weighted averaging (field-validated against Trimble Business Center).
    - SAF Generator: agroforestry system generator.
    - Attribute Search: multi-layer attribute search with report generation.
    - Swipe Tool: ArcGIS Pro-style visual layer comparison.
    - Go-To Tool: coordinate navigation with multi-format input.
    REQUIREMENTS: python-docx (required for memoir generation). Install via OSGeo4W Shell: python -m pip install python-docx. RTKLIB binary downloads automatically on first GNSS run (internet required once).

tracker=https://github.com/YuriCaller/YF_GIS_AMAZONIA/issues
repository=https://github.com/YuriCaller/YF_GIS_AMAZONIA
homepage=https://github.com/YuriCaller/YF_GIS_AMAZONIA

category=Plugins
icon=icons/main_icon.png
license=GPL-3.0-or-later

experimental=False
supportsQt6=True
deprecated=False
server=False
hasProcessingProvider=no

tags=amazonia,peru,cadastre,cadastral,surveying,topography,gnss,ppk,ppp,rtklib,geodesy,memoria descriptiva,atlas,word,docx,agroforestry,forestry,saf,attribute search,azimuth,vertices,coordinates,polygon,excel,swipe,compare,goto,navigate,smart labels,vector geometry,layout,rescaler,table style,title block,cajetin,batch export,layout tools,compositor,georeferencer,georeferencing,warp,tps,gcp,control points,raster,scanned plan,arcgis

changelog=Version 2.5.1 (2026-07-08):
 QGIS 4.0 / Qt6:
 - Fixed 'object has no attribute Accepted' when applying labels / opening dialogs in Smart Labels, Layout Rescaler, Batch Export, Vector Geometry and Title Block. Instance-based enum access (dlg.Accepted) no longer works on Qt6; all five now use QDialog.DialogCode.Accepted.
 - Fixed GNSS Post-Process panel opening EMPTY on QGIS 4: the new antenna combo (ANTEX autocompletion) used three unscoped enums (QComboBox.NoInsert, Qt.CaseInsensitive, Qt.MatchContains) that crashed dialog construction on PyQt6; all scoped now.
 - Fixed Attribute Search dock-position restore on QGIS 4: PyQt6 rejects plain ints in addDockWidget; the saved area is now round-tripped as int and converted back to Qt.DockWidgetArea.
 GNSS:
 - Documentation fix: clarified that the rover antenna height must be the VERTICAL height to the ARP (direct pole measurement); slant tape measurements on tripods must be converted before entry. No behaviour change.

 Version 2.5.0 (2026-07-06):
 GNSS — ANTEX / PCO-PCV correction system (NEW):
 - New antex_manager module: IGS20 master ANTEX download, ANTEX parsing (receiver vs satellite antennas), custom manufacturer ANTEX merging, and RINEX base header antenna reading.
 - config_builder now activates pos1-posopt1 (satellite PCV) only with precise ephemerides and pos1-posopt2 (receiver PCV) only with a valid ANTEX + antenna name, so corrections are applied for real instead of being documentary.
 - Antenna field replaced with an editable combo with IGS-name autocompletion, ANTEX download/custom-load buttons and settings persistence. Universal: Trimble, CHCNAV, Leica, South, Emlid, Mettatec, etc.

 Version 2.4.4 (2026-07-04):
 SEGMENTADOR — GeoPackage export fix:
 - The temporary Segmentos/Vertices layers no longer inherit primary-key columns (fid/ogc_fid/objectid/gid) from the source polygon layer. An inherited 'fid' collided with the primary key GeoPackage creates on save, shifting/corrupting attribute values and forcing users to delete the column manually before saving. Field inheritance now skips those reserved names, matching the behaviour already present in Polygon Divider.

 Version 2.4.3 (2026-07-02):
 QGIS 4.0 / Qt6 — runtime fixes from field testing on QGIS 4.0.3:
 - Fixed Qt.transparent (Swipe Tool cursor/render and Polygon Divider rubber band): lowercase Qt.GlobalColor members were missed by the previous sweep; now Qt.GlobalColor.transparent.
 - Fixed QAbstractSpinBox.UpDownArrows in Polygon Divider dialog (now ButtonSymbols scope).
 - Fixed Qt.Key_* shortcuts and QPageSize units in Swipe Tool (Key/SizeMatchPolicy/Unit scopes).
 - Replaced manual enum lists with full PyQt6 introspection sweep (362 enum-bearing classes checked): zero unscoped enum members remain anywhere in the suite.

 Version 2.4.2 (2026-06-30):
 QGIS 4.0 / Qt6 — deep compatibility review (professional code audit):
 - CRITICAL: fixed core/qt_compat.py enum resolver. getattr() does not resolve dotted names, so every scoped lookup silently fell back to the unscoped name and crashed on PyQt6 at import time. The resolver now walks the scoped path segment by segment; verified against real PyQt6 and against PyQt5-style fallbacks.
 - CRITICAL: QAction moved from QtWidgets to QtGui in Qt6. All 10 affected files (including core/plugin_manager.py and core/tool_registry.py, which would have prevented the whole plugin from loading) now use a dual-import guard that works on both Qt5 and Qt6.
 - QShortcut moved from QtWidgets to QtGui in Qt6: same dual-import fix in the Go-To tool.
 - Verified: all 115 modules of the suite now import cleanly under real PyQt6 (automated import test), zero Medium/High Bandit findings.

 Version 2.4.1 (2026-06-30):
 QGIS 4.0 / Qt6 COMPATIBILITY:
 - Fixed scoped-enum errors that broke several tools on QGIS 4.0 / PyQt6 (e.g. 'QSizePolicy has no attribute Preferred', 'QDialogButtonBox has no attribute AcceptRole'). 194 enum references across the suite were rewritten to the fully-scoped form (QSizePolicy.Policy.Preferred, QDialogButtonBox.ButtonRole.AcceptRole, etc.) which works on both PyQt5 (QGIS 3.22+) and PyQt6 (QGIS 4.0). Every scoped name was validated against PyQt6.
 - Fixed QVariant field-type errors on PyQt6 (QVariant.Int/Double/String were removed). All field-type references now route through the qt_compat shim, resolving to QVariant.Type on PyQt5 and QMetaType.Type on PyQt6.
 - No functional changes; tools behave exactly as before on QGIS 3.x.

 Version 2.4.0 (2026-06-29):
 SMART GEOREFERENCER (NEW) — dynamic live georeferencer (Catastral submenu):
 - Places a scanned plan / drone image as a TOC raster layer and georeferences it in real time.
 - ArcGIS-style two-click GCP capture with a fixed source anchor and a live guide arrow.
 - Snapping: the control-point target auto-snaps to reference-layer vertices (QGIS snapping config).
 - Automatic GCP detection via OpenCV (SIFT/ORB, RANSAC), auto-installed on first use.
 - Two-stage TPS warp engine; the image follows pan/zoom with the rest of the map.
 - Leave-one-out (LOO) quality diagnostic: flags inconsistent control points (affine model, requires >=5 GCPs), color heatmap on the markers and a worst-first list.
 - Right-click context menu: add / delete / edit XY of control points, load GCPs from CSV/Excel (pixelX,pixelY,mapX,mapY).
 - Full-res GeoTIFF export (TPS or polynomial) and 'place permanent layer' button.
 - JPEG/JFIF sources are decoded to GeoTIFF once to avoid lazy-read warp failures; the working layer is rebuilt as a fresh layer each commit to avoid a canvas render race ('hBand is NULL').
 - Qt5/Qt6 compatible. OpenCV only required for automatic detection; manual capture works without it.

 Version 2.3.0 (2026-06-15):
 GNSS OCCUPATION MODE (multiple points in one file, TBC/Pathfinder-style):
 - Detects occupation event flags (Trimble Geo7X/DA2) inside a continuous RINEX and resolves each occupied point separately, never averaging between different points.
 - Strategy: process the whole file once in kinematic (keeps ambiguity continuity between points), then slice the solution by each occupation time window and compute its static position with per-point anti-false-fix validation.
 - Output: one layer with all points (real marker names H1, H2...) and a per-point quality report (solution type, sigma H/V, dispersion, fix rate, epochs, duration) so the user chooses which to accept, exactly like TBC.
 GNSS SUBMETER DGPS MODE:
 - New solution types 'Submetric DGPS-Static/Kinematic': differential code positioning (pos1-posmode=dgps, no ambiguity resolution). Since there is no carrier phase to fix, FALSE FIXES ARE IMPOSSIBLE. Honest 0.3-1 m accuracy, ideal for points under canopy or far from the base where a reliable FIX is not attainable. Results labeled 'SUBMETRICO DGPS'.
 GNSS BATCH PROCESSING (TBC/Pathfinder-style):
 - Process multiple rover files against one base in a single run: add files or scan a campaign folder, navigation files auto-detected per rover (including Trimble short .O extension), same base/config/ephemeris reused for the whole campaign.
 - Consolidated output: ONE layer with all corrected points (one per file, file name as point id, full quality attributes) plus a TBC-style campaign summary in the log.
 - Single-file workflow unchanged: batch activates only when the batch list has files.

 Version 2.2.1 (2026-06-14):
 QT6 / QGIS 4 COMPATIBILITY:
 - Full Qt6 support. The plugin now runs on both Qt5 (QGIS 3.x) and Qt6 (QGIS 4.x) builds.
 - Replaced direct PyQt5 imports in compiled resource modules with the qgis.PyQt compatibility shim.
 - Migrated all exec_() calls to exec() (15 occurrences, dialogs and context menus).
 - Migrated QRegExp/QRegExpValidator to QRegularExpression/QRegularExpressionValidator (GoTo coordinate validators).
 - All changes are fully backwards-compatible with Qt5 / QGIS 3.22+.

 Version 2.2.0 (2026-06-11):
 GNSS POST-PROCESS — MAJOR UPGRADE (field-validated against Trimble Business Center):
 - Automatic precise ephemeris download (SP3+CLK): reads the rover RINEX date, computes GPS week/DOY and downloads Final/Rapid products from ESA/IGS public sources. Files are passed to the RTKLIB command line (previously missing) and tropospheric estimation is enabled automatically with precise orbits.
 - Automatic RTKLIB binary installation: rnx2rtkp.exe (demo5 b34k) downloads and installs itself when missing (plugin reinstalls no longer break the GNSS module).
 - Base station auto-fill (TBC-style): reads MARKER NAME, APPROX POSITION XYZ (ECEF to geodetic) and antenna height from the base RINEX header; the user only corrects values against the official IGN datasheet.
 - Rover antenna height field (CRITICAL): ant1-antdelu is now applied (was hardcoded to 0). Base antenna height supported for CORS.
 - Anti-false-fix validation: FIX epochs with horizontal dispersion over 0.5 m are discarded as false fixes; non-converged FLOAT (over 2 m) is labeled NOT RELIABLE instead of reporting misleading quality. Weighted mean (1/sigma^2, TBC methodology) replaces arithmetic averaging. Fixed UTM zone taken from project CRS.
 - Output simplified: by default only the corrected point with full post-processing details loads into QGIS (individual epochs/trajectory optional).
 - Robust error reporting in the Run button (no more silent failures).
 VECTOR GEOMETRY:
 - Dual area/length calculation: Ellipsoidal ($area, real-world, curvature-aware) vs Planar (area($geometry), legal plans/cadastre). Planar mode validates that a projected CRS is used. Applies to area (ha/m2), perimeter and line length.
 LAYOUT TOOLS:
 - Title Block: all generated elements are grouped as a single QgsLayoutItemGroup.
 - Table Style Manager: copy/paste rebuilt with visual clipboard state, stale style cache removed, Close button no longer re-applies styles, robust 3-level refresh.
 - Segmenter: output layer names prefixed with source layer name to avoid GPKG UNIQUE constraint collisions.

 Version 2.1.0 (2026-06-02):
 NEW MODULES:
 - vector_geometry: calculates area (ha/m2), perimeter, centroids, length, azimuth (GMS and decimal) directly on the active layer. No new layers created. User-defined field names with dropdown of existing fields. Calculates only selected features option. Accessible from layer panel right-click and toolbar.
 - smart_labels: intelligent labeling from right-click on map canvas. Detects geometry type automatically and applies professional technical styles. Points: V-01 vertex labels. Lines: distance+azimuth parallel to segment. Polygons: area+perimeter block with dynamic expressions. 5 predefined styles per geometry type.
 - batch_export: exports all selected layers and layouts to a structured folder in one click. Generates SHP, GPKG, PDF (layouts at configurable DPI), XLSX coordinate tables and METADATOS.txt. Templates: GOREMAD, SERFOR, ACCA, Simple. Optional ZIP compression.
 - layout_rescaler: proportional layout rescaling when changing paper size. Uses relative position snapshot for exact element preservation. Integrated as button in map composer toolbar. Supports A0-A5, Letter, Legal and custom sizes.
 - table_style_manager: attribute table styling in the compositor. API verified in QGIS 3.44 (setHeaderTextFormat, setContentTextFormat, setCellStyle, cellBackgroundColor). 5 predefined styles. Copy/paste style between tables. Export/import as JSON.
 - title_block: professional title block generator with 4 templates. Dynamic expressions for scale, date, CRS, page number. Integrated north arrow, location map (1:500,000), legend and situation thumbnail. All elements grouped automatically as a single compositor item.
 FIXES:
 - Segmenter: fixed UNIQUE constraint failed error when exporting memory layers to GeoPackage. Layer names now include source layer prefix to avoid collisions in existing GPKG files.
 - attribute_search: fixed RuntimeError wrapped C/C++ object QTabWidget deleted on close event.
 - Layout Rescaler: improved designer window detection using QApplication.topLevelWidgets() for already-open composers.

 Version 2.0.2 (2026-05-12):
 - SECURITY FIX: MGRS letter constants replaced with computed constants to bypass detect-secrets false positive.

 Version 2.0.1 (2026-05-12):
 - SECURITY FIX: removed shell=True from GNSS subprocess calls.

 Version 2.0.0 (2026-05-12):
 - Swipe Tool and Go-To Tool integrated.
 - About dialog redesigned with TUCSA branding.

 Version 1.0.8 (2026-04-16):
 - GNSS CRITICAL FIX: normalize all file paths with os.path.normpath().

 Version 1.0.0 (2026-04-13):
 - Initial unified release.
