CLDF - Crushlog Data Format for Dart
A Dart implementation of the Crushlog Data Format (CLDF) for climbing data exchange.
Features
- Read and write CLDF archives (.cldf files)
- JSON serialization/deserialization for all CLDF models
- Type-safe Dart models for all CLDF entities
- Archive creation with automatic checksums
- Automatic statistics calculation when writing archives
- Validation support
- Enhanced Media Support (v1.2.3+)
- Media attachments for routes, locations, sectors, and climbs
- Semantic media designation (topo, beta, approach, etc.)
- Support for embedded files and external URLs
- Captions and timestamps for media items
Platform Support
This package supports all platforms except Web/WASM because CLDF archives require file system access for reading and writing .cldf files. The package works on:
- ✅ Android
- ✅ iOS
- ✅ macOS
- ✅ Windows
- ✅ Linux
- ❌ Web (file I/O not available)
Installation
Add this to your package's pubspec.yaml file:
dependencies:
cldf: ^1.2.3
Usage
Reading a CLDF archive
import 'package:cldf/cldf.dart';
final reader = CLDFReader();
final archive = await reader.readFile('path/to/file.cldf');
// Access data
print('Locations: ${archive.locations.length}');
print('Routes: ${archive.routes.length}');
print('Climbs: ${archive.climbs.length}');
Writing a CLDF archive
import 'package:cldf/cldf.dart';
final archive = CLDFArchive(
manifest: Manifest(
version: '1.0.0',
format: 'CLDF',
creationDate: DateTime.now(),
platform: Platform.iOS,
appVersion: '1.0.0',
),
locations: [
Location(
id: 1,
name: 'Test Crag',
country: 'USA',
isIndoor: false,
),
],
routes: [
Route(
id: 1,
locationId: 1,
name: 'Classic Route',
routeType: RouteType.route,
grades: {'french': '6a'},
),
],
climbs: [
Climb(
id: 1,
date: '2024-01-15',
routeName: 'Classic Route',
type: ClimbType.route,
finishType: FinishType.redpoint,
attempts: 2,
),
],
);
final writer = CLDFWriter();
await writer.writeFile('output.cldf', archive);
Automatic Statistics
When writing an archive, statistics are automatically calculated if not already present in the manifest:
// Stats will be calculated automatically
final archive = CLDFArchive(
manifest: Manifest(
version: '1.0.0',
format: 'CLDF',
creationDate: DateTime.now(),
platform: Platform.android,
appVersion: '1.0.0',
// No stats provided - will be calculated automatically
),
locations: locations,
climbs: climbs,
// ... other data
);
await writer.writeFile('output.cldf', archive);
// The written archive will have stats populated with counts of all entities
Media Support (v1.2.3+)
Attach media to any entity with semantic designation:
final route = Route(
id: 101,
locationId: 1,
name: 'The Dawn Wall',
routeType: RouteType.route,
media: Media(
items: [
MediaItem(
type: MediaType.photo,
path: 'media/dawn_wall_topo.jpg',
designation: MediaDesignation.topo,
caption: 'Full route topo with pitch breakdown',
source: MediaSource.embedded,
),
MediaItem(
type: MediaType.video,
path: 'https://youtube.com/watch?v=example',
designation: MediaDesignation.beta,
caption: 'Beta video from Tommy Caldwell',
source: MediaSource.external,
),
],
count: 2,
),
);
Available Designations:
topo- Route diagramsbeta- How-to informationapproach- Access infolog- Climb documentationoverview- General viewsconditions- Current stategear- Equipment infodescent- Down-climb infoother- Unspecified
Working with JSON
All models support JSON serialization:
// Convert to JSON
final climbJson = climb.toJson();
// Parse from JSON
final climb = Climb.fromJson(jsonData);
Models
The package provides models for all CLDF entities:
Manifest- Archive metadata with automatic statistics calculationLocation- Climbing locationsSector- Sectors within locationsRoute- Routes and bouldersClimb- Individual climb recordsSession- Climbing sessionsTag- Tags for categorizationMediaItem- Media references (photos/videos)Author- Author information for exportsStats- Statistics about the archive content
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Libraries
- api/cldf_archive
- api/cldf_reader
- api/cldf_writer
- cldf
- CLDF - Crushlog Data Format for Dart
- clid/cldf_clid_adapter
- clid/clid_generator
- clid/models/clid
- clid/models/coordinates
- clid/models/location
- clid/models/route
- clid/models/sector
- clid/models/validation_result
- clid/utils/string_utils
- models/checksums
- models/climb
- models/enums/belay_type
- models/enums/climb_type
- models/enums/finish_type
- models/enums/grade_system
- models/enums/media_designation
- models/enums/media_source
- models/enums/media_type
- models/enums/platform
- models/enums/protection_rating
- models/enums/rock_type
- models/enums/route_characteristics
- models/enums/route_type
- models/enums/session_type
- models/enums/terrain_type
- models/grades
- models/location
- models/manifest
- models/media/media
- models/media/media_item
- models/media_metadata_item
- models/route
- models/sector
- models/session
- models/tag
- qr/qr
- QR code generation and scanning for CLDF data
- qr/qr_generator
- qr/qr_scanner
- utils/date_time_converter
- utils/local_date_converter