Skip to main content

Module io

Module io 

Source
Expand description

Import and export of narratives in various formats.

This module provides converters for reading and writing narratives in standard geographic data formats.

§Supported Formats

  • GeoJsonFormat - Standard geographic data format
  • CsvFormat - Tabular data with configurable columns
  • JsonFormat - Custom JSON format optimized for narratives
  • GPX - GPS exchange format (optional feature, TODO)

§Example

use spatial_narrative::io::{GeoJsonFormat, CsvFormat, JsonFormat, Format};
use spatial_narrative::prelude::*;

let narrative = Narrative::builder()
    .title("My Story")
    .event(Event::builder()
        .location(Location::new(40.7128, -74.006))
        .timestamp(Timestamp::now())
        .text("Something happened")
        .build())
    .build();

// Export to GeoJSON
let geojson_format = GeoJsonFormat::new();
let geojson = geojson_format.export_str(&narrative).unwrap();

// Export to CSV
let csv_format = CsvFormat::new();
let csv = csv_format.export_str(&narrative).unwrap();

// Export to custom JSON
let json_format = JsonFormat::pretty();
let json = json_format.export_str(&narrative).unwrap();

Structs§

CsvFormat
CSV format handler.
CsvOptions
Configuration options for CSV import/export.
GeoJsonFormat
GeoJSON format handler.
GeoJsonOptions
Configuration options for GeoJSON import/export.
JsonFormat
Custom JSON format handler.

Traits§

Format
Trait for formats that can import and export narratives.