nmeasim::core::viewsync¶
namespace nmeasim::core::viewsync · Library API
ViewSync output, part of the nmeasim::core library.
It formats the UDP packets that Google Earth and Liquid Galaxy exchange to synchronise their camera, so that a Google Earth instance with ViewSync enabled follows the simulated vessel. Sending them is the job of nmeasim::io.
See also
Types¶
| Type | Description |
|---|---|
ViewSyncOptions |
Camera settings for the packets of one output. |
Summary¶
Functions
| Name | Description |
|---|---|
sanitize_planet() |
Returns a planet name without the characters that would corrupt a packet. |
encode_packet() |
Encodes one packet: counter,latitude,longitude,altitude,heading,tilt,roll,start,end,planet. |
Variables
| Name | Description |
|---|---|
kSecondsBeforeUnixEpoch |
Seconds from 0001-01-01T00:00:00Z to the Unix epoch in the proleptic Gregorian calendar, the origin of ViewSync times. |
Functions¶
sanitize_planet()¶
std::string sanitize_planet(std::string_view planet)
Returns a planet name without the characters that would corrupt a packet.
Commas (the field separator), control characters such as CR and LF, DEL and bytes outside ASCII are removed; every other character is kept, so the valid names sky, mars and moon and any other name Google Earth may accept are sent unchanged.
Parameters
| Name | Type | Description |
|---|---|---|
planet |
std::string_view |
The configured planet name, of any content. |
Returns std::string: The name with only printable ASCII characters other than the comma; empty when none is left, which Google Earth takes as Earth.
Declared in src/core/include/nmeasim/core/viewsync/viewsync.hpp:51 · defined in src/core/src/viewsync/viewsync.cpp:14
encode_packet()¶
std::string encode_packet(
const model::VesselState& state,
const ViewSyncOptions& options,
std::uint32_t counter)
Encodes one packet: counter,latitude,longitude,altitude,heading,tilt,roll,start,end,planet.
Latitude and longitude are the vessel's position in degrees with seven decimals; the altitude is the vessel's altitude plus options.camera_altitude_m; the heading is the vessel's true heading, so the camera looks along it. Altitude, heading, tilt and roll have two decimals. Start and end are both the simulated clock in whole seconds since 0001-01-01T00:00:00Z. The planet is options.planet after sanitize_planet().
Parameters
| Name | Type | Description |
|---|---|---|
state |
const model::VesselState& |
Vessel state that places the camera. |
options |
const ViewSyncOptions& |
Camera settings. |
counter |
std::uint32_t |
Packet counter; the caller increases it by one per packet on the output. |
Returns std::string: The packet without line terminator.
See also
Declared in src/core/include/nmeasim/core/viewsync/viewsync.hpp:66 · defined in src/core/src/viewsync/viewsync.cpp:24
Variables¶
kSecondsBeforeUnixEpoch¶
std::int64_t kSecondsBeforeUnixEpoch{62135596800}
Seconds from 0001-01-01T00:00:00Z to the Unix epoch in the proleptic Gregorian calendar, the origin of ViewSync times.
Declared in src/core/include/nmeasim/core/viewsync/viewsync.hpp:40