Spaces:
Sleeping
Sleeping
File size: 4,114 Bytes
90a13c0 967688d 90a13c0 967688d 90a13c0 967688d 90a13c0 0e394c7 90a13c0 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 | /**
* Shared type definitions for Routes and Adventures
*/
// ============================================================================
// GeoJSON Types
// ============================================================================
export interface GeoJSONPoint {
type: 'Point';
coordinates: [number, number]; // [longitude, latitude]
}
export interface GeoJSONLineString {
type: 'LineString';
coordinates: Array<[number, number]>; // Array of [longitude, latitude]
}
export interface GeoJSONPolygon {
type: 'Polygon';
coordinates: Array<Array<[number, number]>>;
}
export type GeoJSONGeometry = GeoJSONPoint | GeoJSONLineString | GeoJSONPolygon;
export interface GeoJSONFeature<G extends GeoJSONGeometry = GeoJSONGeometry, P = any> {
type: 'Feature';
geometry: G;
properties: P;
}
export interface GeoJSONFeatureCollection<G extends GeoJSONGeometry = GeoJSONGeometry, P = any> {
type: 'FeatureCollection';
features: Array<GeoJSONFeature<G, P>>;
}
// ============================================================================
// Track Types (Public Ski Tracks)
// ============================================================================
export interface TrackProperties {
id: number;
name: string;
description?: string;
difficulty?: string; // e.g., 'beginner', 'intermediate', 'advanced', 'expert'
type?: string; // e.g., 'downhill', 'nordic', 'skitour'
'piste:difficulty'?: string; // From OpenSkiData
'piste:type'?: string; // From OpenSkiData
[key: string]: any; // Allow additional properties from GeoJSON
}
export interface Track {
id: number;
external_id?: string;
name: string;
description?: string;
geojson: GeoJSONGeometry; // The path geometry
properties: Record<string, any>; // Additional properties from GeoJSON
difficulty?: string;
difficulty_convention?: string;
type?: string;
uses?: string[];
ref?: string;
oneway?: string;
gladed?: string;
patrolled?: string;
lit?: string;
grooming?: string;
status?: string;
websites?: string[];
wikidata_id?: string;
elevation_profile?: any;
created_at?: Date;
}
export type TrackFeature = GeoJSONFeature<GeoJSONLineString, TrackProperties>;
export type TrackFeatureCollection = GeoJSONFeatureCollection<GeoJSONLineString, TrackProperties>;
// ============================================================================
// Adventure Types (User-Saved Activities)
// ============================================================================
export interface AdventureProperties {
id: number;
name: string;
description?: string;
user_id?: string;
recorded_at?: Date;
duration?: number; // Duration in seconds
distance?: number; // Distance in meters
[key: string]: any; // Allow additional properties
}
export interface Adventure {
id: number;
user_id?: string;
name: string;
description?: string;
path: GeoJSONGeometry; // The recorded path
properties: Record<string, any>; // Additional properties
recorded_at?: Date;
created_at?: Date;
}
export type AdventureFeature = GeoJSONFeature<GeoJSONLineString, AdventureProperties>;
export type AdventureFeatureCollection = GeoJSONFeatureCollection<GeoJSONLineString, AdventureProperties>;
// ============================================================================
// Activity Types (UI taxonomy)
// ============================================================================
export interface Activity {
id: string; // stable identifier used by routes.uses
label: string;
sort_order?: number;
is_visible?: boolean;
}
// ============================================================================
// API Response Types
// ============================================================================
export interface PaginationInfo {
total: number;
page: number;
limit: number;
pages: number;
}
export interface PaginatedResponse<T> {
type: 'FeatureCollection';
features: T[];
pagination: PaginationInfo;
}
|