Skip to main content

Module export

Module export 

Source
Expand description

Writing a flight out: a Recorder’s rows as CSV or JSON (or Parquet, with the parquet feature), and the center of mass’s path with the landings as GeoJSON or KML for a map.

Every function builds the file’s contents (text, or bytes for Parquet) and returns them; none writes a file (the core crates do no I/O). Text numbers are written in Rust’s shortest round-trip form and Parquet stores each f64’s own 8 bytes, so each reads back as the exact value recorded. A value that isn’t finite is refused rather than written as something a reader would misread (NaN, or JSON’s null).

The two map formats put heights on different datums, as their specifications require:

  • GeoJSON (RFC 7946, section 4): longitude, latitude and height in meters above the WGS 84 ellipsoid.
  • KML (OGC 07-147r2, altitudeMode absolute): longitude, latitude and height above mean sea level (KML’s geoid is EGM96), which is the ellipsoidal height less the site’s geoid undulation (Environment::geoid_undulation_m). The undulation is taken as constant over the flight; the geoid’s slope, about 5 cm/km and up to some 30 cm/km in mountains, moves it by centimeters to decimeters over a rocket’s few kilometers.

Neither cuts a path that crosses the antimeridian (±180° longitude), which RFC 7946 section 3.1.9 asks for; a flight there draws a line the long way round the globe.

Each file names the program that wrote it, its version and its designation in the FusionSpace product system (hpr_core::tool), as a drawing’s title block names the tool that made it: JSON and GeoJSON in a top-level tool object, {"name", "version", "designation"} (in GeoJSON a foreign member, which RFC 7946 section 6.1 allows); KML in an XML comment after the declaration; Parquet in its key-value metadata. CSV is left as bare rows, so it opens cleanly in a spreadsheet: a program writing one keeps the stamp beside it.

The two text formats follow the FusionSpace product system’s data.md (Files and exports, Copying and typing numbers): a CSV’s header gives each column in words with its unit in brackets, time [s] (csv_header), where JSON and Parquet keep the unit in the name, time_s; and JSON and GeoJSON text is ASCII, any other character written as a \u escape (ascii), so the designation’s middle dot reads back as itself.

Structs§

TrackPoint
One point of the center of mass’s path, placed on the Earth.

Constants§

PARQUET_PAGE_ROWS
The most values in one Parquet data page: 1024 doubles, the 8 KiB page the specification recommends (README.md, “Configurations”).

Functions§

ascii
JSON text in ASCII: every character outside it written as its \u escape, a character past U+FFFF as its UTF-16 surrogate pair (RFC 8259, section 7), so · (U+00B7) becomes \u00b7. The product system’s data.md asks JSON to be ASCII (Copying and typing numbers). A reader gets back the same strings: outside a string JSON text is ASCII already, and inside one an escape stands for its character.
csv
The recorded rows as CSV (RFC 4180): a header of the columns in words with their units in brackets (csv_header: time [s] for the column time_s), then one line per row, lines ending in CRLF.
csv_header
A column’s name as a CSV header writes it: the name’s words with spaces, then its unit in brackets, as the product system’s data.md writes a header (time [s]). The unit is the name’s last word or two, read from a table of twelve units: time_s is time [s], velocity_east_m_s is velocity east [m/s], max_acceleration_m_s2 is max acceleration [m/s^2] and dynamic_pressure_pa is dynamic pressure [Pa]; a name with no unit, such as mach or drag_scale, is its words alone. JSON and Parquet keep the name.
geojson
The path and the landings as a GeoJSON FeatureCollection (RFC 7946): a LineString of [longitude, latitude, height above the ellipsoid] whose properties.time_s lists each point’s time, and a Point per landing of summary with its time, body, distance and descent rate. A top-level tool object names the program that wrote it, as json()’s does: a foreign member, which RFC 7946 section 6.1 allows and readers pass over.
geojson_with
The path and the landings as geojson() writes them, with about’s fields, in its order, between tool and features: more foreign members (RFC 7946 section 6.1), such as the motor catalog’s date or how far to trust the landing point, as json_with carries them. A struct or a serde_json::Map keeps the order from one run to the next.
json
The recorded rows as JSON: {"tool": {...}, "columns": [names], "rows": [[values], ...]}, each row in the columns’ order. tool names the program that wrote the file: {"name": "FusionSpace HPR", "version": "0.1.0", "designation": "FS-ACHERNAR \u00b7 SW \u00b7 TOOL 001"}, the text in ASCII (ascii). A FlightSummary is serializable on its own (serde_json::to_string).
json_with
The recorded rows as json() writes them, with about’s fields, in its order, between tool and columns: what the caller knows of the flight that the recorder doesn’t, such as the design flown or how far to trust it. A struct or a serde_json::Map keeps the order from one run to the next; a HashMap doesn’t, so the same flight could write other bytes.
kml
The path and the landings as a KML 2.2 document (OGC 07-147r2) named name: a LineString of longitude,latitude,height above mean sea level with altitudeMode absolute, and a ground-clamped Point per landing of summary. An XML comment after the declaration names the program that wrote it, <!-- FusionSpace HPR 0.1.0 · FS-ACHERNAR · SW · TOOL 001 --> (hpr_core::tool::stamp).
kml_with
The path and the landings as kml() writes them, with description as the Document’s description (OGC 07-147r2 section 9.1.3.6, after its name), such as the motor catalog’s date and how far to trust the path: a map shows it when the file is opened. It is escaped as XML text, but map programs such as Google Earth show a description as HTML, so text from someone else should not be passed through unchecked. An empty description writes none, as kml() does.
parquet
The recorded rows as an Apache Parquet file: one DOUBLE column per recorded column, named as in Recorder::columns, one row group, PLAIN encoding, no compression. Every value reads back as the exact f64 recorded. The footer’s key-value metadata names the program that wrote the file: tool = FusionSpace HPR, tool_version = its version and designation = FS-ACHERNAR · SW · TOOL 001.
parquet_with
The recorded rows as parquet() writes them, with the pairs of about, in its order, after the program’s three in the footer’s key-value metadata: such as the motor catalog’s date and how far to trust the recording, as super::json_with carries them beside its rows. Each is a KeyValue of parquet.thrift, its key and its value UTF-8 strings. Keys other programs read as their own, such as Apache Arrow’s ARROW:schema or pandas’ pandas, are the caller’s to avoid: a reader decodes them, and may refuse the file when they hold something else.
track
The center of mass’s path from a recorder that kept crate::Channel::Time and crate::Channel::CgPosition, placed on environment’s ellipsoid.