Skip to main content

trailgen_core/
lib.rs

1//! Provider-agnostic trail graph, scoring, routing, and route I/O.
2
3pub mod builder;
4pub mod cache;
5pub mod conflate;
6pub mod constraints;
7pub mod crs;
8pub mod enrich;
9pub mod geo;
10pub mod hiking;
11pub mod io;
12pub mod model;
13pub mod optimizer;
14pub mod overlay;
15pub mod raster;
16pub mod route;
17pub mod routing;
18pub mod seed;
19pub mod source;
20pub mod trail;
21
22pub use builder::{
23    DEFAULT_SNAP_TOLERANCE_M, GraphBuilder, JunctionKey, JunctionPolicy, SegmentDraft,
24    TurnRestrictionDraft, TurnRestrictionRule,
25};
26pub use cache::{GRAPH_CACHE, decode_graph, encode_graph};
27pub use conflate::{
28    ConflatedNetwork, ConflationDecision, ConflationPolicy, ConflationReport, ConflationStats,
29    NetworkStratum, conflate,
30};
31pub use constraints::{
32    ConstraintAudit, ConstraintVerdict, DEFAULT_MAX_DISTANCE_M, DEFAULT_MIN_DISTANCE_M,
33    LoopConstraints,
34};
35pub use enrich::{
36    ElevationMosaic, ElevationSample, ElevationSampler, EmbeddedElevation, EnrichmentConfig,
37    PlaneElevation, enrich_graph,
38};
39pub use geo::{Coord, LineString};
40pub use hiking::{EdgeTraversal, HikingModel, TraversalEstimate, joint_work_factor};
41pub use model::{
42    Access, CoverageGap, CoverageGapKind, CrossingControl, CrossingEvidence, CrossingKind, Edge,
43    EdgeAttr, EdgeId, EdgeIndex, EdgeProjection, EdgeTravel, GeometryClaim, GradeDistribution,
44    Provenance, RouteCoverage, RouteSnapStats, Terrain, TrailMarking, TrailStanding, TurnBan,
45    Vertex, VertexId, WalkGraph, WayKind, WayRealm,
46};
47pub use optimizer::{
48    EdgeDisposition, EdgeEdicts, ExactLoopSolver, LoopHunter, RouteSolver, SearchMonitor,
49    SearchParams, SearchProgress, SearchScope, SearchStage, SolverKind,
50};
51pub use overlay::{
52    AccessOverlay, AccessWindow, ContextOverlay, DailyTimeWindow, MonthDay, OverlayGeometry,
53    PlanningDate, PlanningMoment, PlanningTime, SeasonalWindow, TerrainOverlay, Weekday,
54    WeekdaySet, apply_access_overlays, apply_access_overlays_at, apply_context_overlays,
55    apply_terrain_overlays,
56};
57pub use raster::{ArcAsciiGrid, GeoTiffDem, RasterCrs, RasterDem, RasterTransform, VrtDem};
58pub use route::{
59    LOW_CONFIDENCE_THRESHOLD, Route, RouteMetrics, RouteShape, is_restricted_access, rank_routes,
60};
61pub use routing::{RouteRequest, RoutingWorkspace, WalkRealmIndex, WalkRouter};
62pub use seed::{SeedRoute, artifact_key};
63pub use trail::{
64    DEFAULT_ROAD_AVERSION, RoutingLaw, SupportBinding, SupportInsertion, SupportPoint, Trail,
65    TrailRealization, TrailReversal,
66};
67
68#[derive(Debug, thiserror::Error)]
69pub enum TrailgenError {
70    #[error("invalid geometry: {0}")]
71    InvalidGeometry(String),
72    #[error("invalid data: {0}")]
73    InvalidData(String),
74    #[error("support points realize {actual:?}, not {expected:?}")]
75    ShapeMismatch {
76        actual: RouteShape,
77        expected: RouteShape,
78    },
79    #[error("this loop uses a one-way segment")]
80    OneWayReversal,
81    #[error("the reversed walk violates a turn restriction")]
82    TurnRestrictedReversal,
83    #[error("the reversed walk cannot be encoded as support points")]
84    UnrepresentableReversal,
85    #[error("unsupported format: {0}")]
86    UnsupportedFormat(String),
87    #[error("json error: {0}")]
88    Json(#[from] serde_json::Error),
89    #[error("xml error: {0}")]
90    Xml(String),
91}
92
93pub type Result<T> = std::result::Result<T, TrailgenError>;