=== TrailsIQ ===
Contributors: muscode
Tags: trails, gpx, map, hiking, maintenance
Requires at least: 5.9
Tested up to: 6.9
Stable tag: 1.5.7
Requires PHP: 7.4
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Import GPX trails, calculate stats, display on interactive maps with MapLibre GL.

== Description ==

TrailsIQ lets you import GPX files to create trail records with calculated stats (distance, elevation gain, grade). Trails are displayed on interactive MapLibre maps with difficulty styling. Includes a maintenance reporting system for trail crews.

Features:
* Import GPX files and auto-calculate distance, elevation gain, and grade
* Interactive MapLibre GL map with outdoor, satellite, and topo styles
* Trail network management (group trails into networks)
* Maintenance issue reporting with GPS location and photo upload
* Admin dashboard with maintenance status overview
* Frontend shortcodes for maps and maintenance reporting

== Installation ==

1. Upload the plugin files to the `/wp-content/plugins/trailsiq` directory, or install the plugin through the WordPress plugins screen.
2. Activate the plugin through the 'Plugins' screen in WordPress.
3. Go to TrailsIQ > Settings and enter your MapTiler API key.
4. Use TrailsIQ > Import Trail to upload your first GPX file.

== Frequently Asked Questions ==

= Where do I get a MapTiler API key? =

You can get a free API key at maptiler.com. The free tier supports up to 100,000 map views per month.

= What GPX files are supported? =

Standard GPX 1.1 files with trackpoints (trkpt elements). Files with waypoints only are not currently supported.

== External Services ==

This plugin connects to the following external services. By using this plugin you agree to each service's terms of use and privacy policy.

= TrailsIQ central registry (app.trailsiq.com) =
The plugin can register your install with the central TrailsIQ registry at https://app.trailsiq.com so that public reporters using the TrailsIQ Report mobile app and crew members using the TrailsIQ Field mobile app can find your trails and route reports back to your site. The connection is opt-in: the registry only contacts your site after a site administrator pastes a registry token in the Registry settings page (TrailsIQ → Registry).

When connected, the following data flows between your site and app.trailsiq.com:

* On manual or scheduled sync (every 24 hours by default): a simplified copy of your **public** trails — id, name, slug, status, difficulty, color, organisation id, and a Douglas-Peucker-simplified polyline (~50 m tolerance) — is pushed to the registry so the mobile apps can show "trails near me" and route reports back. Private/draft/archived trails are never sent.
* When a public report is filed against one of your trails through the central app, app.trailsiq.com forwards the report (title, description, optional reporter name, lat/lng, photos) to your site's REST API; the report is stored on **your** server and is never retained by app.trailsiq.com.
* When a Field App user signs in with their WordPress credentials, app.trailsiq.com proxies API requests (issues, structures, points of interest, time logs, photos) between the app and your site; the central server does not retain the response payloads — it only forwards them.
* A registry token (random string generated on app.trailsiq.com), the bearer-token hash for any active Field App session on your site, and per-request HTTP timing metadata are kept on app.trailsiq.com to authenticate the proxy traffic.

The registry connection can be removed at any time from TrailsIQ → Registry → Disconnect; trails already pushed remain in the registry until the next sync (which sends an empty list) or until the central operator removes the install.

* Service: https://app.trailsiq.com
* Terms of use: https://trailsiq.com/terms
* Privacy policy: https://trailsiq.com/privacy

= MapTiler =
Map tiles, styles (Outdoor, Satellite, Topo), and terrain data are loaded from MapTiler's servers using your MapTiler API key. Map tile requests include your API key and the coordinates of the map viewport.

* Service: https://www.maptiler.com
* Terms of use: https://www.maptiler.com/terms/
* Privacy policy: https://www.maptiler.com/privacy-policy/

= Open-Meteo =
The Weather & Soil Status module fetches soil moisture, soil temperature, and precipitation forecasts for each network's centroid coordinates from Open-Meteo's free public API. No API key is required and no personally identifying information is sent — only the latitude/longitude of the network being polled.

* Service: https://open-meteo.com
* Terms of use: https://open-meteo.com/en/terms
* Privacy policy: https://open-meteo.com/en/privacy-policy

= MapLibre GL JS =
The interactive map rendering library is bundled locally with the plugin (v4.7.1).

* Source: https://github.com/maplibre/maplibre-gl-js
* License: BSD-3-Clause

= Turf.js =
The geospatial analysis library (used for GPS trail snapping) is loaded from the jsDelivr CDN.

* Service: https://www.jsdelivr.com
* Library: https://cdn.jsdelivr.net/npm/@turf/turf@6/turf.min.js
* Privacy policy: https://www.jsdelivr.com/privacy-policy-jsdelivr-net

== Changelog ==
= 1.3.0 =
* Add Weather & Soil Status module — automated trail condition recommendations via Open-Meteo API (no key required).
* Decision engine evaluates soil moisture, soil temperature, precipitation, and 24/72h rainfall forecast against configurable thresholds per surface type, drainage rating, and trail use.
* Freeze/thaw detection: daytime thaw after frozen soil triggers automatic caution recommendation.
* Three management modes: Auto, Auto-Close Only (default), Approval Required — configurable globally and per network.
* Approval workflow: pending recommendations shown in Weather dashboard with Approve/Override actions and email notifications.
* Cron-based polling: configurable at 1h, 3h, 6h, or daily intervals using WP-Cron.
* Trail Attributes panel on trail edit screen: surface type, drainage rating, primary use, sensitivity override.
* Weather Status panel on network edit screen: live recommendation, snapshot, last checked, management mode override, manual condition buttons.
* Full audit log with filters (network, date range, trigger type) and CSV export.
* Notification emails via wp_mail() on status changes and approval requests.
* DB version 7.0: three new tables (trail_attributes, weather_audit, notifications); new columns on networks and trails.

= 1.2.0 =
* Add unified Field App combining maintenance issue management and structure inventory in one full-screen, offline-capable PWA.
* Field App: single persistent MapLibre map, bottom tab bar navigation (Issues / Structures), center FAB for adding.
* Field App: GPS location dot, trail proximity detection, auto-select trail/network from pin placement.
* Field App: offline-first — all data cached to localStorage + Cache API; status updates and new structures queued in IndexedDB and synced when connectivity returns.
* Field App: combined pending-sync badge in header; manual sync button.
* Field App: photo upload with compression + map snapshot capture for both issues and structures.
* Add Field App Page setting in Settings; add rewrite rule + manifest for field app PWA install.

= 1.1.0 =
* Add Structure Inventory feature: catalog physical structures (bridges, stairs, signs, kiosks, trail maps) on trails.
* New structure_types and structures DB tables with auto-generated codes (BR0001, ST0001, etc.).
* REST API endpoints for structures and structure types (GET/POST/PATCH/DELETE).
* Admin Structures page with filterable card list and side-panel editor.
* Standalone Structure Inventory PWA with offline support via IndexedDB and Service Worker.
* Two-step field form: type selection → map location + details.
* Structures link added to Maintenance App menu.
* Settings page: Structure App Page designation.

= 1.0.15 =
* Add trail condition (Open / Caution / Closed) to networks.

= 1.0.1 =
*

= 1.0.0 =
* Initial release.

== Upgrade Notice ==

= 1.0.0 =
Initial release.
